Skip to main content

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


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.1.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

cnwigee-1.0.1-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file cnwigee-1.0.1.tar.gz.

File metadata

  • Download URL: cnwigee-1.0.1.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for cnwigee-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d9f227f47721435eb05085786e4fcace496d1430897c54b3b42ac7368b73c213
MD5 c8b88b2ea6936770ee66f1b316994521
BLAKE2b-256 96675ff00f0f915fc123a133d13680241bf4c6b71e1f12c6b56e0bbf71fe1764

See more details on using hashes here.

File details

Details for the file cnwigee-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: cnwigee-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for cnwigee-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 106a1e9c8dbf4b59131c75f25b14e6696e267689d86c408dc6c994df844bc896
MD5 8b5197316aa354aaca770b3b9e868003
BLAKE2b-256 6247362e516bd09aa47a9f5344ff3cc93e6c84cef098ceba9c8147a4269df857

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page