ArcGIS Python 获得坐标
import arcpy infc = arcpy.GetParameterAsText(0) # Identify the geometry field # desc = arcpy.Describe(infc) shapefieldname = desc.ShapeFieldName # Create search cursor # rows = arcpy.SearchCursor(infc) # Enter for loop for each feature/row # for row in rows: # Create the geometry object # feat = row.getValue(shapefieldname) # Print the current multipoint's ID # print "Feature %i:" % row.getValue(desc.OIDFieldName) partnum = 0 # Step through each part of the feature # for part in feat: # Print the part number # print "Part %i:" % partnum # Step through each vertex in the feature # for pnt in feat.getPart(partnum): if pnt: # Print x,y coordinates of current point # print pnt.X, pnt.Y else: # If pnt is None, this represents an interior ring # print "Interior Ring:" partnum += 1
改进代码
# -*- coding: cp936 -*- import arcpy infc = arcpy.GetParameterAsText(0) # Identify the geometry field # desc = arcpy.Describe(infc) shapefieldname = desc.ShapeFieldName # Create search cursor # rows = arcpy.SearchCursor(infc) # Enter for loop for each feature/row # for row in rows: # Create the geometry object # feat = row.getValue(shapefieldname) # Print the current multipoint's ID # arcpy.AddMessage("Feature %i:" % row.getValue(desc.OIDFieldName)) print "Feature %i:" % row.getValue(desc.OIDFieldName) partnum = 0 # Step through each part of the feature # for part in feat: # Print the part number # print "Part %i:" % partnum arcpy.AddMessage("Part %i:" % partnum) # Step through each vertex in the feature # i=0 for pnt in feat.getPart(partnum): if pnt: # Print x,y coordinates of current point # print pnt.X, pnt.Y arcpy.AddMessage("i="+str(i)+",X="+str(pnt.X)+", Y="+str(pnt.Y)) else: # If pnt is None, this represents an interior ring # print "Interior Ring:" arcpy.AddMessage("Interior Ring:") i=i+1 partnum += 1
输出坐标如下
消息
执行: 获得坐标 fw_1
开始时间: Mon May 13 08:31:04 2019
正在运行脚本 获得坐标...
Feature 660:
Part 0:
i=0,X=57219.7552977, Y=86478.4272009
i=1,X=57797.135264, Y=86224.559745
i=2,X=57266.9342054, Y=86029.10427
i=3,X=57219.7552977, Y=86478.4272009
Interior Ring:
i=5,X=57345.5657184, Y=86314.4243312
i=6,X=57408.4709287, Y=86170.6409933
i=7,X=57514.0618175, Y=86278.4784967
i=8,X=57345.5657184, Y=86314.4243312
Completed script 获得坐标...
成功 在 Mon May 13 08:31:04 2019 (经历的时间: 0.00 秒)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
2011-05-13 arcgis tin内存溢出解决办法
2011-05-13 ArcGIS10 数据建模 每日一贴 花边图框制作
2011-05-13 ArcGIS10 三维成果展示