locationtech / jts

The JTS Topology Suite is a Java library for creating and manipulating vector geometry.
Other
1.98k stars 443 forks source link

Find voids in polygons #890

Closed mohammedX6 closed 2 years ago

mohammedX6 commented 2 years ago

How do we find voids between polygons? More information

dr-jts commented 2 years ago

JTS doesn't (yet) have the concept of a Topology. It (mostly) operates just on discrete geometry objects. To find voids (AKA gaps) in a polygonal coverage, the easiest way is to combine them into a GeometryCollection and then use Geometry.union() to create a MultiPolygon. Then voids show up as holes in the element polygons.

If you are sure that the input is a valid polygonal coverage you can also use CoverageUnion to do this more performantly.

mohammedX6 commented 2 years ago

Thanks for the response dr. I thought the same thing, but I ended to abandon this idea because my problem is a complex one What I am trying to do is this :

Suppose we have a point that is surrounded by polygons how to check if the point is in a void with no gaps between polygons Like this

Untitled

mohammedX6 commented 2 years ago

For my use case finding holes in the polygons was suffiect.