【ArcPy】如何在ArcPy创建要素中生成精准的XY坐标?解决精度损失问题
使用ArcPy创建要素的代码段前面有发布,【arcpy】创建点、线、面(孔洞、环、多部件)要素、要素类
Q:这些代码里创建要素后会存在XY精度损失的问题,如何解决?
A:解决方案是在创建要素过程中指定正确的空间参考。
部分原文如下:
This observation goes back to 2010. If a spatial reference isn't specified, then you will get lower precision results. See https://geonet.esri.com/thread/10256 for starters. The examples are more extensive. There are even more in subsequent years. Specifying a floating point input has no impact, so rule that out as a thought.
>>> import arcpy
>>> corners =[[0.0,0.0],[0.0,1.0],[1.0,1.0],[1.0,0.0],[0.0,0.0]]
>>> p=arcpy.Polygon(arcpy.Array([arcpy.Point(*coords) for coords in corners]))
>>> p.area
1.0002441555261612
>>> # hmmmm close... try again
>>> SR = arcpy.SpatialReference(3395) # WGS_1984_ World_Mercator_3395.prj doesn't really matter
>>> p=arcpy.Polygon(arcpy.Array([arcpy.Point(*coords) for coords in corners]),SR)
>>> p.area
1.0