gdal2tiles / maptiler reducing image resolution?

683 views
Skip to first unread message

Tubaman

unread,
Apr 20, 2011, 11:24:45 AM4/20/11
to MapTiler User Group
Hi,

I've got an aerial photo with an SRS of OSGB36 / British National Grid
(EPSG:27700), from which I'd like to create TMS tiles using maptiler
or gdal2tiles. The problem I am seeing is that the image resolution
of the resulting tiles is lower than the original image, which I'm
hoping shouldn't be the case.

I get the exactly the same result whether I use maptiler or
gdal2tiles. The command line I use is simply:

gdal2tiles -s EPSG:27700 SP3796.jpg

The input file is .jpg, with a matching .jgw world file. The input
file resolution is 0.25 metres (+0.25 for X, -0.25 for Y). The
resulting tile reprojection works fine, with the tiles positions
lining up correctly with Google maps tiles for the same area. But if
I view the tiles at 100% scaling (1 screen pixel per image pixel, side
by side on the same screen with the original image), features on the
tile images are smaller (represented by less pixels) on the tile than
they are in the source image.

I thought maybe it was a problem with the underlying GeoTransform, so
for a test I tried:

gdalwarp -s_srs EPSG:27700 -t_srs EPSG:900913 SP3796.jpg SP3796.tif

Interestingly, looking at the metadata in the resulting geotiff image
the resolution is stated as 0.4110741398m (positive for X, negative
for Y as expected). But viewing this tif image at 100% scaling
correctly shows features at the same size as the source image (i.e. a
feature takes up the same number of pixels in both images). This
confuses me, as I don't see how the resolution (metres per pixel) can
be different between the two images but things be shown the same
size. However, as this is what I want (the original resolution/level
of detail maintained when viewing), I guess it's just the resolution
image tag definition which I don't understand.

Anyway, if anyone with a better understanding of these things than me
(I'm a geo-newbie) has a clue as to how I can get gdal2tiles to
maintain the resolution (and thus quality) of the source image I'd be
most interested to hear. I realise there's going to be some quality
loss due to the reprojection but if I can get the same result as the
above gdalwarp I'll be happy!

Thanks in advance for any help.

Klokan Petr Přidal

unread,
Apr 20, 2011, 11:50:31 AM4/20/11
to mapt...@googlegroups.com
Hi,

You need to fit the input data into existing predefined pyramid which
is used by Google/Bing/OpenStreetMap.
The pyramid has fixed resolutions on individual predefined zoom levels.

Both GDAL2Tiles and MapTiler by default choose the downscaling to the
nearest possible level.
If you need different behaviour you can always set the required zoom
levels you want to render explicitly - there is an option for that.

Hope this explanation helps,

Regards,

Petr alias Klokan

P.S.
Read more about the Spherical Mercator pyramid at my article:
http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
and check the table with resolutions per zoom level available at:
http://msdn.microsoft.com/en-us/library/bb259689.aspx

> --
> You received this message because you are subscribed to the Google Groups "MapTiler User Group" group.
> To post to this group, send email to mapt...@googlegroups.com.
> To unsubscribe from this group, send email to maptiler+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/maptiler?hl=en.
>
>

--
http://blog.klokan.cz/
http://www.maptiler.org/
http://www.oldmapsonline.org/

Tubaman

unread,
Apr 21, 2011, 6:41:47 AM4/21/11
to MapTiler User Group
Thanks for the helpful explanation Petr. Silly me! For some reason I
wrongly assumed the base tile resolution would match the original
image, with the resolution halved as you go up the pyramid from
there. But thanks to your helpful article I now understand.

Now I see that the loss in quality I was seeing was not due to the
reprojection as I thought, but the resampling to the different
resolution to match the fixed pyramid. I have now tried the different
resampling options and found the cubicspline option works well for my
data. As you suggested, I also used the -z option to create the base
tiles 1 level better resolution, which in this particular case is much
nearer to the original image resolution and so doesn't lose so much
detail.

I also now understand why the image resolution metadata changes when I
reproject. It seems the stated resolution doesn't apply to the
location of the actual data reprojected, it is based on the projection
datum used. So as WGS84 is used for the tiles, the central latitude
is now the equator. So if I multiply the stated 0.411.. resolution by
cos(52.5) (my latitude) I do still get 25cm resolution which explains
why objects are still the same size and I haven't lost resolution
after all in the reprojection.

Thanks again for your assistance, my understanding of coordinate
systems, projections and tiling is improving now!
Reply all
Reply to author
Forward
0 new messages