gdal/ogr: How to really crop a shapefile?

心已入冬 提交于 2019-12-05 22:54:18

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/18319106/gdal-ogr-how-to-really-crop-a-shapefile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!