0

I use PostGIS 2.1.1 to create some concave hulls from several polygons but sometimes it works and sometimes it fails depending on the shape of the polygons.

The following request

SELECT st_astext(ST_ConcaveHull(st_union(
ST_GeomFromText ('POLYGON(...)',
ST_GeomFromText ('POLYGON(...)')
),0.85)) As cc_hull

returns sometimes GEOMETRYCOLLECTION EMPTY with the message

NOTICE: Too few points in geometry component at or near point 0 0

I tried to use st_collect instead of st_union with the same result. Also i tried ST_MakeValid etc..

here is an example that fails

> SELECT st_astext(ST_ConcaveHull(st_union(
ST_GeomFromText ('POLYGON((-0.7528611 46.2531213,-0.711708 46.240873,-0.68886 46.23969,-0.6850865 46.288144,-0.67921 46.29997,-0.673535 46.315953,-0.71736 46.30777,-0.741967 46.283543,-0.7528611 46.2531213))'),
ST_GeomFromText ('POLYGON((-0.8617425 46.3176727,-0.8471857 46.3337108,-0.8469636 46.3339572,-0.84576 46.335272,-0.8393793 46.3405319,-0.8355 46.341544,-0.804777 46.341832,-0.7754804 46.3182422,-0.76213 46.30547,-0.758752 46.300819,-0.753278 46.292984,-0.785317 46.281833,-0.8064719 46.2739175,-0.833606 46.270022,-0.846593 46.291528,-0.85837 46.310202,-0.8617425 46.3176727))')
),0.85)) As cc_hull

How to obtain a valid answer whatever the polygons?

0

It works for me:

POLYGON((-0.803550808455445 46.3415902129884,-0.775116206238198 46.3186944988309,......,-0.803550808455445 46.3415902129884)) (1 row)

Maybe your old version of postgis (mine is 2.4.3) still have bugs in this function ?

You can try to update postgres/postgis, or maybe (with crossing fingers) to copy/past the function (I tried with https://appgeodb.nancy.inra.fr/donnees/documentations/bdd/db_robot/structure/Functions/st_concavehull_public.html (random search for me) and rename it to be sure (like CREATE OR REPLACE FUNCTION public.st_concavehull2 ...) and I'm pretty sure it should work, otherwise I don't see where the problem is from (are you sure it's not somewhere else in your code?).

  • Work for me too with PostGIS 2.3. – user30184 May 20 '18 at 21:48
  • Thank you. This looks like a bug on version 2.1.1. I am going to upgrade PostGIS.. As advised, I tried to update the functions st_concavehull and _st_concavehull and ... it works (on simple examples for now). It seems to be a workaround. – Serge May 21 '18 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.