Skip to content

How to write to geoparquet format? #111

Answered by Maxxen
aborruso asked this question in Q&A
Discussion options

You must be logged in to vote

The recommended way to work with parquet for now is to export the geometry columns as wkb (with ST_AsWKB) and then import from wkb (with ST_GeomFromWKB). This will give you something similar to GeoParquet, except that we don't write the additional metadata required by the spec.

e.g.

INSTALL spatial; INSTALL parquet; LOAD spatial; LOAD parquet;

--- export
COPY  (SELECT * REPLACE (ST_AsWKB(geom) AS wkb_geom) FROM mytable)  TO 'mytable.parquet' (FORMAT PARQUET, CODEC 'ZSTD');

--- import
SELECT * REPLACE (ST_GeomFromWKB(wkb_geom) as geom) FROM 'mytable.parquet';

Getting the spatial and parquet extensions to work better together is on the roadmap.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@aborruso
Comment options

Comment options

You must be logged in to vote
3 replies
@aborruso
Comment options

@Maxxen
Comment options

Answer selected by aborruso
@aborruso
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants