Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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')
share|improve this question
1  
Does oat8t7 refer to a spatial reference object? It's not clear looking at your code. –  Paul Jun 5 at 15:55
    
Sorry, that was supposed to be latitutde, edited to reflect that –  Disp Jun 5 at 16:11
add comment

1 Answer 1

up vote 5 down vote accepted

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!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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