10

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

1
  • 2
    There seems to be an inconsistency in the gdal_translate parameters you posted here: you are associating (lat,lon) = (31.7431761644, 35.1680410195) with two distinct points at (0,0) and (0,2494). Is this really the command you issued, or is it a copy-and-paste error?
    – whuber
    Jun 14, 2012 at 21:59

1 Answer 1

5
+100

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....

8
  • Thanks. When should I do that? as for now I am doing 1.gdalinfo map.png 2.gdal_translate -of VRT -a_srs EPSG:4326 -gcp.... 3. gdal2tiles.py -z 10-16 map.vrt. Do I need to do it after the translate? should I change the EPSG in the translate method?
    – shannoga
    Jun 12, 2012 at 20:31
  • if your map is not coordianted, trying to take info with gdalinfo is in vain.
    – urcm
    Jun 13, 2012 at 6:12
  • So I need to use gdalwarp instead ?
    – shannoga
    Jun 13, 2012 at 6:24
  • is your map coordinated with any projection or not? if yes try to use gdalwarp to reproject it ,otherwise make it coordinated with gdal_transform...
    – urcm
    Jun 13, 2012 at 15:03
  • Hey thanks for your patient. If understand you right it is not. this is a simple square image drawn based on a map no special data on it. I have updated the question with my used commands. Thanks again for your tryings to help.
    – shannoga
    Jun 13, 2012 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.