# Calculating Koppen climate classification in Google Earth Engine seems wrong

For a paper I am writing I need to know the extend of all drylands on earth. Instead of getting third party data I decided to calculate this myself so I keep in control of all steps of the process.

Online the definition of drylands according to Koppen can be easily found:

Multiply the average annual temperature in Celsius by 20, then add

(a) 280 if 70% or more of the total precipitation is in the spring and summer months (April–September in the Northern Hemisphere, or October–March in the Southern), or

(b) 140 if 30%–70% of the total precipitation is received during the spring and summer, or

(c) 0 if less than 30% of the total precipitation is received during the spring and summer.

If the annual precipitation is less than 50% of this threshold, the classification is BW (arid: desert climate); if it is in the range of 50%–100% of the threshold, the classification is BS (semi-arid: steppe climate)

I tried implementing these factors and calculating the arid and semi-arid areas but I am pretty sure that France, the Amazon rain forest, Hungary and even Thailand are no drylands

I have also taken the median of the extend of the TRMM dataset (2000 - 2017) to eliminate inter annual variability but this did not seem to make any difference.

The code I am using is:

``````function ClassifyYear(precipitationdata, temperaturedata, year){

var data = precipitationdata.filterDate(year + "-01-01", (year+1)+"-01-01");
var Temp = temperaturedata.filterDate(year + "-01-01", (year+1)+"-01-01");
var AvTemp = Temp.mean().subtract(273.15); //Average Annual temperature

var PPTns = data.filterDate(year+"-03-20", year+"-09-22").sum(); //Precipitation in the summer of the Northern Hemisphere
var TotPPT = data.sum();
var PPTss = TotPPT.subtract(PPTns); //Precipitation in the summer of the Southern Hemisphere

var mask30 = PPTns.lte(TotPPT.multiply(0.3)); //Masking pixels where summer PPT is less then 30% of the total PPT
var mask70 = PPTns.lte(TotPPT.multiply(0.7)).subtract(mask30); //Masking pixels where summer PPT is less then 70% of the total PPT
var mask100 = mask70.remap([0,1], [1,0]); //Masking pixels where summer PPT is more then 70% of total PPT

var KoppenDry = TotPPT.lte(Threshold); //If PPT is less then Threshold -> Dryland
var KoppenArid = TotPPT.lte(Threshold.multiply(0.5)).rename("arid"); //if PPT less then 0.5*Threshold -> Arid
var KoppenSemi = KoppenDry.subtract(KoppenArid).rename("semi-arid"); //Dryland - Arid = Semi-Arid

return Koppen;
}

var list = [];
for (var year = 2000; year <= 2017;year++){ //Taking the median climate classification

var result = ClassifyYear(TRMM.select("precipitation"),GLDAS.select("Tair_f_inst"), year);
list.push(result);
}
print(list);