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_class_index(), and get_vis_params().

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, filename)

Parameter Type Description
type_image ee.Image classified image
geo ee.Geometry bounding box geometry
scale float scale/resolution of downloaded image
filename string downloaded file name

Returns None. Spawns a download task to Google Drive 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.

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

Uploaded Source

Built Distribution

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

geekgcc-0.2.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for geekgcc-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c6f6206c7104099c904eade6828e2611e39e36846d5b550df45c0d5685db5196
MD5 77b37bde15e3ed22da50e6df900d8902
BLAKE2b-256 78ceb5441e489faca2509558cb8018fe145fd6301872ec4963e6c034ce2c1eb1

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for geekgcc-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f50b4f8a5ea1912a5467fb4e3005e28a8f99dc02def973e11906e1a3e8cfd26c
MD5 a1605fac85524f5c102dd0d946e3357d
BLAKE2b-256 364ae205215982ad8e1de2b0995a008fdaa3097e6f5a26ff24e2d3cd9669e0e3

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