Skip to content

Instantly share code, notes, and snippets.

@ian29
Forked from anonymous/gist:2814958
Created May 27, 2012 16:26
Show Gist options
  • Save ian29/2814962 to your computer and use it in GitHub Desktop.
Save ian29/2814962 to your computer and use it in GitHub Desktop.
select
id,
sum(st_area((gval).geom)
/ 10000) as total_area_ha,
round( min((gval).val)) as min_slope,
round( sum((gval).val * st_area((gval).geom))
/ st_area(st_collect((gval).geom))
) as avg_slope_sqm,
round( max((gval).val)) as max_slope
from (
select st_intersection(rast,1,db.the_geom) as gval,
db.the_geom,
db.gid as id
from slope2020
inner join
(select
TABLE.gid,
TABLE.the_geom,
st_difference(development_bounds.the_geom - rivers_roads7.the_geom) as la)
--where target_use = 'Golf Area', 'Village C'
) as db
on
st_intersects(rast,db.the_geom)
) as foo
-- Here's the new line that lets you constrain the results to below a specified slope:
where (gval).val < 16
-- End of new line.
group by id, foo.the_geom;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment