3

I am trying to get the end points of a polygon which presents a building in a shp file.

Do you know if there is any function in geotools or the steps that i have to follow to do this?

i find a relative question: how would one get the end points of a polyline? But it is not what i need.

  • 4
    what do you mean by the end points of a polygon? they are closed by definition so there is no beginning or end, do you mean max and min in some direction? – Ian Turton Oct 6 '16 at 10:40
  • Are you referring to the vertices of the polygon representing a building? – Hasan Mustafa Oct 6 '16 at 10:41
  • Yes, i am talking about the vertices of the polygon representing a building..? do you know how i can "identify" them? – Elena Valari Oct 6 '16 at 13:38
1

If you got your Polygons from your shapefile you can get all vertices using JTS getCoordinates() method:

// get first coordinate
Coordinate first = yourPolygon.getCoordinates()[0];
// get last coordinate (same as first)
Coordinate last = yourPolygon.getCoordinates()[yourPolygon.getCoordinates().length-1];
// get last coordinate before closing
Coordinate lastBeforeClosing = yourPolygon.getCoordinates()[yourPolygon.getCoordinates().length-2];
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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