Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoJSONSeq write support #141

Closed
ttomasz opened this issue Oct 14, 2023 · 3 comments · Fixed by #145
Closed

GeoJSONSeq write support #141

ttomasz opened this issue Oct 14, 2023 · 3 comments · Fixed by #145

Comments

@ttomasz
Copy link

ttomasz commented Oct 14, 2023

Doc page says that GeoJSONSeq GDAL driver is supported for both reading and writing.

When I try to COPY with the following parameters: WITH (FORMAT GDAL, DRIVER 'GeoJSONSeq') I'm getting:

IO Error: GDAL Error (1): PROJ: proj_create: unrecognized format / unknown name

error.

DuckDB 0.9.1

@Maxxen
Copy link
Member

Maxxen commented Oct 14, 2023

Hi! Thanks for reporting this issue. This looks to be a regression introduced in #128, the GeoJSONSeq driver does not seem to handle an empty string as the "default" CRS identifier and instead errors when it tries to parse it, probably because it always tried to transform to wgs84 as that is mandated by the geojson standard. I should fix it so that we don't set the target SRS at all unless its given by the user.

To work around it for now you could simply specify a target srs. As I mentioned above valid geosjon requires WGS84, so you probably want to write something like:

COPY (SELECT ST_GeomFromText('POINT (1 1)')) 
TO 'test.json' 
WITH (FORMAT GDAL, DRIVER 'GeoJSONSeq', SRS 'EPSG:4326');

@zczc2390
Copy link

zczc2390 commented Oct 15, 2023

Seems there is a regression with the GDAL MVT driver on DuckDB 0.9.1 as well.
Try
COPY (SELECT ST_GeomFromText('POINT (1 1)')) TO 'test.mvt' WITH (FORMAT GDAL, DRIVER 'MVT');
or
COPY (SELECT ST_GeomFromText('POINT (1 1)')) TO 'test.mvt' WITH (FORMAT GDAL, DRIVER 'GeoJSONSeq', SRS 'EPSG:4326');
will get below error
Error: IO Error: Could not read from file "/tmp/test.mvt.temp.db": Bad file descriptor

The first command can work fine with DuckDB 0.8.1.

And is there any way to set the Dataset creation options for GDAL MVT driver in DuckDB? That would be much helpful to work with GDAL MVT driver

@Maxxen
Copy link
Member

Maxxen commented Oct 16, 2023

Hello @zczc2390! I think I have fixed the Bad file descriptor error in #145 but unfortunately the MVT driver is still broken since it spawns its own threads that are unaware of the thread local DuckDB filesystem context. Im going to need some more time to think about how to best solve it but hopefully I can provide a workaround soon.

For what its worth you should be able to pass any dataset creation options through the DATASET_CREATION_OPTIONS parameter, taking a sequence of KEY=VALUE varchar arguments.

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