<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Jesse,</p>
<p>the answer lies in exploring available Spatialite SQL functions:
<a class="moz-txt-link-freetext" href="https://www.gaia-gis.it/gaia-sins/spatialite-sql-5.1.0.html">https://www.gaia-gis.it/gaia-sins/spatialite-sql-5.1.0.html</a></p>
<p>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</p>
<p>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<br>
</p>
<p>untested obviously!<br>
</p>
<div class="moz-cite-prefix">Le 08/05/2024 à 19:09, Meyer, Jesse R.
(GSFC-618.0)[SCIENCE SYSTEMS AND APPLICATIONS INC] via gdal-dev a
écrit :<br>
</div>
<blockquote type="cite"
cite="mid:MN2PR09MB5932D13DD1CCACA8AD804745C9E52@MN2PR09MB5932.namprd09.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator"
content="Microsoft Word 15 (filtered medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Aptos;
panose-1:2 11 0 4 2 2 2 2 2 4;}@font-face
{font-family:Menlo;
panose-1:2 11 6 9 3 8 4 2 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Aptos",sans-serif;
mso-ligatures:standardcontextual;}span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Aptos",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-size:11.0pt;}div.WordSection1
{page:WordSection1;}</style>
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’m wanting to execute a SQL query on a
vector database like:<o:p></o:p></p>
<p class="MsoNormal"
style="line-height:13.5pt;background:#2D2A2E"><span
style="font-size:9.0pt;font-family:Menlo;color:#FCFCFA;mso-ligatures:none">vector_mem_ds</span><span
style="font-size:9.0pt;font-family:Menlo;color:#939293;mso-ligatures:none">.</span><span
style="font-size:9.0pt;font-family:Menlo;color:#A9DC76;mso-ligatures:none">ExecuteSQL</span><span
style="font-size:9.0pt;font-family:Menlo;color:#939293;mso-ligatures:none">(</span><i><span
style="font-size:9.0pt;font-family:Menlo;color:#78DCE8;mso-ligatures:none">f</span></i><span
style="font-size:9.0pt;font-family:Menlo;color:#FFD866;mso-ligatures:none">"select
ST_Centroid(GEOMETRY) as cnt, gdal_get_pixel_value('</span><span
style="font-size:9.0pt;font-family:Menlo;color:#AB9DF2;mso-ligatures:none">{</span><span
style="font-size:9.0pt;font-family:Menlo;color:#FCFCFA;mso-ligatures:none">raster_fp</span><span
style="font-size:9.0pt;font-family:Menlo;color:#AB9DF2;mso-ligatures:none">}</span><span
style="font-size:9.0pt;font-family:Menlo;color:#FFD866;mso-ligatures:none">',
</span><span
style="font-size:9.0pt;font-family:Menlo;color:#AB9DF2;mso-ligatures:none">{</span><span
style="font-size:9.0pt;font-family:Menlo;color:#FCFCFA;mso-ligatures:none">ndvi_band_num</span><span
style="font-size:9.0pt;font-family:Menlo;color:#AB9DF2;mso-ligatures:none">}</span><span
style="font-size:9.0pt;font-family:Menlo;color:#FFD866;mso-ligatures:none">,
'georef', cnt.STX, cnt.STY) from ds"</span><span
style="font-size:9.0pt;font-family:Menlo;color:#939293;mso-ligatures:none">,</span><span
style="font-size:9.0pt;font-family:Menlo;color:#FCFCFA;mso-ligatures:none">
</span><i><span
style="font-size:9.0pt;font-family:Menlo;color:#FC9867;mso-ligatures:none">dialect</span></i><span
style="font-size:9.0pt;font-family:Menlo;color:#FF6188;mso-ligatures:none">=</span><span
style="font-size:9.0pt;font-family:Menlo;color:#939293;mso-ligatures:none">"</span><span
style="font-size:9.0pt;font-family:Menlo;color:#FFD866;mso-ligatures:none">SQLITE</span><span
style="font-size:9.0pt;font-family:Menlo;color:#939293;mso-ligatures:none">")</span><span
style="font-size:9.0pt;font-family:Menlo;color:#FCFCFA;mso-ligatures:none"><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Is this possible largely as-is?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Jesse<o:p></o:p></p>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>