<div dir="ltr">I miss the attachement<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno mer 3 feb 2021 alle ore 15:58 Enrico Ferreguti <<a href="mailto:enricofer@gmail.com">enricofer@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>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:</div><div><br></div><div>mesh = QgsMeshLayer("[path to the attached grib]/20210202_211414_ICON_EU_P06_.grb2","test","mdal")</div><div>#mesh = iface.activeLayer()<br></div><div>p1 = QgsPointXY(1.60301, 38.38453)<br><br>ds_group_index = 1<br><br>for g in mesh.datasetGroupsIndexes():<br>    print ("MESH GROUP:", g, mesh.datasetGroupMetadata(mesh.datasetIndexAtRelativeTime(h0,g)).name())<br><br>for i in range(mesh.dataProvider().datasetCount(ds_group_index)):<br>    meta = mesh.dataProvider().datasetMetadata(QgsMeshDatasetIndex(ds_group_index, i))<br>    t = meta.time()<br>    dataset = QgsMeshDatasetIndex(ds_group_index, i)<br>    value = mesh.datasetValue(dataset, p1)<br>    print ("VALUES P1",t,value.scalar(),value.x(),value.y())</div><div><br></div><div>When I run the script I can get dataset names from metadata but I'getting Nan as values</div><div>I verified that the grib is loadable in mapcanvas and the sample point is within grib extent.</div><div>I read the note in api (<a href="https://qgis.org/api/classQgsMeshLayer.html#a76a7ec072b4acaf45c1a10f5872c4948" target="_blank">https://qgis.org/api/classQgsMeshLayer.html#a76a7ec072b4acaf45c1a10f5872c4948</a>) "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.</div><div><br></div><div>Is there anybody who can help me finding what I'm doing wrong? Thanks.<br></div></div>
</blockquote></div>