I'm trying to parse a text file of point coordinates to create polygons, but any polygon that has points on both sizes of the international date line wraps around the map (when displayed in ArcGIS Pro).
Here is an example of the text:
21-00-00.0N 130-00-00.0E
21-00-00.0N 155-00-00.0E
27-00-00.0N 155-00-00.0E
27-00-00.0N 165-00-00.0E
43-00-00.0N 165-00-00.0E
45-42-00.0N 162-55-00.0E
50-08-00.0N 176-34-00.0W
51-24-00.0N 167-49-00.0W
53-30-00.0N 160-00-00.0W
56-00-00.0N 153-00-00.0W
56-45-42.0N 151-45-00.0W
53-22-03.0N 137-00-00.0W
52-43-00.0N 135-00-00.0W
51-00-00.0N 133-45-00.0W
48-20-00.0N 128-00-00.0W
48-10-00.0N 127-55-30.0W
45-00-00.0N 126-30-00.0W
40-59-00.0N 126-54-00.0W
40-50-00.0N 127-00-00.0W
37-30-23.0N 127-00-00.0W
36-27-43.0N 126-56-00.0W
35-30-00.0N 125-50-00.0W
36-00-00.0N 124-12-00.0W
34-30-00.0N 123-15-00.0W
30-45-00.0N 120-50-00.0W
30-00-00.0N 120-00-00.0W
03-30-00.0N 120-00-00.0W
03-30-00.0N 145-00-00.0W
05-00-00.0S 155-00-00.0W
05-00-00.0S 180-00-00.0W
03-30-00.0N 180-00-00.0W
03-30-00.0N 160-00-00.0E
00-00-00.0N 160-00-00.0E
00-00-00.0N 141-00-00.0E
03-30-00.0N 141-00-00.0E
03-30-00.0N 133-00-00.0E
07-00-00.0N 130-00-00.0E
I can easily create polygons that don't cross the dateline (or the equator), but am unclear how to structure polygons that do.
Would anyone be able to point me in the right direction?
Solved! Go to Solution.
I've always wondered how to deal with issues with the dateline, then I came across a reference to WGS 1984 (G1762) in the Collector section. This Geographic Coordinate System uses decimal degrees that go North and South past +- 90 degrees and East and West past +- 180 degrees. I created a polygon feature using this system and plotted your coordinates. Those to one side of the dateline were converted to the other side; that is, 130 degrees East became -230 degrees West. Here's my script and results:
import arcpy
dataset = r"C:\Path\To\filegeodatabase.gdb\PolyTest"
sr = arcpy.Describe(dataset).spatialReference
print sr.factoryCode
# 104015
print sr.name
# u'WGS_1984_(G1762)'
# A list of features and coordinate pairs
feature_info = [[[-230, 21],[-205, 21],[-205, 27], [-195, 27],[-195, 43],[-197.083333333333, 45.7],
[-176.566666666667, 50.1333333333333],[-167.816666666667, 51.4],[-160, 53.5],[-153, 56],
[-151.75, 56.8666666666667],[-137, 53.375],[-135, 52.7166666666667],[-133.75, 51],
[-128, 48.3333333333333],[-128, 48.1666666666667],[-126.5, 45],[-126.9, 40.9833333333333],
[-127, 40.8333333333333],[-127, 37.5638888888889],[-126.933333333333, 36.5694444444444],
[-125.833333333333, 35.5],[-124.2, 36],[-123.25, 34.5],[-120.833333333333, 30.75],[-120, 30],
[-120, 3.5],[-145, 3.5],[-155, -5],[-180, -5],[-180, 3.5],[-200, 3.5],[-200, 0],[-219, 0],
[-219, 3.5],[-227, 3.5],[-230, 7]]]
# Open an InsertCursor to insert the new geometry
cursor = arcpy.da.InsertCursor(dataset, ['SHAPE@','Name'])
for feature in feature_info:
# Create a Polygon object based on the array of points
# Append to the list of Polygon objects
polygon = arcpy.Polygon(
arcpy.Array([arcpy.Point(*coords) for coords in feature]))
cursor.insertRow([polygon,'Test1'])
# Delete cursor object
del cursor
I've always wondered how to deal with issues with the dateline, then I came across a reference to WGS 1984 (G1762) in the Collector section. This Geographic Coordinate System uses decimal degrees that go North and South past +- 90 degrees and East and West past +- 180 degrees. I created a polygon feature using this system and plotted your coordinates. Those to one side of the dateline were converted to the other side; that is, 130 degrees East became -230 degrees West. Here's my script and results:
import arcpy
dataset = r"C:\Path\To\filegeodatabase.gdb\PolyTest"
sr = arcpy.Describe(dataset).spatialReference
print sr.factoryCode
# 104015
print sr.name
# u'WGS_1984_(G1762)'
# A list of features and coordinate pairs
feature_info = [[[-230, 21],[-205, 21],[-205, 27], [-195, 27],[-195, 43],[-197.083333333333, 45.7],
[-176.566666666667, 50.1333333333333],[-167.816666666667, 51.4],[-160, 53.5],[-153, 56],
[-151.75, 56.8666666666667],[-137, 53.375],[-135, 52.7166666666667],[-133.75, 51],
[-128, 48.3333333333333],[-128, 48.1666666666667],[-126.5, 45],[-126.9, 40.9833333333333],
[-127, 40.8333333333333],[-127, 37.5638888888889],[-126.933333333333, 36.5694444444444],
[-125.833333333333, 35.5],[-124.2, 36],[-123.25, 34.5],[-120.833333333333, 30.75],[-120, 30],
[-120, 3.5],[-145, 3.5],[-155, -5],[-180, -5],[-180, 3.5],[-200, 3.5],[-200, 0],[-219, 0],
[-219, 3.5],[-227, 3.5],[-230, 7]]]
# Open an InsertCursor to insert the new geometry
cursor = arcpy.da.InsertCursor(dataset, ['SHAPE@','Name'])
for feature in feature_info:
# Create a Polygon object based on the array of points
# Append to the list of Polygon objects
polygon = arcpy.Polygon(
arcpy.Array([arcpy.Point(*coords) for coords in feature]))
cursor.insertRow([polygon,'Test1'])
# Delete cursor object
del cursor
Oh interesting. Thanks so much for the reply.
So it looks like in your code feature_info array, you manually converted East coordinates to their West counterparts (I see references to -230 as opposed to 130).
It's not that you just set the feature class to the specific spatial reference, entered the coordinates as is, and it all worked out, right?
So essentially I would just need to ensure all points being added to the polygon are specified as to one side of the dateline, but would have to catch and change that programatically as I parse the points.
Since this was just one example, I used Excel to do the conversion from DMS to decimal degrees and converted degrees East to degrees West. These were done with formulas, so for your project I would suggest writing a python function to do the conversion.