[R-sig-Geo] ASCII grids as spatialgridframe

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Thu Jul 23 15:06:28 CEST 2009


Hi Els,

You need to append only the data from the grid and not the grid itself.

Here is an example with the meuse dataset (available in sp).

data(meuse.grid)
m <- SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")], data =
meuse.grid)
m2 <- SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")], data =
data.frame(extra = sqrt(meuse.grid$dist)))

#this is what you tried.
m[["extra"]] <- m2 

#this is what you should do.
m$extra <- m2$extra

Best regards,

Thierry

------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch] Namens Els Ducheyne
Verzonden: donderdag 23 juli 2009 14:32
Aan: r-sig-geo at stat.math.ethz.ch
Onderwerp: [R-sig-Geo] ASCII grids as spatialgridframe

Dear all
sorry to post this question, but I have been looking across multiple
fora and haven't found the answer

I am trying to read ascii-grids in R using the shapefile -
read.asciigrid I have found that this is of class SpatialGridDataFrame I
would like to combine this with a set of grids that are already in the
workspace but when i use the [[<-option I always get the following error
What am I doing wrong? I am not using rgdal, because of a linking error
that I cannot seem to overcome - even though the installation of rgdal
and all its dependencies didn't yield an erro

Thanks for any help!

  achandata<-read.asciigrid("achan.asc")
 > summary(achandata)
Object of class SpatialGridDataFrame
Coordinates:
            min    max
coords.x1 -2.5 1002.5
coords.x2 -2.5  502.5
Is projected: NA
proj4string : [NA]
Number of points: 2
Grid attributes:
   cellcentre.offset cellsize cells.dim
1                 0        5       201
2                 0        5       101
Data attributes:
    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  0.0000  0.0000  0.3000  0.7088  0.9000  6.2000  >
grids[["achan"]]<-achandata
Error: object is not subsettable
 > summary(grids)
Object of class SpatialGridDataFrame
Coordinates:
            min    max
coords.x1 -2.5 1002.5
coords.x2 -2.5  502.5
Is projected: NA
proj4string : [NA]
Number of points: 2
Grid attributes:
   cellcentre.offset cellsize cells.dim
1                 0        5       201
2                 0        5       101
Data attributes:
       elev            grad
  Min.   :119.8   Min.   :0.0008663
  1st Qu.:140.0   1st Qu.:0.0399718
  Median :144.0   Median :0.0620299
  Mean   :144.3   Mean   :0.0821328
  3rd Qu.:150.1   3rd Qu.:0.1129532
  Max.   :159.5   Max.   :0.3284767

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.



More information about the R-sig-Geo mailing list