[R-sig-Geo] Convert a Matrix into a SpatialGridDataFrame
Rainer M Krug
r.m.krug at gmail.com
Thu Mar 15 09:41:01 CET 2012
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 13/03/12 11:42, jjcabrera20 wrote:
> Hello everybody there!! Maybe a silly question but for doing some manipulation on values of a
> SpatialGridDataFrame I transformed it into a matrix like this *Matrix<-
> as.matrix(SpatialGridDataFrame)* now I want to go back and turn the matrix again into
> SpatialGridDataFrame, but I can't find the way. The matrix is still the same (number of rows
> and columns, grid size, projection) as the original.
Try the following:
# sgdf: SpatialGridDataFrame with one layer
mtr <- as.matrix(sgdf)
# do something with mtr
sgdf at data[[2]] <- as.vector(mtr)
then
the second layer in sgdf is your matrix
Cheers,
Rainer
>
> Thanks
>
> Jorge
>
> -- View this message in context:
> http://r-sig-geo.2731867.n2.nabble.com/Convert-a-Matrix-into-a-SpatialGridDataFrame-tp7368054p7368054.html
>
>
Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
- --
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys.
(Germany)
Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa
Tel : +33 - (0)9 53 10 27 44
Cell: +33 - (0)6 85 62 59 98
Fax : +33 - (0)9 58 10 27 44
Fax (D): +49 - (0)3 21 21 25 22 44
email: Rainer at krugs.de
Skype: RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk9hqx0ACgkQoYgNqgF2egpitgCfWTFeZvPC5Bp+lev+yWJXm/vL
gb8An2x8lbh/Fg0sjkQxsxh8t56eEiJF
=V4nu
-----END PGP SIGNATURE-----
More information about the R-sig-Geo
mailing list