Skip to content

Instantly share code, notes, and snippets.

@geobabbler
Created October 10, 2024 15:13
Show Gist options
  • Save geobabbler/dc4d1d15e2778fb42a8fca3c02fd2654 to your computer and use it in GitHub Desktop.
Save geobabbler/dc4d1d15e2778fb42a8fca3c02fd2654 to your computer and use it in GitHub Desktop.
GeoJSON from DuckDB
WITH geodata AS (
SELECT
ROW_NUMBER() OVER () AS OBJECTID,
*
FROM
read_parquet('~/Downloads/IRL.parquet') LIMIT 1000)
select json_object(
'type', 'FeatureCollection',
'features', array_agg(
json_object(
'type', 'Feature',
'geometry', ST_AsGeoJSON(geometry),
'properties', json_object(
'bf_source', bf_source,
'boundary_id', boundary_id,
'confidence', confidence,
'area_in_meters', area_in_meters,
's2_id', s2_id,
'country_iso', country_iso,
'geohash', geohash,
'OBJECTID', OBJECTID
)
)
)
) AS geojson_featurecollection
FROM geodata;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment