Shape of a Polygon

What shape is this polygon?

POLYGON((-40.0 52.0, 102.0 -6.0, -67.0 -29.0, -40.0 52.0))

Of course, that depends on what projection it is in, but let’s skip cartesian systems and look at it as a geographic shape on the sphere. Google Earth thinks it is shaped like this:

GEarth

But I don’t really think so. It all comes down to how you interpret the edges. I’m not sure what rule Google Earth is using to interpret the edges, but they aren’t Great Circles, because this is what a Great Circle map of the polygon looks like:

See how far south and north they get? Way different from the Google Earth interpretation. If anyone knows what rule Google Earth uses, I’d love to hear it.

Update: Here is the KML if you want it.

<?xml version="1.0" encoding="utf-8" ?>
<kml>
  <Placemark>
    <Polygon>
    <outerBoundaryIs><LinearRing><coordinates>
    -40,52 102,-6 -67,-29 -40,52
    </coordinates></LinearRing></outerBoundaryIs>
    </Polygon>
  </Placemark>
</kml>

Update 2: In the comments, GeoXP posits and Mano Marks confirms that the polygon edges are rhumb lines. Mano notes that curiously, if you draw the same lines as, er, lines, instead of polygons, they will follow great circles instead.

Update 3: Once I take the bit between my teeth, you can’t stop me. In the KML 2.2 specification, the OGC has also ratified this fun interpolation scheme! “The boundary control points of each descendent kml:LinearRing are first projected to the plate carrée plane (where altitude is dropped), then straight line segment interpolation in the plate carrée (long,lat) plane is used between consecutive control points. The interior points are then filled in linearly in the plate carrée plane. Finally, the (long,lat) points of the polygon in the plate carrée plane are mapped back to (long.lat,alt) points on the earth’s terrain surface model.”

Update 4: In the comments, Mike Sumner suggested that I try one over the dateline because it’s “much dumber”. Who can resist an offer like that? So I just translated the whole polygon 150 degrees to the west, giving us this KML:

<?xml version="1.0" encoding="utf-8" ?>
<kml>
  <Placemark>
    <Polygon>
    <outerBoundaryIs><LinearRing><coordinates>
    170,52 -50,-6 143,-29 170,52
    </coordinates></LinearRing></outerBoundaryIs>
    </Polygon>
  </Placemark>
</kml>

And here is what it looks like in the venerable Google Earth.

Dateline Crossing

Basically, it refuses to cross the dateline, it takes the long way around. Which, if you read the OGC description, is entirely unsurprising, since all the interpretation of the edges is happening in cartesian space, in plate carrée, where there is no “dateline” and Siberia and Alaska are at opposite sides of the plane, farther apart than New York and London.

Update 5: Last one. Because the effect is hard to see in the last example, see how this small triangle over the dateline is rendered (in green, below):

POLYGON((170 72, -170 70, -165 54, 170 72))

A polygon enclosing the pole looks even cooler (in yellow, below).

POLYGON((45 85, 135 80, -135 85, -45 80, 45 85))

That dateline is sacrosanct!

Google Earth Dateline 2

EmailTwitterFacebookGoogle+tumblrLinkedIn

15 thoughts on “Shape of a Polygon

  1. For GE it probably depends on the KML ‘tesselate’ value which will force a long linestring to follow the terrain instead of being hidden underground. So my guess would be it’s more a loxodromy than an orthodromy.

  2. Straight line across the interior of the earth then projected to the surface? Need to see this myself…

  3. Thanks Mano. That’s exceedingly weird that the interpolation is different for polygons and lines! I guess it only shows up on world-sized features, but hey it’s a virtual globe, has to happen pretty often, right?

  4. Yeah, you’d think so, and it does come up as a question, but how many data sets are truly big enough that people would notice?

    It is a little strange, but its been documented behavior for awhile so we can’t really change that.

  5. Mano, I think there’s a strong case for supporting both kinds of interpolations, for both line and area geometry. Many (most? all?) straight-line state and national borders are rhumb lines. But the most natural interpretation of a point-to-point path is the shortest-distance. The handling of the dateline, though, is inexcusable :)

  6. Mike, I knew in a theoretical sense, but not in an “I should do that” sense. You’re right, you can draw some really cool dumb broken things over the dateline by hand.

  7. Pingback: Geonews: ImageI/O-Ext, Crowdmap Launched, ArcGIS ArcPy.Mapping, and much more… « Geoinformatic Applications

  8. Pingback: PostGIS, Curves, a Round World, and More | It's All About Data

  9. Pingback: Drilling deeper into KML - OGC Geographic Visualization Standard - Enterprise IT Consultant Views on Technologies and Trends

  10. Thanks for this great post. I was wondering if there is an easy way, like using a tool such as ogr2ogr for example, to address this problem at the data level? ogr2ogr has a -wrapdateline argument you can pass in, but it generates topological exceptions for me when I tried doing this.

    I’ve documented this on this StackExchange question: http://gis.stackexchange.com/questions/30922/how-do-i-split-polygons-that-cross-the-dateline

    I’m experiencing exactly the behavior you detail in this post except on IOS with Mapkit. Any thoughts on how to fix this?

    Keep up the awesome work. Thanks again.

Comments are closed.