hydro-raster


Namehydro-raster JSON
Version 0.0.11 PyPI version JSON
download
home_pagehttps://github.com/mingxiaodong/hydro-raster
SummaryTo process raster data for hydrological/hydrodynamic modelling
upload_time2024-04-27 14:01:51
maintainerNone
docs_urlNone
authorXiaodong Ming
requires_python>=3.6
licenseLICENSE.txt
keywords raster hydrological hydrodynamic
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            hydro_raster
--------
Python code to process raster data for hydrological or hydrodynamic modelling, 
e.g., [SynxFlow](https://github.com/SynxFlow/SynxFlow) or [HiPIMS-CUDA](https://github.com/HEMLab/hipims). The style of this package follows the [Google Python Style Guide](http://google.github.io/styleguide/pyguide.html).

Full documentation about how to install and use is [here](https://hydro-raster.readthedocs.io/en/latest/index.html).

Python version: >=3.6. To use the full function of this package for processing 
raster and feature files, *rasterio* and *pyshp* are required.

**The CRS of both DEM and Shapfiles must be projected crs whose map unit is meter.**

Functions included in this package:

1. merge raster files
2. edit raster cell values based on shapefile
3. convert cross-section lines to river bathymetry raster
4. remove overhead buildings/bridges on raster 
5. read, write, and visualise raster file

To install hydro_raster from command window/terminal:
```
pip install hydro_raster
```
To install using github repo:
```
git clone https://github.com/mingxiaodong/hydro-raster
cd hydro-raster
pip install .
```

Tutorial

A [jupyter-notebook file](https://github.com/mingxiaodong/hydro-raster/blob/main/demo/tutorial_edit_DEM.ipynb) is available to show a more detailed tutorial with outputs/plots of its codes.

1. Read a raster file
```
from hydro_raster.Raster import Raster
from hydro_raster import get_sample_data
tif_file_name = get_sample_data('tif')
ras_obj = Raster(tif_file_name)
```
2. Visualize a raster file
```
ras_obj.mapshow()
ras_obj.rankshow(breaks=[0, 10, 20, 30, 40, 50])
```
3. Clip raster file
```
clip_extent = (340761, 341528, 554668, 555682) # left, right, bottom, top
ras_obj_cut = ras_obj.rect_clip(clip_extent) # raster can aslo be cut by a shapfile using 'clip' function
ras_obj_cut.mapshow()
```
3. Rasterize polygons on a raster and return an index array with the same dimension of the raster array
```
shp_file_name = get_sample_data('shp')
index_array = ras_obj_cut.rasterize(shp_file_name)
index_array = index_array>=0
```
4. Change raster cell values within the polygons by adding a fixed value
```
ras_obj_new = ras_obj_cut.duplicate()
ras_obj_new.array[index_array] = ras_obj_cut.array[index_array]+20
```
5. Show the edited raster with the shapefile polygons
```
import matplotlib.pyplot as plt
from hydro_raster.grid_show import plot_shape_file
fig, ax = plt.subplots(1, 2)
ras_obj_cut.mapshow(ax=ax[0])
plot_shape_file(shp_file_name, ax=ax[0], linewidth=1)
ras_obj_new.mapshow(ax=ax[1])
plot_shape_file(shp_file_name, ax=ax[1], linewidth=1)
# values can also be changed based on the attributes of each shapefile features
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mingxiaodong/hydro-raster",
    "name": "hydro-raster",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "Raster Hydrological Hydrodynamic",
    "author": "Xiaodong Ming",
    "author_email": "xiaodong.ming@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/06/26/2a246b946a34bcf9a50c63343a186dd6b8f80bc2417fef53db119cf63a32/hydro_raster-0.0.11.tar.gz",
    "platform": null,
    "description": "hydro_raster\n--------\nPython code to process raster data for hydrological or hydrodynamic modelling, \ne.g., [SynxFlow](https://github.com/SynxFlow/SynxFlow) or [HiPIMS-CUDA](https://github.com/HEMLab/hipims). The style of this package follows the [Google Python Style Guide](http://google.github.io/styleguide/pyguide.html).\n\nFull documentation about how to install and use is [here](https://hydro-raster.readthedocs.io/en/latest/index.html).\n\nPython version: >=3.6. To use the full function of this package for processing \nraster and feature files, *rasterio* and *pyshp* are required.\n\n**The CRS of both DEM and Shapfiles must be projected crs whose map unit is meter.**\n\nFunctions included in this package:\n\n1. merge raster files\n2. edit raster cell values based on shapefile\n3. convert cross-section lines to river bathymetry raster\n4. remove overhead buildings/bridges on raster \n5. read, write, and visualise raster file\n\nTo install hydro_raster from command window/terminal:\n```\npip install hydro_raster\n```\nTo install using github repo:\n```\ngit clone https://github.com/mingxiaodong/hydro-raster\ncd hydro-raster\npip install .\n```\n\nTutorial\n\nA [jupyter-notebook file](https://github.com/mingxiaodong/hydro-raster/blob/main/demo/tutorial_edit_DEM.ipynb) is available to show a more detailed tutorial with outputs/plots of its codes.\n\n1. Read a raster file\n```\nfrom hydro_raster.Raster import Raster\nfrom hydro_raster import get_sample_data\ntif_file_name = get_sample_data('tif')\nras_obj = Raster(tif_file_name)\n```\n2. Visualize a raster file\n```\nras_obj.mapshow()\nras_obj.rankshow(breaks=[0, 10, 20, 30, 40, 50])\n```\n3. Clip raster file\n```\nclip_extent = (340761, 341528, 554668, 555682) # left, right, bottom, top\nras_obj_cut = ras_obj.rect_clip(clip_extent) # raster can aslo be cut by a shapfile using 'clip' function\nras_obj_cut.mapshow()\n```\n3. Rasterize polygons on a raster and return an index array with the same dimension of the raster array\n```\nshp_file_name = get_sample_data('shp')\nindex_array = ras_obj_cut.rasterize(shp_file_name)\nindex_array = index_array>=0\n```\n4. Change raster cell values within the polygons by adding a fixed value\n```\nras_obj_new = ras_obj_cut.duplicate()\nras_obj_new.array[index_array] = ras_obj_cut.array[index_array]+20\n```\n5. Show the edited raster with the shapefile polygons\n```\nimport matplotlib.pyplot as plt\nfrom hydro_raster.grid_show import plot_shape_file\nfig, ax = plt.subplots(1, 2)\nras_obj_cut.mapshow(ax=ax[0])\nplot_shape_file(shp_file_name, ax=ax[0], linewidth=1)\nras_obj_new.mapshow(ax=ax[1])\nplot_shape_file(shp_file_name, ax=ax[1], linewidth=1)\n# values can also be changed based on the attributes of each shapefile features\n```\n\n\n",
    "bugtrack_url": null,
    "license": "LICENSE.txt",
    "summary": "To process raster data for hydrological/hydrodynamic modelling",
    "version": "0.0.11",
    "project_urls": {
        "Homepage": "https://github.com/mingxiaodong/hydro-raster"
    },
    "split_keywords": [
        "raster",
        "hydrological",
        "hydrodynamic"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c8029c4f9ca6936464fb26606eb5ae501d73ad3e37663490f48b0859ee49b7bb",
                "md5": "a939400772dae5440a99f1ec6ee78c11",
                "sha256": "5ef0cbb89c513cb0099deefdd41556807240eef34a73ad47d9d7f7c3866f3061"
            },
            "downloads": -1,
            "filename": "hydro_raster-0.0.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a939400772dae5440a99f1ec6ee78c11",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 1409383,
            "upload_time": "2024-04-27T14:01:47",
            "upload_time_iso_8601": "2024-04-27T14:01:47.273503Z",
            "url": "https://files.pythonhosted.org/packages/c8/02/9c4f9ca6936464fb26606eb5ae501d73ad3e37663490f48b0859ee49b7bb/hydro_raster-0.0.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "06262a246b946a34bcf9a50c63343a186dd6b8f80bc2417fef53db119cf63a32",
                "md5": "511d270551441c57f770234d2e79ed0d",
                "sha256": "be56be00bc44ae4e30eef2a82de93c0cea08bccb85eef52fc70ee03f41e2da38"
            },
            "downloads": -1,
            "filename": "hydro_raster-0.0.11.tar.gz",
            "has_sig": false,
            "md5_digest": "511d270551441c57f770234d2e79ed0d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 1367750,
            "upload_time": "2024-04-27T14:01:51",
            "upload_time_iso_8601": "2024-04-27T14:01:51.079715Z",
            "url": "https://files.pythonhosted.org/packages/06/26/2a246b946a34bcf9a50c63343a186dd6b8f80bc2417fef53db119cf63a32/hydro_raster-0.0.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-27 14:01:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mingxiaodong",
    "github_project": "hydro-raster",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "hydro-raster"
}
        
Elapsed time: 0.23867s