I have a vector layer with 2498 features (houses) that I want to rasterize/produce a raster image from but can't figure out how:

Column MARK_Z = is Meters above see-level for the base of each house

Column Z = Total meters above see-level for each house

Column BYGG_H = is each buildings total height from base

So ideally I would want code two of them into the new raster attribute, but Raster > Conversion > Rasterize (Vector to Raster) only let's me chose one, so I'm looking at different ways to solve this.

I have a PostGIS up and running with Qgis, How can I rasterize this with PostGIS through Qgis?

More information:

Download this exact vector layer and see if you can sort it out? https://drive.google.com/open?id=0BwFHJFrNX33hZ2E0UlEtZDlUOXc

Running QGIS 2.18.0 'Las Palmas' but could change if another version works better?

enter image description here enter image description here enter image description here


2 Answers 2


I've seen a lot of the same problems you have with this dataset (both this question and your others), and struggled to get this into postgres.

Importing into postgres

Your geometries are of type 31 - shp2pgsql doesn't like that (it's expecting 1006). So create a new shapefile from the old with ogr2ogr, and tell it to save as MULTIPOLYGONZ

ogr2ogr -f "ESRI Shapefile" fixed.shp ./Byggnad_area_3D.shp -nlt MULTIPOLYGONZ

That gets us to the next problem :)

You may need to change the postgres database encoding. I tried several (UTF-8, LATIN1, LATIN4) without success... I get encoding errors. Used this to set the database encoding (I called mine 'sweden')

update pg_database set encoding = pg_char_to_encoding('LATIN1') where datname = 'sweden'

Limitations of gdal_rasterize

A further problem is that gdal_rasterize doesn't support burn values for polygon z coordinates (source). There's a -3d option but according to the docs...

Indicates that a burn value should be extracted from the "Z" values of the feature. As of now, only points and lines are drawn in 3D.

I was able to convert the fixed.shp to lines, and rasterize that. But I suspect that's not quite the effect you were after.

enter image description here


This sounds like a raster attribute table to me. According to this stackexchange post (Build Raster Attribute Table with GDAL Utilities) you can create them using GDAL, but according to another post (Accessing raster attribute table in QGIS?) they are not yet compatible with QGIS.

Give PostGIS or ArcGIS a try instead.

  • Thanks! So strange that this isn't possible yet!? I will edit the question to make it PostGIS specific since I have a PostGIS installation up and running with Qgis.
    – johlund
    Commented Nov 23, 2016 at 19:01
  • If someones got spare time I would appreciate input releated to this question. The main problem I'm trying to solve can be found here: could you think of a work-around? gis.stackexchange.com/questions/218840/…
    – johlund
    Commented Nov 23, 2016 at 19:16

Your Answer

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

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