HRDS
HRDS: A Python package for hierarchical raster datasets - Published in JOSS (2019)
Science Score: 59.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
✓Academic publication links
Links to: joss.theoj.org, zenodo.org -
✓Committers with academic emails
4 of 5 committers (80.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.4%) to scientific vocabulary
Keywords
Scientific Fields
Repository
Hierarchical raster data set: smooth interpolation of raster files at different resolutions for multiscale modelling
Basic Info
Statistics
- Stars: 8
- Watchers: 1
- Forks: 3
- Open Issues: 1
- Releases: 3
Topics
Metadata Files
README.md

About hrds
hrds is a python package for obtaining points from a set of rasters at different resolutions. You can request a point and hrds will return a value based on the highest resolution dataset (as defined by the user) available at that point, blending datasets in a buffer region to ensure consistency.
Prerequisites
- python 3+
- numpy
- scipy
- osgeo.gdal (pygdal) to read and write raster data
hrds is available on conda-forge, so you can install easily using:
bash
conda config --add channels conda-forge
conda install hrds
It is possible to list all of the versions of hrds available on your platform with:
bash
conda search hrds --channel conda-forge
On Debian-based Linux you can also install manually. To install pygdal, first install the libgdal-dev packages and binaries:
bash
sudo apt-get install libgdal-dev gdal-bin
To install pygdal, first check which version of gdal is installed:
bash
gdal-config --version
pygdal can be installed using pip, specifying the version obtained from the command above. Note that you may need to increase the minor version number, e.g. from 2.1.3 to 2.1.3.3.
bash
pip install pygdal==2.1.3.3
Replace 2.1.3.3 with the output from the gdal-config command.
You can then install hrds from source using the standard:
bash
python setup.py install
or from PyPi:
bash
pip install hrds
Functionality
Create buffer zones as a preprocessing step if needed
Obtain value at a point based on user-defined priority of rasters
The software assumes all rasters are already in the same projection space and using the same datum.
This example loads in an XYZ file and obtains data at each point, replacing the Z value with that from hrds.
```python
from hrds import HRDS
points = [] with open("test_mesh.csv",'r') as f: for line in f: row = line.split(",") # grab X and Y points.append([float(row[0]), float(row[1])])
bathy = HRDS("gebcouk.tif", rasters=("emodutm.tif", "inspiredata.tif"), distances=(700, 200)) bathy.setbands()
print(len(points))
with open("output.xyz","w") as f: for p in points: f.write(str(p[0])+"\t"+str(p[1])+"\t"+str(bathy.get_val(p))+"\n") ```
This will turn this:
bash
$ head test_mesh.csv
805390.592314,5864132.9269,0
805658.162910036,5862180.30440542,0
805925.733505999,5860227.68191137,0
806193.304101986,5858275.05941714,0
806460.874698054,5856322.43692232,0
806728.445294035,5854369.81442814,0
806996.015889997,5852417.19193409,0
807263.586486046,5850464.56943942,0
807531.157082069,5848511.94694493,0
807798.727678031,5846559.32445088,0
into this:
bash
$ head output.xyz
805390.592314 5864132.9269 -10.821567728305235
805658.16291 5862180.30441 2.721575532084955
805925.733506 5860227.68191 2.528217188012767
806193.304102 5858275.05942 3.1063558741547865
806460.874698 5856322.43692 5.470234157891056
806728.445294 5854369.81443 1.382685066254607
806996.01589 5852417.19193 1.8997482922322515
807263.586486 5850464.56944 4.0836843606647335
807531.157082 5848511.94694 -2.39508079759155
807798.727678 5846559.32445 -2.401006071401176
An example of use via thetis:
```python import firedrake import thetis from hrds import HRDS
mesh2d = firedrake.Mesh('test_mesh.msh') # mesh file
P12d = firedrake.FunctionSpace(mesh2d, 'CG', 1) bathymetry2d = firedrake.Function(P12d, name="bathymetry") bvector = bathymetry2d.dat.data bathy = HRDS("gebcouk.tif", rasters=("emodutm.tif", "inspiredata.tif"), distances=(700, 200)) bathy.setbands() for i, (xy) in enumerate(mesh2d.coordinates.dat.data): bvector[i] = bathy.get_val(xy) thetis.File('bathy.pvd').write(bathymetry2d)
rest of thetis code
```
These images show the original data in QGIS in the top right, with each data set using a different colour scheme (GEBCO - green-blue; EMOD - grey; UK Gov - plasma - highlighted by the black rectangle).The red line is the boundary of the mesh used (see figure below). Both the EMOD and UK Gov data has NODATA areas, which are shown as transparent here, hence the curved left edge of the EMOD data. The figure also shows the buffer regions created around the two higher resolution datasets (top left), with black showing that data isn't used to white where it is 100% used. The effect of NODATA is clear here. The bottom panel shows a close-up of the UK Gov data with the buffer overlayed as a transparancy from white (not used) to black (100% UK Gov). The coloured polygon is the area of the high resolution mesh (see below).

After running the code above, we produce this blended dataset. Note the coarse mesh used here - it's not realistic for a model simulation!

If we then zoom-in to the high resolution area we can see the high resolution UK Gov data being used and with no obvious lines between datasets.

It is also possible to use HRDS as a simple interpolation routine by specifying a single raster: ```python
from hrds import HRDS
points = [] with open("test_mesh.csv",'r') as f: for line in f: row = line.split(",") # grab X and Y points.append([float(row[0]), float(row[1])])
bathy = HRDS("gebcouk.tif") bathy.setbands()
print(len(points))
with open("output.xyz","w") as f: for p in points: f.write(str(p[0])+"\t"+str(p[1])+"\t"+str(bathy.get_val(p))+"\n") ```
Community
We welcome suggestions for future improvements, bug reports and other issues via the issue tracker. Anyone wishing to contribute code should contact Jon Hill (jon.hill@york.ac.uk) to discuss.
Owner
- Name: Environmental Modelling Research Group
- Login: EnvModellingGroup
- Kind: organization
- Website: https://envmodellinggroup.github.io/
- Repositories: 2
- Profile: https://github.com/EnvModellingGroup
Using the latest numerical technologies to solve environmental problems.
GitHub Events
Total
Last Year
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Jon Hill | j****l@y****k | 144 |
| Chris Barker | C****r@n****v | 5 |
| Chris Barker | P****B@g****m | 4 |
| tomc271 | t****n@y****k | 3 |
| Simon Warder | s****5@i****k | 2 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 23
- Total pull requests: 17
- Average time to close issues: 4 months
- Average time to close pull requests: 12 days
- Total issue authors: 4
- Total pull request authors: 4
- Average comments per issue: 0.96
- Average comments per pull request: 0.24
- Merged pull requests: 15
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- jhill1 (10)
- edoddridge (9)
- PythonCHB (3)
- klaatujk (1)
Pull Request Authors
- jhill1 (10)
- PythonCHB (5)
- tomc271 (1)
- swarder (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 18 last-month
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 1
(may contain duplicates) - Total versions: 5
- Total maintainers: 1
pypi.org: hrds
Read in multiple raster data files in a hierarchical fashion
- Homepage: https://github.com/EnvModellingGroup/hrds
- Documentation: https://hrds.readthedocs.io/
- License: GNU Lesser General Public License v3 (LGPLv3)
-
Latest release: 0.1.4
published over 2 years ago
Rankings
Maintainers (1)
conda-forge.org: hrds
hrds is a python package for obtaining points from a set of rasters at different resolutions. You can request a point (or list of points) and hrds will return a value based on the highest resolution dataset (as defined by the user) available at that point, blending datasets in a buffer region to ensure consistancy.
- Homepage: https://github.com/EnvModellingGroup/hrds
- License: GPL-3.0
-
Latest release: 0.1.1
published over 6 years ago
Rankings
Dependencies
- gdal *
- numpy *
- pytest *
- python >=3.6
- scipy >=0.17
- numpy >=1.11.0
- pygdal >=1.1
- pytest *
- scipy >=0.17
- actions/checkout v3 composite
- actions/setup-python v3 composite