[gdal-dev] FW: Strange results of simple polygonising

Casper Børgesen (CABO) CABO at NIRAS.DK
Fri Jan 20 00:31:17 PST 2017


I have looked at the special case of a raster combining situation 3 and 4 below:

3 + 4:
   # #
#    #
#    #
  #  #

The polygoniser handles this fine by return a result with two separate polygons.

For easier reference, I have included the WKT of the 4 + 1 situations and their results:

1:
Input:   POLYGON ((1 1,3 1,3 2,2 2,2 3,3 3,3 2,4 2,4 4,1 4,1 1))
Result: POLYGON ((1 4,1 1,3 1,3 2,2 2,2 3,3 3,3 2,4 2,4 4,1 4))

2:
Input:   POLYGON ((1 1,4 1,4 3,3 3,3 2,2 2,2 3,3 3,3 4,1 4,1 1))
Result: POLYGON ((1 4,1 1,4 1,4 3,3 3,3 2,2 2,2 3,3 3,3 4,1 4))

3:
Input:   POLYGON ((1 1,4 1,4 4,2 4,2 3,3 3,3 2,2 2,2 3,1 3,1 1))
Result: POLYGON ((2 4,2 3,1 3,1 1,3 1,4 1,4 4,2 4),(2 3,2 2,3 2,3 3,2 3))

4:
Input:   POLYGON ((1 4,1 2,2 2,2 3,3 3,3 2,2 2,2 1,4 1,4 4,1 4))
Result: POLYGON ((1 4,1 2,2 2,2 1,4 1,4 4,1 4),(2 3,3 3,3 2,2 2,2 3))

3 + 4:
Input:   MULTIPOLYGON (((1 2,2 2,2 4,1 4,1 2)),((2 1,4 1,4 5,2 5,2 4,3 4,3 2,2 2,2 1)))
Result: POLYGON ((1 4,1 2,2 2,2 4,1 4)) + POLYGON ((2 5,2 4,3 4,3 2,2 2,2 1,3 1,4 1,4 5,2 5))

I have performed the tests on both GDAL 1.11 and GDAL 2.1 and both return the same results.

Can anyone confirm my observations?

Background: The 4 situations are very simplified versions of much more complicated polygons, where the problem occurs. If I save the results from situation 3 or 4 to a shape file with ogr, the hole in the results are converted to an exterior ring in a separate polygon thus creating overlapping results.

Regards, Casper

From: gdal-dev [mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Casper Børgesen (CABO)
Sent: 19. januar 2017 13:26
To: gdal-dev at lists.osgeo.org
Subject: [gdal-dev] Strange results of simple polygonising

Hi,

I have four simple rasters that I would like to polygonise:

1:
# # #
#    #
# #

2:
# #
#     #
# # #

3:
    # #
#     #
# # #

4:
# # #
#    #
   # #

It's the same shape, just rotated 90, 180, 270 degrees. The resulting polygons for 1 and 2 are simple polygons without holes, where the results for 3 and 4 are polygons with a hole intersecting the exterior ring. Thus 3 and 4 results in invalid geometries with self-intersection.

Is this the intended behavior of the polygoniser?


Regards, Casper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170120/ae86f06e/attachment.html>


More information about the gdal-dev mailing list