Hi,<div><br></div><div>I'm new to PostGIS, at least in the backend, so please excuse my naive question, but I couldn't figure this out Googling.</div><div><br></div><div>So, I've got it all working (PostGIS 2.0, imported the raster file and got the right projection information etc).</div>
<div><div>SELECT PostGIS_full_version();</div><div> postgis_full_version </div><div>-----------------------------------------------------------------------------------------------------------------------------------------------------</div>
<div> POSTGIS="2.0.1 r9979" GEOS="3.3.5-CAPI-1.7.5" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.9.1, released 2012/05/15" LIBXML="2.7.8" TOPOLOGY RASTER</div><div>(1 row)</div>
</div><div><br></div><div><br></div><div>Now I come to querying but cannot seem to get there. I would like to make a simple point query for the height in a point on the raster that we have.</div><div><br></div><div>I tried this:</div>
<div>select st_value(rast,ST_Point(1821416, 5649720)) from nzdem3;</div><div>where ST_Point(1821416, 5649720) is in NZTM (EPSG:2193). However, it doesn't work and just complains it is out of range. So, I did some research and found that it wants the pixel coordinate. Now, I could calculate it by getting the Geo Transformation with GDAL etc, but what is the point of PostGIS if I have to use GDAL instead? The point is that I would like to use PostGIS, because it seems like it's much more powerful. And we have PostGIS running anyway and it seems like the sensible choice.</div>
<div><br></div><div>I also tried this:</div><div>select DISTINCT ST_World2RasterCoordX(rast,ST_Point(1821416, 5649720)) from nzdem3;</div><div><br></div><div>but that gives me a pixel offset for each row in the database which really confuses me. How am I supposed to query if there are 56 different values for x alone:</div>
<div><div>st_world2rastercoordx </div><div>-----------------------</div><div> -6038</div><div> 10762</div><div> 40762</div><div> -4838</div><div> 31162</div>
<div> 33562</div><div> 38362</div><div> -38</div><div> 45562</div><div> 14362</div><div> 19162</div><div> 7162</div>
<div> 11962</div><div> 21562</div><div> -13238</div><div> 20362</div><div> 46762</div><div> 1162</div><div> 8362</div>
<div> -14438</div><div> 27562</div><div> 15562</div><div> 26362</div><div> -15638</div><div> 28762</div><div> -9638</div>
<div> -2438</div><div> -12038</div><div> 49162</div><div> 3562</div><div> 37162</div><div> 39562</div><div> 22762</div>
<div> 9562</div><div> 35962</div><div> -3638</div><div> -16838</div><div> 4762</div><div> 47962</div><div> 5962</div>
<div> 34762</div><div> 2362</div><div> 41962</div><div> 25162</div><div> 17962</div><div> 23962</div><div> -1238</div>
<div> 16762</div><div> -7238</div><div> 32362</div><div> 13162</div><div> 43162</div><div> -8438</div><div> -10838</div>
<div> 44362</div><div> 29962</div><div>(56 rows)</div><div><br></div><div>I see that PostGIS has a lot of potential also with raster queries and ultimately, I would like to be able to intersect it with a line string or even a multi poligon. But for now I would be happy if I could get a point with the projection's geographic coordinates.</div>
<div><br></div><div>Please help!</div><div><br></div><div>Thanks,</div><div>Tim</div><div><br></div><div>Tim-Hinnerk Heuer<br><br>Twitter: @geekdenz<br><div>Blog: <a href="http://www.thheuer.com/" target="_blank">http://www.thheuer.com</a></div>
</div><br>
</div>