Name | cnwigee JSON |
Version |
1.0.2
JSON |
| download |
home_page | |
Summary | Your description of the project |
upload_time | 2023-06-22 14:15:43 |
maintainer | |
docs_url | None |
author | Ryan Hamilton |
requires_python | |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# CNWI-GEE
Canadian National Wetland Inventory Google Earth Engie Random Forest Classifications. Provides high
level access for doing standardized random forest wetland classifications.
# Installation and Setup
This package is built to be used with the annaconda project. For best user experience use some
recent version of conda. These walk though will be using a miniconda3
## Dependencies
- Geopandas
- google earth engine
```sh
conda create -n cnwi-gee python=3.10 -c conda-forge earthengine-api geopandas pandas
```
```sh
# Step 2): activate new conda env and authenticate earth engine api
$ conda activate cnwi-gee
# authenticate earth engine api
(cnwi-gee) $ earthengine authenticate
```
# Example Pipeline
```python
from dataclasses import dataclass
import ee
from cnwi import inputs, rf, td, funcs, sfilters
from cnwi import prebuilt
def main():
# load dataset
dataset = ee.FeatureCollection("users/ryangilberthamilton/BC/williston/fpca/willistonA_no_floodplain")
williston = prebuilt.WillistonA()
# create a training object
training = td.TrainingData(
collection=dataset,
label='cDesc'
)
# create s1 inputs
s1s: List[ee.Image] = inputs.s1_inputs(williston.s1)
# create s2 inputs
s2s: List[ee.Image] = inputs.s2_inputs(williston.s2)
# create elevation inputs
elevation = inputs.nasa_dem()
filter = sfilters.gaussian_filter(3)
smoothed = filter(elevation)
slope = ee.Terrain.slope(smoothed)
# Create the inputs stack
stack = ee.Image.cat(*s1s, *s2s, smoothed, slope)
# sample the stack
training.sample(
stack=stack
)
# create the rf model
model = rf.RandomForestModel()
# train the model
trained = model.train(
training_data=training.samples,
predictors=stack.bandNames(),
classProperty=training.value
)
# classify the image
classified_img = stack.classify(trained).uint8()
# export image and samples to cloud
return sys.exit(0)
if __name__ == '__main__':
main()
```
Raw data
{
"_id": null,
"home_page": "",
"name": "cnwigee",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Ryan Hamilton",
"author_email": "ryangilberthamilton@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/07/04/b507548573536f7b20abbcee2b68dface7f9d84e781a8eaa5574e7af80ff/cnwigee-1.0.2.tar.gz",
"platform": null,
"description": "# CNWI-GEE\r\nCanadian National Wetland Inventory Google Earth Engie Random Forest Classifications. Provides high\r\nlevel access for doing standardized random forest wetland classifications.\r\n\r\n# Installation and Setup\r\nThis package is built to be used with the annaconda project. For best user experience use some \r\nrecent version of conda. These walk though will be using a miniconda3\r\n## Dependencies\r\n- Geopandas\r\n- google earth engine\r\n\r\n```sh\r\nconda create -n cnwi-gee python=3.10 -c conda-forge earthengine-api geopandas pandas\r\n```\r\n\r\n```sh\r\n# Step 2): activate new conda env and authenticate earth engine api\r\n$ conda activate cnwi-gee\r\n# authenticate earth engine api\r\n(cnwi-gee) $ earthengine authenticate\r\n```\r\n\r\n# Example Pipeline\r\n```python\r\nfrom dataclasses import dataclass\r\n\r\nimport ee\r\n\r\nfrom cnwi import inputs, rf, td, funcs, sfilters\r\nfrom cnwi import prebuilt\r\n\r\n\r\n\r\ndef main():\r\n # load dataset\r\n dataset = ee.FeatureCollection(\"users/ryangilberthamilton/BC/williston/fpca/willistonA_no_floodplain\")\r\n williston = prebuilt.WillistonA()\r\n \r\n # create a training object\r\n training = td.TrainingData(\r\n collection=dataset,\r\n label='cDesc'\r\n )\r\n \r\n # create s1 inputs\r\n s1s: List[ee.Image] = inputs.s1_inputs(williston.s1)\r\n \r\n # create s2 inputs\r\n s2s: List[ee.Image] = inputs.s2_inputs(williston.s2)\r\n \r\n # create elevation inputs\r\n elevation = inputs.nasa_dem()\r\n filter = sfilters.gaussian_filter(3)\r\n smoothed = filter(elevation)\r\n slope = ee.Terrain.slope(smoothed)\r\n \r\n # Create the inputs stack\r\n stack = ee.Image.cat(*s1s, *s2s, smoothed, slope)\r\n \r\n # sample the stack\r\n training.sample(\r\n stack=stack\r\n )\r\n \r\n # create the rf model\r\n model = rf.RandomForestModel()\r\n # train the model\r\n trained = model.train(\r\n training_data=training.samples,\r\n predictors=stack.bandNames(),\r\n classProperty=training.value\r\n )\r\n \r\n # classify the image\r\n classified_img = stack.classify(trained).uint8()\r\n \r\n # export image and samples to cloud\r\n return sys.exit(0)\r\n \r\n \r\nif __name__ == '__main__':\r\n main()\r\n```\r\n",
"bugtrack_url": null,
"license": "",
"summary": "Your description of the project",
"version": "1.0.2",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0704b507548573536f7b20abbcee2b68dface7f9d84e781a8eaa5574e7af80ff",
"md5": "3b70eec1854e00ccd09d0ee9d87f159a",
"sha256": "2b92e7b842c4b5b90b3879e172ae086787404dfe8ae44f52d8b3caacd6e7a532"
},
"downloads": -1,
"filename": "cnwigee-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "3b70eec1854e00ccd09d0ee9d87f159a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21287,
"upload_time": "2023-06-22T14:15:43",
"upload_time_iso_8601": "2023-06-22T14:15:43.181014Z",
"url": "https://files.pythonhosted.org/packages/07/04/b507548573536f7b20abbcee2b68dface7f9d84e781a8eaa5574e7af80ff/cnwigee-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-22 14:15:43",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "cnwigee"
}