Thursday, 10 May 2018

geojson - How do I represent the whole Earth as a Polygon?


This is related to determining the interior of a Polygon.


My difficulty is that if I specify a Polygon covering the Earth going from East to West, it will still have a boundary along the antemeridian, which would show up in azimuthal projections. For example, in GeoJSON:


{
"type": "Polygon",
"coordinates": [

[[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]]
]
}

Is there a standard way to specify a whole-sphere Polygon, with no boundary?


I've thought about using an empty exterior ring:


{
"type": "Polygon",
"coordinates": [
[]

]
}

The logic being that I could specify further rings as holes to be punched into the whole-sphere Polygon.


Unfortunately, GeoJSON stipulates that LinearRings must have at least 4 points, so this would be straying from the specification. However, I'm still interested in understanding whether this approach is taken anywhere else.



Answer



Since there doesn't seem to be a standard way to represent this somewhat rare situation of a polygon with no boundary covering the whole Earth, we decided to add our own {type: "Sphere"}, which has worked remarkably well for our purposes.


We decided not to use a Polygon containing an empty LinearRing, since this more intuitively represents an empty polygon and could easily lead to confusion and accidental creation of whole-Earth polygons.


No comments:

Post a Comment