[QGIS-Developer] How to Create a WMS-Time layer via PyQGIS?

Richard Duivenvoorde rdmailings at duif.net
Mon May 10 04:11:55 PDT 2021


On 2021-05-10 11:59, Samweli Twesa Mwakisambwe wrote:

> To add a WMST layer via PyQGIS you will need to pass "type" parameter
> with value "wmst", "temporalSource" parameter and
> "timeDimensionExtent" parameter with the temporal extent value  in the
> layer URI,
> when QGIS find "type=wmst"  in URI, it looks for the
> "timeDimensionExtent" parameter value to create the provider temporal
> capabilities.

Ah, thanks, that was my missing uri information!!

> For your case
>  it fails to find the parameter and while parsing the extent it
> crashes, this is a bug, we need to open an issue and address it.

I created
https://github.com/qgis/QGIS/issues/43158

>> I thought to use the provider defaults (from WMS capabilities), to
>> be
>> able to for example change/set the temporal extent later:
>> layer_temporal_props = layer.temporalProperties( capabilities )
>> but... I cannot get to the WMS capabilities... (@Matthias: THAT is
>> was
>> searching in the api :-) )
> 
> You can achieve that by using  layer_temporal_props =
> layer.temporalProperties(
> ).setDefaultsFromDataProviderTemporalCapabilities(capabilities)

I tried the setDefaultsFromDataProviderTemporalCapabilities method, but 
untill now I'm unable to pass it a capabilities object. The 
'capabilities()' from a (wms)layer return you an integer, and I think 
that the mCaps of a WMS provider are private?

For WMS layers it would be handy if there would be a way to retrieve the 
layer specific information from the GetCapabilities document.
In the case of WMS-T it holds essential information about the 
time-extent en time-step to be used in configuring it as a temporal 
layer.

I will create a wmst layer now based on some external info.

Thanks Samweli,

Richard Duivenvoorde






More information about the QGIS-Developer mailing list