/* AML to import WorldClim BIL files to ArcInfo grids /* Robert Hijmans, Museum of Vertebrate Zoology, UC-Berkeley /* rhijmans@uclink.berkeley.edu /* /* Version 2.1 (January 2004) /* /* Copy this AML to the directory in to which you dowloaded (and unzipped) /* the data tiles /* /* Run it at the "Grid" prompt in Arc/Info by typing /* &run worldclim.aml /* /* Grids are created for each variable (tmean, tmin, tmax, prec, bio), and for each month /* merging seperate zones (tiles) that were downloaded into a single grid, /* and restoring negative values and setting nodata values. &TERMINAL 9999 &if [exists yyy -grid] &then kill yyy &if [exists yyy2 -grid] &then kill yyy2 &if [exists zzz -grid] &then kill zzz &if [exists zzz2 -grid] &then kill zzz2 &if [exists zzz3 -grid] &then kill zzz3 &do i := 1 &to 60 &if [exists z%i% -grid] &then kill z%i% &end &do climvar &list tmean tmin tmax prec bio alt &type Starting import of %climvar% &sv nvars = 12 &if %climvar% = bio &then &sv nvars = 19 &if %climvar% = alt &then &sv nvars = 1 &do m := 1 &to %nvars% &if %climvar% = alt &then &do &if [exists %climvar% -grid] &then kill %climvar% &s bils := [listfile %climvar%*.bil -image] &if [null %bils%] &then &type There are no tiles for %climvar% month %m% &end &else &do &if [exists %climvar%%m% -grid] &then kill %climvar%%m% &s bils := [listfile %climvar%%m%_*.bil -image] &if [null %bils%] &then &type There are no tiles for %climvar% month %m% &end &if [null %bils%] &then &type next &else &do &s num := [token %bils% -count] &do i := 1 &to %num% &sv name = [extract %i% %bils%] &if %i% < 31 &then &do &if %i% = 1 &then &sv listnames = z%i% &else &sv listnames = %listnames%, z%i% &end &else &do &if %i% = 31 &then &sv listnames2 = z%i% &else &sv listnames2 = %listnames2%, z%i% &end arc imagegrid %name% z%i% &end &type merge yyy = merge(%listnames%) zzz = con(yyy >= 32768, yyy - 65536, yyy) kill yyy &if %num% > 30 &then &do yyy2 = merge(%listnames2%) zzz2 = con(yyy2 >= 32768, yyy2 - 65536, yyy2) kill yyy2 zzz3 = merge(zzz, zzz2) kill zzz kill zzz2 %climvar%%m% = setnull(zzz3 == -9999, zzz3) kill zzz3 &end &else &do %climvar%%m% = setnull(zzz == -9999, zzz) kill zzz &end &do i := 1 &to %num% kill z%i% &end arc projectdefine grid %climvar%%m% projection geographic units dd datum WGS84 parameters &if %climvar% = alt &then rename alt1 alt &type %climvar%%m% done &end &end &end &type Finished successfully &return