Hi,
I have a polyline shapefile which opens incorrectly in ArcMap. When ArcMap expects latitude (northing), it reads the longitude in shapefile (eastings). And when it expects longitude (eastings), it reads the latitude in the shapefile (northings). It is weird!
The shapefile wich should be in the Netherlands ends up offshore Somalia East Africa! As shown attached.
How is it possible to invert the lat/lon? In order to open the shapefile correctly...
Here attached is a polyline sample if it helps.
Thanks
Solved! Go to Solution.
Try the following steps:
1. Convert the vertices of lines to Points.
2. To the above point layer, add two fields, viz., Lat and Lon, and assign opposite coordinates to each using Calculate Geometry. Say X coordinate for Lat and Y coordinate for Lon.
4. Add XY data from excel sheet as a layer. Export the event layer to a shapefile/feature class.
5. Convert Points to Line using Orig_FID as the LINE_FIELD.
Hope it will resolve the issue.
where did the shapefile come from, or how was it created? If it never appears in the correct place, I would suspect the errors lies in how it was created, perhaps from gps data, which often has a bad habit of offering latitude/longitude as the order of coordinates.
Try the following steps:
1. Convert the vertices of lines to Points.
2. To the above point layer, add two fields, viz., Lat and Lon, and assign opposite coordinates to each using Calculate Geometry. Say X coordinate for Lat and Y coordinate for Lon.
4. Add XY data from excel sheet as a layer. Export the event layer to a shapefile/feature class.
5. Convert Points to Line using Orig_FID as the LINE_FIELD.
Hope it will resolve the issue.
That is an exceptionally convoluted path to do what ArcPy can do in under a page of code (with a da.UpdateCursor, swapping ordinate order).
I wouldn't recommend passing ANY GIS data through Excel, just on principle.
- V
To illustrate Vince's point/comment:
>>> fc = # path to feature class
>>> with arcpy.da.UpdateCursor(fc, "SHAPE@") as cur:
... for polyline, in cur:
... SR = polyline.spatialReference
... polyline = arcpy.Polyline(
... arcpy.Array(
... (arcpy.Point(pt.Y, pt.X) for pt in part)
... for part
... in polyline.getPart()
... ), SR
... )
... cur.updateRow([polyline])
...
>>> arcpy.RecalculateFeatureClassExtent_management(fc)
Thanks
It did work! I was not sure about the point "ordering" when converting Points to Line. Also, I made an export to a tab .txt file to avoid Excel (via .dbf).