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

Abdelghani Tamort abdel.tmrt at gmail.com
Tue Apr 30 08:01:12 PDT 2024


This is what I'm trying to achieve (sorry my QGIS GUI is in french, I know
it's not very pleasant for the eye) :
[image: image.png]
I'm supposed to define the symbology first using the
class QgsAbstract3DSymbol then feeding it to the QgsVectorLayer3DRenderer
(I imagine), but I haven't got a clue how to start doing that.

On Tue, 30 Apr 2024 at 16:38, Abdelghani Tamort <abdel.tmrt at gmail.com>
wrote:

> Hello Stefanos,
>
> Thanks a lot, it works for me!
> How about showing extruded buildings from a vector layer (using an
> attribute containing height in meters)? I'm supposed to work with
> the QgsVectorLayer3DRenderer class right ?
>
> Best regards,
>
> Abdelghani TAMORT
>
> On Tue, 30 Apr 2024 at 11:12, Stefanos Natsis via QGIS-Developer <
> qgis-developer at lists.osgeo.org> wrote:
>
>> Hi Abdelghani,
>>
>> You should be able to achieve that by setting the project's terrain:
>> ```
>> p=QgsRasterDemTerrainProvider()
>> p.setLayer(dem_layer)
>> QgsProject.instance().elevationProperties().setTerrainProvider(p)
>> ```
>> This should get your dem_layer as a terrain for any new 3d views.
>> I don't think the API to change the 3d views' terrain is exposed to
>> python yet.
>>
>> 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/20240430/43407ba1/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 52761 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240430/43407ba1/attachment-0001.png>


More information about the QGIS-Developer mailing list