I am experiencing projection problems with the following set up:

  • GeoServer with ESPG:4326 based shapefiles (*.shp)
  • OpenJump to edit my shapefiles
  • Openlayers with EPSG:900913 base layers
  • GeoServer provides the shapefiles as WMS to OpenLayers.

Here is my source code:

    <title>Openplanning mit Geoserver</title>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
    <script type='text/javascript' src='http://www.openlayers.org/api/OpenLayers.js'></script>


    <div id="map-id"></div>
            var geographic = new OpenLayers.Projection("EPSG:4326");
            var mercator = new OpenLayers.Projection("EPSG:900913");

            var world = new OpenLayers.Bounds(-180, -89, 180, 89).transform(
                geographic, mercator
            var vienna_center = new OpenLayers.LonLat(16.3670, 48.205333).transform(
                geographic, mercator

            var options = {
                projection: mercator,
                displayProjection: geographic,
                units: "m",
                maxExtent: world,
                maxResolution: 156543.0399

            var map = new OpenLayers.Map("map-id",options);

            var osm = new OpenLayers.Layer.OSM();


            var vienna = new OpenLayers.Layer.WMS(
                "Vienna Calling",
                {layers: "topp:ma_vienna", 
                transparent: true}
            map.setCenter(vienna_center, 8);
            map.addControl(new OpenLayers.Control.LayerSwitcher());
            //zeigt die Koordinaten der aktuellen Mause-Position an
            map.addControl(new OpenLayers.Control.MousePosition());


It seems that GeoServer is converting from ESPG:4326 to EPSG:900913 internally. Here you can see a sample request for Vienna (which is sent by my OpenLayers application to GeoServer):


My problem: the requested file looks distored, as you can see here:

https://i.sstatic.net/UcWBQ.png (sorry, I had to post a link again after my edit ...)

In case I open the WMS layer in the OpenLayers preview of GeoServer, it looks OK:

https://i.sstatic.net/P8IMj.png (sorry, I had to post a link again after my edit ...)

The question is: Why is my shapefile distorted in my OpenLayers application, but not in the GeoServer preview? As you can see, the GeoServer preview uses EPSG:4326 and my OpenLayers application EPSG:900913 (Update: EPSG:4326 as well; mouse coordinates are displayed as latitude/longitude). But, however, as GeoServer provides a WMS interface with EPSG:900913 capabilities, shouldn't it correctly reproject my vector sources?

  • 1
    Are you sure your shapefile data in geographic coordinates (degrees)? And mouse coordinates are not always connected with layer projection, for set projection for display mouse position option displayProjection is used
    – drnextgis
    Commented Nov 25, 2011 at 2:11

1 Answer 1


The first thing to check is that your data is really in 4326 (lat/lon) and that GeoServer is reading them in in that projection - check on the DataStore page for "Native Projection" if that is unknown then go to http://prj2epsg.org/search and paste in the contents of your shapefile .prj file, this will give you a correct projection to put in the projection box.

If your shapefile doesn't have a .prj file then you need to go back to the data supplier and ask them what projection the data is in.

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.