Arcpy几何类.ProjectAs函数

2024-06-26 00:24:45 发布

您现在位置:Python中文网/ 问答频道 /正文

有没有人有过使用.ProjectAsArcGIS geometry class?我正在创建一个点形状文件。这些点以WGS1984 lat/long (EPSG 4326)的形式从文本文件中读取,我想投影到OSGB (EPSG: 27700)中,然后使用InsertCursor插入到空白点形状文件中。我可以创建点几何图形,但插入行时,不会将投影应用到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

Tags: theiffloatsplitheightshapegeometryarcpy
1条回答
网友
1楼 · 发布于 2024-06-26 00:24:45

在InsCur.insertRow说明(最后一行)将原始东距、北距、高度(无投影)传递到新几何体,如下所示形状@X", "形状@Y", "形状@Z“属性。在

由于点几何图形本身已经包含这些特性,并且您已经使用所有这些特性正确地定义了新的点几何图形,因此不必逐个明确地设置这些特性。在

因此,请尝试仅使用“SHAPE@”属性启动InsertCursor:

arcpy.da.InsertCursor(OutShp, ["SHAPE@"])

然后只插入投影点对象:

^{pr2}$

相关问题 更多 >