[R-sig-Geo] writeRaster and coord ref problem

Johannes Radinger JRadinger at gmx.at
Tue Mar 6 15:36:25 CET 2012


Hi,

I need to load some data from the Worldclim Database and reproject them
to some other, already existing rasters. Because I don't want to use the reprojected rasters from the memory I want to save the brick as a GeoTiff (like the other rasters) using writeRaster. But somehow writeRaster() changes the coord. ref. line and drops "+datum=Potsdam". Here what I am doing:

> WC.bio <- projectRaster(getData("worldclim", var="bio", res=0.5, lon=9.3, lat=54.5),second.map)
> WC.bio
class       : RasterBrick 
dimensions  : 912, 840, 766080, 19  (nrow, ncol, ncell, nlayers)
resolution  : 50, 50  (x, y)
extent      : 3505300, 3547300, 6025800, 6071400  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +datum=potsdam +units=m +no_defs +ellps=bessel +towgs84=606.0,23.0,413.0 
values      : in memory
min values  :   78.0   58.0   26.0 5675.8  194.0  -24.0  214.0   52.1   28.0  151.0 ... 
max values  :   85   68   29 5964  210  -16  229  156   35  161 ...

> writeRaster(WC.bio, "/path/to/file.tif", format="GTiff", overwrite = TRUE)
class       : RasterBrick 
dimensions  : 912, 840, 766080, 19  (nrow, ncol, ncell, nlayers)
resolution  : 50, 50  (x, y)
extent      : 3505300, 3547300, 6025800, 6071400  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +towgs84=606,23,413,0,0,0,0 +units=m +no_defs 
values      : /Users/Johannes Radinger/Documents/IGB/IMPACT_Data/Treene/SDM/Predictors/WC.bio.tif 
min values  :   78.0   58.0   26.0 5675.8  194.0  -24.0  214.0   52.1   28.0  151.0 ... 
max values  :   85   68   29 5964  210  -16  229  156   35  161 ... 


This is a problem to my as I want to combine the other maps with the reprojected Worldclim maps into a new stack from the files. But these files have different projections....

Best regards,
Johannes



More information about the R-sig-Geo mailing list