[GIS] Distance between centroid and farthest point of polygon

arcgis-10.1arcgis-desktopmapinfoqgis

I have a village polygon layer which has more than 6,00,000 records.
I have calculated centroid of each village.
I want to find the distance between centroid and the farthest node of each polygon.
Check the image below for reference. Black lines are polygon boundaries.
enter image description here

enter image description here

enter image description here

Best Answer

Using PostGIS, I used ST_ConvexHull to simplify the polygon for a faster result:

Get the furthest Point:

SELECT Villages_v4_Trial_region.geom as FarPoint from (
SELECT ST_PointN(ST_ExteriorRing(ST_ConvexHull(Villages_v4_Trial_region.geom)),
generate_series(1, ST_NPoints(ST_ExteriorRing(ST_ConvexHull(Villages_v4_Trial_region.geom))))) as points, 
geom
FROM Villages_v4_Trial_region
ORDER BY ST_MaxDistance(points,ST_Centroid(Villages_v4_Trial_region.geom)) DESC
LIMIT 1;

And if you are interested in creating a Circle from the centroid:

SELECT ST_Buffer(Center,ST_Distance(Center,FarPoint)) as Circle
FROM (
SELECT Villages_v4_Trial_region.geom as FarPoint, Center from (
    SELECT ST_PointN(ST_ExteriorRing(ST_ConvexHull(Villages_v4_Trial_region.geom)),
    generate_series(1, ST_NPoints(ST_ExteriorRing(ST_ConvexHull(Villages_v4_Trial_region.geom))))) as points,
    ST_Centroid(Villages_v4_Trial_region.geom) as Center, 
    geom
    FROM Villages_v4_Trial_region
    ) as Villages_v4_Trial_region
    ORDER BY ST_MaxDistance(points,Center) DESC
    LIMIT 1) as foo;

enter image description here

Related Question