3

I have 390 invisibility depth viewshed rasters, each with a size of 687 MB. The rasters contain the maximum value a building could attain at any given location, before it's visible from any of the 390 viewshed points.

Would it be possible to get PostGIS to query all the rasters that intersects with a vector polygon (could be converted to raster if easier) and return a list of filenames to those rasters that the vector polygon (a planned building with height in a column called "Z") intersects with?

I would like to be able to take a planned building and without to much manual work get a list/summary over which of the 390 rasters it intersects with.

If this is possible, how would you recommend me to set it up to be able to minimize manual steps?

2
  • 2
    The answer to just about every "is it possible" question is, "Yes." Unfortunately, the how depends on a lot of details not present, and really needs you to start the process before the question can be edited to be focused enough to fit our "Focused question / Best answer" model. I'd question the need to load rasters when the footprint of the images is all you need.
    – Vince
    Commented Oct 5, 2017 at 23:13
  • Thanks Vince, I realised the question was to broad but currently I'm so lost that I simply can't focus the question enough. I've tried to create all different sort of footprints from the raster with QGIS but no matter how I do it I end up with a much bigger file size than the original raster. Polygonize gives me a 4,33 GB file compared to 687 MB. With the plugin 'image footprint' I only get strange looking (unusable) polygons and a much bigger file size. My raster resolution is 2x2 meters and I'm gonna need to keep it that way for accurate results. Any help much appricated!
    – johlund
    Commented Jan 4, 2018 at 10:16

1 Answer 1

2

Yes. Assuming you have your rasters already loaded in the database, you can use the ST_Intersects function.

SELECT r.rid, r.rast, g.gid, g.geom
   FROM rast_table AS rINNER JOIN geom_table AS g
   ON ST_Intersects(r.rast,g.geom);

See - http://postgis.net/docs/manual-2.4/RT_ST_Intersects.html

Not the answer you're looking for? Browse other questions tagged or ask your own question.