[FWTools] Clipping based on polygons

Frank Warmerdam warmerdam at pobox.com
Fri Dec 1 13:38:54 EST 2006

Travis Kirstine wrote:
> Hi All,
> I am fairly familiar with the command line utilities included with FWTools
> and would like to automate some of tasks I perform via python.   What I
> would like to do is clip shapefiles and or rasters based on a existing tile
> index. I have done a little python scripting in the past but would
> appreciate some direction.


I would advise you to review some of the scripts in




Do you want to clip the actual geometries in a shapefile to some predefined
tile boundary or just select all features with geometries touching the tile
area.  Clipping is a bit more involved ... you would need to use the
ogr.Geometry.Intersection() method on the geometries and a tile rectangle.

I think rel.py could be helpful in writing a script to do spatial clipping.
Are you wanting to clip to a rectangle or to a polygon?

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org

More information about the FWTools mailing list