1

Our problem is that we need to convert a shapefile to raster. Then, we need to generate tiles from zoom 15 to zoom 17 (2millions tiles to 16millions tiles).

Before we were using this methodology:

  • Step 1 : Import shape in QGIS, then generate a raster
  • Step 2 : Then we change the color/opacity of the raster using QGIS as well.
  • Step 3 : we generate a new raster (tif) of 1Tera Byte (~1TB).
  • Step 4: we use gdal2tiles to generate tiles.

This works fine. But the image is so big in size that it takes a while to tile.

But, now, we use directly GDAL as follows:

  • Step 1: gdal_rasterize to convert a shape to raster in the right color/opacity with compression. It generates a raster of 1GB.
gdal_rasterize -of GTiff -co BIGTIFF=IFNEEDED -co COMPRESS=DEFLATE     
               -burn 102-burn 120 -burn 42 -burn 255 -co PREDICTOR=2          
               -co ZLEVEL=9 -ot Byte -a_nodata 255 -a class
               -ts 500000 500000 -l input C:/input.shp C:/output.tif
  • Step 2: we want to generate tiles but gdal2tiles is hanging for a while just to generate a single tile. Maybe it does not support compressed file for tiling.

Any idea how to proceed?

  • This isn't very clear. Can you edit your question to show step-by-step what you've done, what the results were, and what you expected to happen instead. Right now, its hard to say what you are even asking. – BradHards Jan 14 '16 at 9:11
  • Ok, we edit the previous post. Hope this is more clear for you now. Any idea? – AhmeX2 Jan 14 '16 at 9:52
  • You can see what gdal2tiles is doing by reading the python, but basically you are not doing this very smartly. If you compress the image (the COMPRESS=DEFLATE part, it'll have to be decompressed for each tile. Does it work better if you use -co TILED=YES in the gdal_rasterize step? It would be smarter to break up the geotiff at rasterize time, or to rasterize to a tiled format like geopackage. – BradHards Jan 14 '16 at 10:00
  • even when we put '-co TILED=YES ' we get the same result ...can you explain me more how to process geopackage? – AhmeX2 Jan 14 '16 at 14:31
  • 1
    Just use -of GPKG and adjust the -co to be for that format (see help page). – BradHards Jan 14 '16 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.