Python 如何在arcpy中的要素类内添加具有XY坐标的点?
我是arcpy的新手,我花了一整天的时间试图弄清楚如何在arcpy的要素类中添加一个具有XY坐标的点。以下是我现在掌握的代码:Python 如何在arcpy中的要素类内添加具有XY坐标的点?,python,python-2.7,gis,arcpy,arcmap,Python,Python 2.7,Gis,Arcpy,Arcmap,我是arcpy的新手,我花了一整天的时间试图弄清楚如何在arcpy的要素类中添加一个具有XY坐标的点。以下是我现在掌握的代码: coordinates = raw_input("Please enter longitude and latitude as floats split by a space: ") c_split = coordinates.split() lng = float(c_split[0]) lat = float(c_split[1]) spatial_referen
coordinates = raw_input("Please enter longitude and latitude as floats split by a space: ")
c_split = coordinates.split()
lng = float(c_split[0])
lat = float(c_split[1])
spatial_reference = arcpy.SpatialReference(3857)
arcpy.CreateFeatureclass_management('D:\Documents\GIS_DATA\buildings_sample_8', "center.shp", "POINT", "", "DISABLED", "DISABLED", spatial_reference)
center = "center.shp"
cursor = arcpy.da.InsertCursor('D:\Documents\GIS_DATA\buildings_sample_8\center.shp', ["SHAPE@XY"])
xy = (lng, lat)
cursor.insertRow([xy])
这将在适当的目录中创建shapefile center.shp,但我无法将用户输入的经度和纬度值添加到该点,使该点显示为默认的0,0
这可能是一个超级简单的问题,但我一直无法在网上找到文档
谢谢大家! 尝试更改此选项:
xy = (lng, lat)
为此:
xy = arcpy.Point(lng, lat)
我猜您的坐标浮点实际上是一个点(.)而不是一个逗号(,),否则您在尝试创建点时会出错(输入值不是数字)。您可以尝试与这里相同的过程,但将其插入(文件)地理数据库中的要素类吗?