Reputation: 1
I'm developping a QGIS plugin to convert data from hdf5 file. After having converted the data I want into raster, I load it into the interface with addRasterLayer. Then I do :
temporal_properties = layer.temporalProperties()
temporal_properties.setMode(mode)
# temporal_properties.setIsActive(True)
start = date
end = date
temporal_properties.setFixedTemporalRange(QgsDateTimeRange(start - timedelta(minutes=self.pas_minutes/2), end + timedelta(minutes=self.pas_minutes/2)))
temporal_properties.setIsActive(True)
It works well, but when I activate manually the temporal controller to show raster at the good time, it does not display anything. I have to go to the properties windows of my layer, click on apply to make it display. For one layer seems not too boring, but I will have many.
I didn't find any usefull info, I wonder if I forget something or if it's a QGIS bug.
(It's not working from QGIS 3.16, was working on 3.10).
If anyone could help... Thanks
Trying to display automatically a raster with temporal in the controller in QGIS. I've tried refresh canvas functions, updateTemporalRange for the QGIS controller.
Upvotes: 0
Views: 101
Reputation: 1
Ok after many tries I managed to figure out what was going on. My dates (start & end) we of datetime type. What's needed is QDateTime. So I transformed them into the good type.
Still had de the issue. It came that my QDateTime were not in UTC. I added this tag en then went ok. That gave something like :
start = date
end = date
print("date layer",date)
start = start - timedelta(minutes=pas/2)
end = end + timedelta(minutes=pas/2)
# Définir la date de début et fin
date_debut = QDateTime()
date_debut.setTime(QTime(int(start.hour),int(start.minute),int(start.second)))
date_debut.setDate(QDate(int(start.year),int(start.month),int(start.day)))
date_debut.setTimeSpec(Qt.UTC)
#print("date_debut",date_debut,type(date_debut))
date_fin = QDateTime()
date_fin.setDate(QDate(int(end.year),int(end.month),int(end.day)))
date_fin.setTime(QTime(int(end.hour),int(end.minute),int(end.second)))
date_fin.setTimeSpec(Qt.UTC)
mon_range = QgsDateTimeRange(date_debut, date_fin,includeEnd = True)
layer.temporalProperties().setIsActive(True)
layer.temporalProperties().setFixedTemporalRange(mon_range)
Upvotes: 0