descObj = arcpy.Describe(inFeatures) shapeName = descObj.shapeFieldName spatialRef = descObj.spatialReference pointGeometryList = [] ### finds polygon centroid in projected meters rows = arcpy.SearchCursor(inFeatures) for row in rows: polyCent = row.getValue(shapeName).centroid pointGeometry = arcpy.PointGeometry(polyCent, spatialRef) pointGeometryList.append(pointGeometry) del rows ### creates in memory point feature if arcpy.Exists(outFeatures): arcpy.Delete_management(outFeatures) arcpy.CopyFeatures_management(pointGeometryList, outFeatures) ### projects centoid to WGS84 (must write to FeatClass) if arcpy.Exists(ddFeatures): arcpy.Delete_management(ddFeatures) arcpy.Project_management(outFeatures, ddFeatures, ddPrj) ### find centroid in decimal degrees descObj = arcpy.Describe(ddFeatures) shapeName = descObj.shapeFieldName rows = arcpy.SearchCursor(ddFeatures) for row in rows: longitude = row.getValue(shapeName).centroid.X latitude = row.getValue(shapeName).centroid.Y print str(longitude) print str(latitude) del rows
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.