Examples Inside Polygon 2
Temiz asks:
How can I find the points that are in a polygon that have certain distance ( say 4.5m) to polygon's exterior ring ?
Kevin answers:
- Extract the exterior ring of your token polygon
- Extract all the interior rings of your polygon
- Find all interior rings that are within a certain distance from the exterior ring
- Buffered the exterior ring
- Compute the intersection of the buffered exterior ring and the interior ring that is "close"
-- Create a sample polygon with two interior rings. CREATE TABLE sample_poly AS SELECT 'POLYGON (( 990030.8379 1002264.8323, 990029.6966 1002282.0018, 990036.8891 1002286.596, 990043.8774 1002287.3757, 990055.7296 1002285.7607, 990067.8854 1002291.298, 990073.974 1002293.0334, 990078.2256 1002297.9519, 990084.8219 1002310.654, 990092.914 1002314.2926, 990112.8638 1002313.4552, 990117.7626 1002311.2194, 990121.5065 1002305.1711, 990121.2326 1002301.0389, 990121.9657 1002294.9971, 990118.7723 1002289.1226, 990111.6309 1002285.4819, 990093.4161 1002281.2291, 990074.46 1002277.9317, 990067.3481 1002277.3112, 990063.0965 1002272.3927, 990063.9371 1002265.397, 990058.5601 1002259.6862, 990034.5683 1002256.5587, 990030.8379 1002264.8323 ), ( 990087.7546 1002286.4867, 990110.8467 1002290.5701, 990115.2003 1002297.3959, 990111.4054 1002302.4905, 990094.3804 1002302.209, 990081.0698 1002292.8592, 990081.768 1002286.6585, 990087.7546 1002286.4867 ), ( 990045.9613 1002265.1177, 990051.0778 1002268.9216, 990051.2954 1002274.9614, 990045.6124 1002282.2855, 990039.5748 1002281.5037, 990034.4074 1002276.7462, 990034.1898 1002270.7064, 990038.9005 1002265.4508, 990045.9613 1002265.1177 ))'::geometry AS geom;
-- Extract exterior ring CREATE TABLE exterior_ring AS SELECT ST_ExteriorRing(geom) AS geom FROM sample_poly; -- Extract interior rings CREATE TABLE interior_rings AS SELECT ST_InteriorRingN( geom, generate_series(1, ST_NumInteriorRings(geom))) AS geom FROM sample_poly;
-- Identify intersection points of buffered ext ring and interior rings. SELECT ST_Intersection(e.buff_geom, i.geom) FROM (SELECT geom, ST_Buffer(geom, 4.5) AS buff_geom FROM exterior_ring ) AS e, interior_rings i WHERE ST_DWithin(e.geom, i.geom, 4.5);
Last modified
16 years ago
Last modified on 04/15/09 12:03:22
Attachments (3)
- close_points2.png (9.1 KB ) - added by 16 years ago.
- close_points1.png (6.6 KB ) - added by 16 years ago.
- close_points3.png (10.5 KB ) - added by 16 years ago.
Download all attachments as: .zip
Note:
See TracWiki
for help on using the wiki.