0

I have a problem stitching tiles together to get a specified resolution from map bounds. Im getting the bounds from a leaflet container using openmaptyles raster as a source.

Tile format : (http://host/styles/dark/{z}/{x}/{y}@4x.png), tiles can be sizes of 256,512,1024

Example Bounds : ( Zoom 13, xMin 4148, yMin 2817, xMax 4150, yMax 2819 )

Now, I need to export an image at a resolution of 8268 x 11811px specifically for print.

Ive looked into using mapnik render_to_file to accomplish this but is it possible to use this source to do it?

The way im doing it now is with a python script which gets the correct tiles from the extent but I cant get the exact resolution im looking for.

I am no GIS expert.

1

I personally use ImageMagick for tile stiching. Format of the output image can be specified in detail, but it works only with local (downloaded) tiles.

Basic example of image stitching:

magick montage @file_list.txt -mode concatenate -tile 4x4 stitched_img.jpg

Here 16 images are stitched togeteher, four rows by four columns. List of images is given in input file file_list.txt, which looks something like:

d:\tiles\11.jpg
d:\tiles\12.jpg
d:\tiles\13.jpg
d:\tiles\14.jpg
d:\tiles\21.jpg
...

Input images are just stiched without any transformation. Simple size trasformation can be done by resizing input tiles. If original tiles are 256x256, final stitched image will be half of the default stitched size by specifying:

magick montage @file_list.txt -mode concatenate -tile 4x4 -geometry 128x128 stitched_img.jpg

Better option for final image formating is to go in two steps: first stitch and then transform. Simple command for just size transformation:

magick convert stitched_img.jpg -resize 512x512 final_img.jpg

ImageMagick has tons of transformation options which can be found here Resize or Scaling and here Resampling Filters.

I also found this solution on GitHub: stitch-osm-tiles. It also uses ImageMagick but can have tiles from online OSM map as input. I never used it but it looks promising.

  • Thanks for your reply. Could you provide me with an example of how you achieve this with ImageMagick with specifying the format of the output image. I tried stitch-osm-tiles, looks promising but i can't configure it to get the desired resolution. Thank you! – baneG Oct 14 '17 at 20:20
  • I modified my answer with example of how this can be done. – TomazicM Oct 15 '17 at 9:35
  • Did you finally succeed to get desired resolution? – TomazicM Oct 18 '17 at 16:30

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.