1

In my program I am looking for a best place for a golf course. Three of the conditions are:

  1. The course must be on a hill,
  2. it must be at least 100 meters away from roads and
  3. must not be larger than x.

Some of the generated courses are divided into two pieces by a road in the middle.

My question is:

How do I get those pieces as separate features or geometries to check their area? Is that even possible? Can I check if a certain geometry is whole, not split?

Edit: I am using geotools platform. (Feeling stupid that I forgot to mention)

3
  • 1
    which program are you using? have you tried multiparts to singleparts?
    – neogeomat
    May 20, 2018 at 13:22
  • 1
    Any sensible answer would be software dependent; platforms like ArcGIS and GDAL/OGR both have methods to check if a geometry contains more than one part but first you would need to dissolve by Lot/plan to create your multipart polygons if that has not been done already - again, how you do this is software dependent. Please indicate what software/API you have available. May 21, 2018 at 3:26
  • Forgot to mention. I am using geotools so I am looking for a java geotools solution. May 21, 2018 at 17:02

2 Answers 2

1

Most GIS programs have Multiparts to single parts tools that will separate those features into individual parts.

1
  • This would make mulitpart detection harder, and isn't necessary to solve the task.
    – Vince
    May 21, 2018 at 10:52
1

Alright, I have found out how to do what I originally wanted to do.

So in geotools you can get the amount of split (separated) geometries in a feature using method geometry.getNumGeometries();

You can get the single geometry itself using

geometry.getGeometryN(i);

So to do whatever you need (i.e. create new features for each geometry) just use a for loop like this:

Geometry geometry = feature.getDefaultGeometry();
for (int i=0, n=geometry.getNumGeometries(); i<n; i++) {
   Geometry singleGeom = geometry.getGeometryN(i);
   /*Do whatever you need*/
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.