I have a polygon layer (consist of buildings) and it has different attributes including the height attribute. I want to use that height in order to extrude my all polygons or give height to my building then export the dxf file. Want to give that height to my all polygons using the PyQGIS. I am able to find extrude documentation but unable to locate any working example as I am confused with two parameters of extrude which is x and y. I guess it should be consist of one parameter of height only.

extrude(self, x: float, y: float) → QgsGeometry
Returns an extruded version of this geometry.

Some code which I have applied without any success(no visual appearance change of polygone)

#getting the desired layer
if QgsProject.instance().mapLayersByName(layerUpdateName):
    layerUpdate = QgsProject.instance().mapLayersByName(layerUpdateName)[0]; 

for lu in layerUpdate.getFeatures():
    print (lu["Height"])
    #geom = lu.geometry().asPolygone()

2 Answers 2


What about forgoing 0.5D?


If you don't really need extruded polygons, bot only a 3D-like representation, the 2.5D rendering option might work for you.

You can apply a calculated value to be used as "extrusion" height, based on one or multiple fields.

enter image description here

Of course this is not a real extrusion, but might suffice in many cases.

  • 2
    I am looking for actual extrusion as i have to export it for 3d modelling tool and make proper building with actual height. Commented Oct 16, 2019 at 7:15
  • 1
    exported the layer in dxf file format and there is no height. Commented Oct 16, 2019 at 12:32

Based on your comment where you say:

I am looking for actual extrusion as i have to export it for 3d modelling tool and make proper building with actual height.

I would recommend installing the qgis2threejs plugin, setting up your extrusion there, and exporting as glTF:

enter image description here

glTF export

glTF is a JSON 3D format that can be imported into a 3D modelling software. For example, I have successfully exported extruded building polygons projected onto a DEM draped with ortophoto to Blender 3D using this method.

Wikipedia for glTF: https://en.wikipedia.org/wiki/GlTF

Although a caveat is that you most likely will lose georeferencing with this process.

  • Gitf file is not opening in Max Commented Oct 18, 2019 at 14:08
  • I am trying to use this extustion but it giving me error gis.stackexchange.com/questions/254710/… Commented Oct 18, 2019 at 14:09
  • Hi hexamon! thannks for the answer, i tried it again. And the scale of the model is very narrow? How do i scale? Commented Jan 22, 2020 at 5:17
  • @MuhammadFaizanKhan Could you elaborate a bit? What do you mean by "narrow"? And is it narrow after you've imported it to Max? Assuming that you mean that the scale is wrong in one axis, I would think the problem is either the projection you are using when exporting from QGIS or some import issue in Max.
    – hexamon
    Commented Jan 22, 2020 at 7:56
  • I exported gltf file and imported in blender(as only blender support it not max). Then simply i make the fbx from blender. Commented Jan 22, 2020 at 9:24

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.