Wednesday, 15 November 2017

gdal - Understanding the Map Tile creation properties


I am trying to create a tile base map. I have an image that I want to create the tile from and I am using GDAL.


I managed to create the tiles but when I view the result it seems that the tiled map is:



  1. It is flipped


  2. The proportions are not right


This is the map overlay image: map image


This is the result of the tiling:


tile result


I checked many times that the coordinates are good by comparing the image corners on an orthophoto.


An other thing is that in google earth with the same coordinates the map image fits precisely to google map.


google earth overlay


EDITED




gdalinfo map_overlay.png



with this output:



Driver: PNG/Portable Network Graphics Files: map_overlay.png Size is 3527, 2494 Coordinate System is `' Image Structure Metadata:
INTERLEAVE=PIXEL Corner Coordinates: Upper Left ( 0.0, 0.0) Lower Left ( 0.0, 2494.0) Upper Right ( 3527.0, 0.0) Lower Right ( 3527.0, 2494.0) Center ( 1763.5, 1247.0) Band 1 Block=3527x1 Type=Byte, ColorInterp=Red Mask Flags: PER_DATASET ALPHA Band 2 Block=3527x1 Type=Byte, ColorInterp=Green Mask Flags: PER_DATASET ALPHA Band 3 Block=3527x1 Type=Byte, ColorInterp=Blue
Mask Flags: PER_DATASET ALPHA Band 4 Block=3527x1 Type=Byte, ColorInterp=Alpha



Then translate:




gdal_translate -of VRT -a_srs EPSG:4326 -gcp 0 0 31.7431761644 35.1680410195 -gcp 3527 0 31.7493769674 35.1784535489 -gcp 3527 2492 31.7431011291 35.1784951643 -gcp 0 2494 31.7431761644 35.1680410195 map_overlay.png map_overlay.vrt



with this output:



Input file size is 3527, 2494



and lastly:



gdal2tiles.py -z 14-21 map_overlay.vrt




The overlay is a simple .png image without any special data.


I will appreciate any help.


Shani



Answer



Try to use metric coordinated image before tiling it as:


   gdalwarp -of GTiff -t_srs EPSG:3857 input.tif output.tif 



UPDATE


Note: even if we specify the gcp’s, gdal_translate would not specify the corner coordinates of the tiff.



Beside this you dont need to create virtual dataset (.vrt) because of having only one file ...


use the following code:


  gdal_translate -of  GTiff  -gcp 0 0 31.7431761644 35.1680410195 -gcp 3527 0 
31.7493769674 35.1784535489 -gcp 3527 2492 31.7431011291 35.1784951643
-gcp 0 2494 31.7431761644 35.1680410195 map_overlay.png map_overlay.tif

then


  gdalwarp -s_srs epsg:4326 -t_srs epsg:4326  map_overlay.tif warped_map_overlay.tif

and now try to use gdalinfo... if u dont see any problem, run this command:



  gdal2tiles.py -z 14-21 warped_map_overlay.tif

if your tiles dont fit, run above code before update, i have given.


You can get more info here


i hope it helps you....


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...