GithubHelp home page GithubHelp logo

crop-yield-analysis's Introduction

Background:

Through the use of Python data science tools, this toolset utilizes crop yield and weather data to enable the analysis of crop yield, weather, and drought data. Although much of what was done in this project could have been completed more easily using other tools (such as data file cleaning in Excel, graphing in R or Tableau, etc.), one of my personal goals for this project was to use as much Python as possible to simplify the amount of software knowledge needed to run these tools. This toolset was my project for the 2021 Purdue Data Science in Digital Agriculture REEU Program.

The extra packages required for this toolset are Pandas, Requests, Datetime, and Matplotlib. An internet connection is also required when using the API to retrieve weather data (Read_Data_2.py).

How to Use:

I have included the original crop yield data files that I used (they were downloaded from USDA/NASS's QuickStats website at https://quickstats.nass.usda.gov) in the Raw_Data directory. I have also included in this directory a State.csv file that is used to merge State specific data such as initials to processed data (this data was retrieved from https://www.census.gov/library/reference/code-lists/ansi/ansi-codes-for-states.html). Read_Data_1.py will process and merge (if needed) crop yield data frames and remove all data that does not span the complete 30 years of interest (I downloaded the files containing data from 1991 up to 2020). The cleaned data is then exported to the Processed_Data directory to be later used.

The Read_Data_2.py program uses a custom API call to the Applied Climate Information System's database (I used the ACIS' QueryBuilder at http://builder.rcc-acis.org to set up the parameters for this call) to download the weather data for all years and regions of interest. The data is then exported into new files in the Processed_Data/Weather_Data directory (this file needs to be added manually). By default, Read_Data_2.py will download Average Temperature and Precipitation files, but the file can be modified to download Average Temperature, Precipitation, Maximum Temperature, and/or Minimum Temperature files depending on the desired analysis need. Note: The weather data has NOT been uploaded, so this program needs to be run before any more can be done (it can take a while to run, but print statements have been included in the code to allow for progress monitoring).

Process_Data.py merges crop yield and weather data into singular files before analysis. This program also calculates drought information such as the number of short, medium, and long length droughts (5-8, 9-14, & 15+ days respectively), the total precipitation, and the amount of time spent in drought. This program utilizes estimated growing seasons for each crop to limit the drought calculations to a certain time span, and these can be edited as needed (I have provided rough estimates based on the given data in the 1997 Usual Planting and Harvesting Dates for U.S. Field Crops available at https://usda.library.cornell.edu/concern/publications/vm40xr56k).

The Analyze_Data.py program brings together the data processed from the other tools into one analysis-focused program. The data is imported into this file and can be edited as desired by the user to do in depth analysis at the total, state, or county level. Some example graphs and data calculations are provided to guide your own analysis.

crop-yield-analysis's People

Contributors

jamesrdoyle avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

obsidjan

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.