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

With spatial extension, writing file raise a GDAL error (only in wasm) #1840

Open
TomBor opened this issue Sep 5, 2024 · 2 comments
Open

Comments

@TomBor
Copy link

TomBor commented Sep 5, 2024

What happens?

Writing a file with the spatial extension in duckbb wasm raise a GDAL error (IO Error: GDAL Error (3): Cannot write feature).

COPY table TO 'polygon.geojson' WITH (FORMAT 'GDAL', DRIVER 'GeoJSON');
Capture d’écran 2024-09-02 à 11 42 14

I also wrote a similar issue in the spatial repo #363

To Reproduce

See this reproductible example in the shell

Browser/Environment:

Chrome 128

Device:

MacBook Pro 2019

DuckDB-Wasm Version:

[email protected]

DuckDB-Wasm Deployment:

shell.duckdb.org

Full Name:

Thomas Ansart

Affiliation:

Sciences Po

@alexkreidler
Copy link

I'm getting the same error in https://www.quackdb.com/, another DuckDB WASM environment

@jdoig
Copy link

jdoig commented Oct 3, 2024

This will get you round the issue in the mean time:

await db.registerFileHandle('tmp_results.geojson', new Uint8Array(), 0, true);  // Duck/Spatial needs this but can't create is for some reason?
await db.registerFileHandle('results.geojson', new Uint8Array(), 0, true); // The file name you want to use without the 'tmp_' prefix

await connection.query(`
  copy (
    select * 
    from 'area_data.parquet'
  ) to 'results.geojson'
  with (
    FORMAT GDAL, DRIVER 'GeoJSON', LAYER_CREATION_OPTIONS 'WRITE_BBOX=YES'
  );`
);
const geojson_buffer = await db.copyFileToBuffer('results.geojson');
const link = URL.createObjectURL(new Blob([geojson_buffer]));
console.log("geojson url: ", link);

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

No branches or pull requests

4 participants