Use geometry in spatial relationships - DuckDB #151
Closed
Callum Scoby (callumscoby)
started this conversation in
Discussion
Replies: 1 comment 3 replies
-
|
same error when i export a duckdb table with geometry into parquet, then read it back and failed to convert the geometry blob into geometry data type |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I've extracted all the points from the recent beta.0 places release using the duckdb client in Python, storing it as a number of local Parquet files:
COPY (WITH formatting AS( SELECT id, UNNEST([names], recursive := true), UNNEST([addresses], recursive := true), country, confidence, categories->>'main' AS category, UNNEST([brand], recursive := true), ST_GeomFromWKB(geometry) AS geom_p_4326 FROM '{{raw_path}}' SELECT id, "primary" as name, country, category, primary_1 AS brand, confidence, geom_p_4326 FROM formatting) TO 'global.parquet' (FORMAT 'parquet', COMPRESSION 'snappy', ROW_GROUP_SIZE 1000000, PER_THREAD_OUTPUT true);I now need to query these Parquet files for a given country, and ensure that all the POI are within a polygon of the countries boundaries.
In these Parquet files, the geometries look like this:
When I try to use them in ST_Within, I get the error that it doesn't support BLOB geometries:
So I try to convert them to geometries using ST_GeomFromWKB, which gives this error when testing the conversion:
I'm really at a loss of how to get the points converted to the GEOMETRY type, or how to get them to work in the ST_Within - any help or advice would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions