I've got a collection of geometry objects. Now i want to calculate the minimal bounding rectangle from the whole collection. i'm using the java topology suite, but I can't figure out how to do this?
Have a look in http://tsusiatsoftware.net/jts/javadoc/index.html
If I assume you are using a GeometryCollection instance. If it's true, you can directly call
geometry.getEnvelope();
or
geometry.getEnvelopeInternal();
If you want an Envelope instance
It will return you the minimum rectangle of the GeometryCollection.
If you have a collection of Geometries, you can use an envelope directly, and expand it each time you process a new geometryc of your collection.
Envelope env = new Envelope();
for(Geometry g : mySet){
env.expandToInclude(g.getEnvelopeInternal()):
}
or
Envelope env = new Envelope();
for(Geometry g : mySet){
env.expandToInclude(g.getBoundary().getEnvelopeInternal()):
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With