[R] rpy2 postgres qgis problem

R. Michael Weylandt michael.weylandt at gmail.com
Wed May 1 20:05:41 CEST 2013


On Wed, May 1, 2013 at 3:05 PM, Enzo Cocca <enzo.ccc at gmail.com> wrote:
> Hello every body,
> I am using rpy2_2.0.8  with postgres and Qgis.
> The code that I wrote is the following:
>
> def on_calcola_pressed (self):
>                 # bottone per calcoli statistici
>                 import rpy2
>                 import rpy2.robjects as robjects
>                 import rpy2.robjects as ro

Redundant no?

>
>                 r = robjects.r
>                 robjects.r

Why?

>                 r.library("RPostgreSQL")
>                 r.library("gstat")
>                 r.library("zoo")
>                 rcmd_drv = r["dbDriver"]
>                 rcmd_con = r["dbConnect"]
>                 rcmd = r["dbListTables"]
>                 rcmd_archezoology_table = r["dbReadTable"]
>                 png = r.png
>                 drv = rcmd_drv("PostgreSQL")
>                 con = rcmd_con(drv, host="127.0.0.1", dbname="pyarchinit",
> port="5432", password="enzo", user="postgres")
>                 archezoology_table =
> rcmd_archezoology_table(con,"archeozoology_table")
>
> r.png(file="/home/enzo/Scrivania/prova.png",width=512,height=512)
>                 plot = r.plot
>                 zoo = r.zoo
>                 ('VGM_PARAM_A3 <- gstat(id="bos_bison",
> formula=combusto~1,locations=~coord_x+coord_y, data=archezoology_table,
> nmax = 10) VGM_PARAM_A3 <- gstat(VGM_PARAM_A3, "calcinati", strie~1,
> locations=~coord_x+coord_y, archezoology_table, nmax = 10)VGM_PARAM_A3 <-
> gstat(VGM_PARAM_A3, "camoscio", cervo~1,
> locations=~coord_x+coord_y,archezoology_table, nmax = 10) VGM_PARAM_A3 <-
> gstat(VGM_PARAM_A3, model=vgm(1, "Sph", 5, 0), fill.all=TRUE ESV_A3 <-
> variogram(VGM_PARAM_A3, cutoff=9) VARMODEL_A3 = fit.lmc(ESV_A3,
> VGM_PARAM_A3)')
>                 plot(zoo('ESV_A3, model = VARMODEL_A3,xlab=,ylab=,pch=20,
> cex=0.7, col="red",main="Linear Model of Coregionalization for A3
> variables"'))

As this appeared in my mailer, it's not valid python or R; perhaps you
could try resending not in HTML? It's rather dificult to debug as is.

Even better would be to see if you can get it working solely within R
-- post that code -- and then work on translating into rpy2.

Cheers,
MW

>
>
> The error is the following:
>
>  res = super(RFunction, self).__call__(*new_args, **new_kwargs)
> RRuntimeError: Error in plot.window(...) : invalid 'ylim' value
>
>
>
> Do you have a suggestion or examples about how to call a function with the
> gistat module on a postgress tab using rpy2?
>
> Thank you,
>
> Enzo
>
> --
> Enzo Cocca (PhD Candidate)
> Research Fellow
> Università di Napoli "L'Orientale"
> mail: enzo.ccc at gmail.com
> cell: +393495087014
>
>         [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list