[QGIS-Developer] Choose DEM layer as terrain in 3D view using PyQGIS

Abdelghani Tamort abdel.tmrt at gmail.com
Thu May 2 09:15:39 PDT 2024


Hello Stefanos,

This works for me, thanks! I've also adjusted the altitude clamping so the
buildings don't hover over the terrain.

I've tried to manually export the scene but the results is a bit
disappointing:
[image: image.png]
The terrain is broken, any ideas why ?

Also I've seen that in the python API documentation it is mentioned that
Qgs3DMapScene is not available. Which means I cannot export the scene using
pyQGIS?
[image: image.png]

Thank you in advance,

Cheers,

Abdelghani

On Tue, 30 Apr 2024 at 23:26, Stefanos Natsis via QGIS-Developer <
qgis-developer at lists.osgeo.org> wrote:

> Hi Abdelghani,
>
> You need to create a symbol, set its data defined properties, assign it to
> a 3d renderer and then assign the 3d renderer to the layer:
>
> ```
> s = QgsPolygon3DSymbol()
> p = QgsProperty()
> p.setField('field_containing_height')
> c = QgsPropertyCollection()
> c.setProperty(QgsPolygon3DSymbol.Property.ExtrusionHeight, p)
> s.setDataDefinedProperties(c)
> layer.setRenderer3D(QgsVectorLayer3DRenderer(s))
> ```
>
> Best,
> Stefanos
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240502/05497fc7/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 287468 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240502/05497fc7/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 37568 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240502/05497fc7/attachment-0003.png>


More information about the QGIS-Developer mailing list