2

I am trying to import the ne_10m_admin_0_countries shp file from Natural Earth into TileMill but I get strange map tearing around Antarctica.

I tried through PostGIS first (my main motivation for using this dataset) but later experimented and just tried to import the shp file directly with the same result.

Does anyone have an idea what is going on and how to fix it?

This is with TileMills default country layer:

TileMill default layer

With the ne_10m_admin_0_countries shp file:

Natural Earth Data

and with both of the layers showing:

Both layers visible


(edit from comments below) The data looks fine in QGIS:

QGIS vector layer


(2nd edit) It seems to come down to the following 2 points on Antarctica, but I am unsure how to fix it. I've increased the line-width to make the problem more clear.

Northern / left problem point (zoom 10):

northern / left

Southern / right problem point (zoom 10):

southern / right


(3rd edit) Okay so I tried reprojecting it from QGIS which just lead to QGIS crashing when I tried to save the shape file. I was trying to reproject it into EPSG:3857 / 900913:

+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over

However I was able to get QGIS to do on the fly reprojection to EPSG:3857 and that also looks a bit strange:

QGIS on the fly projection

  • My first intuition is there's something wrong with the geometry for Antarctica, like a vertex is out of order or missing, which is causing part of the polygon to invert. What's it look like in QGIS or another similar program? That will narrow down if it's the shapefile or Tilemill causing the issue. – msayler Jul 1 '14 at 21:17
  • Could be happening if Tilemill is converting it to Web Mercator. Things can get funky at the edges of world data depending on how it was created. Next idea I have is to reproject it into Web Mercator in QGIS, then bring THAT shapefile into Tilemill, and see if it behaves. – msayler Jul 1 '14 at 22:32
  • 2
    If that doesn't do it, I'd contact Mapbox support so they can take a look at the data and determine if it's something they need to address in Tilemill or the Natural Earth folks might need to adjust with their data. They have Natural Earth tiles, so I'm pretty sure they'll know who to talk to if it comes down to that. – msayler Jul 1 '14 at 22:37
  • It's just the bottom line in WGS84 at -90° latitude that spoils the Web Mercator rendering. If you remove it in QGIS, rendering should work. – AndreJ Nov 4 '15 at 12:22
2

The ne_10m_admin_0_countries shp file is in EPSG:4326 projection and it looks like you want to use it in EPSG:3785 (TileMill default). The extent of the data in that shapefile is (-180.000000, -90.000000) - (180.000000, 83.634101), which is valid for WGS84. Pseudo-Mercator however has a maximum extent of (-180, -85.06) - (180, 85.06) and this is causing the map glitches in TileMill and QGIS because the data is out of bounds.

You can use ogr2ogr or QGIS to clip the shapefile to the maximum extents of EPSG:3785 before you reproject and that should clear up your issue.

In QGIS select Processing > Toolbox and filter for "clip". Use the OGR "Clip vectors by extent" tool.

For ogr2ogr you can use something like this:

$ ogr2ogr -clipsrc -180 -85.06 180 85.06 -t_srs EPSG:3785 ne_10m_admin_0_countries_proj.shp ne_10m_admin_0_countries.shp

This will clip it in the source projection first, then reproject it to EPSG:3785 on output. The shapefile should then work fine in QGIS/TileMill.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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