How to Extract the River Reach Geometry for HMA2_RSRD using GDAL
This article provides a guide on how to extract and export river reach geometry data contained within the High Mountain Asia Daily Reach-Scale River Discharge using Data Assimilation, 2004–2019, Version 1 NetCDF file -- HMA2_RSRD_2004-2019_daily_discharge_V01.0.nc.
Prerequisites
To extract the river geometry, you must have the Geospatial Data Abstraction Library (GDAL) installed on your system.
- GDAL Website: http://gdal.org/
Extracting the Reach Geometry
Within the NetCDF file, the river geometry information for all river reaches is stored in the variable named geometry_container.
To extract the geometry_container data and export it as a GeoPackage (.gpkg) file, execute the following command in your terminal:
ogr2ogr -f GPKG <output_filename>.gpkg HMA2_RSRD_2004-2019_daily_discharge_V01.0.nc geometry_container- Note: Replace
<output_filename>with the desired name for your output file.
The river geometry may also be exported to various other supported formats by simply changing the output format flag (-f) and ensuring the output file extension matches.
For example, use the following command to export the geometry as a shapefile:
ogr2ogr -f "ESRI Shapefile" <output_name>.shp HMA2_RSRD_2004-2019_daily_discharge_V01.0.nc geometry_container- Note: If the
.shpextension is not included in this command, a new directory named<output_name>will be created. This newly created directory will contain the.shpfile as well as its sidecar files (e.g.,.prj,.dbf,.shx).- If
.shpis included in the command like the example above, the.shpand its sidecar files will each be placed in your current working directory.
- If
For more information on the ogr2ogr command, including other supported formats and advanced options, refer to the official GDAL documentation: https://gdal.org/en/stable/programs/ogr2ogr.html