1

I'm using mercator-projected overlays from a crowdsourced website where volunteers georectify images of maps by hand. Unfortunately, the slippy map that serves as the site's interface wraps and allows users to place points outside [-180, 180]/[90,-90].

I have a bunch of features with bad coordinates, like the following:

var feature = {"geometry": {"type": "Polygon", "coordinates": [[[-231.304241727798, 1682.74422719708], [825.474710540096, 1682.74422719708], [825.474710540096, -272.6456886681], [-231.304241727798, -272.6456886681], [-231.304241727798, 1682.74422719708]]]}, "type": "Feature", "properties": {"id": "7014"}}

Here's some relevant data from the WMS file:

<SRS>EPSG:4269</SRS>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:900913</SRS>
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
<BoundingBox SRS="EPSG:4326"
            minx="-180" miny="-90" maxx="180" maxy="90" />
...
<Layer queryable="0" opaque="0" cascaded="0">
    <Name>image</Name>
    <SRS>EPSG:4326</SRS>
    <SRS>EPSG:4269</SRS>
    <SRS>EPSG:900913</SRS>
    <LatLonBoundingBox minx="-231.304" miny="-272.646" maxx="825.475" maxy="1682.74" />
    <BoundingBox SRS="EPSG:4326"
                minx="-231.304" miny="-272.646" maxx="825.475" maxy="1682.74" />

I've tried to wrap the coordinates back into something that a map library can read, but to no avail, first using this:

lng = ((x + 180) % 360) - 180), lat = ((y + 90) % 180) - 90)

then after figuring out problems with mod in Javascript:

lng = ((((x + 180) % 360) + 360) % 360) - 180
lat = ((((y + 90) % 180) + 180) % 180) - 90

but I still get incorrect coordinates. How do I convert these out-of-bounds mercator coordinates back to something that I can put on a map?

1 Answer 1

1

It looks like that feature geometry is corrupted, as the coordinates are just the min/max bounding box of the SRID as set by the WMS. (Plus or minus a few significant digits)

The problem seems to stem from EPSG:900913 being defined incorrectly. 900913 is no longer in use, it has since been changed to 3857. The bounding box should be +/- 20 million X and +/- 10 million Y. Note that the mercator XY extent is different than the lat/long extent.

3
  • Sorry, I didn't make this clear-- I generated that GeoJSON feature from a KML file containing the metadata / bounding box for an image. That's when I noticed that the coordinates were incorrect and discovered a lot of other georectified images with similar problems.
    – mike
    Commented Apr 1, 2015 at 0:19
  • Do you have an example of bad coordinates and what they should be? That might help to determine what's going on.
    – Mintx
    Commented Apr 1, 2015 at 21:53
  • Pastebin. The problem is that the slippy map wraps latitude and longitude into a never-ending map and users are scrolling outside of normal lat/long boundaries to place points. It's a bug in the mapping library, and I'm not able to figure out the math to correct these coordinates after the fact.
    – mike
    Commented Apr 3, 2015 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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