3

I am trying to create a new layer with just a single point using arcpy. All that is provided is a gps lat and long. It seems like it should be a simple problem but I just can't get it to work. I've determined the error is that I'm not using the correct spatial reference (the point I get right now is next to the equator/meridian) but I'm not sure how to fix that.

import arcpy

arcpy.env.workspace = 'c:\\Scrap'
arcpy.env.overwriteOutput = True

latitude = 41
longitude = -71

p = arcpy.Point(longitude, latitude)
pg = arcpy.PointGeometry(p)
arcpy.CopyFeatures_management(pg, 'test.shp')
2
  • 1
    Does oat8t7 refer to a spatial reference object? It's not clear looking at your code.
    – Paul
    Jun 5, 2014 at 15:55
  • Sorry, that was supposed to be latitutde, edited to reflect that
    – Disp
    Jun 5, 2014 at 16:11

1 Answer 1

5

If you're using lat/lng you want to make sure that your output coordinate system is set to something like WGS84. I assume oat8t7 is a typo and is actually referring to your 'latitude.' It could be as easy as setting your output coordinate system as such:

arcpy.env.workspace = 'c:\\scrap'
arcpy.env.overwriteOutput = True
sr = arcpy.SpatialReference('WGS 1984')
arcpy.env.outputCoordinateSystem = sr

latitude = 41
longitude = -71

p = arcpy.Point(longitude, latitude)
pg = arcpy.PointGeometry(p)
arcpy.CopyFeatures_management(pg, 'test.shp')

This puts the point just off the coast of Rhode Island!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.