1

I have several images in EPSG:3857 which are originally from the Google maps API. I have a map layer which is based on OpenLayers v3.6 and it is in EPSG:21781. I would like to project the images from EPSG:3857 on top of EPSG:21781 layer. From the Openlayers API V3.11 there is an option to reproject at the client side on the fly with the following example code.

layers['bng'] = new ol.layer.Tile({
        source: new ol.source.XYZ({
          projection: 'EPSG:3857',
          url: 'https://tileserver.maptiler.com/miniscale/{z}/{x}/{y}.png',
          crossOrigin: '',
          maxZoom: 6
        })
      });

Since I am stuck with V3.6, I would like to convert the images at the server side and project them on top of EPSG:21781. Could someone help me with this.

User1836
  • 45
  • 6
  • 2
    Please give more context to your questions. I saw your tag for openlayer-3: is your final goal to show the image in openlayer in EPSG:21781? Are your trying to reproject before publishing your images in a webmap? Or do you want to reproject on the fly in the webmap? – Djana Aug 30 '16 at 09:33
  • why not use gdal ? – radouxju Aug 30 '16 at 09:44
  • @Djana Sorry for not posting the question clearly. Now I have edited the question. I want to reproject before publishing my images in the webmap. – User1836 Aug 30 '16 at 10:37
  • @radouxju I am quite new to GIS and gdal, Could you please give me some hint how to use gdal for my problem. Thanks. – User1836 Aug 30 '16 at 10:54
  • 2
    see http://gis.stackexchange.com/questions/174658/transform-an-image-with-projection-epsg4326-to-epsg3857?rq=1 for example – radouxju Aug 30 '16 at 11:03
  • @radouxju Thanks for the reply. That does not answer my question because, I have multiple images at multiple zoom levels with multiple bounds. In the above example in my question you can see that the URL value is being calculated on the fly based on the zoom level and bounds. I didn't find a solution for such case. Could you please point me to such example. – User1836 Aug 30 '16 at 11:27

1 Answers1

2

If you are not familiar with gdal and the command line (see comment from @radouxju) and if you actually have the image as files (which is not clear) and referenced, you can use QGIS and a few clicks.

1) Load your image in QGIS and make sure that QGIS interpreted your image correctly as EPSG:3857 (go to the layer's properties and set the right projection system)

Method A

2) Click on the "Raster" menu, pick Projections > Wrap (reproject)

Method B

2) Right click on the image name in the layer stack, "Save As.."

3) Pick the new projection system when saving (under CRS)

PS: I am not sure what's the policy about re-using tiles from the Google API, so you should make sure you are allowed to use them for your purpose

[EDIT] If you are requesting the tiles and want to transform them on the fly (as it seems from your last comment), and you cannot do it on the client side with OL3 because you are using v3.6, then the easiest is to switch to 3.11, IMHO.

Djana
  • 613
  • 6
  • 19
  • Thanks for the answer. I am not reprojecting Google API tiles but other tiles which are projected on top of Google API tiles. I don't have the images locally but the images are coming from the different server and I would like to reproject them on top of EPSG:21781. From EPSG:4326 to EPSG:3857 I could reproject at the client side very easily with the formula explained in the following link. http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Derivation_of_tile_names

    But I am not able to find such simple solution for the EPSG:3857 to EPSG:21781 conversion.

    – User1836 Aug 30 '16 at 12:45
  • Well, EPSG:4326 and EPSG:3857 are common for web mapping and similar (for their difference: (http://gis.stackexchange.com/questions/34276/whats-the-difference-between-epsg4326-and-epsg900913) ). EPSG:21781 is based on a different ellipsoid, so the transformation is not that easy. But you could use the Proj4.js (http://proj4js.org/) library if you are looking for the reprojection parameters. – Djana Aug 31 '16 at 07:17
  • It seems I could solve my problem using Mapproxy (https://mapproxy.org/). I will post the answer as soon as I am done with that. – User1836 Aug 31 '16 at 13:40