[gdal-dev] Any trick to run SELECT gdal_get_pixel_value for lots of points?
Laurențiu Nicola
lnicola at dend.ro
Thu Jan 19 11:17:10 PST 2023
Hi,
I think I've mentioned it on the mailing list before, but https://www.orfeo-toolbox.org/CookBook/Applications/app_SampleExtraction.html has a pretty good (threaded) implementation of this.
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.
Regards,
Laurențiu
On Thu, Jan 19, 2023, at 21:09, Rahkonen Jukka wrote:
> Hi,
>
> I tried the new SQL function “gdal_get_pixel_value” from this PR https://github.com/OSGeo/gdal/pull/6877. 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
>
> 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
> INFO: Open of `p3412A.gpkg'
> using driver `GPKG' successful.
>
> Layer name: SELECT
> Geometry: None
> Feature Count: 3
> Layer SRS WKT:
> (unknown)
> p1: Real (0.0)
> OGRFeature(SELECT):0
> p1 (Real) = 11.1850004196167
>
> OGRFeature(SELECT):1
> p1 (Real) = 11.7200002670288
>
> OGRFeature(SELECT):2
> p1 (Real) = 13.5690002441406
>
> 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?
> The ultimate use case would be to find an alternative for the GRASS function v.drape https://grass.osgeo.org/grass82/manuals/v.drape.html.
>
> -Jukka Rahkonen-
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230119/8498beb1/attachment.htm>
More information about the gdal-dev
mailing list