The code and data in this repository will replicate the tables and figures in the main body of "Deep Learning to Map Concentrated Animal Feeding Operations." The replication code is designed to work on macOS.
When using these models and/or the underlying data, please cite the paper above with mention that the location data used to train the models was developed by the Environmental Working Group and Waterkeeper Alliance, with validation by the research team at Stanford.
- The python code requires the dependencies in the cafo_environment.yml file. To replicate this environment, install the open-source anaconda distribution, navigate to the top level of the replication directory, and run
conda env create --name cafo -f=environments/cafo_environment.yml
- The R code was developed using the session described in environments/r_session_info. Upon execution, the R scripts will automatically to try to install the required packages and their dependencies.
- Figure 5 requires a Google Maps Static API key, which the script will ask for. Instructions on how to obtain one are provided in the Google Maps Platform documentation.
Each script that creates a table or a figure is named for the figure or table
it creates in the manuscript as it appears in the raw tex file. The naming
convention is [Item number]_[item_type]_[item name]
.
The script create_cafo_facilities.py
replicates the facility consolidation
algorithm that was run after the class activation mapping and rescoring process
demonstrated in 3_Figure_fgcam_CAM_Algorithm_Illustration.py.
To replicate all figures and tables, open a bash shell and activate the python virtual environment created from cafo_environment.yml. Navigate to the top level of the replication directory and run:
chmod u+x code/replicate_all.sh
./replicate_all.sh
The variable names and descriptions of all variables in the csv files are included in data/csv/codebook.xlsx.