2

I have made a Simple points shapefile with seven points and I would like to be able to query which of these points are contained within the boundary of the raster layer.

SELECT "points inside raster_test".name FROM "points inside raster_test", myraster3 where ST_Within ("points inside raster_test".geom, myraster3.rast); 

I keep getting the following error-

ERROR: function st_contains(geometry, raster) does not exist LINE 3: where ST_contains ("points inside raster_test".geom, myraste... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. 

Do I have to write this query differently because there is a raster instead of another vector layer? I have tried using a vector polygon with the same points and wrote it exactly the same and it has given me the results I have desired.

1 Answer 1

1

You need the bounding box of the raster. Something like this:

where st_within("points inside raster_test".geom, st_envelope(myraster3.rast)) 

Should do it.

(ref. to docs.)

2
  • is the bounding box of a raster the exact size of the raster? or is it like the bounding box of vector object? Commented Dec 8, 2017 at 20:35
  • It's a bounding box, rather than an exact footprint. It returns: "The polygon is defined by the corner points of the bounding box ((MINX, MINY), (MINX, MAXY), (MAXX, MAXY), (MAXX, MINY), (MINX, MINY))", in the crs of your raster. Commented Dec 10, 2017 at 10:25

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.