Skip to main content

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()

Release files for cnwigee 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cnwigee 1.0.2
File Size Uploaded
cnwigee-1.0.2.tar.gz 21.3 kB Details

Release files / cnwigee-1.0.2.tar.gz

Download URL cnwigee-1.0.2.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2b92e7b842c4b5b90b3879e172ae086787404dfe8ae44f52d8b3caacd6e7a532
BLAKE2b-256 checksum
How to use checksums
0704b507548573536f7b20abbcee2b68dface7f9d84e781a8eaa5574e7af80ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

1.0.2 This release

1 release file

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page