Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a polygon ready in QGIS. What I want to do is to calculate the maximum possible distance in kilometres from the centroid of the polygon up to the boundary of that polygon.

I need two things:

  • Maximum possible distance covered from the centroid of the polygon up to their boundary
  • centre of the Polygon (Lat/Long)
share|improve this question
add comment

1 Answer

To get the centroid you can use Vector->Geometry Tools->Polygon Centroids. Then to get the coordinates you can either add a couple of fields to the attribute table and use the field calculator set to $x and $y respectively for each field or use the Coordinate Capture plugin.

To get the maximum distance you will need to do a little more work. A very simple approach would be to convert your polygon to nodes (Vector->Geometry Tools->Extract Nodes) and then use the distance matrix tool (Vector->AnalysisTools->Distance Matrix). This will give you the distance to every vertex of the polygon and you merely need to sift the result to get the highest value. To improve the accuracy of this approach you could densify your vertices first. If you ensure that your centroid and nodes point datasets preserve an ID from the polygon, this operation should be straightforward.

You could also use the PostGis ST_Distance_spheroid function instead of the QGIS Distance Matrix function as this will give you the linear distance on a spheroid and possibly save you reprojecting your data. Unfortunately the ST_Distance function only gives you the minimum distance so either way, you will need to iterate all the points for a given polygon.

share|improve this answer
Many thanks to You.! –  user1586957 Feb 4 '13 at 11:42
actually i have corner Points and centroid(lat/long) of Polygon in excel..how can we do in excel.. any for formula.. i have centroid in column 'A' and List of corner points in Column 'B'. How could I calculate max. Possible Distance in Column 'C. –  user1586957 Feb 4 '13 at 11:43
distance matrix returns distance in deg. I want it to km. i cant transform this data to any particuar UTM Projection. coz it covers entire India country. Any trick to do that. –  user1586957 Feb 4 '13 at 13:20
You need to do a great circle distance calculation. Search this site for 'Haversine'. –  MappaGnosis Feb 4 '13 at 13:57
(1) Unless the polygon is very large, there is no need to densify the vertices: the maximum distance to the boundary must occur at one of the vertices (using Euclidean calculations). (2) Provided the polygon stays within a hemisphere, why not compute the shortest distance between the polygon and the antipode of its center? The point(s) on the polygon where that shortest distance is attained will be maximally far from the center. The antipode is obtained by negating the latitude and adding 180 degrees (modulo 360) to the longitude; e.g., the antipode of (lon,lat)=(2,50) is at (-178,-50). –  whuber Feb 4 '13 at 14:19
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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