Geographic Information Systems Asked by Gery on January 10, 2021
Based on an irregular distribution of points (longitude,latitude), I obtained the convex hull below (I use saga_cmd with polygon convexity in 1). Would you have a way to create a convex hull that closely follows this irregular shape using one-liner commands or similar? I call commands from a bash terminal in Linux.
Using PostGIS ST_ConcaveHull
you may get the envelope to follow more closely the irregular shape, as stated in your post;
ogr2ogr -f GPKG concave.gpkg points.gpkg -nln concave_layer -dialect sqlite -sql "select 'a', ST_ConcaveHull(st_collect(geometry),0.9) from points_layer"
A few remarks:
You are using a point layer, so if you call st_concave_hull
directly on your geometry it will try to make a polygon for each point, which will return empty geometries, so first we call st_collect(geometry)
;
The layer name in the sql query can be retrieved with ogrinfo file.gpkg
, it is often not the same name as the layer.
For some functions to work in ogr2ogr you need a non-geometry field, that's why I passed 'a'
to the command, here it works without it.
It is an expensive algorithm, to test it you may use a subset of your layer passing where fid < 1000
to the query
Correct answer by Elio Diaz on January 10, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP