ArcPy PointGeometry not placing the point on the correct value

458
1
Jump to solution
03-18-2022 03:32 PM
ccowin_odfw
Occasional Contributor

Hello,

Writing a script and am taking data from a sqlite3 database and inserting it into a gdb. Figured it out with just adding the x and y as a tuple into the insert cursor but also wanted to add elevation as it was an available field. It is successfully inserting the point but the point is not placed at the coordinate points that it was given.

Here is my code:

sr = arcpy.Describe(output_table).spatialReference

if db_count > gdb_count:
print(f'{collar_id} has {db_count} rows in the sqlite db and {gdb_count} in the gdb.')
rows_no_geo = rows[-(db_count - gdb_count):]
for rows in rows_no_geo:
# Convert tuple to list to extract needed data
rows_as_list = list(rows)

# Assign variables to needed values
# Lat, Long, Height first to build point geometry
lat = rows_as_list[8]
long = rows_as_list[9]
height = rows_as_list[10]
geo = arcpy.PointGeometry(arcpy.Point(long, lat, height), spatial_reference=sr, has_z=True)

 I've tried with and without the spatial reference and it places it in the same point. For example one point is at 44.56669, -117.7572 and it is being placed at 41.6444452°N , 125.3000668°W. I'm assuming this has to be something to spatial reference but I don't know how to resolve it. I generally work in NAD 1983 Oregon Statewide Lambert (Intl Feet).

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

Seems like you're taking a tuple of lat/longs and creating new points specifying those lat longs as xy for NAD83 oregon.  Probably placing all your points near to the false origin of the planimetric coordinate system.

#create wgs84 geometry first
geo = arcpy.PointGeometry(arcpy.Point(long, lat, height), spatial_reference="4326", has_z=True)

#project into NAD83 oregon
#theres a transformation_name parameter also if you have one
#NB you may have more control over using an arcpy method instead
geo_projected = geo.projectAs(sr)

View solution in original post

1 Reply
DavidPike
MVP Frequent Contributor

Seems like you're taking a tuple of lat/longs and creating new points specifying those lat longs as xy for NAD83 oregon.  Probably placing all your points near to the false origin of the planimetric coordinate system.

#create wgs84 geometry first
geo = arcpy.PointGeometry(arcpy.Point(long, lat, height), spatial_reference="4326", has_z=True)

#project into NAD83 oregon
#theres a transformation_name parameter also if you have one
#NB you may have more control over using an arcpy method instead
geo_projected = geo.projectAs(sr)