diff --git a/data/h3_data_importer/Makefile b/data/h3_data_importer/Makefile index 0b60a80fc..9c1ffdc99 100644 --- a/data/h3_data_importer/Makefile +++ b/data/h3_data_importer/Makefile @@ -26,6 +26,7 @@ WORKDIR_LIVESTOCK_GHG=data/livestock_ghg WORKDIR_DEFAULT_COMMODITY=data/default_commodity WORKDIR_EARTHSTAT=data/earthstat WORKDIR_CROPGRIDS=data/cropgrids +WORKDIR_CROPLAND=data/cropland CHECKSUMS_PATH=data_checksums @@ -105,6 +106,35 @@ convert-cropgrids: download-cropgrids python raster_folder_to_h3_table.py $(WORKDIR_CROPGRIDS)/crop-grids-production h3_grid_cropgrids_global_prod production cropgrids 2020 --h3-res=6 --thread-count=$(PARALLELIZATION_FACTOR) python raster_folder_to_h3_table.py $(WORKDIR_CROPGRIDS)/crop-grids-harvest h3_grid_cropgrids_global_ha harvest_area cropgrids 2020 --h3-res=6 --thread-count=$(PARALLELIZATION_FACTOR) + + +# --------------------------------------------- +# CROP LAND +# --------------------------------------------- + +download-cropland: + mkdir -p $(WORKDIR_CROPLAND) + aws s3 cp s3://landgriffon-raw-data/raw/CroplandPastureArea2000_Geotiff.zip $(WORKDIR_CROPLAND)/CroplandPastureArea2000_Geotiff.zip + +extract-cropland: download-cropland + unzip -q -j -o -u $(WORKDIR_CROPLAND)/CroplandPastureArea2000_Geotiff.zip CroplandPastureArea2000_Geotiff/Cropland2000_5m.tif -d $(WORKDIR_CROPLAND)/ + mkdir -p $(WORKDIR_CROPLAND)/production + mkdir -p $(WORKDIR_CROPLAND)/harvest + mv $(WORKDIR_CROPLAND)/Cropland2000_5m.tif $(WORKDIR_CROPLAND)/harvest/es_Cropland2000_ha.tif + # global yield value of cropland from faostat + gdal_calc.py --quiet --calc "A * 9.127829341" --format GTiff --type Float32 \ + -A $(WORKDIR_CROPLAND)/harvest/es_Cropland2000_ha.tif --A_band 1 \ + --outfile $(WORKDIR_CROPLAND)/production/es_Cropland2000_prod.tif; + + rm -f $(WORKDIR_CROPLAND)/CroplandPastureArea2000_Geotiff.zip + +convert-cropland: extract-cropland + python raster_folder_to_h3_table.py $(WORKDIR_CROPLAND)/production h3_grid_cropland_global_prod production cropland 2000 --h3-res=6 + python raster_folder_to_h3_table.py $(WORKDIR_CROPLAND)/harvest h3_grid_cropland_global_ha harvest_area cropland 2000 --h3-res=6 + + + + ############################################################### # Gridded Livestock of the World (GLW3) - pasture production # ############################################################### diff --git a/data/h3_data_importer/raster_folder_to_h3_table.py b/data/h3_data_importer/raster_folder_to_h3_table.py index fade65420..dab8c6c13 100644 --- a/data/h3_data_importer/raster_folder_to_h3_table.py +++ b/data/h3_data_importer/raster_folder_to_h3_table.py @@ -151,6 +151,7 @@ def update_for_material_indicator(cursor: psycopg.Cursor, dataset: str, column_n spam_id = f"spam_{column_name.split('PerTProduction')[0].lower()}" # something like 'spam_ocerwhea' cursor.execute('select id from material where "datasetId" = %s', (spam_id,)) material_ids = cursor.fetchall() + breakpoint() if not material_ids: log.warning(f"Material with 'datasetId' {spam_id} does not exists") raise ValueError(f"Material with 'datasetId' {spam_id} does not exists") diff --git a/data/preprocessing/cropland/Makefile b/data/preprocessing/cropland/Makefile new file mode 100644 index 000000000..e69de29bb