An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20121105/f10bc2f9/attachment.pl>
Saving a variogram in gstat
9 messages · carolina monmany, Mauricio Zambrano-Bigiarini, Sarah Goslee
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20121105/d1edee62/attachment.pl>
The following reproducible example works for me
(please run it in a new session):
-------- START ----------
library(gstat)
data(meuse)
# no trend:
coordinates(meuse) = ~x+y
myvgm <- variogram(log(zinc)~1, meuse)
# saving the variogram to your home directory
setwd("~")
save(myvgm, file="Myvgm.RData")
## remove (almost) everything in the working environment.
## IMPORTANT:: You will get no warning, so
## don't do this unless you are really sure.
rm(list = ls())
## Loading the variogram
load("Myvgm.RData")
summary(myvgm)
-------- END ----------
IHTH,
Mauricio
================================================= Water Resources Unit Institute for Environment and Sustainability (IES) Joint Research Centre (JRC), European Commission TP 261, Via Enrico Fermi 2749, 21027 Ispra (VA), IT webinfo : http://floods.jrc.ec.europa.eu/ ================================================= DISCLAIMER: "The views expressed are purely those of the writer and may not in any circumstances be regarded as sta- ting an official position of the European Commission" ================================================= Linux user #454569 -- Ubuntu user #17469 ================================================= "It is a mistake to look too far ahead. Only one link in the chain of destiny can be handled at a time" (Sir Winston Churchill) On 05/11/12 15:04, carolina monmany wrote: > Thanks, Sarah. I've tried that and it looks like it is loaded but when I > try to do anything such as plot(variog1) or fit it it does not work. When I > ask > > class(variog1) > > it says > > character > > > 2012/11/5 Sarah Goslee<sarah.goslee at gmail.com> > >> If you use save() to save your variograms, you need to use load() to load >> them. >> >> load("variog1.Rdata") >> >> Sarah >> >> >> On Monday, November 5, 2012, carolina monmany wrote: >> >>> Dear all, >>> >>> I am using R 2.15.1 and the package gstat in Linux to calculate variograms >>> from large datasets (200x200m high resolution satellite images). >>> >>> I need to save all the variograms for later modelling and others and I >>> realized late that I was using the wrong command: >>> >>> save(variog1, file="variog1.Rdata") >>> >>> the variograms were being indeed saved but I cannot open them again >>> because they not being saved as variograms but as characters. >>> >>> I tried to save them using the suggested command: >>> >>> data(variog1): 'variog1'; >>> >>> with no success. My main question is: is there a way I can recover the >>> already saved variograms? >>> And the other question : what is the correct syntaxis for saving >>> variograms >>> in gstat? >>> >>> Thanks a lot. >>> -- >>> --------------------------- >>> A. CAROLINA MONMANY >>> Universidad de Puerto Rico >>> Departamento de Biologia - CN 235 >>> POBOX 23360 >>> San Juan, Puerto Rico 00931-3360 >>> Tel: +1 787 764 0000 x2847 >>> Fax: +1 787 764 2610 >>> >>> [[alternative HTML version deleted]] >>> >>> _______________________________________________ >>> R-sig-Geo mailing list >>> R-sig-Geo at r-project.org >>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo >>> >> >> >> -- >> Sarah Goslee >> http://www.stringpage.com >> http://www.sarahgoslee.com >> http://www.functionaldiversity.org >> > > >
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20121105/de3983e7/attachment.pl>
On Mon, Nov 5, 2012 at 10:26 AM, carolina monmany <acmonmany at gmail.com> wrote:
Thanks Sarah and Mauricio, here's the example
library(gstat)
setwd("/home/acmonmany/matricesDN")
tuc11.2.frm = read.table("plot11_2.txt", header=T)
coordinates(tuc11.2.frm) <- c("X", "Y")
proj4string(tuc11.2.frm) <-CRS("+proj=utm +zone=20 +south +ellps=intl
+towgs84=-355,21,72,0,0,0,0 +units=m +no_defs")
variog11.2 <- variogram(reflectance~1, data=tuc11.2.frm) save(variog11.2, file="tuc11.2.200.var.Rdata")
NOW when I try to load the saved file (I do not change directory and I can see the files there, in the directory stated above):
load("tuc11.2.200.var.Rdata")
class("tuc11.2.200.var.Rdata")
[1] "character"
Of course it is: "tuc11.2.200.var.Rdata" is a character string, as is anything in quotes.
summary(tuc11.2.200.var)
Error in summary(tuc11.2.200.var) : error in evaluating the argument 'object' in selecting a method for function 'summary': Error: object 'tuc11.2.200.var' not found
That's not anything, just the name of your Rdata file. The R object itself keeps the same name as it had when you saved it: variog11.2 summary(variog11.2) will show you its properties. If you ls() you'll see there is no R object called tuc11.2.200.var If you want your saved object to have that name, you need to rename it before saving. Sarah -- Sarah Goslee http://www.functionaldiversity.org
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20121105/572cf136/attachment.pl>
Hi Carolina,
You can save all the variables of your current session by using 'save.image':
save.image("myVGMsession.RData")
and then load it as before (from Windows or GNU/Linux):
load("myVGMsession.RData")
Kinds,
Mauricio
2012/11/5 carolina monmany <acmonmany at gmail.com>:
I see, Sarah. Thank you! Now I need to transfer those variograms to my PC running windows and that was the reason I was doing save(variog11.2, file="tuc11.2.200.var.Rdata") and transfering those files from Linux to Windows. Should I transfer the .Rdata in the directory instead? Where are the objects themselves? 2012/11/5 Sarah Goslee <sarah.goslee at gmail.com>
On Mon, Nov 5, 2012 at 10:26 AM, carolina monmany <acmonmany at gmail.com> wrote:
Thanks Sarah and Mauricio, here's the example
library(gstat)
setwd("/home/acmonmany/matricesDN")
tuc11.2.frm = read.table("plot11_2.txt", header=T)
coordinates(tuc11.2.frm) <- c("X", "Y")
proj4string(tuc11.2.frm) <-CRS("+proj=utm +zone=20 +south +ellps=intl
+towgs84=-355,21,72,0,0,0,0 +units=m +no_defs")
variog11.2 <- variogram(reflectance~1, data=tuc11.2.frm) save(variog11.2, file="tuc11.2.200.var.Rdata")
NOW when I try to load the saved file (I do not change directory and I
can
see the files there, in the directory stated above):
load("tuc11.2.200.var.Rdata")
class("tuc11.2.200.var.Rdata")
[1] "character"
Of course it is: "tuc11.2.200.var.Rdata" is a character string, as is anything in quotes.
summary(tuc11.2.200.var)
Error in summary(tuc11.2.200.var) : error in evaluating the argument 'object' in selecting a method for function 'summary': Error: object 'tuc11.2.200.var' not found
That's not anything, just the name of your Rdata file. The R object itself keeps the same name as it had when you saved it: variog11.2 summary(variog11.2) will show you its properties. If you ls() you'll see there is no R object called tuc11.2.200.var If you want your saved object to have that name, you need to rename it before saving. Sarah -- Sarah Goslee http://www.functionaldiversity.org
--
---------------------------
A. CAROLINA MONMANY
Universidad de Puerto Rico
Departamento de Biologia - CN 235
POBOX 23360
San Juan, Puerto Rico 00931-3360
Tel: +1 787 764 0000 x2847
Fax: +1 787 764 2610
[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
===================================== Water Resources Unit Institute for Environment and Sustainability Joint Research Centre, European Commission webinfo : http://floods.jrc.ec.europa.eu/ ===================================== DISCLAIMER:\ "The views expressed are purely those of th...{{dropped:13}}
On Mon, Nov 5, 2012 at 10:55 AM, carolina monmany <acmonmany at gmail.com> wrote:
I see, Sarah. Thank you! Now I need to transfer those variograms to my PC running windows and that was the reason I was doing save(variog11.2, file="tuc11.2.200.var.Rdata") and transfering those files from Linux to Windows. Should I transfer the .Rdata in the directory instead? Where are the objects themselves?
The R object named variog11.2 is saved in the binary file named tuc11.2.200.var.Rdata. That file can be copied to other computers and loaded using load(), which will create the variogram variog11.2 in that workspace (potentially overwriting any object already named variog11.2). I don't understand your question about directories. Sarah
2012/11/5 Sarah Goslee <sarah.goslee at gmail.com>
On Mon, Nov 5, 2012 at 10:26 AM, carolina monmany <acmonmany at gmail.com> wrote:
Thanks Sarah and Mauricio, here's the example
library(gstat)
setwd("/home/acmonmany/matricesDN")
tuc11.2.frm = read.table("plot11_2.txt", header=T)
coordinates(tuc11.2.frm) <- c("X", "Y")
proj4string(tuc11.2.frm) <-CRS("+proj=utm +zone=20 +south +ellps=intl
+towgs84=-355,21,72,0,0,0,0 +units=m +no_defs")
variog11.2 <- variogram(reflectance~1, data=tuc11.2.frm) save(variog11.2, file="tuc11.2.200.var.Rdata")
NOW when I try to load the saved file (I do not change directory and I
can
see the files there, in the directory stated above):
load("tuc11.2.200.var.Rdata")
class("tuc11.2.200.var.Rdata")
[1] "character"
Of course it is: "tuc11.2.200.var.Rdata" is a character string, as is anything in quotes.
summary(tuc11.2.200.var)
Error in summary(tuc11.2.200.var) : error in evaluating the argument 'object' in selecting a method for function 'summary': Error: object 'tuc11.2.200.var' not found
That's not anything, just the name of your Rdata file. The R object itself keeps the same name as it had when you saved it: variog11.2 summary(variog11.2) will show you its properties. If you ls() you'll see there is no R object called tuc11.2.200.var If you want your saved object to have that name, you need to rename it before saving. Sarah
-- Sarah Goslee http://www.functionaldiversity.org
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20121105/fdc59179/attachment.pl>