Opened 16 years ago

Closed 14 years ago

#31 closed defect (fixed)

Negative distance buffer

Reported by: joao...@… Owned by:
Priority: medium Milestone: PostGIS 1.4.3
Component: postgis Version: 1.4.X
Keywords: Cc:

Description (last modified by pramsey)

I’ve detected a possible bug or at least a bizarre behavior when performing a buffer query with negative distances (e.g.: SELECT st_buffer(a.the_geom, -5.725)...). In some cases interior rings are not being used to perform the inner buffer generation (this is illustrated by the reddish features in the image attachment) although for most of the cases rings are correctly used (green features).

Tests using polygon/multipolygon themes revealed the same result. I've

compared the areas of buffered and non-buffered polygons with very small distances, and in some cases the negative buffered area is bigger revealing the inclusion of the rings areas.

Performing an intersction positevely identifies the problematic polygons:

SELECT a.gid,

a.the_geom

FROM original a, negative_buffer b WHERE st_intersects(a.the_geom, b.st_buffer) AND a.gid<>b.gid;

Enviroment: -- WinXP SP2 -- PostgreSQL 8.2.0.7 -- PostGIS 1.3.3 (data imported under 1.3.2)

Change History (13)

comment:1 by pramsey, 16 years ago

I can't even run a -5.725 buffer on the test data.

test=# select area(buffer(the_geom,-5)) from neutral_landscape_model; ERROR: getPoint2d_p: point offset out of range

All polygons test out as valid, however.

comment:2 by joao...@…, 16 years ago

Sorry, the previous query was a generic sample although I don't have any problem executing it. Try this out (for multi themes):

SELECT st_buffer(st_geometryn(a.the_geom, 1), -0.001) FROM neutral_landscape_model AS a;

MULTIPOLYGONS with gid(s) 1794 and 1830 correspond to the non-buffered rings in geometry 2063 for the submited image/test data. To test the area effect you have to try with a very small negative distance (close to 0).

comment:3 by joao...@…, 16 years ago

Hi! Any progress about this issue? I've been continuously testing this problem over more than 20 valid datasets, and keep getting the same error/behaviour for the st_buffer function. Sometimes the number of non-buffered rings is quite small in other cases (for very large multi/polygons with hundreds of rings) is very high.

I also found that in some cases, using simple polygons with no rings, they don't get

negatively or positively buffered at all. I've also found differential behaviour when trying to buffer (+ or -) valid GEOMETRYCOLLECTIONs, MULTIPOLYGONs or POLYGONs, and that the last achieves the most complete results for all the geom types.

Buffer function needs to be reviewed and some geometrical aspects of buffer

aspect/configuration/generation really need to be clarified and improved, mainly because it severely affects many aspects when performing spatial analysis and querying. I hope this helps to strengthen the case.

comment:4 by mcayland, 16 years ago

Hi,

I apologise if this has fallen from the radar, it seems that most of the developers (including myself) are busy with other projects at the moment. One thing that would be a great help would be to determine whether or not the problem is caused by just GEOS or PostGIS' interaction with GEOS.

If you could run your POLYGONs through GEOS' XMLTester and compare the results with PostGIS, then this would be a helpful starting point.

ATB,

Mark.

comment:5 by joao...@…, 16 years ago

Seems like a similar problem is already in GEOS trac (http://trac.osgeo.org/geos/ticket/158).

I had some difficulties when trying to find out some information/samples/examples

regarding the use of the XMLTester in GEOS and also regarding the XML test schema. However, I was able to assemble some xml files from my test data (used a simple script to generate this files based on PostGIS results) and I ran them through the XMLTester as suggested for GEOS and also for JTS. The results can be observed in the attached files. Seems like there is a high error rate when using st_buffer (for both inner and outer rings) and that JTS has got a more conservative error detection approach (?) compared to GEOS.

Please check out the syntax for the attached xml files and the results. I hope that

this tests help to track the problem. Any ideas for results interpretation? More testing needed?

comment:6 by mcayland, 16 years ago

Hi,

Thanks for providing the test results above. It does seem as if this is a GEOS/JTS issue, and I'm afraid the internals of GEOS are outside of my personal sphere of knowledge. It may be useful to file the same bug on the GEOS bugtracker so that it gets picked up there; unfortunately I'm not really sure how active the GEOS developers are at the moment - perhaps someone else would be able to comment.

ATB,

Mark.

comment:7 by nicholas.domnic.i, 16 years ago

Hi, just started with postgis, does any one know how do i find the roads which runs along a polygon. There are two tables. Roads and River i have to find the roads that run along the border of River.

thank you Nicholas I

comment:8 by robe, 16 years ago

Nicholas,

This is the bug report system. I think you would have better luck and its more appropriate to ask your question to the postgis-users group which you can subscribe to from here

http://postgis.refractions.net/mailman/listinfo/postgis-users

comment:9 by pramsey, 14 years ago

Description: modified (diff)
Milestone: PostGIS 1.4.3
Status: acceptednew
Version: 1.4.X

comment:10 by pramsey, 14 years ago

Resolution: acceptedfixed
Status: newclosed
Note: See TracTickets for help on using tickets.