Your description of the project
Project description
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
conda create -n cnwi-gee python=3.10 -c conda-forge earthengine-api geopandas pandas
# 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
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cnwigee-1.0.0.tar.gz
(21.4 kB
view details)
Built Distribution
cnwigee-1.0.0-py3-none-any.whl
(24.6 kB
view details)
File details
Details for the file cnwigee-1.0.0.tar.gz
.
File metadata
- Download URL: cnwigee-1.0.0.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bb1ee5790a5263ff990585e6509e531f6cb074e7dfc144e5781fe8830f77472 |
|
MD5 | 6a0582b9ed51c4318be675b4cb565d27 |
|
BLAKE2b-256 | ed879bb494988eb14ae26e331c46d4df4c0e87667e6385181e8ab82dfe6227b2 |
File details
Details for the file cnwigee-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: cnwigee-1.0.0-py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37c6af0e514f9d903fb687b8f5b550dabe82b9373bef15c9ac6306524f43a0a6 |
|
MD5 | 5c3af710137f83356590dd9be9d2fb7e |
|
BLAKE2b-256 | 60296c428d47c39feeb08811afb437f354d2e83d9e7386534856360a707008ed |