I've downloaded the 450MB coastline shapefile from OpenStreetMap, I want to split it up in smaller parts. Is there a way to generate a shapefile with only the polygons contained in a smaller area?

The file comes with the water areas already split up in rectangular shapes.

  • 2
    According to the docs, it's not "one big polygon," but has already been "divided into 100km x 100km squares." Do you need to clip out smaller portions of those square features or would it suffice to select those squares covering your study region? – whuber Feb 10 '11 at 14:31
  • It would be enough if I could export a couple of those 100km squares. Not optimal, if I'm limited to such a big grid, but very doable. – Erik Johansson Feb 17 '11 at 0:27

With ogr2ogr, you can specify a bounding box that you'd like to clip by with -clipsrc x_min y_min x_max y_max, so for example, to only get the northern hemisphere of a global dataset you could do:

ogr2ogr -f "ESRI Shapefile" borders_north.shp borders.shp -clipsrc -180 0 180 90

See the ogr2ogr documentation for further options, including clipping to another geometry.

|improve this answer|||||
  • If you have an old GDAL version (<1.7) this "works": ogr2ogr -f "ESRI Shapefile" borders_north.shp borders.shp -spat -180 0 180 90 It will not clip so if you have one big geometry you will still have to upgrade, – Erik Johansson Dec 12 '11 at 12:29
  • The file is of course in spherical mercator, so you will have to covnert the coordinates in someway. – Erik Johansson Dec 13 '11 at 10:39

You can install and use qgis to load the file you downloaded; use the mouse or query the data for the features that you would like to select; and export the selected features to a new shapefile.

QGIS is a cross-platform (Linux, Windows, Mac) open source application with many common GIS features and functions.

A link containing tutorials that illustrates these steps in qgis is available here http://qgis.spatialthoughts.com/

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.