Possible difference anomaly

Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible difference anomaly

Paul Meems
Hi List,

I'm creating irregular polygons and I don't want to let them overlap.
So before adding the polygon to my list of 'good' polygons, I do an overlap check first.
When the polygon overlaps with an existing polygon I do a clip difference and add the clipped polygon to my good list.

Sometimes two polygons still overlap after a clip difference.

I managed to extract two sets that barely overlap. The first set doesn't overlap anymore after clipping the second one is still overlapping.

Set 1:
shp = POLYGON ((259449.071118579 543868.469050065,259460.460699968 543878.23006619,259463.245769758 543873.768560297,259455.578068317 543860.876455946,259449.071118579 543868.469050065))
shp2 = POLYGON ((259463.243735243 543856.317227775,259458.0148573 543864.973555723,259462.906856719 543873.198728218,259471.741696109 543861.450443661,259463.243735243 543856.317227775))
shp3 (clipped result) = POLYGON ((259463.243735243 543856.317227775,259458.014857301 543864.973555722,259462.906856719 543873.198728217,259471.741696109 543861.450443661,259463.243735243 543856.317227775))

Set 2:
shp = POLYGON ((259073.014081524 544320.092508488,259085.267633063 544321.677731439,259085.942168897 544320.308101652,259074.192475622 544310.983687036,259073.014081524 544320.092508488))
shp2 = POLYGON ((259087.677538158 544333.393525226,259097.260135269 544321.853428493,259090.546766392 544316.354731347,259079.984140336 544327.005127152,259087.677538158 544333.393525226))
shp3 (clipped result) = POLYGON ((259087.677538158 544333.393525226,259097.260135269 544321.853428493,259090.546766392 544316.354731347,259085.267633064 544321.677731438,259085.267633063 544321.677731439,259085.267633062 544321.677731439,259079.984140336 544327.005127152,259087.677538158 544333.393525226))

I'm using C# with MapWinGIS to do the actions:
            if (shp.Overlaps(shp2))
            {
                var shp3 = shp2.Clip(shp, tkClipOperation.clDifference);
                Assert.IsFalse(shp.Overlaps(shp3), "New shape still overlaps");
            }

MapWinGIS is using the GDAL v2.3.3 binaries from GisInternals which in turn is using geos-3.4 
MapWinGIS is directly porting its functions to the GEOS functions:

Before I report this as a defect I want to know if my workflow and expectations are correct.

Thanks,

Paul

_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel
Reply | Threaded
Open this post in threaded view
|

Re: Possible difference anomaly

Paul Ramsey
No, assumptions are not quite correct.
It’s possible you’ll get an introduced vertex in the clipped geometry that is not a component of the clipping geometry and is also slightly inside one of the clipping geometry’s edges… I think in order to handle this we’d need to have a function that takes in both geometries and adjusts them both. If you’re only generating one geometry, it seems like it is always possible to have cases with edge mismatches. Maybe for your case if you difference to to get your input geometry, and then difference *that* from all the stored polygons you already have, which would hopefully result in an output collection in which all neighbours have the same vertices in the same places.

P

On Jan 2, 2019, at 7:48 AM, Paul Meems <[hidden email]> wrote:

Hi List,

I'm creating irregular polygons and I don't want to let them overlap.
So before adding the polygon to my list of 'good' polygons, I do an overlap check first.
When the polygon overlaps with an existing polygon I do a clip difference and add the clipped polygon to my good list.

Sometimes two polygons still overlap after a clip difference.

I managed to extract two sets that barely overlap. The first set doesn't overlap anymore after clipping the second one is still overlapping.

Set 1:
shp = POLYGON ((259449.071118579 543868.469050065,259460.460699968 543878.23006619,259463.245769758 543873.768560297,259455.578068317 543860.876455946,259449.071118579 543868.469050065))
shp2 = POLYGON ((259463.243735243 543856.317227775,259458.0148573 543864.973555723,259462.906856719 543873.198728218,259471.741696109 543861.450443661,259463.243735243 543856.317227775))
shp3 (clipped result) = POLYGON ((259463.243735243 543856.317227775,259458.014857301 543864.973555722,259462.906856719 543873.198728217,259471.741696109 543861.450443661,259463.243735243 543856.317227775))

Set 2:
shp = POLYGON ((259073.014081524 544320.092508488,259085.267633063 544321.677731439,259085.942168897 544320.308101652,259074.192475622 544310.983687036,259073.014081524 544320.092508488))
shp2 = POLYGON ((259087.677538158 544333.393525226,259097.260135269 544321.853428493,259090.546766392 544316.354731347,259079.984140336 544327.005127152,259087.677538158 544333.393525226))
shp3 (clipped result) = POLYGON ((259087.677538158 544333.393525226,259097.260135269 544321.853428493,259090.546766392 544316.354731347,259085.267633064 544321.677731438,259085.267633063 544321.677731439,259085.267633062 544321.677731439,259079.984140336 544327.005127152,259087.677538158 544333.393525226))

I'm using C# with MapWinGIS to do the actions:
            if (shp.Overlaps(shp2))
            {
                var shp3 = shp2.Clip(shp, tkClipOperation.clDifference);
                Assert.IsFalse(shp.Overlaps(shp3), "New shape still overlaps");
            }

MapWinGIS is using the GDAL v2.3.3 binaries from GisInternals which in turn is using geos-3.4 
MapWinGIS is directly porting its functions to the GEOS functions:

Before I report this as a defect I want to know if my workflow and expectations are correct.

Thanks,

Paul
_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel


_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel
Reply | Threaded
Open this post in threaded view
|

Re: Possible difference anomaly

Darafei "Komяpa" Praliaskouski
Hi,

last time I researched the topic generating a set of administrative boundaries from different tataset pprepair was a lifesaver, patching up the planar partition of my heterogeneous coverage: https://github.com/tudelft3d/pprepair


ср, 2 янв. 2019 г. в 19:33, Paul Ramsey <[hidden email]>:
No, assumptions are not quite correct.
It’s possible you’ll get an introduced vertex in the clipped geometry that is not a component of the clipping geometry and is also slightly inside one of the clipping geometry’s edges… I think in order to handle this we’d need to have a function that takes in both geometries and adjusts them both. If you’re only generating one geometry, it seems like it is always possible to have cases with edge mismatches. Maybe for your case if you difference to to get your input geometry, and then difference *that* from all the stored polygons you already have, which would hopefully result in an output collection in which all neighbours have the same vertices in the same places.

P


On Jan 2, 2019, at 7:48 AM, Paul Meems <[hidden email]> wrote:

Hi List,

I'm creating irregular polygons and I don't want to let them overlap.
So before adding the polygon to my list of 'good' polygons, I do an overlap check first.
When the polygon overlaps with an existing polygon I do a clip difference and add the clipped polygon to my good list.

Sometimes two polygons still overlap after a clip difference.

I managed to extract two sets that barely overlap. The first set doesn't overlap anymore after clipping the second one is still overlapping.

Set 1:
shp = POLYGON ((259449.071118579 543868.469050065,259460.460699968 543878.23006619,259463.245769758 543873.768560297,259455.578068317 543860.876455946,259449.071118579 543868.469050065))
shp2 = POLYGON ((259463.243735243 543856.317227775,259458.0148573 543864.973555723,259462.906856719 543873.198728218,259471.741696109 543861.450443661,259463.243735243 543856.317227775))
shp3 (clipped result) = POLYGON ((259463.243735243 543856.317227775,259458.014857301 543864.973555722,259462.906856719 543873.198728217,259471.741696109 543861.450443661,259463.243735243 543856.317227775))

Set 2:
shp = POLYGON ((259073.014081524 544320.092508488,259085.267633063 544321.677731439,259085.942168897 544320.308101652,259074.192475622 544310.983687036,259073.014081524 544320.092508488))
shp2 = POLYGON ((259087.677538158 544333.393525226,259097.260135269 544321.853428493,259090.546766392 544316.354731347,259079.984140336 544327.005127152,259087.677538158 544333.393525226))
shp3 (clipped result) = POLYGON ((259087.677538158 544333.393525226,259097.260135269 544321.853428493,259090.546766392 544316.354731347,259085.267633064 544321.677731438,259085.267633063 544321.677731439,259085.267633062 544321.677731439,259079.984140336 544327.005127152,259087.677538158 544333.393525226))

I'm using C# with MapWinGIS to do the actions:
            if (shp.Overlaps(shp2))
            {
                var shp3 = shp2.Clip(shp, tkClipOperation.clDifference);
                Assert.IsFalse(shp.Overlaps(shp3), "New shape still overlaps");
            }

MapWinGIS is using the GDAL v2.3.3 binaries from GisInternals which in turn is using geos-3.4 
MapWinGIS is directly porting its functions to the GEOS functions:

Before I report this as a defect I want to know if my workflow and expectations are correct.

Thanks,

Paul
_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel

_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel
--
Darafei Praliaskouski
Support me: http://patreon.com/komzpa

_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel
Reply | Threaded
Open this post in threaded view
|

Re: Possible difference anomaly

Martin Davis-3
In reply to this post by Paul Meems
As Paul says, this is expected behaviour, due to the fact that in general constructed intersection vertices do not lie exactly on the line segments which intersect.  Furthermore, this can't be solved by using a coarser precision model - that just makes the problem worse!

So the only way to "solve" this is to ask a different question.  One possibility is to to process all or some of the input polygons to form a properly noded coverage.  Or, use a tolerance value in the overlaps predicate, and accept that the output coverage will only be approximately accurate.

Both of these solutions will require some new algorithms in GEOS...

On Wed, Jan 2, 2019 at 7:48 AM Paul Meems <[hidden email]> wrote:
Hi List,

I'm creating irregular polygons and I don't want to let them overlap.
So before adding the polygon to my list of 'good' polygons, I do an overlap check first.
When the polygon overlaps with an existing polygon I do a clip difference and add the clipped polygon to my good list.

Sometimes two polygons still overlap after a clip difference.

I managed to extract two sets that barely overlap. The first set doesn't overlap anymore after clipping the second one is still overlapping.

Set 1:
shp = POLYGON ((259449.071118579 543868.469050065,259460.460699968 543878.23006619,259463.245769758 543873.768560297,259455.578068317 543860.876455946,259449.071118579 543868.469050065))
shp2 = POLYGON ((259463.243735243 543856.317227775,259458.0148573 543864.973555723,259462.906856719 543873.198728218,259471.741696109 543861.450443661,259463.243735243 543856.317227775))
shp3 (clipped result) = POLYGON ((259463.243735243 543856.317227775,259458.014857301 543864.973555722,259462.906856719 543873.198728217,259471.741696109 543861.450443661,259463.243735243 543856.317227775))

Set 2:
shp = POLYGON ((259073.014081524 544320.092508488,259085.267633063 544321.677731439,259085.942168897 544320.308101652,259074.192475622 544310.983687036,259073.014081524 544320.092508488))
shp2 = POLYGON ((259087.677538158 544333.393525226,259097.260135269 544321.853428493,259090.546766392 544316.354731347,259079.984140336 544327.005127152,259087.677538158 544333.393525226))
shp3 (clipped result) = POLYGON ((259087.677538158 544333.393525226,259097.260135269 544321.853428493,259090.546766392 544316.354731347,259085.267633064 544321.677731438,259085.267633063 544321.677731439,259085.267633062 544321.677731439,259079.984140336 544327.005127152,259087.677538158 544333.393525226))

I'm using C# with MapWinGIS to do the actions:
            if (shp.Overlaps(shp2))
            {
                var shp3 = shp2.Clip(shp, tkClipOperation.clDifference);
                Assert.IsFalse(shp.Overlaps(shp3), "New shape still overlaps");
            }

MapWinGIS is using the GDAL v2.3.3 binaries from GisInternals which in turn is using geos-3.4 
MapWinGIS is directly porting its functions to the GEOS functions:

Before I report this as a defect I want to know if my workflow and expectations are correct.

Thanks,

Paul
_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel

_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel
Reply | Threaded
Open this post in threaded view
|

Re: Possible difference anomaly

Paul Meems
Thanks all for the quick reply and sorry for my late response.

Thanks, Paul and Martin for clarifying the behavior to me. I'll see if I can change my workflow to handle these edge cases.

Also thanks to Darafei for the link to pprepair. I'll have a look at it, but I'm running Windows so it is a bit more complex to quickly test ;)

Regards,

Paul

Paul Meems 
Release manager, configuration manager
and forum moderator of MapWindow GIS.
www.mapwindow.org

Owner of MapWindow.nl - Support for
Dutch speaking users.
www.mapwindow.nl


The MapWindow GIS project has moved to GitHub!


Download the latest MapWinGIS mapping engine.

Download the latest MapWindow 5 open source desktop application.



Op wo 2 jan. 2019 om 18:26 schreef Martin Davis <[hidden email]>:
As Paul says, this is expected behaviour, due to the fact that in general constructed intersection vertices do not lie exactly on the line segments which intersect.  Furthermore, this can't be solved by using a coarser precision model - that just makes the problem worse!

So the only way to "solve" this is to ask a different question.  One possibility is to to process all or some of the input polygons to form a properly noded coverage.  Or, use a tolerance value in the overlaps predicate, and accept that the output coverage will only be approximately accurate.

Both of these solutions will require some new algorithms in GEOS...

On Wed, Jan 2, 2019 at 7:48 AM Paul Meems <[hidden email]> wrote:
Hi List,

I'm creating irregular polygons and I don't want to let them overlap.
So before adding the polygon to my list of 'good' polygons, I do an overlap check first.
When the polygon overlaps with an existing polygon I do a clip difference and add the clipped polygon to my good list.

Sometimes two polygons still overlap after a clip difference.

I managed to extract two sets that barely overlap. The first set doesn't overlap anymore after clipping the second one is still overlapping.

Set 1:
shp = POLYGON ((259449.071118579 543868.469050065,259460.460699968 543878.23006619,259463.245769758 543873.768560297,259455.578068317 543860.876455946,259449.071118579 543868.469050065))
shp2 = POLYGON ((259463.243735243 543856.317227775,259458.0148573 543864.973555723,259462.906856719 543873.198728218,259471.741696109 543861.450443661,259463.243735243 543856.317227775))
shp3 (clipped result) = POLYGON ((259463.243735243 543856.317227775,259458.014857301 543864.973555722,259462.906856719 543873.198728217,259471.741696109 543861.450443661,259463.243735243 543856.317227775))

Set 2:
shp = POLYGON ((259073.014081524 544320.092508488,259085.267633063 544321.677731439,259085.942168897 544320.308101652,259074.192475622 544310.983687036,259073.014081524 544320.092508488))
shp2 = POLYGON ((259087.677538158 544333.393525226,259097.260135269 544321.853428493,259090.546766392 544316.354731347,259079.984140336 544327.005127152,259087.677538158 544333.393525226))
shp3 (clipped result) = POLYGON ((259087.677538158 544333.393525226,259097.260135269 544321.853428493,259090.546766392 544316.354731347,259085.267633064 544321.677731438,259085.267633063 544321.677731439,259085.267633062 544321.677731439,259079.984140336 544327.005127152,259087.677538158 544333.393525226))

I'm using C# with MapWinGIS to do the actions:
            if (shp.Overlaps(shp2))
            {
                var shp3 = shp2.Clip(shp, tkClipOperation.clDifference);
                Assert.IsFalse(shp.Overlaps(shp3), "New shape still overlaps");
            }

MapWinGIS is using the GDAL v2.3.3 binaries from GisInternals which in turn is using geos-3.4 
MapWinGIS is directly porting its functions to the GEOS functions:

Before I report this as a defect I want to know if my workflow and expectations are correct.

Thanks,

Paul
_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel
_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel

_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel