Skip to content

Instantly share code, notes, and snippets.

Created May 17, 2012 17:18
Show Gist options
  • Save anonymous/2720296 to your computer and use it in GitHub Desktop.
Save anonymous/2720296 to your computer and use it in GitHub Desktop.
slope and area constraints on multiple contiguous polygons
Drop view slope_area3;
create or replace view slope_area3 as
select gid::integer, new_geom, area_hectare from
(select generate_series(1, ST_NumGeometries(mymulti)) as gid,
ST_GeometryN(mymulti, generate_series(1, ST_NumGeometries(mymulti))) as new_geom,
st_area(ST_GeometryN(mymulti, generate_series(1, ST_NumGeometries(mymulti))))
/10000 AS area_hectare
from (select max(gid) as gid, st_memunion(the_geom) as mymulti
from
(select * from parcel_stats
where max_slope < 20
and st_intersects(st_buffer(st_geomfromtext('POINT(7501221 4674923)', 97392), 1500),parcel_stats.the_geom))
as t1) as t2
--group by gid
) as t3
where area_hectare >= 40;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment