<!DOCTYPE html><html><head><title></title><style type="text/css">#qt p.qt-MsoNormal{margin-top:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:0cm;font-size:11pt;font-family:Calibri, sans-serif;}
#qt a:link{color:rgb(5, 99, 193);text-decoration-line:underline;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;}

p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div style="font-family:Arial;">Hi,<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">I think I've mentioned it on the mailing list before, but <a href="https://www.orfeo-toolbox.org/CookBook/Applications/app_SampleExtraction.html">https://www.orfeo-toolbox.org/CookBook/Applications/app_SampleExtraction.html</a> has a pretty good (threaded) implementation of this.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Of course, it's an extra piece of software to install. If you want to do it in pure SQL, you could also try VALUES to define a set of sampling coordinates, then call gdal_get_pixel_value over it.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Regards,<br></div><div style="font-family:Arial;">Laurențiu</div><div style="font-family:Arial;"><br></div><div>On Thu, Jan 19, 2023, at 21:09, Rahkonen Jukka wrote:<br></div><blockquote type="cite" id="qt" style="overflow-wrap:break-word;"><div class="qt-WordSection1"><p class="qt-MsoNormal">Hi,<br></p><p class="qt-MsoNormal"> <br></p><p class="qt-MsoNormal"><span lang="EN-US">I tried the new SQL function “gdal_get_pixel_value” from this PR <a href="https://github.com/OSGeo/gdal/pull/6877">https://github.com/OSGeo/gdal/pull/6877</a>. It is made to query a single point at a time but with some SQL I managed to query a few points with one ogrinfo command. I think that the query works even the</span><br></p><p class="qt-MsoNormal"><span lang="EN-US"> </span><br></p><p class="qt-MsoNormal"><span lang="EN-US">ogrinfo -sql "SELECT gdal_get_pixel_value('P3412A.tif', 1, 'pixel', 100, 200) as p1 UNION SELECT gdal_get_pixel_value('P3412A.tif', 1, 'pixel', 100, 400) as p1 UNION SELECT gdal_get_pixel_value('P3412A.tif', 1, 'pixel',
 300, 400) as p1" p3412A.gpkg --config OGR_SQLITE_ALLOW_EXTERNAL_ACCESS YES</span><br></p><p class="qt-MsoNormal"><span lang="EN-US">INFO: Open of `p3412A.gpkg'</span><br></p><p class="qt-MsoNormal"><span lang="EN-US">      using driver `GPKG' successful.</span><br></p><p class="qt-MsoNormal"><span lang="EN-US"> </span><br></p><p class="qt-MsoNormal"><span lang="EN-US">Layer name: SELECT</span><br></p><p class="qt-MsoNormal"><span lang="EN-US">Geometry: None</span><br></p><p class="qt-MsoNormal"><span lang="EN-US">Feature Count: 3</span><br></p><p class="qt-MsoNormal"><span lang="EN-US">Layer SRS WKT:</span><br></p><p class="qt-MsoNormal"><span lang="EN-US">(unknown)</span><br></p><p class="qt-MsoNormal"><span lang="EN-US">p1: Real (0.0)</span><br></p><p class="qt-MsoNormal"><span lang="EN-US">OGRFeature(SELECT):0</span><br></p><p class="qt-MsoNormal"><span lang="EN-US">  p1 (Real) = 11.1850004196167</span><br></p><p class="qt-MsoNormal"><span lang="EN-US"> </span><br></p><p class="qt-MsoNormal"><span lang="EN-US">OGRFeature(SELECT):1</span><br></p><p class="qt-MsoNormal"><span lang="EN-US">  p1 (Real) = 11.7200002670288</span><br></p><p class="qt-MsoNormal"><span lang="EN-US"> </span><br></p><p class="qt-MsoNormal"><span lang="EN-US">OGRFeature(SELECT):2</span><br></p><p class="qt-MsoNormal"><span lang="EN-US">  p1 (Real) = 13.5690002441406</span><br></p><p class="qt-MsoNormal"><span lang="EN-US"> </span><br></p><p class="qt-MsoNormal"><span lang="EN-US">However, the SQL statement with UNIONs gets too long if user wants to query hundreds or points. Is there any simple trick, SQL based or other, to make such a query?<br> The ultimate use case would be to find an alternative for the GRASS function v.drape <a href="https://grass.osgeo.org/grass82/manuals/v.drape.html">https://grass.osgeo.org/grass82/manuals/v.drape.html</a>.</span></p><p class="qt-MsoNormal"><span lang="EN-US"> </span><br></p><p class="qt-MsoNormal"><span lang="EN-US">-Jukka Rahkonen-</span><br></p></div><div>_______________________________________________<br></div><div>gdal-dev mailing list<br></div><div><a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br></div><div><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></div><div><br></div></blockquote><div style="font-family:Arial;"><br></div></body></html>