[R-sig-Geo] Problem with readRAST6
Roger Bivand
Roger.Bivand at nhh.no
Fri Jan 29 13:32:43 CET 2010
On Fri, 29 Jan 2010, Rainer M Krug wrote:
> Hi
>
> I have a question concerning readRAST6 and the plugin. When I use the
> default (plugin=NULL), I get the error below,
Well, this does happen. I never knowingly use the plugins for raster or
vector any more, because I have multiple GDAL and GRASS installations, and
the cross-dependencies take more time to manage than any accruing benefit.
Use plugin=TRUE to avoid the sanity check.
If you would like to find the cause, please run debug(readRAST6) first,
then run the command, and print out the values of gg (returned by
gmeta6()), and fninfo (returned by GDALinfo). The values of gg$n and
fninfo[5] are found to differ, but gg$w and fninfo[4] not. It could be
that fninfo[5] is set wrongly; in GDALinfo, it is:
ysign <- sign(gt[6])
offset.y <- ifelse(ysign < 0, gt[4] + ysign * d[1] *
abs(cellsize[2]), gt[4] + abs(cellsize[2]))
where gt is the vector of values returned by RGDAL_GetGeoTransform from
the file-specific driver, and d[1] is the number of rows.
If you in addition say debug(GDALinfo), and print the values of gt, we
could see whether the values seem sane for this driver. They "must" be
anyway for reading with plugin=TRUE to work, because they set up the
GridTopology for the object read in; checking with gdalinfo of the same
raster would also be helpful.
Short answer, use plugin=TRUE if you want to use it.
Hope this helps,
Roger
>
>> x <- readRAST6("MASK")
> raster map/current region mismatch detected in components:
> cols rows origin.northing origin.easting
> TRUE TRUE FALSE TRUE
> set plugin=TRUE to override; continuing with plugin=FALSE
>
> I am absolutely sure, that the raster map:
>
>
>> execGRASS("r.info", parameters=list(map="MASK"))
> +----------------------------------------------------------------------------+
> | Layer: MASK Date: Fri Jan 29 13:19:03 2010
> |
> | Mapset: HLsim_Rtmpe2v0qc Login of Creator: rkrug
> |
> | Location: grass
> |
> | DataBase: /home/rkrug/Documents/Projects/HakeaLandscape/trunc/
> |
> | Title: Reclass of region in HLsim_Rtmpe2v0qc ( MASK )
> |
> | Timestamp: none
> |
> |----------------------------------------------------------------------------|
> |
> |
> | Type of Map: reclass Number of Categories: 1
> |
> | Data Type: CELL
> |
> | Rows: 520
> |
> | Columns: 192
> |
> | Total Cells: 99840
> |
> | Projection: UTM (zone -34)
> |
> | N: 6247000 S: 6195000 Res: 100
> |
> | E: 270200 W: 251000 Res: 100
> |
> | Range of data: min = 1 max = 1
> |
> |
> |
> | Data Source:
> |
> | Reclassified map based on:
> |
> | Map [region] in mapset [HLsim_Rtmpe2v0qc]
> |
> |
> |
> | Data Description:
> |
> | generated by r.reclass
> |
> |
> |
> |
> |
> |----------------------------------------------------------------------------|
> | Reclassification of [region] in mapset [HLsim_Rtmpe2v0qc]
> |
> |
> |
> | Category Original categories
> |
> |
> |
> | 1 1
> |
> +----------------------------------------------------------------------------+
>
>> execGRASS("g.region", flags="p")
> projection: 1 (UTM)
> zone: -34
> datum: wgs84
> ellipsoid: wgs84
> north: 6247000
> south: 6195000
> west: 251000
> east: 270200
> nsres: 100
>
> gdal info:
>
>> library(rgdal)
> Loading required package: sp
> Geospatial Data Abstraction Library extensions to R successfully loaded
> Loaded GDAL runtime: GDAL 1.6.3, released 2009/11/19
> Path to GDAL shared files: /usr/share/gdal16
> Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
> Path to PROJ.4 shared files: (autodetected)
>
>> sessionInfo()
> R version 2.10.1 (2009-12-14)
> i486-pc-linux-gnu
>
> locale:
> [1] LC_CTYPE=en_ZA.UTF-8 LC_NUMERIC=C
> [3] LC_TIME=en_ZA.UTF-8 LC_COLLATE=en_ZA.UTF-8
> [5] LC_MONETARY=C LC_MESSAGES=en_ZA.UTF-8
> [7] LC_PAPER=en_ZA.UTF-8 LC_NAME=C
> [9] LC_ADDRESS=C LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_ZA.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] multicore_0.1-3 RSQLite_0.8-0 DBI_0.2-5 spgrass6_0.6-12
> [5] XML_2.6-0 maptools_0.7-29 lattice_0.18-3 foreign_0.8-38
> [9] simecol_0.6-9 deSolve_1.6 rgdal_0.6-24 sp_0.9-52
>
> loaded via a namespace (and not attached):
> [1] grid_2.10.1 tools_2.10.1
>>
>
> Cheers,
>
> Rainer
>
>
--
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