Giter VIP home page Giter VIP logo

kenya-crop-mask's Introduction

Kenya crop mapping

Annual and in-season mapping of cropland in Kenya

Introduction

This repository contains code and data to generate an annual and in-season crop mask for Kenya. Two models are trained - a multi-headed pixel wise classifier to classify pixels as containing crop or not, and a multi-spectral satellite image forecaster which forecasts a 12 month timeseries given a partial input:

models

These can be used to create annual and in season crop maps. This repository contains the code to do this for Kenya, and Busia county in Kenya:

models

These maps are available on Google Earth Engine:

In addition, they are available on Zenodo.

The model which originally accompanied the paper requires data from Plant Village and One Acre Fund. We thank those organizations for making these datasets available to us - please contact them if you are interested in accessing the data. The code used to process these datasets is available on the ccai_2020 branch of this repository.

The main branch currently uses Plant Village's open source dataset, hosted on MLHub (but copied into the data folder here for convenience).

Pipeline

The main entrypoints into the pipeline are the scripts. Specifically:

The split_tiff.py script is useful to break large exports from Google Earth Engine, which may be too large to fit into memory.

Setup

Anaconda running python 3.6 is used as the package manager. To get set up with an environment, install Anaconda from the link above, and (from this directory) run

conda env create -f environment.yml

This will create an environment named landcover-mapping with all the necessary packages to run the code. To activate this environment, run

conda activate landcover-mapping

If you are using a GPU, environment.gpu.yml additionally installs cudatoolkit so that pytorch can use it too.

Earth Engine

Earth engine is used to export data. To use it, once the conda environment has been activated, run

earthengine authenticate

and follow the instructions. To test that everything has worked, run

python -c "import ee; ee.Initialize()"

Note that Earth Engine exports files to Google Drive by default (to the same google account used sign up to Earth Engine).

Running exports can be viewed (and individually cancelled) in the Tabs bar on the Earth Engine Code Editor.

Exports from Google Drive should be saved in data/raw.

Tests

The following tests can be run against the pipeline:

black .  # code formatting
mypy src  # type checking

Reference

If you find this code useful, please cite the following paper:

Gabriel Tseng, Hannah Kerner, Catherine Nakalembe and Inbal Becker-Reshef. 2020. Annual and in-season mapping of cropland at field scale with sparse labels. Tackling Climate Change with Machine Learning workshop at NeurIPS โ€™20: December 11th, 2020

The hand labelled dataset used for training, and the crop maps, can be found at https://doi.org/10.5281/zenodo.4271143

kenya-crop-mask's People

Contributors

gabrieltseng avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.