An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20070321/0e6f0256/attachment.pl>
help on Polygon(sp)?
6 messages · Virgilio Gómez-Rubio, zhijie zhang, Roger Bivand +1 more
Hi, El mi?, 21-03-2007 a las 22:45 +0800, zhijie zhang escribi?:
Dear friends,
I have a .shp file of region boundary, and i want to use it as the polygon
in the khat(splancs) function, but it goes wrong.
# khat(pts,poly,s,newstyle=FALSE)
guichi<-readShapePoly("d:/d/guichi2.shp") # read the shp data of region
boundary
guichi2<-Polygon(coordinates(guichi), hole=as.logical(NA)) #generate the
I think that you could try as.points(coordinates(guichi)) here to get the boundary in the appropriate format. As far as I know, khat does not use sp objects. Best regards, Virgilio
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20070321/7ab9213d/attachment.pl>
Hi,
#errors occurs???????? env.lab <- Kenv.label(case_pts,control_pts,splancs_poly, nsim=999, seq (0,23000,500)) error:v error in erifyclass(X, "ppp") : argument 'X' is not of class 'ppp' Q1: Now that khat(splancs) goes fine, why not Kenv.label(splancs)? From the help, it didn't say that it needs the point data set to be the class of ppp(spatstat).
The problem is not in Kenv.label() but in rlabel(), which is called from Kenv.label and that has versions in Splancs and Spatstat. So, if you loaded Spatstat after Splancs, then you will be using the 'wrong' (non- Splancs) version. My advice is to load Splancs only and do the analysis. I think you could use Spatstat as well to get the envelopes of the K- function (using envelope() ) but it might require a few more lines of code. Best, Virgilio P.S: Is it wise to use variable names with underscore in it?
On Wed, 21 Mar 2007, Virgilio G?mez-Rubio wrote:
Hi,
#errors occurs???????? env.lab <- Kenv.label(case_pts,control_pts,splancs_poly, nsim=999, seq (0,23000,500)) error:v error in erifyclass(X, "ppp") : argument 'X' is not of class 'ppp' Q1: Now that khat(splancs) goes fine, why not Kenv.label(splancs)? From the help, it didn't say that it needs the point data set to be the class of ppp(spatstat).
The problem is not in Kenv.label() but in rlabel(), which is called from Kenv.label and that has versions in Splancs and Spatstat. So, if you loaded Spatstat after Splancs, then you will be using the 'wrong' (non- Splancs) version. My advice is to load Splancs only and do the analysis.
These things do happen, I think that neither splancs nor spatstat have
namespaces, which restrict the visibility of functions, so here you need
to be careful. The warning:
The following object(s) are masked from package:splancs :
rlabel
should have been displayed.
I think you could use Spatstat as well to get the envelopes of the K- function (using envelope() ) but it might require a few more lines of code.
And if you use spatstat, you can convert the SpatialPolygons to owin with functions in maptools: as(guichi, "owin") ought to do it. Roger
Best, Virgilio P.S: Is it wise to use variable names with underscore in it?
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand 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
Hello, I'm having trouble with using the alpha channel for transparency with lines with spplot and sp.lines. If I use transparency via the alpha argument to rgb to overplot lines on spplot.grid the transparent colour affects all of the colours in the plot. Example follows. I've put the pdfs as created below here for reference: http://staff.acecrc.org.au/~mdsumner/Rutas/misc/ BTW, I know my usage of the panel plots is not right, but I'm learning, so any advice would be appreciated. Cheers, Mike. I'm using Windows XP, SP2 with R version 2.4.1 (2006-12-18) i386-pc-mingw32 locale: LC_COLLATE=English_Australia.1252;LC_CTYPE=English_Australia.1252;LC_MONETARY=English_Australia.1252;LC_NUMERIC=C;LC_TIME=English_Australia.1252 attached base packages: [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" [7] "base" other attached packages: sp "0.9-9" Example: library(sp) data(meuse.grid) coordinates(meuse.grid) <- ~x+y gridded(meuse.grid) <- TRUE ## create some lines bb <- bbox(meuse.grid) xy <- cbind(runif(10, bb[1,1], bb[1,2]), runif(10, bb[2,1], bb[2,2])) ll <- SpatialLines(list(Lines(list(Line(xy)), "1"))) ## this is fine, colour grid with black lines pdf("test.pdf", version = "1.4") pg <- function(...) { panel.gridplot(...) sp.lines(ll) } spplot(meuse.grid[1], panel = pg) dev.off() ## in this the colour grid is "greyed" like the lines pdf("testAlpha.pdf", version = "1.4") pg <- function(...) { panel.gridplot(...) sp.lines(ll , col = rgb(190, 190, 190, 100, max = 255)) } spplot(meuse.grid[1], panel = pg) dev.off() ## try with blue lines - colour grid is "blued" . . . pdf("testBlueAlpha.pdf", version = "1.4") pg <- function(...) { panel.gridplot(...) sp.lines(ll , col = rgb(0, 0, 190, 100, max = 255)) } spplot(meuse.grid[1], panel = pg) dev.off()