cuttin tiles
tl:dr This is adventure with GDAL, specifically gdal2tiles and the VRT format. I had more than 1,000 ‘raw’ .tif files of 1-foot resolution imagery, totalling 300+ gigabytes. Looking for ‘web tiles’ / a Tile Map Service (TMS), I stumbled upon the adventures below…
My local County acquired countywide 1-foot imagery. At work, we are often editing OpenStreetMap and we wanted to use our own current/more-accurate data, so we built “a VRT (Virtual Dataset) that is a mosaic of the list of input GDAL datasets”, warped it to web mercator and cut it up with gdal2tiles.
-
gdalbuildvrt merge.vrt *.tif
mosaic/merge all teh .tif files -
gdalwarp -t_srs EPSG:3857 -dstnodata 0 -of VRT merge.vrt mergewarp.vrt
warp them alls,-dstnodata 0
worked to carry through the input nodata - i think -
mkdir tiles
make a folder for your output -
gdal2tiles.py -v mergewarp.vrt tiles/
many options, see the docs. You’ll want to use-e
if you need to stop/resume a job (see below).
joe larson @oeon rough calcs say 34 hours for gdal2tiles to cut zoom 18
^temporary^ see tweet since I can’t embed without breaking Jekyll - yes, I tried this already :/
I started the job on a Friday night and sometime Monday it finished. 1.24 million .png tiles and 91-ish gigabytes later - done! By default zoom level 7 - 18 were made.
Dirty little tiles, rolled by hand, with free software.
There were a few stragglers because some .tif’s were delievered in CA State Plane Zone V meters (instead of EPSG:2229 - feet!) but working to get the rest done. Remember that -e
flag for gdal2tiles I mentioned? Well, this is a situation where you’ll need it. I need to delete all the tiles that were created with those nodata/white tiles and run it again, with that flag.
Final stats:
###Final thoughts:
- Might cut some lower zoom levels - up to 21? Wow, how long will that take?
- Might try saving reducing the TMS total size by using something else (NAIP?) at the higher zoom levels.
- I’m not sure how much compression at the early stages of the processing would effect the results, both quality and size. I am going to see how processing this same area but from MrSID format, will affect size/quality.
- .vrt / VRT has come a long way. Just a couple years ago - I think it was just coming out and things like this weren’t possible. Thanks FrankW!