Database Reference
In-Depth Information
CREATE TABLE chp02.contour_2_cm_only AS
SELECT contour.elevation, contour.gid,
contour.div_10, contour.div_20, contour.div_50,
contour.div_100, cc.id,
ST_Intersection(contour.the_geom, cc.the_geom)
AS the_geom FROM
chp02.cuy_contours_2 AS contour,
chp02.contour_clip as cc
WHERE ST_Within(contour.the_geom,cc.the_geom
OR
ST_Crosses(contour.the_geom,cc.the_geom);
We are performing two tests here in our query. We are using ST_Within , which
testswhetheragivencontourisentirelywithinourareaofinterest.Ifso,weperform
an intersection; the resultant geometry should just be the geometry of the contour.
The ST_Crosses functioncheckswhetherthecontourcrossestheboundaryofthe
geometrywearetesting.Thisshouldcaptureallthegeometrieslyingpartiallyinside
andpartiallyoutsideourareas.Thesearetheonesthatwewilltrulyintersecttoget
the resultant shape.
Inourcase,itiseasierandwedon'trequirethepreviousstep.Ourcontourshapes
arealreadyindividualshapefilesclippedtorectangularboundaries,asshowninthe
following screenshot:
Search WWH ::




Custom Search