In leaflet js I added an image to my map (image overlay).
The image is a georeferenced jpeg, and it's a raster generated by Qgis.
In leaflet I setted the image bound points correctly (NE and SW), and I tested this even after the map is rendered.
So, if the extreme points (NE and SW) are corrects, the internal image points do not correspond to the real coordinates, as you can see in the image (see the detail of railway tracks): overlay.png

Any clue?

  • 1
    Which projection is the image in? Do you have any control points? – IvanSanchez Sep 14 '16 at 8:02
  • Image projection is in UTM33 WGS84. File .jwt contains this informations: 0.301796417216513 ; 0.000000000000000 ; 0.000000000000000 ; -0.301811376146870 ; 708474.757291694870000 ; 4520957.402170119800000 . The last values represent NE point coordinate, then convert it to LatLon (40.81316823608622 - 17.47176623188087). In Qgis I made sure that the SW limit point is 711519.02 - 4519312.78 (LatLon 40.79758814357056 17.507270150411824). – T. Phanelly Sep 14 '16 at 8:18
  • I suggest you reproject the raster into EPSG:3875 (web mercator, Leaflet's default) and try again (unless you're using proj4leaflet to use UTM33 in the browser) – IvanSanchez Sep 14 '16 at 8:30
  • Should be EPSG:3857? (Not 3875) – T. Phanelly Sep 14 '16 at 8:40
  • I always confuse those two :-) – IvanSanchez Sep 14 '16 at 10:00

Make sure that the projection of your raster file matches the display projection (i.e. the projection used by Leaflet).

Remember that Leaflet works in EPSG:3857 (aka "web mercator") whereas aerial imagery might be in a different projection. Even if the corners of your raster match, different projections mean that your raster might warp in unexpected ways.

You can either warp your raster image into EPSG:3857, or use proj4leaflet to make Leaflet display everything in a different CRS - both these solutions should work.

  • I regenerated the image raster with projection EPSG:3857 and now the positioning is perfect. Thanks! – T. Phanelly Sep 14 '16 at 15:38

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.