Jesse,

the answer lies in exploring available Spatialite SQL functions: https://www.gaia-gis.it/gaia-sins/spatialite-sql-5.1.0.html

ST_Centroid() returns a Point geometry. You may get its coordinates with ST_X() and ST_Y(). I suppose you'd need to use a sub-select construct to get things working, like

SELECT gdal_get_pixel_value(path, band_num, 'georef', ST_X(centroid), ST_Y(centroid)) FROM (SELECT ST_Centroid(geometry) AS centroid FROM ds) x

untested obviously!

Le 08/05/2024 à 19:09, Meyer, Jesse R. (GSFC-618.0)[SCIENCE SYSTEMS AND APPLICATIONS INC] via gdal-dev a écrit :

Hi,

I’m wanting to execute a SQL query on a vector database like:

vector_mem_ds.ExecuteSQL(/f/"select ST_Centroid(GEOMETRY) as cnt, gdal_get_pixel_value('{raster_fp}', {ndvi_band_num}, 'georef', cnt.STX, cnt.STY) from ds",/dialect/="SQLITE")

In particular, I want to use the geometry’s centroid for gdal_get_pixel_value, but the latter function takes two parameters, and ST_Centroid provides 1 return value (a compound type Point), so I am hoping for some way to unpack this into the form necessary expected from get_pixel_value. Apparently some GIS query engines do expose a STX and STY field but that’s if you trust random google results.  But as is this fails.

Is this possible largely as-is?

Thanks,

Jesse


_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

--
http://www.spatialys.com
My software is free, but my time generally not.
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev
  • ... Meyer, Jesse R. (GSFC-618.0)[SCIENCE SYSTEMS AND APPLICATIONS INC] via gdal-dev
    • ... Even Rouault via gdal-dev
      • ... Meyer, Jesse R. (GSFC-618.0)[SCIENCE SYSTEMS AND APPLICATIONS INC] via gdal-dev

Reply via email to