ukcp-data / ukcp-data-processor

Python library for reading, writing, processing and plotting UKCP data.
6 stars 1 forks source link

Manipulating shape files using gdal #5

Closed nmassey001 closed 1 month ago

nmassey001 commented 5 years ago

I used gdal (https://www.gdal.org/) to manipulate the shape files in:

ukcp-data-processor/ukcp_dp/public/shapefiles/

To see what is in the file, use the ogrinfo command, which is part of gdal:

ogrinfo BritishIsles.shp -al -geom=NO

To manipulate the shapefiles, use the ogr2ogr command, also part of gdal. This can use SQL style queries.

To produce BritishIslesReduced I used this command: ogr2ogr BritishIslesReduced.shp BritishIsles.shp -sql "SELECT * from BritishIsles where ET_ID<=6"

To produce the Small versions of the files I used the simplify feature of ogr2ogr2: ogr2ogr BritishIslesReducedSmall.shp BritishIslesReduced.shp -simplify 100

the weird thing with ogr2ogr is that it expects the destination file first, before the source file, i.e.: ogr2ogr <destination> <source> <command>

Hope that helps!