2

As OpenLayers supports raster reprojection I would like to make it reproject xyz-tilelayers e.g. from OSM, Mercator projection to Mollweide projection (ESRI:53009).

From this example I took the necessary code snippets for using Mollweide projection, although in the example vector data is used.

I do not understand why the extent is set to [-9009954.605703328, -9009954.605703328, 9009954.605703328, 9009954.605703328], but it seems to work as the whole world is displayed.

In my case, reprojection itself seems to work, too, but all I get is a limited view of the world:

source: OpenStreetMap contributors

Furthermore, tiles disappear completely on some panning and zooming (out) interactions.

What am I doing wrong?

var projCode = 'ESRI:53009';
proj4.defs(projCode, '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +a=6371000 +b=6371000 +units=m no_defs');              
var mollweide = new ol.proj.Projection({
        code: projCode,
        extent: [-9009954.605703328, -9009954.605703328, 9009954.605703328, 9009954.605703328],
        worldExtent: [-179, -89.99, 179, 89.99]           
});

var map = new ol.Map({
        target: 'map',
        layers: [
            new ol.layer.Tile({
                source: new ol.source.OSM()
            })
        ],
        view: new ol.View({
            center: [10,10],
            projection: mollweide,
            zoom: 0
        })
});
2

Starting from the Raster Reprojection Tutorial I found that the projection parameters you are using are for Mollweide Sphere.

The Reprojection Example uses parameters for World Mollweide (ESRI:54009). Combining this example with OpenStreetMap Reprojection Example you can get a working reprojected map to Mollweide.

See this codepen or the following code from the pen:

var projCode = 'ESRI:54009';

proj4.defs('ESRI:54009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 ' +
          '+units=m +no_defs');
var proj54009 = ol.proj.get('ESRI:54009');
proj54009.setExtent([-18e6, -9e6, 18e6, 9e6]);

var map = new ol.Map({
  layers: [
    new ol.layer.Tile({
      source: new ol.source.OSM()
    })
  ],
  target: 'map',
  view: new ol.View({
    projection: projCode,
    center: [0, 0],
    zoom: 2
  })
});
  • Thank you, it works! I realized that my projection code and definition work. It's the extent you define, that makes the difference. Do You have an idea how to manage, that no part of the world is duplicated and the map appears in the typical oval form? The Tilelayer-wrapX-option seems not to work for Mollweide. – dijea May 3 '18 at 11:21
  • @dijea I don't know how to cut the tiles to get the oval form. Maybe with some kind of mask. I would recommend you ask another question for this problem. – bennos May 4 '18 at 7:02
  • I opened another thread – dijea May 4 '18 at 11:42

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.