ArcGIS中Python逆地理编码,根据坐标获取实际的地址
import json import urllib import arcpy def getAddress(lng,lat): url= 'http://restapi.amap.com/v3/geocode/regeo?key=9f8bd8c2574ed9000d1e995b894c4c12&location={},{}&poitype=&radius=1000&extensions=base&batch=false&roadlevel=' url=url.format(lng,lat) req = urllib.urlopen(url) ret = req.readlines() ret = json.loads(ret[0]) ret =ret['regeocode']['formatted_address'] return ret def mainFunc(): mxd = arcpy.mapping.MapDocument("CURRENT") layers = arcpy.mapping.ListLayers(mxd) fields = ['FID',"SHAPE@XY","地址"] with arcpy.da.UpdateCursor(layers[0], fields) as cursor: for row in cursor: addr = getAddress(row[1][0],row[1][1]) row[2]=addr cursor.updateRow(row)