10

Given a SHP file corresponding to European countries, and...

Given defined area corresponting to France such :

West : 005° 48' W
East : 010° E
North : 051° 30' N
South : 041° N

How to get only the dots/geometries which intersects my defined area with gdal ? so my crop indeed is a real crop, which just keep the necessary geometries. Strong preference to gdal, ogr or console solutions.

chrki
  • 6,143
  • 6
  • 35
  • 55
Hugolpz
  • 17,296
  • 26
  • 100
  • 187

1 Answers1

15

Use GDAL's ogr2ogr command-line utility. If you have a file Europe.shp which has a spatial reference with units of degrees, then use the -clipsrc option with decimal degrees to make a new shapefile:

ogr2ogr -clipsrc -5.8 41 10 51.5 France.shp Europe.shp

There is also an example at the ogr2ogr page with France used as an example.

Mike T
  • 41,085
  • 18
  • 152
  • 203
  • 1
    Ok, so basically clip = crop. Thanks ! [Validation when I have time to test!] – Hugolpz Aug 21 '13 at 09:04
  • 1
    There is also `-spat` which works on the geometry instead of feature level. I don't know how they came up with these wack names ;) – Meekohi Jan 09 '20 at 23:02