In my PostGIS / PostgreSQL DB I have a DEM cropped to the size of Germany. As a second (vector) layer I have 1300 catchment areas (<30km²) for which I want to calculate the slope. To reduce the calculation time and effort I decided to clip the DEM to the geometries of the catchment and calculate their slope values afterwards. The DEM has to be transformed to SRID 31467.
DROP TABLE IF EXISTS spatial_derived.ezg_slope; CREATE TABLE spatial_derived.ezg_slope AS SELECT gid rid, ST_Union(rast) rast FROM ( SELECT ezg.gid, ST_slope(ST_Clip(ST_Transform(eu.rast, 31467), ezg.geom, -9999, true),1,'32BF','degree',1,false) rast FROM spatial_derived.land_use_ezg30 ezg, spatial.eu_dem eu WHERE ST_Intersects(eu.rast, ezg.geom) AND ST_IsValid(ezg.geom) )t1 GROUP BY gid
This worked nicely for a LIMIT of 20 rows:
However when I try to apply the query on all the data I just get an area of the size of the bounding box with 0s, and the polygons are not presented anymore. Up to now I can't go into more detail what might have gone wrong. My question here is if the query contains any evident flaws?