We had a task, which i believe would have taken days with ArcMap Editor. But postgis made it easier with updating a records and finding the points surrounding point from another table.
Here is a sample query.
Description: Find me exit locations, when two exits are within 150m from each other and update the table with shared infromation from each others.
UPDATE new_non_is_exits --new_is_exits_1 --rats
SET
int_id_rte_no=IS_EXITS1.id_rte_no,
int_road_name=IS_EXITS1.road_name,
int_mp_int_rte_name=IS_EXITS1.mp_int_rte_name,
int_routeid=IS_EXITS1.routeid,
int_id_prefix=IS_EXITS1.id_prefix,
int_mp_suffix=IS_EXITS1.mp_suffix
--of1 = tmp.of1,
-- sumof1 = tmp.sumof1
FROM (SELECT a.county, a.ogc_fid, a.id_rte_no, a.road_name,a.mp_int_rte_name, a.routeid, a.id_prefix, a.mp_suffix
--b.county , b.ogc_fid, b.id_rte_no, b.road_name,b.mp_int_rte_name, b.routeid, b.id_prefix, b.mp_suffix
FROM
--SELECT id, AVG(o) AS of1, SUM(o) AS sumof1
-- FROM rats,
-- offset1
-- GROUP BY id)
(SELECT ogc_fid,
county,
road_name,
id_rte_no,
mp_int_rte_name,
routeid,
id_prefix,
mp_suffix,
ST_Collect(wkb_geometry) AS geom
FROM New_IS_Exits_1
GROUP BY
ogc_fid,
county,
road_name,
id_rte_no,
mp_int_rte_name,
routeid,
id_prefix,
mp_suffix
) AS a,
(SELECT ogc_fid,
county,
road_name,
id_rte_no,
mp_int_rte_name,
routeid,
id_prefix,
mp_suffix,
ST_Collect(wkb_geometry) AS geom
FROM new_non_is_exits
GROUP BY
ogc_fid,
county,
road_name,
id_rte_no,
mp_int_rte_name,
routeid,
id_prefix,
mp_suffix
) AS b
WHERE ST_Distance(a.geom, b.geom) < 150 AND a.mp_int_rte_name = b.mp_int_rte_name AND a.county = b.county)
AS IS_EXITS1
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment