We're running MapServer with a map that has just one layer, political boundaries from a SHP file. This layer is using a basic EPSG:4326 projection, and the map itself is using EPSG:3857. The resulting images generated by MapServer CGI queries have horizontal lines at certain latitudes:

enter image description here

Beyond this problem, the map is okay and lines up perfectly with the Open Street Map in OpenLayers. The MAPFILE we're using:

        "wms_title" "Map Server"
        "wms_enable_request"  "*"
        "wms_srs"             "EPSG:3857"


  EXTENT -20037508.34 -20037508.34 20037508.34 20037508.34
  SIZE           400 300
  SHAPEPATH      "../data"
  IMAGECOLOR     71 245 242

  LAYER # States polygon layer begins here
    NAME         Borders
    DATA         ne_10m_admin_1_states_provinces_shp
    STATUS       OFF
    TYPE         POLYGON


      NAME       "Borders"

        COLOR        43 156 51
        OUTLINECOLOR 32 32 32
  END # States polygon layer ends here


I've verified that the proj.4 EPSG file has the proper definition of EPSG:3857, and don't understand what's happening. Any insight would be greatly appreciated.

3 Answers 3


Your question implies that the problem doesn't occur when the data isn't projected. Is this the case?

It looks like the issue is with features that cross the -180 / +180 meridian. The problem arises when the GIS assumes that the west boundary of the polygon has a lower X ordinate than the east boundary, but in these cases this is reversed.

The problem isn't specific to MapServer and I expect you would see the same issue in any GIS software.

One way to address this sticky problem is to split these polygons over the meridian, so that the east side of the feature displays on the west of the map and the west side of the polygon is on the east side of the map.

  • 1
    Yes, that's right. The layer looks fine at its normal 4326 projection. Viewing the file in TatukGIS at certain projections, such as EPSG:3349, results in similar problems. So I think you guys are right about the shapefile containing some bad polygons. Interestingly, the problem doesn't happen when viewing the file at EPSG:3857.
    – Geoff
    Commented Dec 13, 2012 at 16:25

Check whether your shapefiles are valid and contain no unclosed polygons. Apart from that it is better for your performance to reproject your shapefile first.

This can be done with eg ogr2ogr: ogr2ogr -s_srs EPSG:4326 -t_srs EPSG:3857 outfile.shp infile.shp

  • Wow, thanks. I used TatukGIS to view the SHP file and was able to track down one of the errant polygons. Adding a filter for it to the mapfile got rid of the line through Australia! The other polygons are harder to find. Is there a GDAL tool or debugging feature that would help?
    – Geoff
    Commented Dec 12, 2012 at 22:30
  • 1
    Try reprojecting the shapefile, it may already solve your problem by closing all polygons when they are written again. If you want to keep the file in 4326 you just replace the -t_srs, but keep in mind that reprojecting layers on the fly is not good for performance.
    – johanvdw
    Commented Dec 13, 2012 at 8:22
  • Thanks. When I tried reprojecting the shapefile liked you suggested yesterday, the problem remained. I'll experiment with it some more today.
    – Geoff
    Commented Dec 13, 2012 at 16:14

you may use the -wrapdateline option, together with a temp format (-f), say KML. It works fine.

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.