diff --git a/code/make_yields.py b/code/make_yields.py index 60a2fa1..f6f545c 100644 --- a/code/make_yields.py +++ b/code/make_yields.py @@ -148,6 +148,33 @@ def process_india(): india_kharif.to_csv('./static_data_files/india_kharif_yields_standardized.csv', index=False) india_rabi.to_csv('./static_data_files/india_rabi_yields_standardized.csv', index=False) +def process_ethiopia(): + HARVEST_YEARS = [2001+i for i in range(16) if i != 2] + + CROP_TRANSLATIONS = { + 1122: "corn" + } + + ethiopia = pd.read_csv('./static_data_files/ethiopia_yields_raw.csv', encoding='utf-8') + ethiopia = ethiopia[['Admin 1', 'Admin2_mod', 'Year', 'Season', 'Crop', + 'AreaPlanted_ha', 'QuantityProduced_mt', 'Yield_mt_ha']].copy() + ethiopia["Admin 1"] = ethiopia["Admin 1"].map(CLEAN_NAME) + ethiopia = ethiopia[~ethiopia["Admin2_mod"].isna()].copy() + ethiopia["Admin2_mod"] = ethiopia["Admin2_mod"].map(CLEAN_NAME) + ethiopia['Crop'] = ethiopia['Crop'].map(lambda s: CROP_TRANSLATIONS[s]) + + ethiopia = ethiopia[ethiopia["Season"] == "Meher"].copy() + ethiopia = ethiopia.drop("Season", axis=1).copy() + + ethiopia = ethiopia.rename({'QuantityProduced_mt': PRODUCTION, + 'AreaPlanted_ha': AREA_PLANTED, + 'Yield_mt_ha': YIELD, + 'Admin 1': REGION_1, + 'Admin2_mod': REGION_2, + 'Crop': CROP, + 'Year': YEAR}, axis=1) + ethiopia.to_csv('./static_data_files/ethiopia_yields_standardized.csv', index=False) + if __name__ == '__main__': name = sys.argv[1] @@ -159,3 +186,5 @@ def process_india(): process_argentina() elif (name == 'india'): process_india() + elif (name == 'ethiopia'): + process_ethiopia() diff --git a/code/pull_modis.py b/code/pull_modis.py index bc5a584..4845c2b 100644 --- a/code/pull_modis.py +++ b/code/pull_modis.py @@ -36,6 +36,7 @@ 'brazil', 'india', 'usa', + 'ethiopia', ] # "Boundary Filters": A rough bounding box for the entire country, to help GEE search for imagery faster @@ -44,6 +45,7 @@ [-34, -34, -74, 6], [68, 6, 97.5, 37.2], [-80, 32, -104.5, 49], + [33, 3.5, 48, 15.4], ] # "Feature Collections": The path in Google Earth Engine to a shapefile table specifying a set of subdivisions of the country @@ -52,6 +54,7 @@ 'users/nikhilarundesai/BRMEE250GC_SIR', 'users/nikhilarundesai/India_Districts', 'users/nikhilarundesai/US_Counties', + 'users/nikhilarundesai/ET_Admin2', ] # "Feature Key Functions": Lambda functions that extract a human-readable name from the metadata for a single feature in the shapefile @@ -60,6 +63,7 @@ lambda region: CLEAN_NAME(region, 'NM_MESO') + "-brasil", # BR: "-brasil" lambda region: CLEAN_NAME(region, 'DISTRICT') + "-" + CLEAN_NAME(region, 'ST_NM'), # IN: "-" lambda region: CLEAN_NAME(region, 'NAME') + "-" + GET_FIPS(region, 'STATEFP'), # US: "-" + lambda region: CLEAN_NAME(region, 'ADMIN2') + "-" + CLEAN_NAME(region,'ADMIN1'), # ET: "-" ] # "Feature Filter Functions": Lambda function that uses metadata to determine whether imagery is worth pulling for a particular region. @@ -69,6 +73,7 @@ lambda region: True, lambda region: True, lambda region: region.get('properties').get('STATEFP') in USA_SOY_FIPS_CODES, # US: only pull imagery from states with soy production + lambda region: True, ]