Skip to content

Commit

Permalink
Add Ethiopia to set of countries on which we can train
Browse files Browse the repository at this point in the history
  • Loading branch information
nadesai committed Dec 16, 2018
1 parent 2778a29 commit 9f7f437
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
29 changes: 29 additions & 0 deletions code/make_yields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -159,3 +186,5 @@ def process_india():
process_argentina()
elif (name == 'india'):
process_india()
elif (name == 'ethiopia'):
process_ethiopia()
5 changes: 5 additions & 0 deletions code/pull_modis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -60,6 +63,7 @@
lambda region: CLEAN_NAME(region, 'NM_MESO') + "-brasil", # BR: "<mesoregion name>-brasil"
lambda region: CLEAN_NAME(region, 'DISTRICT') + "-" + CLEAN_NAME(region, 'ST_NM'), # IN: "<district name>-<state name>"
lambda region: CLEAN_NAME(region, 'NAME') + "-" + GET_FIPS(region, 'STATEFP'), # US: "<county name>-<state name>"
lambda region: CLEAN_NAME(region, 'ADMIN2') + "-" + CLEAN_NAME(region,'ADMIN1'), # ET: "<zone name>-<state name>"
]

# "Feature Filter Functions": Lambda function that uses metadata to determine whether imagery is worth pulling for a particular region.
Expand All @@ -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,
]


Expand Down

0 comments on commit 9f7f437

Please sign in to comment.