[R-sig-Geo] raster CRS changes on tis own
Agustin Lobo
alobolistas at gmail.com
Tue Nov 13 10:41:56 CET 2012
Hi!
I modify the CRS of a raster object:
> vinedomosaicMCA03 <- brick(paste(mosdir,"mosaico_envi.dat",sep="/"))
> proj <- CRS("+init=epsg:3042")
> proj
CRS arguments:
+init=epsg:3042 +proj=utm +zone=30 +ellps=GRS80
+towgs84=0,0,0,0,0,0,0 +units=m +no_defs
> projection(vinedomosaicMCA03) <- proj
> vinedomosaicMCA03
class : RasterBrick
dimensions : 1486, 1162, 1726732, 6 (nrow, ncol, ncell, nlayers)
resolution : 0.170881, 0.170881 (x, y)
extent : 578587.4, 578785.9, 4722025, 4722279 (xmin, xmax, ymin, ymax)
coord. ref. : +init=epsg:3042 +proj=utm +zone=30 +ellps=GRS80
+towgs84=0,0,0,0,0,0,0 +units=m +no_defs
data source : /media/Iomega_HDD/UAVetal/vinedo/Clara_final/mosaico_envi.dat
names : mosaico_envi.1, mosaico_envi.2, mosaico_envi.3,
mosaico_envi.4, mosaico_envi.5, mosaico_envi.6
But then, after a reordering, the CRS changes again on its own:
> vinedomosaicMCA03v2 <- subset(vinedomosaicMCA03,c(3,1,2,4,5,6))
> vinedomosaicMCA03v2
class : RasterStack
dimensions : 1486, 1162, 1726732, 6 (nrow, ncol, ncell, nlayers)
resolution : 0.170881, 0.170881 (x, y)
extent : 578587.4, 578785.9, 4722025, 4722279 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=30 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0
+units=m +no_defs
names : mosaico_envi.3, mosaico_envi.1, mosaico_envi.2,
mosaico_envi.4, mosaico_envi.5, mosaico_envi.6
min values : NA, NA, NA, NA, NA, NA
max values : NA, NA, NA, NA, NA, NA
The correct CRS is conserved if I write to GTiff:
> projection(vinedomosaicMCA03v2) <- proj
> vinedomosaicMCA03v2
class : RasterStack
dimensions : 1486, 1162, 1726732, 6 (nrow, ncol, ncell, nlayers)
resolution : 0.170881, 0.170881 (x, y)
extent : 578587.4, 578785.9, 4722025, 4722279 (xmin, xmax, ymin, ymax)
coord. ref. : +init=epsg:3042 +proj=utm +zone=30 +ellps=GRS80
+towgs84=0,0,0,0,0,0,0 +units=m +no_defs
names : mosaico_envi.3, mosaico_envi.1, mosaico_envi.2,
mosaico_envi.4, mosaico_envi.5, mosaico_envi.6
min values : NA, NA, NA, NA, NA, NA
max values : NA, NA, NA, NA, NA, NA
> writeRaster(vinedomosaicMCA03v2,file="mosaico_enviv2",overwrite=T,format="GTiff")
class : RasterBrick
dimensions : 1486, 1162, 1726732, 6 (nrow, ncol, ncell, nlayers)
resolution : 0.170881, 0.170881 (x, y)
extent : 578587.4, 578785.9, 4722025, 4722279 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=30 +ellps=GRS80 +units=m +no_defs
data source : /media/Iomega_HDD/UAVetal/vinedo/RNavarra/mosaico_enviv2.tif
names : mosaico_enviv2.1, mosaico_enviv2.2, mosaico_enviv2.3,
mosaico_enviv2.4, mosaico_enviv2.5, mosaico_enviv2.6
min values : 0, 0, 0, 0, 0, 0
max values : 175, 224, 179, 199, 196, 204
But it is modified if I write to ENVI format:
> writeRaster(vinedomosaicMCA03v2,file="mosaico_enviv2",overwrite=T,format="ENVI")
class : RasterBrick
dimensions : 1486, 1162, 1726732, 6 (nrow, ncol, ncell, nlayers)
resolution : 0.170881, 0.170881 (x, y)
extent : 578587.4, 578785.9, 4722025, 4722279 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=30 +datum=NAD27 +units=m +no_defs
+ellps=clrk66 +nadgrids=@conus, at alaska, at ntv2_0.gsb, at ntv1_can.dat
data source : /media/Iomega_HDD/UAVetal/vinedo/RNavarra/mosaico_enviv2.envi
names : mosaico_enviv2.1, mosaico_enviv2.2, mosaico_enviv2.3,
mosaico_enviv2.4, mosaico_enviv2.5, mosaico_enviv2.6
min values : 0, 0, 0, 0, 0, 0
max values : 175, 224, 179, 199, 196, 204
Is this a bug in raster or rgdal, or am I doing something wrong?
Agus
More information about the R-sig-Geo
mailing list