有没有人有使用.ProjectAs ArcGIS geometry class?的经验我正在创建一个点shapefile。这些点是作为WGS1984 lat/long (EPSG 4326)从文本文件中读取的,我想投影到OSGB (EPSG: 27700)中,然后使用InsertCursor插入到空白点shapefile中。我可以创建点几何图形,但在插入行时不会将投影应用到OSGB。
http://pro.arcgis.com/en/pro-app/arcpy/classes/geometry.htm
with open(nmealist,'r') as srcFile:
with arcpy.da.InsertCursor(OutShp, ["SHAPE@", "SHAPE@X", "SHAPE@Y", "SHAPE@Z"]) as InsCur:
for fileLine in srcFile:
# split the line up into a list
lSplit = fileLine.split(",")
if len(lSplit) == 1:
lSplit = fileLine.split(",")
if len(lSplit) > 1:
# more than just one word on the line
pointsOK = True
try:
FILENAME = str(lSplit[0])
DOS = yymmdd
TIME = str(lSplit[1])
EASTING = float(lSplit[3])
NORTHING = float(lSplit[2])
HEIGHT = float(lSplit[4])
HEADING = float(lSplit[5])
IVA = float(lSplit[6])
FLIGHTID = sortie
except:
arcpy.AddWarning("Unable to translate points")
pointsOK = False
if pointsOK:
newGeom.SpatialReference = srwgs1984 # set spatial reference
# create a point geometry from the 3 coordinates - EASTING, NORTHING, HEIGHT
newGeom = arcpy.PointGeometry(arcpy.Point(EASTING,NORTHING,HEIGHT))
# project point into OSGB
projectedpoint = newGeom.projectAs(srosgb)
InsCur.insertRow([projectedpoint, EASTING, NORTHING, HEIGHT])# insert this point into the feature class发布于 2017-09-29 20:02:21
在InsCur.insertRow指令(最后一行)中,将原始的东距、北距、高度(不带投影)作为"SHAPE@X“、"SHAPE@Y”、"SHAPE@Z“特性传递给新几何图形。
由于点几何图形本身已经包含了这些属性,并且您已经使用所有这些属性正确地定义了新的点几何图形,因此您不应该逐个显式地设置它们。
因此,尝试仅使用"SHAPE@“属性来初始化InsertCursor:
arcpy.da.InsertCursor(OutShp, ["SHAPE@"])然后仅插入投影点对象:
InsCur.insertRow([projectedpoint])https://stackoverflow.com/questions/37883815
复制相似问题