GDAL/OGR primer
OGR/GDAL is a swiss army knife for spatial data. It can read u multitude of grid and vector formats and interact with OGC services. The tool includes 2 clusters of scripts:
GDAL utilities
interact with gridsOGR utilities
interact with vector formats
Installation
- On Windows, most easy install is using Conda. Other option is via ms4w. Note that QGIS (C:Files3.xx.exe) and ArcMap are also packaged with GDAL.
- For Apple, use brew install gdal
- On Ubuntu, run add-apt-repository ppa:ubuntugis/ppa && apt update && apt install gdal-bin
- On Debian, use Conda
- For Docker, use this container
GDAL exersize
- Get details of a gridded dataset
gdalinfo https://files.isric.org/soilgrids/latest/data/bdod/bdod_0-5cm_mean.vrt
- Get details of a geojson file
ogrinfo https://github.com/gregoiredavid/france-geojson/raw/master/cantons-avec-outre-mer.geojson
- Convert geojson to shapefile
ogr2ogr cantons.shp https://github.com/gregoiredavid/france-geojson/raw/master/cantons-avec-outre-mer.geojson
GML Application Schema
In 2017 a large work on GDAL introduced support for GML Application Schema. GDAL will read the schema of the xml and generate a relational database schema required to store the data. Verify that the build of GDAL includes GMLAS, it needs a special library XERCES
- Convert a gml file to geopackage
ogr2ogr -f GPKG test.gpkg GMLAS:/path/to/the.gml
- Use DBeaver or similar to evaluate the contents of the GeoPackage
GDAL and Python
GDAL includes python bindings, but many prefer the Fiona and Rasterio library, which do the same in a more pythonic
way.