Python script for comparing "zonal statistics" implementations/algorithms

bash_grass_set_cmd.sh 1.1KB

123456
  1. resX=$(pkinfo -i "/home/thomas/tmp/zonalbenchmark/test_data/wc2.0_10m_tavg_07.tif" -ns | cut -d ' ' -f 2);resY=$(pkinfo -i "/home/thomas/tmp/zonalbenchmark/test_data/wc2.0_10m_tavg_07.tif" -nl | cut -d ' ' -f 2);xmin=$(pkinfo -i "/home/thomas/tmp/zonalbenchmark/test_data/wc2.0_10m_tavg_07.tif" -ulx | cut -d '=' -f 2);xmin_abs=${xmin#-};xmax=$(pkinfo -i "/home/thomas/tmp/zonalbenchmark/test_data/wc2.0_10m_tavg_07.tif" -lrx | cut -d '=' -f 2);ymax=$(pkinfo -i "/home/thomas/tmp/zonalbenchmark/test_data/wc2.0_10m_tavg_07.tif" -uly | cut -d '=' -f 2);ymin=$(pkinfo -i "/home/thomas/tmp/zonalbenchmark/test_data/wc2.0_10m_tavg_07.tif" -lry | cut -d '=' -f 2);ymin_abs=${ymin#-}
  2. INDIR="/home/thomas/tmp/zonalbenchmark/test_data"
  3. g.region n=$ymax e=$xmax s=$ymin w=$xmin rows=$resY cols=$resX
  4. r.in.gdal input=/home/thomas/tmp/zonalbenchmark/test_data/wc2.0_10m_tavg_07.tif output=tmp_raster --overwrite
  5. r.in.gdal input=/home/thomas/tmp/zonalbenchmark/test_data/mask.tif output=tmp_zones --overwrite
  6. r.univar -t map=tmp_raster zones=tmp_zones separator=comma output=/tmp/zonal_grass_out.csv --overwrite