Skip to content

Commit

Permalink
Add mapsmap coffe
Browse files Browse the repository at this point in the history
  • Loading branch information
BielStela committed Dec 12, 2024
1 parent 3216687 commit e472cf9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
15 changes: 8 additions & 7 deletions data/h3_data_importer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ WORKDIR_LIVESTOCK_PROCESSED=data/livestock_processed
WORKDIR_LIVESTOCK_GHG=data/livestock_ghg
WORKDIR_DEFAULT_COMMODITY=data/default_commodity
WORKDIR_EARTHSTAT=data/earthstat
WORKDIR_EARTHSTAT=data/cropgrids
WORKDIR_CROPGRIDS=data/cropgrids


CHECKSUMS_PATH=data_checksums
Expand Down Expand Up @@ -68,15 +68,15 @@ download-mapspam-crop-production:
cd $(WORKDIR_MAPSPAM_PROD) && sha256sum --check ../../$(CHECKSUMS_PATH)/mapspam_prod

convert-mapspam-crop-production: download-mapspam-crop-production
python raster_folder_to_h3_table.py $(WORKDIR_MAPSPAM_PROD) h3_grid_spam2010v2r0_global_prod production spam 2010 --h3-res=6 --thread-count=$(PARALLELIZATION_FACTOR)
python raster_folder_to_h3_table.py $(WORKDIR_MAPSPAM_PROD) h3_grid_spam2010v2r0_global_prod production spam 2020 --h3-res=6 --thread-count=$(PARALLELIZATION_FACTOR)

download-mapspam-crop-harvest:
mkdir -p $(WORKDIR_MAPSPAM_HA)
aws s3 sync $(AWS_S3_BUCKET_URL)/processed/mapspam/spam2020V1r0_global_harvested_area/ $(WORKDIR_MAPSPAM_HA)
cd $(WORKDIR_MAPSPAM_HA) && sha256sum --check ../../$(CHECKSUMS_PATH)/mapspam_ha

convert-mapspam-crop-harvest: download-mapspam-crop-harvest
python raster_folder_to_h3_table.py $(WORKDIR_MAPSPAM_HA) h3_grid_spam2010v2r0_global_ha harvest_area spam 2010 --h3-res=6 --thread-count=$(PARALLELIZATION_FACTOR)
python raster_folder_to_h3_table.py $(WORKDIR_MAPSPAM_HA) h3_grid_spam2010v2r0_global_ha harvest_area spam 2020 --h3-res=6 --thread-count=$(PARALLELIZATION_FACTOR)

# ---------------------------------------------
# EARTHSTAT - production and harvest
Expand All @@ -95,14 +95,15 @@ convert-earthstat: download-earthstat
# ---------------------------------------------
# CROPGRIDS - production and harvest
# ---------------------------------------------

download-cropgrids:
mkdir -p $(WORKDIR_CROPGRIDS)/production $(WORKDIR_CROPGRIDS)/harvest
aws s3 sync $(AWS_S3_BUCKET_URL)/processed/earthstat/ $(WORKDIR_CROPGRIDS)
cd $(WORKDIR_CROPGRIDS) && sha256sum --check ../../$(CHECKSUMS_PATH)/earthstat
aws s3 sync $(AWS_S3_BUCKET_URL)/processed/crop-grids/ $(WORKDIR_CROPGRIDS)
#cd $(WORKDIR_CROPGRIDS) && sha256sum --check ../../$(CHECKSUMS_PATH)/earthstat

convert-cropgrids: download-cropgrids
python raster_folder_to_h3_table.py $(WORKDIR_CROPGRIDS)/production h3_grid_cropgrids_global_prod production cropgrids 2000 --h3-res=6 --thread-count=$(PARALLELIZATION_FACTOR)
python raster_folder_to_h3_table.py $(WORKDIR_CROPGRIDS)/harvest h3_grid_cropgrids_global_ha harvest_area cropgrids 2000 --h3-res=6 --thread-count=$(PARALLELIZATION_FACTOR)
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)

###############################################################
# Gridded Livestock of the World (GLW3) - pasture production #
Expand Down
8 changes: 8 additions & 0 deletions data/preprocessing/mapspam/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ compute-mapspam-crop-production: nodata-production
-F $(WORKDIR_MAPSPAM)/spam2020V1r0_global_production/spam2020_v1r0_global_P_CNUT_A.tif \
-G $(WORKDIR_MAPSPAM)/spam2020V1r0_global_production/spam2020_v1r0_global_P_RAPE_A.tif \
--outfile $(WORKDIR_MAPSPAM)/spam2020V1r0_global_production/spam2020_v1r0_global_P_OilpSoybGrouOoilSunfCnutRape_A.tif
gdal_calc.py --calc "A+B" --format GTiff --type Float32 --hideNoData --NoDataValue 0 \
-A $(WORKDIR_MAPSPAM)/spam2020V1r0_global_production/spam2020_v1r0_global_P_COFF_A.tif \
-B $(WORKDIR_MAPSPAM)/spam2020V1r0_global_production/spam2020_v1r0_global_P_RCOF_A.tif \
--outfile $(WORKDIR_MAPSPAM)/spam2020V1r0_global_production/spam2020_v1r0_global_P_CoffRcof_A.tif
for file in $(WORKDIR_MAPSPAM)/spam2020V1r0_global_production/spam2020_v1r0_global_P_*.tif; do \
gdal_translate -a_nodata 0 -co COMPRESS=DEFLATE -co PREDICTOR=3 $$file $$file.tmp.tif;\
mv $$file.tmp.tif $$file;\
Expand Down Expand Up @@ -211,6 +215,10 @@ compute-mapspam-crop-harvest: nodata-harvest
-F $(WORKDIR_MAPSPAM)/spam2020V1r0_global_harvested_area/spam2020_v1r0_global_H_CNUT_A.tif --F_band 1 \
-G $(WORKDIR_MAPSPAM)/spam2020V1r0_global_harvested_area/spam2020_v1r0_global_H_RAPE_A.tif --G_band 1 \
--outfile $(WORKDIR_MAPSPAM)/spam2020V1r0_global_harvested_area/spam2020_v1r0_global_H_OilpSoybGrouOoilSunfCnutRape_A.tif
gdal_calc.py --calc "A+B" --format GTiff --type Float32 --hideNoData --NoDataValue 0 \
-A $(WORKDIR_MAPSPAM)/spam2020V1r0_global_harvested_area/spam2020_v1r0_global_H_COFF_A.tif \
-B $(WORKDIR_MAPSPAM)/spam2020V1r0_global_harvested_area/spam2020_v1r0_global_H_RCOF_A.tif \
--outfile $(WORKDIR_MAPSPAM)/spam2020V1r0_global_harvested_area/spam2020_v1r0_global_H_CoffRcof_A.tif
for file in $(WORKDIR_MAPSPAM)/spam2020V1r0_global_harvested_area/spam2020_v1r0_global_H_*.tif; do \
gdal_translate -a_nodata 0 -co COMPRESS=DEFLATE -co PREDICTOR=3 $$file $$file.tmp.tif;\
mv $$file.tmp.tif $$file;\
Expand Down

0 comments on commit e472cf9

Please sign in to comment.