# JUNTO Practice: Data Analysis, Historical Crop Yields

Discussed on October 22, 2020.

Analyze this dataset and create a short report:

Click to see:

# Has the average global crop yield increased, year-over-year, from 1981 to 2016?

Have we gotten better at agriculture? I use the "Global Dataset of Historical Yield" to examine data for maize, rice, wheat, and soybean, from 1981 to 2016. I find that there is an overall increase in the average global yield all crops from 1981 to 2016. But, year over year, the yield fluctuates and may decrease. Future research should (1) group the data by administrative division, (2) quantify the trend in average yield, and (3) analyze the crops by growing season.

## Introduction

The Global Dataset of Historical Yield has year-by-year estimates for the yield of major crops worldwide, from 1981 to 2016. This includes maize, rice, wheat, and soybean.

I want to know if average global crop yield has increased. Have we gotten better at agriculture in the past 35 years?

## Methods

I downloaded the crop yield data from "The global dataset of historical yields for major crops 1981–2016" (https://doi.org/10.20783/DIAS.564).

I used the Python library netCDF4 to open the datafiles.

Then I moved the data into a SQLite table with this schema:

``````CREATE TABLE GlobalYield (
id_crop
TEXT NOT NULL
CHECK( id_crop IN ('maize', 'rice', 'soybean', 'wheat') ),

val_year
INTEGER NOT NULL
CHECK( val_year BETWEEN 1981 AND 2016 ),

amt_yield -- Units: t/ha
REAL NOT NULL
CHECK( amt_yield >= 0 )
);
``````

Then I used the Python library pandas to create the tables and plots seen in the Results section.

## Results

Table 1:Average global yield (units: t/ha), from 1981 to 2016.
YearMaizeRiceSoybeanWheat
1981 2.40 2.66 1.54 1.68
1982 2.82 3.33 1.64 3.05
1983 2.53 3.30 1.66 3.23
1984 2.79 3.49 1.72 3.34
1985 2.93 3.48 1.85 3.30
1986 2.97 3.52 1.82 3.25
1987 2.96 3.55 1.82 3.29
1988 2.77 3.55 1.78 3.22
1989 3.03 3.86 1.83 3.24
1990 3.13 3.71 1.98 3.31
1991 3.07 3.87 1.87 3.14
1992 3.22 3.83 1.91 3.39
1993 3.21 3.98 2.01 3.28
1994 3.36 3.94 2.08 3.43
1995 3.30 3.97 2.04 3.13
1996 3.54 4.24 2.15 3.46
1997 3.46 4.11 2.17 3.41
1998 3.66 4.10 2.27 3.47
1999 3.62 4.36 2.19 3.58
2000 3.66 4.30 2.13 3.40
2001 3.79 4.45 2.31 3.54
2002 3.78 4.46 2.31 3.37
2003 3.89 4.39 2.24 3.54
2004 4.13 4.42 2.25 3.75
2005 4.11 4.52 2.29 3.64
2006 4.14 4.66 2.30 3.74
2007 4.16 4.65 2.25 3.56
2008 4.33 4.84 2.29 3.82
2009 4.35 4.87 2.27 3.78
2010 4.49 5.00 2.43 3.89
2011 4.71 5.16 2.48 4.08
2012 4.51 5.23 2.38 4.03
2013 4.93 5.09 2.44 4.19
2014 5.15 5.46 2.48 4.15
2015 5.52 5.37 2.49 3.91
2016 5.12 5.40 2.61 4.29

## Discussion

Using visual analysis, it is clear that the global average yield of all 4 crops increased from 1981 to 2016. However, despite the overall trend, yield fluctuates and does not always increase year-over-year.

Future research should try three things:

1. Group the data by administrative division. Does some countries have a higher average yield than other countries?

2. Quantify the trend in average yield. Perhaps use something like linear regression.

3. Analyze the crops by growing season. Look at winter wheat vs summer weather. Look at the major and minor seasons for double cropped soybeans.

### Daniel Bassett

``````from shutil import unpack_archive

unpack_archive("gdhy_v1.2_v1.3_20190128.zip")
``````

# Crop Yield Analysis

by Daniel Bassett

## Abstract

Based on data[1] from Pangaea, Data Publisher for Earth and Environmental Science, we are going to run analysis on global historical crop yields from 1981-2016. After opening and preparing our large dataset, we will start by testing some basic theories on possible relations (and correlations) of the yield values. From a general perspective, we will look into relations of X and Y for a specified time interval.

``````import netCDF4
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
``````

## 1.0: Scope

Because this is a large dataset with several different crops, and a large time interval, we are going to narrow our scope. A good starting place is to focus on the year 1990. Subsequently, we will add in the next years in the time sequence, namely, 1991-1995. We will be assessing all four of the available crops, wheat, soybean, rice, maize, during this period. After cleaning our data to fit the scope, we will continue on to our next section wherein some basic analysis of these variables will be tested.

``````rice_path = "rice/yield_1990.nc4"
wheat_path = "wheat/yield_1990.nc4"
maize_path = "maize/yield_1990.nc4"
soy_path = "soybean/yield_1990.nc4"
``````
``````ncr = netCDF4.Dataset(rice_path, "r")
ncw = netCDF4.Dataset(wheat_path, "r")
ncm = netCDF4.Dataset(maize_path, "r")
ncs = netCDF4.Dataset(soy_path, "r")
``````
``````print(ncr.variables.keys(), ncw.variables.keys())
``````
``````dict_keys(['lon', 'lat', 'var']) dict_keys(['lon', 'lat', 'var'])
``````

As we expect, the crops seem to all have the same variables.

``````print(ncr["lon"], ncr["var"])
``````
``````<class 'netCDF4._netCDF4.Variable'>
float64 lon(lon)
units: degrees_east
long_name: Longitude
unlimited dimensions:
current shape = (720,)
filling on, default _FillValue of 9.969209968386869e+36 used <class 'netCDF4._netCDF4.Variable'>
float32 var(lat, lon)
_FillValue: -999000000.0
unlimited dimensions:
current shape = (360, 720)
filling on
``````
``````for dim in ncr.dimensions.items():
print(dim)
``````
``````('lon', <class 'netCDF4._netCDF4.Dimension'>: name = 'lon', size = 720)
('lat', <class 'netCDF4._netCDF4.Dimension'>: name = 'lat', size = 360)
``````
``````rlon = ncr["lon"]
rice_lon = rlon[:]
mlon = ncm["lon"]
maize_lon = mlon[:]
wlon = ncw["lon"]
wheat_lon = wlon[:]
slon = ncs["lon"]
soy_lon = slon[:]
``````
``````print(rice_lon, maize_lon)
``````
``````[2.5000e-01 7.5000e-01 1.2500e+00 1.7500e+00 2.2500e+00 2.7500e+00
3.2500e+00 3.7500e+00 4.2500e+00 4.7500e+00 5.2500e+00 5.7500e+00
6.2500e+00 6.7500e+00 7.2500e+00 7.7500e+00 8.2500e+00 8.7500e+00
9.2500e+00 9.7500e+00 1.0250e+01 1.0750e+01 1.1250e+01 1.1750e+01
1.2250e+01 1.2750e+01 1.3250e+01 1.3750e+01 1.4250e+01 1.4750e+01
1.5250e+01 1.5750e+01 1.6250e+01 1.6750e+01 1.7250e+01 1.7750e+01
1.8250e+01 1.8750e+01 1.9250e+01 1.9750e+01 2.0250e+01 2.0750e+01
2.1250e+01 2.1750e+01 2.2250e+01 2.2750e+01 2.3250e+01 2.3750e+01
2.4250e+01 2.4750e+01 2.5250e+01 2.5750e+01 2.6250e+01 2.6750e+01
2.7250e+01 2.7750e+01 2.8250e+01 2.8750e+01 2.9250e+01 2.9750e+01
3.0250e+01 3.0750e+01 3.1250e+01 3.1750e+01 3.2250e+01 3.2750e+01
3.3250e+01 3.3750e+01 3.4250e+01 3.4750e+01 3.5250e+01 3.5750e+01
3.6250e+01 3.6750e+01 3.7250e+01 3.7750e+01 3.8250e+01 3.8750e+01
3.9250e+01 3.9750e+01 4.0250e+01 4.0750e+01 4.1250e+01 4.1750e+01
4.2250e+01 4.2750e+01 4.3250e+01 4.3750e+01 4.4250e+01 4.4750e+01
4.5250e+01 4.5750e+01 4.6250e+01 4.6750e+01 4.7250e+01 4.7750e+01
4.8250e+01 4.8750e+01 4.9250e+01 4.9750e+01 5.0250e+01 5.0750e+01
5.1250e+01 5.1750e+01 5.2250e+01 5.2750e+01 5.3250e+01 5.3750e+01
5.4250e+01 5.4750e+01 5.5250e+01 5.5750e+01 5.6250e+01 5.6750e+01
5.7250e+01 5.7750e+01 5.8250e+01 5.8750e+01 5.9250e+01 5.9750e+01
6.0250e+01 6.0750e+01 6.1250e+01 6.1750e+01 6.2250e+01 6.2750e+01
6.3250e+01 6.3750e+01 6.4250e+01 6.4750e+01 6.5250e+01 6.5750e+01
6.6250e+01 6.6750e+01 6.7250e+01 6.7750e+01 6.8250e+01 6.8750e+01
6.9250e+01 6.9750e+01 7.0250e+01 7.0750e+01 7.1250e+01 7.1750e+01
7.2250e+01 7.2750e+01 7.3250e+01 7.3750e+01 7.4250e+01 7.4750e+01
7.5250e+01 7.5750e+01 7.6250e+01 7.6750e+01 7.7250e+01 7.7750e+01
7.8250e+01 7.8750e+01 7.9250e+01 7.9750e+01 8.0250e+01 8.0750e+01
8.1250e+01 8.1750e+01 8.2250e+01 8.2750e+01 8.3250e+01 8.3750e+01
8.4250e+01 8.4750e+01 8.5250e+01 8.5750e+01 8.6250e+01 8.6750e+01
8.7250e+01 8.7750e+01 8.8250e+01 8.8750e+01 8.9250e+01 8.9750e+01
9.0250e+01 9.0750e+01 9.1250e+01 9.1750e+01 9.2250e+01 9.2750e+01
9.3250e+01 9.3750e+01 9.4250e+01 9.4750e+01 9.5250e+01 9.5750e+01
9.6250e+01 9.6750e+01 9.7250e+01 9.7750e+01 9.8250e+01 9.8750e+01
9.9250e+01 9.9750e+01 1.0025e+02 1.0075e+02 1.0125e+02 1.0175e+02
1.0225e+02 1.0275e+02 1.0325e+02 1.0375e+02 1.0425e+02 1.0475e+02
1.0525e+02 1.0575e+02 1.0625e+02 1.0675e+02 1.0725e+02 1.0775e+02
1.0825e+02 1.0875e+02 1.0925e+02 1.0975e+02 1.1025e+02 1.1075e+02
1.1125e+02 1.1175e+02 1.1225e+02 1.1275e+02 1.1325e+02 1.1375e+02
1.1425e+02 1.1475e+02 1.1525e+02 1.1575e+02 1.1625e+02 1.1675e+02
1.1725e+02 1.1775e+02 1.1825e+02 1.1875e+02 1.1925e+02 1.1975e+02
1.2025e+02 1.2075e+02 1.2125e+02 1.2175e+02 1.2225e+02 1.2275e+02
1.2325e+02 1.2375e+02 1.2425e+02 1.2475e+02 1.2525e+02 1.2575e+02
1.2625e+02 1.2675e+02 1.2725e+02 1.2775e+02 1.2825e+02 1.2875e+02
1.2925e+02 1.2975e+02 1.3025e+02 1.3075e+02 1.3125e+02 1.3175e+02
1.3225e+02 1.3275e+02 1.3325e+02 1.3375e+02 1.3425e+02 1.3475e+02
1.3525e+02 1.3575e+02 1.3625e+02 1.3675e+02 1.3725e+02 1.3775e+02
1.3825e+02 1.3875e+02 1.3925e+02 1.3975e+02 1.4025e+02 1.4075e+02
1.4125e+02 1.4175e+02 1.4225e+02 1.4275e+02 1.4325e+02 1.4375e+02
1.4425e+02 1.4475e+02 1.4525e+02 1.4575e+02 1.4625e+02 1.4675e+02
1.4725e+02 1.4775e+02 1.4825e+02 1.4875e+02 1.4925e+02 1.4975e+02
1.5025e+02 1.5075e+02 1.5125e+02 1.5175e+02 1.5225e+02 1.5275e+02
1.5325e+02 1.5375e+02 1.5425e+02 1.5475e+02 1.5525e+02 1.5575e+02
1.5625e+02 1.5675e+02 1.5725e+02 1.5775e+02 1.5825e+02 1.5875e+02
1.5925e+02 1.5975e+02 1.6025e+02 1.6075e+02 1.6125e+02 1.6175e+02
1.6225e+02 1.6275e+02 1.6325e+02 1.6375e+02 1.6425e+02 1.6475e+02
1.6525e+02 1.6575e+02 1.6625e+02 1.6675e+02 1.6725e+02 1.6775e+02
1.6825e+02 1.6875e+02 1.6925e+02 1.6975e+02 1.7025e+02 1.7075e+02
1.7125e+02 1.7175e+02 1.7225e+02 1.7275e+02 1.7325e+02 1.7375e+02
1.7425e+02 1.7475e+02 1.7525e+02 1.7575e+02 1.7625e+02 1.7675e+02
1.7725e+02 1.7775e+02 1.7825e+02 1.7875e+02 1.7925e+02 1.7975e+02
1.8025e+02 1.8075e+02 1.8125e+02 1.8175e+02 1.8225e+02 1.8275e+02
1.8325e+02 1.8375e+02 1.8425e+02 1.8475e+02 1.8525e+02 1.8575e+02
1.8625e+02 1.8675e+02 1.8725e+02 1.8775e+02 1.8825e+02 1.8875e+02
1.8925e+02 1.8975e+02 1.9025e+02 1.9075e+02 1.9125e+02 1.9175e+02
1.9225e+02 1.9275e+02 1.9325e+02 1.9375e+02 1.9425e+02 1.9475e+02
1.9525e+02 1.9575e+02 1.9625e+02 1.9675e+02 1.9725e+02 1.9775e+02
1.9825e+02 1.9875e+02 1.9925e+02 1.9975e+02 2.0025e+02 2.0075e+02
2.0125e+02 2.0175e+02 2.0225e+02 2.0275e+02 2.0325e+02 2.0375e+02
2.0425e+02 2.0475e+02 2.0525e+02 2.0575e+02 2.0625e+02 2.0675e+02
2.0725e+02 2.0775e+02 2.0825e+02 2.0875e+02 2.0925e+02 2.0975e+02
2.1025e+02 2.1075e+02 2.1125e+02 2.1175e+02 2.1225e+02 2.1275e+02
2.1325e+02 2.1375e+02 2.1425e+02 2.1475e+02 2.1525e+02 2.1575e+02
2.1625e+02 2.1675e+02 2.1725e+02 2.1775e+02 2.1825e+02 2.1875e+02
2.1925e+02 2.1975e+02 2.2025e+02 2.2075e+02 2.2125e+02 2.2175e+02
2.2225e+02 2.2275e+02 2.2325e+02 2.2375e+02 2.2425e+02 2.2475e+02
2.2525e+02 2.2575e+02 2.2625e+02 2.2675e+02 2.2725e+02 2.2775e+02
2.2825e+02 2.2875e+02 2.2925e+02 2.2975e+02 2.3025e+02 2.3075e+02
2.3125e+02 2.3175e+02 2.3225e+02 2.3275e+02 2.3325e+02 2.3375e+02
2.3425e+02 2.3475e+02 2.3525e+02 2.3575e+02 2.3625e+02 2.3675e+02
2.3725e+02 2.3775e+02 2.3825e+02 2.3875e+02 2.3925e+02 2.3975e+02
2.4025e+02 2.4075e+02 2.4125e+02 2.4175e+02 2.4225e+02 2.4275e+02
2.4325e+02 2.4375e+02 2.4425e+02 2.4475e+02 2.4525e+02 2.4575e+02
2.4625e+02 2.4675e+02 2.4725e+02 2.4775e+02 2.4825e+02 2.4875e+02
2.4925e+02 2.4975e+02 2.5025e+02 2.5075e+02 2.5125e+02 2.5175e+02
2.5225e+02 2.5275e+02 2.5325e+02 2.5375e+02 2.5425e+02 2.5475e+02
2.5525e+02 2.5575e+02 2.5625e+02 2.5675e+02 2.5725e+02 2.5775e+02
2.5825e+02 2.5875e+02 2.5925e+02 2.5975e+02 2.6025e+02 2.6075e+02
2.6125e+02 2.6175e+02 2.6225e+02 2.6275e+02 2.6325e+02 2.6375e+02
2.6425e+02 2.6475e+02 2.6525e+02 2.6575e+02 2.6625e+02 2.6675e+02
2.6725e+02 2.6775e+02 2.6825e+02 2.6875e+02 2.6925e+02 2.6975e+02
2.7025e+02 2.7075e+02 2.7125e+02 2.7175e+02 2.7225e+02 2.7275e+02
2.7325e+02 2.7375e+02 2.7425e+02 2.7475e+02 2.7525e+02 2.7575e+02
2.7625e+02 2.7675e+02 2.7725e+02 2.7775e+02 2.7825e+02 2.7875e+02
2.7925e+02 2.7975e+02 2.8025e+02 2.8075e+02 2.8125e+02 2.8175e+02
2.8225e+02 2.8275e+02 2.8325e+02 2.8375e+02 2.8425e+02 2.8475e+02
2.8525e+02 2.8575e+02 2.8625e+02 2.8675e+02 2.8725e+02 2.8775e+02
2.8825e+02 2.8875e+02 2.8925e+02 2.8975e+02 2.9025e+02 2.9075e+02
2.9125e+02 2.9175e+02 2.9225e+02 2.9275e+02 2.9325e+02 2.9375e+02
2.9425e+02 2.9475e+02 2.9525e+02 2.9575e+02 2.9625e+02 2.9675e+02
2.9725e+02 2.9775e+02 2.9825e+02 2.9875e+02 2.9925e+02 2.9975e+02
3.0025e+02 3.0075e+02 3.0125e+02 3.0175e+02 3.0225e+02 3.0275e+02
3.0325e+02 3.0375e+02 3.0425e+02 3.0475e+02 3.0525e+02 3.0575e+02
3.0625e+02 3.0675e+02 3.0725e+02 3.0775e+02 3.0825e+02 3.0875e+02
3.0925e+02 3.0975e+02 3.1025e+02 3.1075e+02 3.1125e+02 3.1175e+02
3.1225e+02 3.1275e+02 3.1325e+02 3.1375e+02 3.1425e+02 3.1475e+02
3.1525e+02 3.1575e+02 3.1625e+02 3.1675e+02 3.1725e+02 3.1775e+02
3.1825e+02 3.1875e+02 3.1925e+02 3.1975e+02 3.2025e+02 3.2075e+02
3.2125e+02 3.2175e+02 3.2225e+02 3.2275e+02 3.2325e+02 3.2375e+02
3.2425e+02 3.2475e+02 3.2525e+02 3.2575e+02 3.2625e+02 3.2675e+02
3.2725e+02 3.2775e+02 3.2825e+02 3.2875e+02 3.2925e+02 3.2975e+02
3.3025e+02 3.3075e+02 3.3125e+02 3.3175e+02 3.3225e+02 3.3275e+02
3.3325e+02 3.3375e+02 3.3425e+02 3.3475e+02 3.3525e+02 3.3575e+02
3.3625e+02 3.3675e+02 3.3725e+02 3.3775e+02 3.3825e+02 3.3875e+02
3.3925e+02 3.3975e+02 3.4025e+02 3.4075e+02 3.4125e+02 3.4175e+02
3.4225e+02 3.4275e+02 3.4325e+02 3.4375e+02 3.4425e+02 3.4475e+02
3.4525e+02 3.4575e+02 3.4625e+02 3.4675e+02 3.4725e+02 3.4775e+02
3.4825e+02 3.4875e+02 3.4925e+02 3.4975e+02 3.5025e+02 3.5075e+02
3.5125e+02 3.5175e+02 3.5225e+02 3.5275e+02 3.5325e+02 3.5375e+02
3.5425e+02 3.5475e+02 3.5525e+02 3.5575e+02 3.5625e+02 3.5675e+02
3.5725e+02 3.5775e+02 3.5825e+02 3.5875e+02 3.5925e+02 3.5975e+02] [2.5000e-01 7.5000e-01 1.2500e+00 1.7500e+00 2.2500e+00 2.7500e+00
3.2500e+00 3.7500e+00 4.2500e+00 4.7500e+00 5.2500e+00 5.7500e+00
6.2500e+00 6.7500e+00 7.2500e+00 7.7500e+00 8.2500e+00 8.7500e+00
9.2500e+00 9.7500e+00 1.0250e+01 1.0750e+01 1.1250e+01 1.1750e+01
1.2250e+01 1.2750e+01 1.3250e+01 1.3750e+01 1.4250e+01 1.4750e+01
1.5250e+01 1.5750e+01 1.6250e+01 1.6750e+01 1.7250e+01 1.7750e+01
1.8250e+01 1.8750e+01 1.9250e+01 1.9750e+01 2.0250e+01 2.0750e+01
2.1250e+01 2.1750e+01 2.2250e+01 2.2750e+01 2.3250e+01 2.3750e+01
2.4250e+01 2.4750e+01 2.5250e+01 2.5750e+01 2.6250e+01 2.6750e+01
2.7250e+01 2.7750e+01 2.8250e+01 2.8750e+01 2.9250e+01 2.9750e+01
3.0250e+01 3.0750e+01 3.1250e+01 3.1750e+01 3.2250e+01 3.2750e+01
3.3250e+01 3.3750e+01 3.4250e+01 3.4750e+01 3.5250e+01 3.5750e+01
3.6250e+01 3.6750e+01 3.7250e+01 3.7750e+01 3.8250e+01 3.8750e+01
3.9250e+01 3.9750e+01 4.0250e+01 4.0750e+01 4.1250e+01 4.1750e+01
4.2250e+01 4.2750e+01 4.3250e+01 4.3750e+01 4.4250e+01 4.4750e+01
4.5250e+01 4.5750e+01 4.6250e+01 4.6750e+01 4.7250e+01 4.7750e+01
4.8250e+01 4.8750e+01 4.9250e+01 4.9750e+01 5.0250e+01 5.0750e+01
5.1250e+01 5.1750e+01 5.2250e+01 5.2750e+01 5.3250e+01 5.3750e+01
5.4250e+01 5.4750e+01 5.5250e+01 5.5750e+01 5.6250e+01 5.6750e+01
5.7250e+01 5.7750e+01 5.8250e+01 5.8750e+01 5.9250e+01 5.9750e+01
6.0250e+01 6.0750e+01 6.1250e+01 6.1750e+01 6.2250e+01 6.2750e+01
6.3250e+01 6.3750e+01 6.4250e+01 6.4750e+01 6.5250e+01 6.5750e+01
6.6250e+01 6.6750e+01 6.7250e+01 6.7750e+01 6.8250e+01 6.8750e+01
6.9250e+01 6.9750e+01 7.0250e+01 7.0750e+01 7.1250e+01 7.1750e+01
7.2250e+01 7.2750e+01 7.3250e+01 7.3750e+01 7.4250e+01 7.4750e+01
7.5250e+01 7.5750e+01 7.6250e+01 7.6750e+01 7.7250e+01 7.7750e+01
7.8250e+01 7.8750e+01 7.9250e+01 7.9750e+01 8.0250e+01 8.0750e+01
8.1250e+01 8.1750e+01 8.2250e+01 8.2750e+01 8.3250e+01 8.3750e+01
8.4250e+01 8.4750e+01 8.5250e+01 8.5750e+01 8.6250e+01 8.6750e+01
8.7250e+01 8.7750e+01 8.8250e+01 8.8750e+01 8.9250e+01 8.9750e+01
9.0250e+01 9.0750e+01 9.1250e+01 9.1750e+01 9.2250e+01 9.2750e+01
9.3250e+01 9.3750e+01 9.4250e+01 9.4750e+01 9.5250e+01 9.5750e+01
9.6250e+01 9.6750e+01 9.7250e+01 9.7750e+01 9.8250e+01 9.8750e+01
9.9250e+01 9.9750e+01 1.0025e+02 1.0075e+02 1.0125e+02 1.0175e+02
1.0225e+02 1.0275e+02 1.0325e+02 1.0375e+02 1.0425e+02 1.0475e+02
1.0525e+02 1.0575e+02 1.0625e+02 1.0675e+02 1.0725e+02 1.0775e+02
1.0825e+02 1.0875e+02 1.0925e+02 1.0975e+02 1.1025e+02 1.1075e+02
1.1125e+02 1.1175e+02 1.1225e+02 1.1275e+02 1.1325e+02 1.1375e+02
1.1425e+02 1.1475e+02 1.1525e+02 1.1575e+02 1.1625e+02 1.1675e+02
1.1725e+02 1.1775e+02 1.1825e+02 1.1875e+02 1.1925e+02 1.1975e+02
1.2025e+02 1.2075e+02 1.2125e+02 1.2175e+02 1.2225e+02 1.2275e+02
1.2325e+02 1.2375e+02 1.2425e+02 1.2475e+02 1.2525e+02 1.2575e+02
1.2625e+02 1.2675e+02 1.2725e+02 1.2775e+02 1.2825e+02 1.2875e+02
1.2925e+02 1.2975e+02 1.3025e+02 1.3075e+02 1.3125e+02 1.3175e+02
1.3225e+02 1.3275e+02 1.3325e+02 1.3375e+02 1.3425e+02 1.3475e+02
1.3525e+02 1.3575e+02 1.3625e+02 1.3675e+02 1.3725e+02 1.3775e+02
1.3825e+02 1.3875e+02 1.3925e+02 1.3975e+02 1.4025e+02 1.4075e+02
1.4125e+02 1.4175e+02 1.4225e+02 1.4275e+02 1.4325e+02 1.4375e+02
1.4425e+02 1.4475e+02 1.4525e+02 1.4575e+02 1.4625e+02 1.4675e+02
1.4725e+02 1.4775e+02 1.4825e+02 1.4875e+02 1.4925e+02 1.4975e+02
1.5025e+02 1.5075e+02 1.5125e+02 1.5175e+02 1.5225e+02 1.5275e+02
1.5325e+02 1.5375e+02 1.5425e+02 1.5475e+02 1.5525e+02 1.5575e+02
1.5625e+02 1.5675e+02 1.5725e+02 1.5775e+02 1.5825e+02 1.5875e+02
1.5925e+02 1.5975e+02 1.6025e+02 1.6075e+02 1.6125e+02 1.6175e+02
1.6225e+02 1.6275e+02 1.6325e+02 1.6375e+02 1.6425e+02 1.6475e+02
1.6525e+02 1.6575e+02 1.6625e+02 1.6675e+02 1.6725e+02 1.6775e+02
1.6825e+02 1.6875e+02 1.6925e+02 1.6975e+02 1.7025e+02 1.7075e+02
1.7125e+02 1.7175e+02 1.7225e+02 1.7275e+02 1.7325e+02 1.7375e+02
1.7425e+02 1.7475e+02 1.7525e+02 1.7575e+02 1.7625e+02 1.7675e+02
1.7725e+02 1.7775e+02 1.7825e+02 1.7875e+02 1.7925e+02 1.7975e+02
1.8025e+02 1.8075e+02 1.8125e+02 1.8175e+02 1.8225e+02 1.8275e+02
1.8325e+02 1.8375e+02 1.8425e+02 1.8475e+02 1.8525e+02 1.8575e+02
1.8625e+02 1.8675e+02 1.8725e+02 1.8775e+02 1.8825e+02 1.8875e+02
1.8925e+02 1.8975e+02 1.9025e+02 1.9075e+02 1.9125e+02 1.9175e+02
1.9225e+02 1.9275e+02 1.9325e+02 1.9375e+02 1.9425e+02 1.9475e+02
1.9525e+02 1.9575e+02 1.9625e+02 1.9675e+02 1.9725e+02 1.9775e+02
1.9825e+02 1.9875e+02 1.9925e+02 1.9975e+02 2.0025e+02 2.0075e+02
2.0125e+02 2.0175e+02 2.0225e+02 2.0275e+02 2.0325e+02 2.0375e+02
2.0425e+02 2.0475e+02 2.0525e+02 2.0575e+02 2.0625e+02 2.0675e+02
2.0725e+02 2.0775e+02 2.0825e+02 2.0875e+02 2.0925e+02 2.0975e+02
2.1025e+02 2.1075e+02 2.1125e+02 2.1175e+02 2.1225e+02 2.1275e+02
2.1325e+02 2.1375e+02 2.1425e+02 2.1475e+02 2.1525e+02 2.1575e+02
2.1625e+02 2.1675e+02 2.1725e+02 2.1775e+02 2.1825e+02 2.1875e+02
2.1925e+02 2.1975e+02 2.2025e+02 2.2075e+02 2.2125e+02 2.2175e+02
2.2225e+02 2.2275e+02 2.2325e+02 2.2375e+02 2.2425e+02 2.2475e+02
2.2525e+02 2.2575e+02 2.2625e+02 2.2675e+02 2.2725e+02 2.2775e+02
2.2825e+02 2.2875e+02 2.2925e+02 2.2975e+02 2.3025e+02 2.3075e+02
2.3125e+02 2.3175e+02 2.3225e+02 2.3275e+02 2.3325e+02 2.3375e+02
2.3425e+02 2.3475e+02 2.3525e+02 2.3575e+02 2.3625e+02 2.3675e+02
2.3725e+02 2.3775e+02 2.3825e+02 2.3875e+02 2.3925e+02 2.3975e+02
2.4025e+02 2.4075e+02 2.4125e+02 2.4175e+02 2.4225e+02 2.4275e+02
2.4325e+02 2.4375e+02 2.4425e+02 2.4475e+02 2.4525e+02 2.4575e+02
2.4625e+02 2.4675e+02 2.4725e+02 2.4775e+02 2.4825e+02 2.4875e+02
2.4925e+02 2.4975e+02 2.5025e+02 2.5075e+02 2.5125e+02 2.5175e+02
2.5225e+02 2.5275e+02 2.5325e+02 2.5375e+02 2.5425e+02 2.5475e+02
2.5525e+02 2.5575e+02 2.5625e+02 2.5675e+02 2.5725e+02 2.5775e+02
2.5825e+02 2.5875e+02 2.5925e+02 2.5975e+02 2.6025e+02 2.6075e+02
2.6125e+02 2.6175e+02 2.6225e+02 2.6275e+02 2.6325e+02 2.6375e+02
2.6425e+02 2.6475e+02 2.6525e+02 2.6575e+02 2.6625e+02 2.6675e+02
2.6725e+02 2.6775e+02 2.6825e+02 2.6875e+02 2.6925e+02 2.6975e+02
2.7025e+02 2.7075e+02 2.7125e+02 2.7175e+02 2.7225e+02 2.7275e+02
2.7325e+02 2.7375e+02 2.7425e+02 2.7475e+02 2.7525e+02 2.7575e+02
2.7625e+02 2.7675e+02 2.7725e+02 2.7775e+02 2.7825e+02 2.7875e+02
2.7925e+02 2.7975e+02 2.8025e+02 2.8075e+02 2.8125e+02 2.8175e+02
2.8225e+02 2.8275e+02 2.8325e+02 2.8375e+02 2.8425e+02 2.8475e+02
2.8525e+02 2.8575e+02 2.8625e+02 2.8675e+02 2.8725e+02 2.8775e+02
2.8825e+02 2.8875e+02 2.8925e+02 2.8975e+02 2.9025e+02 2.9075e+02
2.9125e+02 2.9175e+02 2.9225e+02 2.9275e+02 2.9325e+02 2.9375e+02
2.9425e+02 2.9475e+02 2.9525e+02 2.9575e+02 2.9625e+02 2.9675e+02
2.9725e+02 2.9775e+02 2.9825e+02 2.9875e+02 2.9925e+02 2.9975e+02
3.0025e+02 3.0075e+02 3.0125e+02 3.0175e+02 3.0225e+02 3.0275e+02
3.0325e+02 3.0375e+02 3.0425e+02 3.0475e+02 3.0525e+02 3.0575e+02
3.0625e+02 3.0675e+02 3.0725e+02 3.0775e+02 3.0825e+02 3.0875e+02
3.0925e+02 3.0975e+02 3.1025e+02 3.1075e+02 3.1125e+02 3.1175e+02
3.1225e+02 3.1275e+02 3.1325e+02 3.1375e+02 3.1425e+02 3.1475e+02
3.1525e+02 3.1575e+02 3.1625e+02 3.1675e+02 3.1725e+02 3.1775e+02
3.1825e+02 3.1875e+02 3.1925e+02 3.1975e+02 3.2025e+02 3.2075e+02
3.2125e+02 3.2175e+02 3.2225e+02 3.2275e+02 3.2325e+02 3.2375e+02
3.2425e+02 3.2475e+02 3.2525e+02 3.2575e+02 3.2625e+02 3.2675e+02
3.2725e+02 3.2775e+02 3.2825e+02 3.2875e+02 3.2925e+02 3.2975e+02
3.3025e+02 3.3075e+02 3.3125e+02 3.3175e+02 3.3225e+02 3.3275e+02
3.3325e+02 3.3375e+02 3.3425e+02 3.3475e+02 3.3525e+02 3.3575e+02
3.3625e+02 3.3675e+02 3.3725e+02 3.3775e+02 3.3825e+02 3.3875e+02
3.3925e+02 3.3975e+02 3.4025e+02 3.4075e+02 3.4125e+02 3.4175e+02
3.4225e+02 3.4275e+02 3.4325e+02 3.4375e+02 3.4425e+02 3.4475e+02
3.4525e+02 3.4575e+02 3.4625e+02 3.4675e+02 3.4725e+02 3.4775e+02
3.4825e+02 3.4875e+02 3.4925e+02 3.4975e+02 3.5025e+02 3.5075e+02
3.5125e+02 3.5175e+02 3.5225e+02 3.5275e+02 3.5325e+02 3.5375e+02
3.5425e+02 3.5475e+02 3.5525e+02 3.5575e+02 3.5625e+02 3.5675e+02
3.5725e+02 3.5775e+02 3.5825e+02 3.5875e+02 3.5925e+02 3.5975e+02]
``````
``````plt.scatter(rice_lon, maize_lon)
plt.scatter(wheat_lon, soy_lon)
``````
``````<matplotlib.collections.PathCollection at 0x297c1c49130>
``````
``````rvar = ncr["var"]
rice_var = rvar[:]
print(rice_var)
rlat = ncr["lat"]
rice_lat = rlat[:]
print(rice_lat)
``````
``````[[-- -- -- ... -- -- --]
[-- -- -- ... -- -- --]
[-- -- -- ... -- -- --]
...
[-- -- -- ... -- -- --]
[-- -- -- ... -- -- --]
[-- -- -- ... -- -- --]]
[-89.75 -89.25 -88.75 -88.25 -87.75 -87.25 -86.75 -86.25 -85.75 -85.25
-84.75 -84.25 -83.75 -83.25 -82.75 -82.25 -81.75 -81.25 -80.75 -80.25
-79.75 -79.25 -78.75 -78.25 -77.75 -77.25 -76.75 -76.25 -75.75 -75.25
-74.75 -74.25 -73.75 -73.25 -72.75 -72.25 -71.75 -71.25 -70.75 -70.25
-69.75 -69.25 -68.75 -68.25 -67.75 -67.25 -66.75 -66.25 -65.75 -65.25
-64.75 -64.25 -63.75 -63.25 -62.75 -62.25 -61.75 -61.25 -60.75 -60.25
-59.75 -59.25 -58.75 -58.25 -57.75 -57.25 -56.75 -56.25 -55.75 -55.25
-54.75 -54.25 -53.75 -53.25 -52.75 -52.25 -51.75 -51.25 -50.75 -50.25
-49.75 -49.25 -48.75 -48.25 -47.75 -47.25 -46.75 -46.25 -45.75 -45.25
-44.75 -44.25 -43.75 -43.25 -42.75 -42.25 -41.75 -41.25 -40.75 -40.25
-39.75 -39.25 -38.75 -38.25 -37.75 -37.25 -36.75 -36.25 -35.75 -35.25
-34.75 -34.25 -33.75 -33.25 -32.75 -32.25 -31.75 -31.25 -30.75 -30.25
-29.75 -29.25 -28.75 -28.25 -27.75 -27.25 -26.75 -26.25 -25.75 -25.25
-24.75 -24.25 -23.75 -23.25 -22.75 -22.25 -21.75 -21.25 -20.75 -20.25
-19.75 -19.25 -18.75 -18.25 -17.75 -17.25 -16.75 -16.25 -15.75 -15.25
-14.75 -14.25 -13.75 -13.25 -12.75 -12.25 -11.75 -11.25 -10.75 -10.25
-9.75  -9.25  -8.75  -8.25  -7.75  -7.25  -6.75  -6.25  -5.75  -5.25
-4.75  -4.25  -3.75  -3.25  -2.75  -2.25  -1.75  -1.25  -0.75  -0.25
0.25   0.75   1.25   1.75   2.25   2.75   3.25   3.75   4.25   4.75
5.25   5.75   6.25   6.75   7.25   7.75   8.25   8.75   9.25   9.75
10.25  10.75  11.25  11.75  12.25  12.75  13.25  13.75  14.25  14.75
15.25  15.75  16.25  16.75  17.25  17.75  18.25  18.75  19.25  19.75
20.25  20.75  21.25  21.75  22.25  22.75  23.25  23.75  24.25  24.75
25.25  25.75  26.25  26.75  27.25  27.75  28.25  28.75  29.25  29.75
30.25  30.75  31.25  31.75  32.25  32.75  33.25  33.75  34.25  34.75
35.25  35.75  36.25  36.75  37.25  37.75  38.25  38.75  39.25  39.75
40.25  40.75  41.25  41.75  42.25  42.75  43.25  43.75  44.25  44.75
45.25  45.75  46.25  46.75  47.25  47.75  48.25  48.75  49.25  49.75
50.25  50.75  51.25  51.75  52.25  52.75  53.25  53.75  54.25  54.75
55.25  55.75  56.25  56.75  57.25  57.75  58.25  58.75  59.25  59.75
60.25  60.75  61.25  61.75  62.25  62.75  63.25  63.75  64.25  64.75
65.25  65.75  66.25  66.75  67.25  67.75  68.25  68.75  69.25  69.75
70.25  70.75  71.25  71.75  72.25  72.75  73.25  73.75  74.25  74.75
75.25  75.75  76.25  76.75  77.25  77.75  78.25  78.75  79.25  79.75
80.25  80.75  81.25  81.75  82.25  82.75  83.25  83.75  84.25  84.75
85.25  85.75  86.25  86.75  87.25  87.75  88.25  88.75  89.25  89.75]
``````
``````from statistics import mean

rice_lat.mean()
rice_var.mean()
``````
``````3.7061101112565447
``````

### 1.1: Basic Plotting

Now that we have our variables organized, we are going to do some basic plotting with the 1990 data. We will first plot the VAR of the rice yield along with it’s lon/lat coordinate. Then we will add in the other variables. In the next section, we will do a time series analysis using mulitple years and the same variables.

``````rice_varmod = rice_var[:, 0]
rice_lonmod = rice_lon[:360]
rice_varmod.shape, rice_lat.shape, rice_lonmod.shape
``````
``````((360,), (360,), (360,))
``````
``````from mpl_toolkits.mplot3d import Axes3D

x = rice_lonmod
y = rice_lat
z = rice_varmod

fig = plt.figure(figsize=(6, 6))
ax.scatter(x, y, z)
plt.show()
``````

There appears to be some bifurcation in the data which could signal some type of clustering depending on the geography. In addition, there is a slight error in this visual as I had to slice the datasets in order for them to have the same dimensions. I’m going to try to reorganize these datasets more realistically and according to actual location. But first let’s plot the VARs individually with latitude and longtitude separately.

``````plt.scatter(y, z)
plt.title("Rice: Latitude vs. Variance")
plt.xlabel("Latitude")
plt.ylabel("Variance")
plt.show()
``````

## 1.2: Findings

From our basic plotting, it seems there is higher variance of yield at more extreme values of latitude. This makes sense: the further north or south you go, the colder and more varied the weather. And this finding from our basic plotting is only with rice, adding in the other crops, some of which have even more sensitivity to temperature/climate, we’d expect to see higher variance the more extreme we move latitudinally.

Therefore, in Section 2, we will incorporate the other yields before adding in our time series analysis in Section 3. We will be able to further test our thesis: crop yields vary more the further away you go from latitudinal 0.

We are now going to add the other crops, wheat, soybean and maize, to our analysis. We hope to not only see the same correlation, but perhaps a trend of which crops respond more to latitudinal change.

``````wvar = ncw["var"]
wheat_var = wvar[:]

wlat = ncw["lat"]
wheat_lat = wlat[:]

wheat_varmod = wheat_var[:, 0]

x = wheat_lat
y = wheat_varmod

plt.scatter(x, y)
plt.title("Wheat: Latitude vs. Variance")
plt.xlabel("Latitude")
plt.ylabel("Variance")
plt.show()
``````

Very Interesting. Wheat seems to show more consistent change in correlation with latitudinal change. In addition, there is a smaller domain of latitudes where it appears to be grown…

``````mvar = ncm["var"]
maize_var = mvar[:]

mlat = ncm["lat"]
maize_lat = mlat[:]

maize_varmod = maize_var[:, 0]

x = maize_lat
y = maize_varmod

plt.scatter(x, y)
plt.title("Maize: Latitude vs. Variance")
plt.xlabel("Latitude")
plt.ylabel("Variance")
plt.show()
``````

We see similar clustering with maize as we do with rice. Perhaps they grow well in similar climates, unlike wheat, which seems to prefer a very specific climate window.

``````svar = ncs["var"]
soy_var = svar[:]

slat = ncs["lat"]
soy_lat = slat[:]

soy_varmod = soy_var[:, 0]

x = soy_lat
y = soy_varmod

plt.scatter(x, y)
plt.title("Soy: Latitude vs. Variance")
plt.xlabel("Latitude")
plt.ylabel("Variance")
plt.show()
``````

To be continued…

### Sources

1. Iizumi, Toshichika (2019): Global dataset of historical yields v1.2 and v1.3 aligned version. PANGAEA, https://doi.org/10.1594/PANGAEA.909132, Supplement to: Iizumi, Toshichika; Sakai, T (2020): The global dataset of historical yields for major crops 1981–2016. Scientific Data, 7(1), https://doi.org/10.1038/s41597-020-0433-7