2

This question is an update on the problem formulated here.

I wanted to redefine the border of a set of polygons, in order to "smooth it". My first approach (described in the former question) was to grab the points from the border and throw them at the Concave Hull function. However, the "pixelated" look of the border was not improved, since I am keeping the same set of points to define the border.

Concave Hull of the "pixelated" polygons

Thus my second approach, was to use the "raw" points within the polygon, that were used to generate it in the first place.

raw points

The idea would be to to something like this:

  • do a point in polygon query (ST_Contains) to find out the points inside each polygon.
  • send each collection of points inside a polygon to the concave hull constructor; this implies a group by query regarding the polygon geometry.

Considering the raw points table (tweets_malaga) and polygon table (exploded), I figured the query would be something like this:

SELECT ST_ConcaveHull(ST_UNION(tweets_malaga.geom),0.8) from exploded,tweets_malaga WHERE ST_Contains(exploded.geom,tweets_malaga.geom) group by exploded.geom;

However I am getting a weird error, stating:

ERROR:  Operation on mixed SRID geometries
CONTEXT:  PL/pgSQL function st_concavehull(geometry,double precision,boolean) line 71 at assignment

This bugs me, as all the geometries are correctly set to 4326 :-(

srids

UPDATE:

I was able to make the above query work, setting the target_percent parameter of ST_ConcaveHull to 0.99, which is very close from having a convex hull. This parameter controls the target percent of area of convex hull the PostGIS solution will try to approach before giving up or exiting. If I set this parameter to anything less than 0.99 it will fail with the mixed SRID geometries error.

I was wondering if this had anything to do with having holes in the geometry, so I fiddled around with the allow_holes parameter of the ST_Concave without any success (in any case, the default is false).

As you can see bellow I was able to generate the concave hull, but I won't mark this question as solved as I don't understand why it is not possible to decrease the target_percent.

enter image description here

  • Are both showing in geometry_columns? I have seen this when even though the datatype claims to be geometry, 4326, if it is not in geometrycolumns you can get this error. You can fix by running updategeometrysrid. Alternatively, you can explicitly call ST_SetSrid around the geometry, though this is a horrible solution, I think. – John Powell Oct 1 '14 at 11:07
  • Thanks for your answer John. I am 100% sure the SRID is correct, as you can see by the image I added above. Somehow I sense there is something wrong with the way I am writing the query (rather with the base data).... I'll keep researching and will post any findins here – doublebyte Oct 1 '14 at 11:12
  • Usually a SRID is only needed when you are combining two geoms, eg, ST_Intersects, as I'm sure you are aware. So it is odd as you are getting it on the concavehull part. – John Powell Oct 1 '14 at 11:23
  • Yes, it is definitely weird as it works sometimes (see my edited answer above). Maybe it's a bug? – doublebyte Oct 1 '14 at 11:33
  • 1
    Interesting. Bizarre that tolerance should contribute to srid error. Did you know that concave hull function is written in plpgsql so you can read it without needing to know C and fiddle with it. – John Powell Oct 1 '14 at 12:03

Your Answer

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

Browse other questions tagged or ask your own question.