[R-sig-Geo] error message rgdal: dimensions do not match
Roger.Bivand at nhh.no
Tue Jul 4 18:59:11 CEST 2006
On Tue, 4 Jul 2006 karl.sommer at dpi.vic.gov.au wrote:
> I am encountering a error message when attempting to do "inverse distance
> kriging" or variogram calculations. The error is always the same
> ERROR: dimensions do not match: locations 1513600 and data 611452.
Indeed strange, given that 880 by 860 is 756800 (though 756800*2 is the
first number). What does summary(t1) say? Is the single column named band1
or ndvi? The class of t1 will be SpatialGridDataFrame, wouldn't
SpatialPointsDataFrame be more digestible? Does doing it in two steps
(gstat() then predict() of the gstat object) show anything? What did
traceback() say after krige()?
> What puzzles me is the fact that I am using the same code as I have
> used with 2 other images.
> I have tried to reduce the dimensions of the imported image in using
> gdal_translate from the command prompt. The same error was still present
> but with different "address-numbers" relating to locations and data.
> I have tried to find some pointers re error messages under the GDAL
> manual but without success.
> I am able to plot the imported image as well as the target grid and SPDF
> without error.
> following is the code:
> # import image
> > t1 <- readGDAL("images/test1.bil", half.cell=c(0.5, 0.5), silent = FALSE)
> images/test1.bil has GDAL driver GTiff
> and has 860 rows and 880 columns
> Closing GDAL dataset handle 0100ACB8... destroyed ... done.
> Closing GDAL dataset handle 00000000... done.
> # get shape file of field
> > image(t1)
> > poly <- locator()
> > poly <- do.call("cbind", poly)
> > poly <- rbind(poly, poly[1,])
> > lines(poly)
> > field <- SpatialPolygons(list(Polygons(list(Polygon(poly)), ID="field")))
> > grd <- GridTopology(c(599040, 6228570), c(.5,.5), c(880, 860))
> > SG <- SpatialGrid(grd)
> > x1 <- overlay(SG, field)
> > SGDF <- SpatialGridDataFrame(grd, data=AttributeList(list(field=x1)))
> > SPDF <- as(SGDF, "SpatialPixelsDataFrame")
> # do kriging
> > library(gstat)
> > t1.idw <- krige(ndvi~1, t1, SPDF)
> Error: dimensions do not match: locations 1513600 and data 611452
> Karl J Sommer,
> Department of Primary Industries,
> Catchment & Agriculture Services,
> PO Box 905
> Mildura, VIC, Australia 3502
> Tel: +61 (0)3 5051 4390
> Fax +61 (0)3 5051 4534
> Email: karl.sommer at dpi.vic.gov.au
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
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