Arcpy几何类.项目函数



是否有人有使用.projects 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

在inscur.inserstrow指令中(最后一行)您通过原始的速度,北方,高度(没有投影),以" shape@x",shape@y为" shape@x"," shape@z"属性。

由于点的几何形状本身已经包含了这些属性,并且您已经使用所有这些属性正确地定义了新点几何形状,因此您不必一个一个一个earplicity。

因此,尝试仅使用" shape@"属性来启动插入器:

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

,然后仅插入投影点对象:

InsCur.insertRow([projectedpoint])

相关内容

  • 没有找到相关文章

最新更新