关注公众号"seeling_GIS",回复『前端视频』,领取前端学习视频资料
因为最近在处理一些数据的时候用到 spatial adjustment这个工具,就想着能否通过arcpy来实现整体图形偏移,目前的代码只实现了根据一个固定的经纬度差值或者墨卡托差值来做整体偏移
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 数据处理完成'% row[1]
geometry = arcpy.Polygon(array, arcpy.SpatialReference(4326))
if g.type==u'polygon':
array.add(array.getObject(0)) # 最后一个点位和第一个点位相同组合成一个polygon
geometry = arcpy.Polygon(array, arcpy.SpatialReference(4326))
array.removeAll()
row[0] = geometry
cursor.updateRow(row)
print '%s 图形更新完成' % row[1]
更多内容,欢迎关注公众号