[geos-devel] Clipping geometries

Sandro Santilli strk at keybit.net
Mon Dec 16 03:02:09 PST 2013


On Mon, Dec 16, 2013 at 10:54:47AM +0100, Paul Meems wrote:
> Hi List,
> 
> We use GEOS with GDAL in our MapWinGIS project (mapwingis.codeplex.com) and
> we have some questions about clipping and how it is implemented in GEOS.
> 
> I have a polyline shapefile with the USA major roads, most roads overlap
> multiple states.
> I also have a polygon shapefile with USA states.
> 
> When I clip the roads with the states I would expect a polyline as a result
> where a road that crosses a state border is clipped resulting in two
> polylines.
> Is this the expected behavior and which GEOS methods should I use to
> accomplish this?

ST_Intersection(road, state), for each state, would give the state-belonging
segment at each call.

> Now switching the layers. I clip the states with the roads and when a road
> crosses the state and starts and ends outside the state the state is
> divided into two polygons with the road as the new border.
> This might be less common, so I wonder if I can expect from GEOS to handle
> this. And again which GEOS methods should I use if this is possible?

There's no single method in GEOS doing that.
PostGIS exposes an ST_Split method to do it, which basically
polygonizes the noded linework of inputs.

--strk;


More information about the geos-devel mailing list