An LSTM to generate a crop mask for Togo
# Togo Crop Mask
A pixel-wise land type classifier, used to generate a crop mask for Togo
## Introduction
This repository contains code and data to generate a crop mask for Togo.
It was used to deliver a high-resolution (10m) cropland mask in 10 days to help the government distribute aid to smallholder farmers during the COVID-19 pandemic.
It combines a hand-labelled dataset of crop / non-crop images with a global database of crowdsourced cropland data
to train a multi-headed LSTM-based model to predict the presence of cropland in a pixel.
The map can be found on Google Earth Engine.
## Pipeline
The main entrypoints into the pipeline are the scripts. Specifically:
* scripts/export.py exports data (locally, or to Google Drive - see below)
* scripts/process.py processes the raw data
* scripts/engineer.py combines the earth observation data with the labels to create (x, y) training data
* scripts/models.py trains the models
* scripts/predict.py takes a trained model and runs it on exported tif files (the path to these files is defined in the script)
The split_tiff.py script is useful to break large exports from Google Earth Engine, which may
be too large to fit into memory.
Once the pipeline has been run, the directory structure of the data folder should look like the following. If you get errors, a good first check would be to see if any files are missing.
```
data
│ README.md
│
└───raw // raw exports
│ └───togo // this is included in this repo
│ └───geowiki_landcover_2017 // exported by scripts.export.export_geowiki()
│ └───earth_engine_togo // exported to Google Drive by scripts.export.export_togo(), and must be copied here
│ │ // scripts.export.export_togo() expects processed/togo{_evaluation} to exist
│ └───earth_engine_togo_evaluation // exported to Google Drive by scripts.export.export_togo(), and must be copied here
│ │ // scripts.export.export_togo() expects processed/togo{_eva …