My query in (Dutch SRID, in meter):
SELECT ST_NearestValue(ahn.rast, 1, ST_SetSRID(ST_Point(135742.6965165309,453864.2795337387), 28992) FROM ahn2.ahn WHERE ST_Intersects(ahn.rast, ST_SetSRID(ST_Point(135742.6965165309,453864.2795337387), 28992)::geometry, 1))
returns nothing in pgAdmin4:
I am sure the point is located in the middle of a raster. Slightly changing the coordinates results in:
- 135742.6965165309, 453864.2795337387 (original)
- 135740.6965165309, 453864.2795337387 (returns value)
- 135744.6965165309, 453864.2795337387 (returns value)
- 135742.6965165309, 453865.2795337387 (returns value)
- 135742.6965165309, 453863.2795337387 (returns value)
- 135741.6965165309, 453864.2795337387 (also nothing)
Why is my query returning nothing and how can it be fixed?
I'm working on a script that needs to calculate whether or not a certain locations has a shadow. To do that a line of sight (LOS) between the ground and the sun is calculated. This line is in fact a list of coordinates (x, y, and z). To determine whether or not there is shadow the height of the terrain needs to be determined for each x and y coordinate. If it is below the z (from the line) than the LOS is not blocked. The above query serves to extract the terrain height.
POSTGIS="2.4.4 r16526" PGSQL="100" GEOS="3.6.2-CAPI-1.10.2 4d2925d" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.2.4, released 2018/03/19" LIBXML="2.7.8" LIBJSON="0.12" LIBPROTOBUF="1.2.1" RASTER