[R-sig-Geo] Problem reading back a raster from GRASS
Roger Bivand
Roger.Bivand at nhh.no
Fri Jan 28 20:58:51 CET 2011
On Fri, 28 Jan 2011, Pierre Racine wrote:
> Hi,
>
> It seems I'm having problem storing a raster into GRASS using the
> spgrass6 package. I writeRAST6() a 1376x1376 raster to GRASS, but when I
> readRAST6() it back to R the raster is only 1x1 pixels... Note that the
> raster is a bmp and hence is not projected to any coordinate system.
>
> I must be doing something wrong. Here is my R code:
What is the current region of your GRASS location? You can check by
looking at the output of gmeta6(). If it does not match the extent of the
file, you may experience this. Have you checked the extent of the data as
seem by GRASS before reading it back? Are you running R within GRASS or
did you start GRASS with initGRASS() from within R? If you used initGRASS,
did you use the SG= argument?
Roger
>
> ------------------------------------------------------------------
>> image1 = readGDAL("D:/temp/image01.bmp")
> D:/Clients/AlainPaquette/AnalyseDeCimeR/images/image01.bmp has GDAL driver BMP
> and has 1376 rows and 1376 columns
>
>> summary(image1)
> Object of class SpatialGridDataFrame
> Coordinates:
> min max
> x -2953 8123703
> y -8123703 2953
> Is projected: NA
> proj4string : [NA]
> Number of points: 2
> Grid attributes:
> cellcentre.offset cellsize cells.dim
> x 0 5906 1376
> y -8120750 5906 1376
> Data attributes:
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> 0.0000 1.0000 1.0000 0.9962 1.0000 1.0000
>
>> writeRAST6(image1, "image1", overwrite=TRUE)
> ATTENTION : Raster map <image1> already exists and will be overwritten
> Projection of input dataset and current location appear to match
>
> RINGDA~1 terminé. Raster map <image1> created.
>
>> image1_2 <- readRAST6(c("image1"), cat=c(TRUE), ignore.stderr=TRUE, plugin=NULL)
>
>> summary(image1_2)
> Object of class SpatialGridDataFrame
> Coordinates:
> min max
> x 0 1
> y 0 1
> Is projected: NA
> proj4string : [NA]
> Number of points: 2
> Grid attributes:
> cellcentre.offset cellsize cells.dim
> x 0.5 1 1
> y 0.5 1 1
> Data attributes:
>
> 1
>
>>
> ------------------------------------------------------------------
>
> Thanks,
>
> Pierre
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list