[gdal-dev] Clipping shapefiles

Ari Jolma ari.jolma at tkk.fi
Sat Sep 6 08:22:47 EDT 2008


Matthew Huck kirjoitti:
>   Hi,
>   
> I've got a reasonably large shapefile that I wish to break down
> into areas that match the topographic maps in NZMG. I've got a
> python script that creates a shapefile with each topomap as a
> polygon in it (and I can create a shapefile per topo map too if
> required). What I can't work out how to do is to clip my master
> shapefile by the smaller shapefiles. I've seen ideas of copying
> across the features if they intersect with the clipping box, but
> the data is contour lines so I want to "cut" the contour lines at
> the boundry of the clipping boxes.  Any ideas on the best way to
> do it, I can get MapWindow to do it (sometimes, but it crashes
> frequently).

I would use the GEOS function Intersection to clip to the box. Maybe it 
would be easiest to import the data into PostGIS and do it there. It 
wouldn't be too hard to write a GDAL script for the task either.

I did a similar job with road data of whole Finland in PostGIS and it 
took a while but there were no problems due to the clipping.

Regards,

Ari




More information about the gdal-dev mailing list