Right. To minimize the amount of intermediate computation you can add a discriminant to the first query:
WITH floodareas AS ( SELECT ST_MapAlgebra(rast, ‘1BB’, ‘CASE WHEN [rast] < 10 THEN 1 ELSE NULL END’) rast FROM elevation e, districts d WHERE ST_Intersects(d.geom, e.rast) ) SELECT d.* FROM districts d, floodareas f WHERE ST_Intersects(d.geom, f.rast) Pierre De : postgis-users <[email protected]> De la part de [email protected] Envoyé : 15 juillet 2019 14:40 À : [email protected] Objet : Re: [postgis-users] raster regions Thanks, Pierre, It seems ok to model the query the way you showed, however, that implies the generation of an entire intermediate binary raster, just to identify the region inside the whole mapped area. My issue is on avoiding such intermediate data by incorporating map algebra expression into the same query expression, Another example, ""... d.geom touch (ndvi2018 < ndvi2019)" where ndvixxxx are raster data. Att. Em 15-07-2019 14:43, Pierre Racine escreveu: Hi, That could translate into something like this in PostGIS: WITH floodareas AS ( SELECT ST_MapAlgebra(rast, ‘1BB’, ‘CASE WHEN [rast] < 10 THEN 1 ELSE NULL END’) rast FROM elevation ) SELECT d.* FROM districts d, floodareas f WHERE ST_Intersects(g.geom, f.rast) NULL becomes nodata values. You could also use ST_Reclass() instead of ST_Mapalgebra(). Pierre De : postgis-users <[email protected]<mailto:[email protected]>> De la part de Joao Cordeiro Envoyé : 15 juillet 2019 10:19 À : 'PostGIS Users Discussion' <[email protected]<mailto:[email protected]>> Objet : [postgis-users] raster regions Hi there, I am not actually a POSTGIS user, or developer, although I am doing some research of integration of vector -raster in a dbms context. My main question s about identifying regions represented in a domain like the "hybrid raster" so that they can be referred to in a query. For example, I would like to write something like "select d from districts where d.geometry touches flooding", where "flooding" indicates an expression intended to decide on the pertinence of locations to a flooding risk area described, for instance through map algebra. Thanks for any hints or suggestions. Att. _______________________________________________ postgis-users mailing list [email protected]<mailto:[email protected]> https://lists.osgeo.org/mailman/listinfo/postgis-users
_______________________________________________ postgis-users mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/postgis-users
