Name | soilgrids JSON |
Version |
0.1.4
JSON |
| download |
home_page | http://csdms.colorado.edu |
Summary | Fetch global gridded soil information from the SoilGrids system https://www.isric.org/explore/soilgrids |
upload_time | 2023-04-26 22:27:13 |
maintainer | |
docs_url | None |
author | Tian Gan |
requires_python | |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# soilgrids
[](https://soilgrids.readthedocs.io/en/latest/?badge=latest)
[](https://github.com/gantian127/soilgrids/blob/master/LICENSE.txt)
[](https://mybinder.org/v2/gh/gantian127/soilgrids/master?filepath=notebooks%2Fsoilgrids.ipynb)
soilgrids provides a set of functions that allow downloading of
the global gridded soil information from [SoilGrids](https://www.isric.org/explore/soilgrids),
a system for global digital soil mapping to map the spatial distribution of soil properties across the globe.
soilgrids also includes a [Basic Model Interface (BMI)](https://bmi.readthedocs.io/en/latest/),
which converts the SoilGrids dataset into a reusable,
plug-and-play data component ([pymt_soilgrids](https://pymt-soilgrids.readthedocs.io/)) for
the [PyMT](https://pymt.readthedocs.io/en/latest/?badge=latest) modeling framework developed
by Community Surface Dynamics Modeling System ([CSDMS](https://csdms.colorado.edu/wiki/Main_Page)).
If you have any suggestion to improve the current function, please create a github issue
[here](https://github.com/gantian127/soilgrids/issues).
## Get Started
#### Install package
##### Stable Release
The soilgrids package and its dependencies can be installed with pip
```
$ pip install soilgrids
```
or with conda.
```
$ conda install -c conda-forge soilgrids
```
##### From Source
After downloading the source code, run the following command from top-level folder
(the one that contains setup.py) to install soilgrids.
```
$ pip install -e .
```
#### Download SoilGrids Data
You can launch binder to test and run the code below.
##### Example 1: use SoilGrids class to download data (Recommended method)
```python
import matplotlib.pyplot as plt
from soilgrids import SoilGrids
# get data from SoilGrids
soil_grids = SoilGrids()
data = soil_grids.get_coverage_data(service_id='phh2o', coverage_id='phh2o_0-5cm_mean',
west=-1784000, south=1356000, east=-1140000, north=1863000,
crs='urn:ogc:def:crs:EPSG::152160',output='test.tif')
# show metadata
for key, value in soil_grids.metadata.items():
print('{}: {}'.format(key,value))
# plot data
data.plot(figsize=(9,5))
plt.title('Mean pH between 0 and 5 cm soil depth in Senegal')
```

##### Example 2: use BmiSoilGrids class to download data (Demonstration of how to use BMI)
```python
import matplotlib.pyplot as plt
import numpy as np
from soilgrids import BmiSoilGrids
# initiate a data component
data_comp = BmiSoilGrids()
data_comp.initialize('config_file.yaml')
# get variable info
var_name = data_comp.get_output_var_names()[0]
var_unit = data_comp.get_var_units(var_name)
var_location = data_comp.get_var_location(var_name)
var_type = data_comp.get_var_type(var_name)
var_grid = data_comp.get_var_grid(var_name)
print('variable_name: {} \nvar_unit: {} \nvar_location: {} \nvar_type: {} \nvar_grid: {}'.format(
var_name, var_unit, var_location, var_type, var_grid))
# get variable grid info
grid_rank = data_comp.get_grid_rank(var_grid)
grid_size = data_comp.get_grid_size(var_grid)
grid_shape = np.empty(grid_rank, int)
data_comp.get_grid_shape(var_grid, grid_shape)
grid_spacing = np.empty(grid_rank)
data_comp.get_grid_spacing(var_grid, grid_spacing)
grid_origin = np.empty(grid_rank)
data_comp.get_grid_origin(var_grid, grid_origin)
print('grid_rank: {} \ngrid_size: {} \ngrid_shape: {} \ngrid_spacing: {} \ngrid_origin: {}'.format(
grid_rank, grid_size, grid_shape, grid_spacing, grid_origin))
# get variable data
data = np.empty(grid_size, var_type)
data_comp.get_value(var_name, data)
data_2D = data.reshape(grid_shape)
# get X, Y extent for plot
min_y, min_x = grid_origin
max_y = min_y + grid_spacing[0]*(grid_shape[0]-1)
max_x = min_x + grid_spacing[1]*(grid_shape[1]-1)
dy = grid_spacing[0]/2
dx = grid_spacing[1]/2
extent = [min_x - dx, max_x + dx, min_y - dy, max_y + dy]
# plot data
fig, ax = plt.subplots(1,1, figsize=(9,5))
im = ax.imshow(data_2D, extent=extent)
fig.colorbar(im)
plt.xlabel('X')
plt.ylabel('Y')
plt.title('Mean pH between 0 and 5 cm soil depth in Senegal')
```
Raw data
{
"_id": null,
"home_page": "http://csdms.colorado.edu",
"name": "soilgrids",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Tian Gan",
"author_email": "jamy127@foxmail.com",
"download_url": "",
"platform": null,
"description": "# soilgrids\n[](https://soilgrids.readthedocs.io/en/latest/?badge=latest)\n[](https://github.com/gantian127/soilgrids/blob/master/LICENSE.txt)\n[](https://mybinder.org/v2/gh/gantian127/soilgrids/master?filepath=notebooks%2Fsoilgrids.ipynb)\n\n\n\nsoilgrids provides a set of functions that allow downloading of\nthe global gridded soil information from [SoilGrids](https://www.isric.org/explore/soilgrids),\na system for global digital soil mapping to map the spatial distribution of soil properties across the globe. \n\nsoilgrids also includes a [Basic Model Interface (BMI)](https://bmi.readthedocs.io/en/latest/),\nwhich converts the SoilGrids dataset into a reusable,\nplug-and-play data component ([pymt_soilgrids](https://pymt-soilgrids.readthedocs.io/)) for \nthe [PyMT](https://pymt.readthedocs.io/en/latest/?badge=latest) modeling framework developed \nby Community Surface Dynamics Modeling System ([CSDMS](https://csdms.colorado.edu/wiki/Main_Page)).\n\nIf you have any suggestion to improve the current function, please create a github issue \n[here](https://github.com/gantian127/soilgrids/issues).\n\n## Get Started\n\n#### Install package\n\n##### Stable Release\n\nThe soilgrids package and its dependencies can be installed with pip\n```\n$ pip install soilgrids\n```\nor with conda.\n```\n$ conda install -c conda-forge soilgrids\n```\n##### From Source\n\nAfter downloading the source code, run the following command from top-level folder \n(the one that contains setup.py) to install soilgrids.\n```\n$ pip install -e .\n```\n\n#### Download SoilGrids Data\nYou can launch binder to test and run the code below.\n\n##### Example 1: use SoilGrids class to download data (Recommended method)\n\n```python\nimport matplotlib.pyplot as plt\nfrom soilgrids import SoilGrids\n\n# get data from SoilGrids\nsoil_grids = SoilGrids()\ndata = soil_grids.get_coverage_data(service_id='phh2o', coverage_id='phh2o_0-5cm_mean', \n west=-1784000, south=1356000, east=-1140000, north=1863000, \n crs='urn:ogc:def:crs:EPSG::152160',output='test.tif')\n\n# show metadata\nfor key, value in soil_grids.metadata.items():\n print('{}: {}'.format(key,value))\n\n\n# plot data\ndata.plot(figsize=(9,5))\nplt.title('Mean pH between 0 and 5 cm soil depth in Senegal')\n```\n\n\n\n##### Example 2: use BmiSoilGrids class to download data (Demonstration of how to use BMI)\n\n```python\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfrom soilgrids import BmiSoilGrids\n\n\n# initiate a data component\ndata_comp = BmiSoilGrids()\ndata_comp.initialize('config_file.yaml')\n\n# get variable info\nvar_name = data_comp.get_output_var_names()[0]\nvar_unit = data_comp.get_var_units(var_name)\nvar_location = data_comp.get_var_location(var_name)\nvar_type = data_comp.get_var_type(var_name)\nvar_grid = data_comp.get_var_grid(var_name)\nprint('variable_name: {} \\nvar_unit: {} \\nvar_location: {} \\nvar_type: {} \\nvar_grid: {}'.format(\n var_name, var_unit, var_location, var_type, var_grid))\n\n# get variable grid info \ngrid_rank = data_comp.get_grid_rank(var_grid) \n\ngrid_size = data_comp.get_grid_size(var_grid)\n\ngrid_shape = np.empty(grid_rank, int)\ndata_comp.get_grid_shape(var_grid, grid_shape)\n\ngrid_spacing = np.empty(grid_rank)\ndata_comp.get_grid_spacing(var_grid, grid_spacing)\n\ngrid_origin = np.empty(grid_rank)\ndata_comp.get_grid_origin(var_grid, grid_origin)\n\nprint('grid_rank: {} \\ngrid_size: {} \\ngrid_shape: {} \\ngrid_spacing: {} \\ngrid_origin: {}'.format(\n grid_rank, grid_size, grid_shape, grid_spacing, grid_origin))\n\n# get variable data \ndata = np.empty(grid_size, var_type)\ndata_comp.get_value(var_name, data)\ndata_2D = data.reshape(grid_shape)\n\n# get X, Y extent for plot\nmin_y, min_x = grid_origin\nmax_y = min_y + grid_spacing[0]*(grid_shape[0]-1)\nmax_x = min_x + grid_spacing[1]*(grid_shape[1]-1)\ndy = grid_spacing[0]/2\ndx = grid_spacing[1]/2\nextent = [min_x - dx, max_x + dx, min_y - dy, max_y + dy]\n\n# plot data\nfig, ax = plt.subplots(1,1, figsize=(9,5))\nim = ax.imshow(data_2D, extent=extent)\nfig.colorbar(im)\nplt.xlabel('X')\nplt.ylabel('Y')\nplt.title('Mean pH between 0 and 5 cm soil depth in Senegal')\n```\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Fetch global gridded soil information from the SoilGrids system https://www.isric.org/explore/soilgrids",
"version": "0.1.4",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3ea90acdac1b2168d7eaa0264292cfc6aa73e448c693857413b1de57053172b2",
"md5": "00610c4f4ae7d28d04405f29d9fe8b21",
"sha256": "b9e72eea1d4a1604e3d1c35b3d475ba912cfa2cc39ec40c7000a1056a7a5134e"
},
"downloads": -1,
"filename": "soilgrids-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "00610c4f4ae7d28d04405f29d9fe8b21",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 12655,
"upload_time": "2023-04-26T22:27:13",
"upload_time_iso_8601": "2023-04-26T22:27:13.263682Z",
"url": "https://files.pythonhosted.org/packages/3e/a9/0acdac1b2168d7eaa0264292cfc6aa73e448c693857413b1de57053172b2/soilgrids-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-26 22:27:13",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "soilgrids"
}