does anyone have experience of using the .ProjectAs ArcGIS geometry class? I'm creating a point shapefile. The points are being read from a text file as WGS1984 lat/long (EPSG 4326) and I want to project into OSGB (EPSG: 27700) and then insert into blank point shapefile using InsertCursor. I can create the point geometry but when inserting the row is doesn't apply the projection to 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
Aucun commentaire:
Enregistrer un commentaire