I am using OSM vector data which has been converted into shapefiles. I have polygons representing buildings, landuse and lines representing roads as shown bellow:

enter image description here

I want to assign some symbology to the features like blue color for the buildings, green for landuse and white color for the roads with different width and convert them into a raster file, some thing like this:

enter image description here

I know that there are several tools for rending vector data into raster like mapnik and Maperitive etc.. but I want to do this task independent of such tools in a open source environment. I tried gdal_rasterize, the problem with it is that it only accepts one geometry type at a time, I can cannot feed multiple geometries like polygon and lines together. I can use it separately for each geometry type and then somehow merge all the rasters but an other problem in this approach is that I cannot specify width to the line, rather it will take the line with single pixel width.

Some folks have suggested me to simply export the Map to Image by setting the background of canvas as black in QGIS, but I need georeferenced maps which doesn't seems to be possible with this approach.

  • 2
    QGIS 3.X lets you set a scale and resolution when exporting, using basic mathematics you should be able to achieve a spatial resolution of 0.5 m. – Erik Apr 23 at 15:17
  • @Erik I have updated the last para of the question. – FJ_Abbasi Apr 24 at 13:44
  • I export the map screen as images all the time and there is always the suiting world-file created. – Erik Apr 24 at 14:27
  • @Erik Ok I just realized that. Is it possible to somehow automate this process? as I have to deal with hundreds of such images. – FJ_Abbasi Apr 24 at 14:51
  • Using pygis this is possible. Take a look at this gis.stackexchange.com/questions/287472/… for inspiration. – Erik Apr 24 at 15:04

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.