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.
It looks like you are working with MapInfo. The "Distance Calculator" (find it in tool manager) has many options and I think it can handle this task too. There is an article about it here: http://web.pb.com/mapinfopro-jul-2013/Toolbox-Distance-Calculator
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;
Using next PyQGIS code:
from math import sqrt layer = iface.activeLayer() feats = [ feat for feat in layer.getFeatures() ] n = len(feats) centroids = [ feat.geometry().centroid().asPoint() for feat in feats ] polygons = [ feat.geometry().asPolygon() for feat in feats ] lengths =  for i, pol in enumerate(polygons): max_dist = 0 idx_j = 0 for j, point in enumerate(pol): dist = sqrt(centroids[i].sqrDist(point)) if dist > max_dist: max_dist = dist idx_j = j print i, idx_j, max_dist lengths.append([centroids[i], pol[idx_j]]) crs = layer.crs() epsg = crs.postgisSrid() uri = "LineString?crs=epsg:" + str(epsg) + "&field=id:integer""&index=yes" mem_layer = QgsVectorLayer(uri, 'max_distance', 'memory') prov = mem_layer.dataProvider() feats = [ QgsFeature() for i in range(n) ] for i, feat in enumerate(feats): feat.setAttributes([i]) feat.setGeometry(QgsGeometry.fromPolyline(lengths[i])) prov.addFeatures(feats) QgsMapLayerRegistry.instance().addMapLayer(mem_layer)
and this shapefile (with 11 features):
I got a memory layer where polylines were the distance between centroid and farthest point of each polygon (feature); as it can be observed at the next image:
At the Python Console of QGIS, it was also printed the index of feature, the index of point in feature where distance from centroid is a maximum and, finally, maximum distance.
As it looks like you're using MapInfo, here is a MapBasic function I wrote a while back for an in-house tool I was working on. It takes a source node (your centroid point) and a region object (the polygon) as arguments and returns a point object at the furthest node in the polygon from the source point.
Function GetFurthest(ByVal oNode1 as Object, ByVal oObj as Object) as Object Dim sourceE,sourceN,East,North,Longest,Dist as Float, nNodes,nPolys,i,j as SmallInt, oNode2 as Object sourceE = CentroidX(oNode1) sourceN = CentroidY(oNode1) Longest = 0 nPolys = ObjectInfo(oObj,OBJ_INFO_NPOLYGONS) For i = 1 to nPolys nNodes = ObjectInfo(oObj,OBJ_INFO_NPOLYGONS+nPolys) For j = 1 to nNodes East = ObjectNodeX(oObj,i,j) North = ObjectNodeY(oObj,i,j) Dist = Distance(sourceE,sourceN,East,North,"m") If Dist > Longest then Longest = Dist oNode2 = CreatePoint(East,North) End if Next Next GetFurthest = oNode2 End Function