duckdb / duckdb/duckdb-spatial

ST_GeneratePoints implementation

Open
#367 3 comments 0 reactions 0 assignees View on GitHub
roadmap
Dominant language
C
Stars
708
Forks
96
Avg merge
1d 21h
Merged PRs (30d)
5

Description

## Summary
Requesting the addition of the `ST_GeneratePoints` function to the DuckDB spatial extension. This function generates a specified number of random points within a given geometry and is available in PostGis for instance.

## Motivation
The absence of `ST_GeneratePoints` in DuckDB requires me to connect to Postgres for this functionality.
Integrating this function directly into DuckDB will streamline spatial data workflows by eliminating this dependency. It will also improve significantly my jobs runtime by eliminating steps.

## Example of workaround (SQL)
-- Connecting Postgres to add a point by point column with st_generatepoints, with mandatory geometry handling

ATTACH 'dbname=postgres user=postgres host=127.0.0.1 port=5439' AS postgres_db (TYPE postgres);

drop table tmp_menages_esri50_discretise;
create table tmp_menages_esri50_discretise as
SELECT ST_GeometryN(st_GeneratePoints(st_geomfromtext(geom),1),1) point_individuel, a.*
FROM tmp_menages_esri50 a;

-- back to DuckDb to handle the end of the job
copy (select
st_geomfromhexwkb(point_individuel) geom_point_individuel, st_x(st_geomfromhexwkb(point_individuel)) x_geom_point_individuel, st_y(st_geomfromhexwkb(point_individuel)) y_geom_point_individuel, "type_logt" from postgres_db.tmp_menages_esri50_discretise
limit 10000000
)
to "C:\Users\ali.hmaou\__LocalEnv\Projets\POINTILLES\export.geojson"
WITH (FORMAT GDAL, DRIVER 'GeoJSON', LAYER_CREATION_OPTIONS 'WRITE_BBOX=YES')

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.