Skip to main content

Köppen-Geiger Climate Classification in Google Earth Engine

Project description

Description

A Python-based package that creates Köppen-Geiger Climate Classification (KGCC) maps from monthly climate images prepared by the user. The earthengine-api (ee) dependency handles these images as image collection objects. Besides loading resulting KGCC maps to memory, the package can download KGCC geotif maps to Google Drive. Additionally, when the geemap library is installed, the maps may be visualized with only a few lines of code.

Requirements

  • Google Account
  • Google Earth Engine Account
  • Python 3
  • earthengine-api library
  • geemap library (optional for visualization)

Setup

In a default Google Colab environment, setup requirements are already met for installing geekgcc. The earthengine-api (ee) depency is automatically installed with geekgcc and in Colab. When using Colab, prepend an exclamation mark (!) to the beginning of installation code lines. To install the geekgcc Python package using Pip and the PyPI distribution:

pip install geekgcc

To install the geekgcc Python package using Git and Pip:

git clone https://github.com/ARS-SWRC/GEE-KGCC
pip install GEE-KGCC/geekgcc_package

To install the geekgcc Python package locally from a downloaded clone of the repository, use the following steps. In an environment tool like conda, activate your Python environment and navigate to the top of the geekgcc_package sub-directory, which should contain a .toml file. Then, run the following Pip command:

pip install .

For visualization, additionally install the geemaps library. In Colab, this library is pre-installed.

Installation instructions may be found at: https://geemap.org/

To authenticate ee and import necessary libraries, use the following steps. Start by importing, authenticating, and initializing ee, then import geekgcc.

import ee

#This will open a web browser for log-in steps.
ee.Authenticate()
geeusername = 'yourusername' #Enter your GEE user name.
geeproject = 'ee-yourusername' #Enter your GEE project name.
ee.Initialize(project=geeproject)
#The user must have an existing project.
#Default project names are in the format: "ee-yourusername".
#The web browser log-in steps assist with creating a project
#or one may be created at https://code.earthengine.google.com/

#ee should be initialized before importing geekgcc.
import geekgcc

Usage Notes

The user must provide ee.ImageCollection objects of long-term average monthly precipitation and temperature (12 images each). These should be overlapping images and should exist enitrely within a hemisphere (i.e., not in both hemispheres, such that at least two operations are needed to produce global coverage). WGS84 coordinate system is assumed in geekgcc. Climate images should be reprojected if they are in some other coordinate system.

The following methods are included in geekgcc: classify(), download(), get_vis_params(), and get_class_index().

Classification from monthly precipitation and temperature raster images:

geekgcc.KGCC.classify(p_ic, t_ic, hemi)

Parameter Type Description
p_ic ee.ImageCollection 12 monthly precipitation images (mm)
t_ic ee.ImageCollection 12 monthly mean temperature images (°C)
hemi string "north" or "south" hemisphere

Returns a classified ee.Image object. Possible output values are in the range from 1 to 30.

Download classified image to Google Drive:

geekgcc.KGCC.download(type_image, geo, scale, crs, filename)

Parameter Type Description
type_image ee.Image classified image
geo ee.Geometry.BBox bounding box geometry
scale float scale/resolution of downloaded image
crs string coordinate reference system code
filename string download file name

Returns None. Spawns a download task to Google Drive of the classified image in geotif format. Download progress may be monitored in the Earth Engine Online Code Editor.

Get visualization parameters:

geekgcc.KGCC.get_vis_params()

Parameter Type Description
- - -

Returns a dict of visualization parameters including the minimum value (1), maximum value (30), and a commonly used color scheme for KGCC. Only needed when visualizing with geemaps.

Get class look-up dictionary:

geekgcc.KGCC.get_class_index()

Parameter Type Description
- - -

Returns a dict that relates class values to class names and letter labels corresponding to 30 climate classes.

Test Example

The geekgcc_test.ipynb notebook is available for testing functionality of geekgcc at the GitHub repository linked below. The monthly WorldClim dataset is used in this example because it requires minimal pre-processing.

GitHub Repository

https://github.com/ARS-SWRC/GEE-KGCC/tree/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

geekgcc-1.0.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geekgcc-1.0.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file geekgcc-1.0.0.tar.gz.

File metadata

  • Download URL: geekgcc-1.0.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for geekgcc-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e6ea354ecfffd98be068120c0d14139c5569e316976fceec01aa4ad73d0cf034
MD5 d1cfc25ee2be1e3c47909ce6aca04929
BLAKE2b-256 953b5206fe26d94d64da0a7e1a6daf4a38f45ef415c71f09b4a8f2eb8867a79f

See more details on using hashes here.

File details

Details for the file geekgcc-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: geekgcc-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for geekgcc-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afcd10979faa2fe02de1cc77c9d6799303ab5ea6d8ad80006e4ab18a6dae15b8
MD5 e019959d15e516b27a50ddd768621f9d
BLAKE2b-256 2c9ec7d203a4fb9fc5c5fbda51fd13fac4a52898969312ea112c00efdddde34b

See more details on using hashes here.

Supported by

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