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)

 

posted @ 2018-12-30 15:15  lwn6  阅读(622)  评论(0编辑  收藏  举报
什么是幸福?天天在做自己想做的事情,家人、同事、朋友、客户、网友都和和睦睦,身体健康、钱包鼓鼓、女朋友天天开心、生活无忧无虑就是最大的幸福