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

Uploaded Source

File details

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

File metadata

  • Download URL: cnwigee-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 2b92e7b842c4b5b90b3879e172ae086787404dfe8ae44f52d8b3caacd6e7a532
MD5 3b70eec1854e00ccd09d0ee9d87f159a
BLAKE2b-256 0704b507548573536f7b20abbcee2b68dface7f9d84e781a8eaa5574e7af80ff

See more details on using hashes here.

Provenance

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