PostGis 查询

1. 查询一个网格内的所有Feature

select b.*
into build_1090
from huadu b, smallgz3 g
where ST_Intersects(b.the_geom, g.the_geom) AND g.”name” = ‘Area_1090’;

2. 查询相交后的网格
SELECT p.id, b.”房高” as height, ST_Intersection(b.the_geom, p.the_geom),
From building b INNER JOIN grids p ON st_intersects(b.the_geom,p.the_geom)
WHERE ST_Overlaps(b.the_geom, p.the_geom)
AND (p.id > 40787660 and p.id < 40787800)
LIMIT 100;

3. 更新地理信息
DROP TABLE mroad_258;

SELECT m.*
INTO mroad_258
FROM main_road as m, smallgz2 as g
WHERE (ST_Overlaps(m.p_geom, g.the_geom) OR st_within(m.p_geom, g.the_geom)) AND
(g.id = 258 OR g.id = 276 OR g.id = 295);
DROP TABLE tmp;

SELECT g.gid
INTO tmp
FROM grid125 as g INNER JOIN mroad_258 as m ON st_intersects(g.the_geom, m.p_geom)
WHERE ST_Overlaps(g.the_geom, m.p_geom) OR ST_Within(g.the_geom, m.p_geom);

UPDATE grid125 as g
SET mroad_type = 1
FROM tmp
WHERE g.gid = tmp.gid;
转载自:https://blog.csdn.net/iteye_15840/article/details/81683954

You may also like...