码迷,mamicode.com
首页 > 编程语言 > 详细

ArcGIS中Python逆地理编码,根据坐标获取实际的地址

时间:2018-12-30 15:36:15      阅读:411      评论:0      收藏:0      [点我收藏+]

标签:bat   ext   level   lib   turn   tap   .com   list   [1]   

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)

 

ArcGIS中Python逆地理编码,根据坐标获取实际的地址

标签:bat   ext   level   lib   turn   tap   .com   list   [1]   

原文地址:https://www.cnblogs.com/lwngreat/p/10199527.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!