Open barnabasharris opened 6 months ago
Just read some earlier issues around this and discovered the workaround of dumping the geometry
column to a new column (named e.g. geometry_wkb
) of type bytea
using the PostGIS function ST_AsEWGB(geometry)
prior to attachment. Then DuckDB can make the a new geometry
column using ST_GeomFromWKB(geometry_wkb)
.
Unsure of the technical implications but from a user perspective it would be great if this process could occur automatically either on attachment or copy of geometry column from Postgres to DuckDB.
I ran into the same problem and found another workaround: The VARCHAR column that DuckDB receives can be converted directly to a geometry by calling ST_GeomFromHEXWKB
on it.
This way Postgis tables can be used by directly querying them e.g.:
SELECT ST_GeomFromHEXWKB(lonlat) from pg_db.public.my_table
Hi, If I have a Postgres/PostGIS DB containing tables with
geometry
columns of typepublic.geometry(multilinestring, 27700)
I can attach it to my DuckDB database (with spatial extension already installed and loaded) with:D ATTACH 'dbname=bharris user=postgres host=127.0.0.1' AS db (TYPE POSTGRES, READ_ONLY);
I notice that the geometry columns are represented as type
VARCHAR
:And I can't do any spatial operations on them.
What's the best method for getting DuckDB to recognise these columns as geometry columns?