3.16 The attachment was missing. You can download it from here: https://beato.duckdns.org/nextcloud/s/Ra4opS94zYfgfXa
Il mer 3 feb 2021, 16:26 Vincent Cloarec <vcloa...@gmail.com> ha scritto: > Hi Enrico, > > As that will depend of the version of QGIS, which version do you use? > > Le mer. 3 févr. 2021 à 10:59, Enrico Ferreguti <enrico...@gmail.com> a > écrit : > >> I'm trying to write a simple function for retrieving wind speed and >> direction at a specified moment from a given grib file readable as mesh >> layer the prototype script is the following: >> >> mesh = QgsMeshLayer("[path to the attached >> grib]/20210202_211414_ICON_EU_P06_.grb2","test","mdal") >> #mesh = iface.activeLayer() >> p1 = QgsPointXY(1.60301, 38.38453) >> >> ds_group_index = 1 >> >> for g in mesh.datasetGroupsIndexes(): >> print ("MESH GROUP:", g, >> mesh.datasetGroupMetadata(mesh.datasetIndexAtRelativeTime(h0,g)).name()) >> >> for i in range(mesh.dataProvider().datasetCount(ds_group_index)): >> meta = >> mesh.dataProvider().datasetMetadata(QgsMeshDatasetIndex(ds_group_index, i)) >> t = meta.time() >> dataset = QgsMeshDatasetIndex(ds_group_index, i) >> value = mesh.datasetValue(dataset, p1) >> print ("VALUES P1",t,value.scalar(),value.x(),value.y()) >> >> When I run the script I can get dataset names from metadata but I'getting >> Nan as values >> I verified that the grib is loadable in mapcanvas and the sample point is >> within grib extent. >> I read the note in api ( >> https://qgis.org/api/classQgsMeshLayer.html#a76a7ec072b4acaf45c1a10f5872c4948) >> "It uses previously cached and indexed triangular mesh and so if the layer >> has not been rendered previously (e.g. when used in a script) it returns >> NaN value" so I tried to process an already loaded mesh (decomment line 2) >> without luck. >> >> Is there anybody who can help me finding what I'm doing wrong? Thanks. >> _______________________________________________ >> QGIS-Developer mailing list >> QGIS-Developer@lists.osgeo.org >> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer >> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer >> >
_______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer