關(guān)注公眾號(hào)"seeling_GIS"骤视,回復(fù)『前端視頻』鞍爱,領(lǐng)取前端學(xué)習(xí)視頻資料
因?yàn)樽罱谔幚硪恍?shù)據(jù)的時(shí)候用到 spatial adjustment這個(gè)工具,就想著能否通過(guò)arcpy來(lái)實(shí)現(xiàn)整體圖形偏移尚胞,目前的代碼只實(shí)現(xiàn)了根據(jù)一個(gè)固定的經(jīng)緯度差值或者墨卡托差值來(lái)做整體偏移
import arcpy
from arcpy import env
env.workspace = r'F:\gisdata\arcpy_test\spatialAdjust'
point = arcpy.Point()
array = arcpy.Array()
with arcpy.da.UpdateCursor('polygon2.shp',['SHAPE@','FID']) as cursor:
for row in cursor:
g = row[0]
for pts in g:
print list(pts)
for pt in pts:
if pt is not None:
point.X = pt.X + 0.315567
point.Y = pt.Y - 0.055089
array.add(point)
print '%s 數(shù)據(jù)處理完成'% row[1]
geometry = arcpy.Polygon(array, arcpy.SpatialReference(4326))
if g.type==u'polygon':
array.add(array.getObject(0)) # 最后一個(gè)點(diǎn)位和第一個(gè)點(diǎn)位相同組合成一個(gè)polygon
geometry = arcpy.Polygon(array, arcpy.SpatialReference(4326))
array.removeAll()
row[0] = geometry
cursor.updateRow(row)
print '%s 圖形更新完成' % row[1]
更多內(nèi)容硬霍,歡迎關(guān)注公眾號(hào)