Re: [R-sig-Geo] Point Pattern question
I want to study if there is a spatial clustering on fare evasion stops data (as points) e.g. there are 9 evaders in stop "A" but in stop "B" are 20 evaders. So what I've read about point patterns is that considers the location of an event only and not its attributes, so I was wondering if it is possible to include an attribute as weight of a given location in the study of spatial clustering. ¿Is the right approach or should I do a geostatistical interpolation? No, I haven't read that book but I did read the Applied Spatial Data Analysis (https://asdar-book.org/) Regards, Ariel Fuentes Le jeu. 26 déc. 2019 à 22:49, Frazier, Tyler a écrit : > Hi Ariel, > > I believe you are asking if it is possible to estimate a model with marks > (different variable outcomes) as attributes to the points in your planar > point pattern. Last I read this was still under development, but not sure > if I properly interpreted your question, or if it is currently possible. > > Have you read https://book.spatstat.org ? > > Best wishes, > Tyler > > Tyler J. Frazier, Ph.D. > *Lecturer of Interdisciplinary Studies* > *Data Science Program* > *College of William and Mary* > *Webpage:* https://tyler-frazier.github.io > > > > On Dec 24, 2019, at 11:29 AM, Ariel Fuentesdi > wrote: > > Hi! > > I have a conceptual question, can I use the Point Pattern model to find a > clustered region, but in each location it is more than one case?. What I > mean is to use attributes for the spatial locations. > > Regards, > Ariel Fuentes > > [[alternative HTML version deleted]] > > ___ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > > > [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] Point Pattern question
Hi! I have a conceptual question, can I use the Point Pattern model to find a clustered region, but in each location it is more than one case?. What I mean is to use attributes for the spatial locations. Regards, Ariel Fuentes [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] Spatio-temporal Predictions with CARBayesST
Hi everyone, I'm trying to use the CARBayesST package and I need to do Spatio-temporal predictions. In the vignette of the package on page 27 says " If there had been say m missing values, then the Y component of the list would have contained m columns, with each one containing posterior predictive samples for one of the missing observations." https://cran.r-project.org/web/packages/CARBayesST/vignettes/CARBayesST.pdf But I don't understand well how to obtain the posterior predictive values of Y, let's say I want to predict the value of Y for the next 3 periods for each zone. How should I do it? This is the reproducible code (found in the vignette): library(CARBayesST) # Run the model on simulated data on a lattice # set up the regular lattice x.easting <- 1:10 x.northing <- 1:10 Grid <- expand.grid(x.easting, x.northing) K <- nrow(Grid) N <- 10 N.all <- N * K set up spatial neighbourhood matrix W distance <- as.matrix(dist(Grid)) W <-array(0, c(K,K)) W[distance==1] <-1 Simulate the elements in the linear predictor and the data gamma <- rnorm(n=N.all, mean=0, sd=0.001) x <- rnorm(n=N.all, mean=0, sd=1) beta <- 0.1 Q.W <- 0.99 * (diag(apply(W, 2, sum)) - W) + 0.01 * diag(rep(1,K)) Q.W.inv <- solve(Q.W) phi.temp <- mvrnorm(n=1, mu=rep(0,K), Sigma=(0.1 * Q.W.inv)) phi <- phi.temp for(i in 2:N) { phi.temp2 <- mvrnorm(n=1, mu=(0.8 * phi.temp), Sigma=(0.1 * Q.W.inv)) phi.temp <- phi.temp2 phi <- c(phi, phi.temp) } LP <- 3 + x * beta + phi mean <- exp(LP) Y <- rpois(n=N.all, lambda=mean) Run the model model <- ST.CARar(formula=Y~x, family="poisson", W=W, burnin=10, n.sample=50) Regards, Ariel [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] Spatio-temporal modelling for trip generation data
Hi everyone, I want to produce a prediction of trip generation for the next year, I'm thinking could be useful a Spatio-temporal model with covariates data. I have trips values in point locations since 2015 also the population in census tracts and supply which are bus lines and I'm thinking to convert them into an accessibility grid (from the census tracts to bus stops). I have seen that Spatio-temporal models are applied to environmental problems only, would you recommend me any specific approach or the use of a specific model? Regards, Ariel Fuentes [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] help: Problem getting centroids inside lists
I understand, but I said "it doesn't work" because it gave an undesired solution, but I'll try to be more explicit next time. And I forgot to say that: s <- 1: length(ct) And thank you for your advice, but the answer of Vijay Lulla resolved my problem. Regards, Ariel 2018-09-12 17:43 GMT-03:00 MacQueen, Don : > On any R mailing list, whenever you say "it doesn't work", you should > always copy exactly what R command you gave, and any error messages. > > First notice: > > > ct$a$two > SpatialPoints: > lon lat > [1,] -18 -2 > [2,] -16 50 > Coordinate Reference System (CRS) arguments: NA > > Then compare these: > > > coordinates(ct$a$two) > lon lat > [1,] -18 -2 > [2,] -16 50 > > > coordinates(slot(ct$a$two,'coords')) > lon lat > [1,] -18 -2 > [2,] -16 50 > > The results are the same. Why are you using the slot() function? There is > no need, and it makes it more difficult to understand. > > > You have assumed the mean() function will give you what you want when > there are two points. It doesn't. Try it and see: > > > mean( coordinates(ct$a$two)) > [1] 3.5 > > > mean(coordinates(slot(ct$a$two,'coords'))) > [1] 3.5 > > Replace the mean() function with a function that will give you the > "centroid" of two points, however you want to define that centroid. Perhaps > the means of the two columns? R has a function for that. > > - > In this bit: > > ctply <- lapply(X = s, FUN = function(x) sapply(X = ct[[x]], > FUN = function(y) > > Using X = s is wrong because you haven't defined or created s anywhere. X > should be ct. > > Also, X = ct[[x]] is wrong. When the first FUN is executed, it will be > supplied automatically with the whole of ct$a, then ct$b. Try > > ctply <- lapply(X = s, FUN = function(x) sapply(X = x, > FUN = function(y) > > The whole thing is easier to understand and test if you define the > functions outside the lapply and sapply calls. > > -Don > -- > Don MacQueen > Lawrence Livermore National Laboratory > 7000 East Ave., L-627 > Livermore, CA 94550 > 925-423-1062 > Lab cell 925-724-7509 > > > > On 9/12/18, 11:42 AM, "R-sig-Geo on behalf of Ariel Fuentesdi" < > r-sig-geo-boun...@r-project.org on behalf of ariel.fuente...@usach.cl> > wrote: > > I went to a more general approach, that is: > > ctply <- lapply(X = s, FUN = function(x) sapply(X = ct[[x]], > FUN = function(y) if(length(y)>1) geosphere::centroid(slot(y, > "coords")) > else sp::coordinates(slot(y, "coords" > > But now I want to add the case when they are only two elements. The > dataset > will be: > > ct <- list(a = list(one = data.frame(lon = c(-180, -160, -60), lat = > c(-20, > 5, 0)), > two = data.frame(lon = c(-18, -16), lat = c(-2, > 50))), >b = list(one = data.frame(lon = c(-9, -8, -3), lat = c(-1, > 25, > 5)), > two = data.frame(lon = c(-90), lat = c(-1 > coordinates(ct$a$one) <- ~lon+lat > coordinates(ct$a$two) <- ~lon+lat > coordinates(ct$b$one) <- ~lon+lat > coordinates(ct$b$two) <- ~lon+lat > > And I did the following but it doesn't work: > > ctply <- lapply(X = s, FUN = function(x) sapply(X = ct[[x]], > FUN = function(y) > if(length(y)>2) geosphere::centroid(slot(y, "coords")) > else if (length(y) == > 1) > sp::coordinates(slot(y, "coords")) > else > mean(sp::coordinates(slot(y, "coords") > > I need the result of each element of the list will be a matrix of two > rows > per column (named: one, two). How do I fix it? > > Regards, > Ariel > > 2018-09-10 17:29 GMT-03:00 MacQueen, Don : > > > If all of your data frames had enough points then this should work: > > > > myfun1 <- function(le) { > > list(one=geosphere::centroid(coordinates(le$one)), > >two=geosphere::centroid(coordinates(le$two)) > >) > > } > > > > lapply(ct, myfun1) > > > > To handle the one point case, try the following, which I think works > with > > your example data, but is untested if there just two points. > > It also assumes
Re: [R-sig-Geo] help: Problem getting centroids inside lists
I went to a more general approach, that is: ctply <- lapply(X = s, FUN = function(x) sapply(X = ct[[x]], FUN = function(y) if(length(y)>1) geosphere::centroid(slot(y, "coords")) else sp::coordinates(slot(y, "coords" But now I want to add the case when they are only two elements. The dataset will be: ct <- list(a = list(one = data.frame(lon = c(-180, -160, -60), lat = c(-20, 5, 0)), two = data.frame(lon = c(-18, -16), lat = c(-2, 50))), b = list(one = data.frame(lon = c(-9, -8, -3), lat = c(-1, 25, 5)), two = data.frame(lon = c(-90), lat = c(-1 coordinates(ct$a$one) <- ~lon+lat coordinates(ct$a$two) <- ~lon+lat coordinates(ct$b$one) <- ~lon+lat coordinates(ct$b$two) <- ~lon+lat And I did the following but it doesn't work: ctply <- lapply(X = s, FUN = function(x) sapply(X = ct[[x]], FUN = function(y) if(length(y)>2) geosphere::centroid(slot(y, "coords")) else if (length(y) == 1) sp::coordinates(slot(y, "coords")) else mean(sp::coordinates(slot(y, "coords") I need the result of each element of the list will be a matrix of two rows per column (named: one, two). How do I fix it? Regards, Ariel 2018-09-10 17:29 GMT-03:00 MacQueen, Don : > If all of your data frames had enough points then this should work: > > myfun1 <- function(le) { > list(one=geosphere::centroid(coordinates(le$one)), >two=geosphere::centroid(coordinates(le$two)) >) > } > > lapply(ct, myfun1) > > To handle the one point case, try the following, which I think works with > your example data, but is untested if there just two points. > It also assumes the data frames are named 'one' and 'two', and will ignore > any others. To handle other names, I think you > could replace $one with [[1]] and $two with [[2]] . > > myfun <- function(le) { > list(one=if (length(le$one)>1) geosphere::centroid(coordinates(le$one)) > else coodinates(le$one), >two=if (length(le$two)>1) geosphere::centroid(coordinates(le$two)) > else coordinates(le$two) >) > } > > lapply(ct, myfun) > > > To see a little bit of what's going on, try > > myfun(ct[[1]]) > myfun1(ct[[1]]) > myfun1(ct[[2]]) > myfun(ct[[2]]) > > > > I would also verify that the length method for objects of class > SpatialPoints does return the number of points, as it appears to: > > > class(ct$a$two) > [1] "SpatialPoints" > attr(,"package") > [1] "sp" > > > length(ct$a$one) > [1] 3 > > length(ct$a$two) > [1] 3 > > length(ct$a$two) > [1] 3 > > length(ct$b$two) > [1] 1 > > -- > Don MacQueen > Lawrence Livermore National Laboratory > 7000 East Ave., L-627 > Livermore, CA 94550 > 925-423-1062 > Lab cell 925-724-7509 > > > > On 9/10/18, 10:56 AM, "R-sig-Geo on behalf of Ariel Fuentesdi" < > r-sig-geo-boun...@r-project.org on behalf of ariel.fuente...@usach.cl> > wrote: > > Hi everyone, > > I have a list of coordinates called "ct" and I want to extract the > centroids of each sublist, but it only works when it has only 3 or more > points. In ct$b$two only has one point; in that case, I would rescue > that > point as If it were a centroid. > > This is what I did: > > library(dplyr) > library(geosphere) > > ct <- list(a = list(one = data.frame(lon = c(-180, -160, -60), lat = > c(-20, > 5, 0)), > two = data.frame(lon = c(-18, -16, -6), lat = > c(-2, 50, > 10))), >b = list(one = data.frame(lon = c(-9, -8, -3), lat = c(-1, > 25, > 5)), > two = data.frame(lon = c(-90), lat = c(-1 > > coordinates(ct$a$one) <- ~lon+lat > coordinates(ct$a$two) <- ~lon+lat > coordinates(ct$b$one) <- ~lon+lat > coordinates(ct$b$two) <- ~lon+lat > > s <- 1:length(ct) > ctply <- list() > for (i in s){ > for (j in 1:length(ct[[i]])) { > ctply[[i]][j] <- ifelse(test = lengths(ct[[i]][1]) > 2, yes = > sapply(X = > ct[[i]][j], > FUN = function(y) geosphere::centroid(slot(y, "coords"))), no = > ct[[i]][j] ) > } > } > > Thanks in advance > > Regards, > Ariel > > [[alternative HTML version deleted]] > > ___ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > > > [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] Spatial Query (Selection) with Apply
Thanks, Robin It worked perfectly, although I transformed the data from sf to SpatialDataFrame objects with: zones <- as(zones, "Spatial") nodes <- as(nodes, "Spatial") The next step I will follow is to create Distance Matrix like this: coord <- tmp2[[1]]@coords dist1 <- apply(X = coord, MARGIN = 1, FUN = function(x) spDistsN1(coord, x, longlat = T)) obviously, the task is a distance matrix for every selection. ¿What would you recommend, the aggregate function as you talked before or something like a nested apply? Regards, Ariel 2018-08-27 19:32 GMT-03:00 Robin Lovelace : > Hi Ariel, > > It helps when asking for help with code to produce a reproducible example. > To understand your input data I've created nodes and zones based on the > spData data nz_height and nz_elev. Based on the assumption you want to find > all the nodes in each zone I think the direct answer to your question is > something like the following: > > tmp2 = lapply(s, function(x) { > nodes[zones[x, ], ] > }) > > The longer answer is that aggregate(), st_join() + aggregate()/summarize() > may provide quicker solutions, depending on what you want to do with the > points after grouping them by which zone they fall in. > Note: I've used sf objects based on the explanation here > https://geocompr.robinlovelace.net/spatial-operations.html#spatial-vec > which may not work with sp data but the aggregate code should work roughly > the same: > > # install.packages("sf") > # install.packages("spData") > library(spData) > library(sf) > #> Linking to GEOS 3.6.2, GDAL 2.2.3, proj.4 4.9.3 > zones = nz > nodes = nz_height > tmp = list() > s = 1:nrow(nz) > > for(i in s) { > tmp[[i]] = nodes[nz[i, ], ] > } > > # understand what's going on with plots (not shown) > # plot(st_geometry(nz)) > # plot(st_geometry(tmp[[i]]), add = TRUE, col = "red") > # plot(nz[i, ], col = "green", add = TRUE) > > tmp2 = lapply(s, function(x) { > nz_height[nz[x, ], ] > }) > > identical(tmp, tmp2) > #> [1] TRUE > > Created on 2018-08-27 by the [reprex package](http://reprex.tidyverse.org) > (v0.2.0). > > I've also pasted the reprex into the geocompr github tracker so the plots > can be seen and the code formatted: https://github.com/Robinlovela > ce/geocompr/issues/294 > > Hope this helps, > > Robin > > > On Mon, Aug 27, 2018 at 9:53 PM, Ariel Fuentesdi > wrote: > >> Hi, >> >> I want to do multiple selections of a point shapefile based on polygons on >> other layers, I can do this in a for loop, but I desire to do this in a >> function of the apply family. >> >> I named the point shapefile "nodes" and the polygons shapefile "zones". >> >> This is what I did: >> >> tmp <- list() >> for (i in 1:nrow(zones@data)) { >> tmp[[i]] <- nodes[subset(zones, ESTUDIO == i),] >> tmp >> } >> >> But I have no clue how to change it to the apply family, can you provide >> an example of this? >> >> Thanks in advance. >> >> Regards, >> Ariel Fuentes >> >> [[alternative HTML version deleted]] >> >> ___ >> R-sig-Geo mailing list >> R-sig-Geo@r-project.org >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo >> > > [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] Spatial Query (Selection) with Apply
Hi, I want to do multiple selections of a point shapefile based on polygons on other layers, I can do this in a for loop, but I desire to do this in a function of the apply family. I named the point shapefile "nodes" and the polygons shapefile "zones". This is what I did: tmp <- list() for (i in 1:nrow(zones@data)) { tmp[[i]] <- nodes[subset(zones, ESTUDIO == i),] tmp } But I have no clue how to change it to the apply family, can you provide an example of this? Thanks in advance. Regards, Ariel Fuentes [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] parallelize distance matrix
Hi, I want to parallelize the calculation of a distance matrix, I've tried but I wasn't succesful, this is what I did with a training data. My data set is: ll <- matrix(c(5, 6, 60, 60), ncol=2) And I use the function *spDistsN1* from the library *"sp"* to obtain a distance matrix with *apply*: apply(ll, 1, function(x) spDistsN1(as.matrix(ll), x, longlat = T)) But I want to do it with parallelization, so for that: library(parallel) ncore <- detectCores() cl <- makeCluster(ncore) clusterEvalQ(cl = cl, expr = c(library(sp))) parRapply(cl = cl, x = ll, FUN = function(x) spDistsN1(as.matrix(ll), x, longlat = T)) It shows the following error: *Error in checkForRemoteErrors(val) : 4 nodes produced errors; first error: object 'll' not found* How do I fix it? Regards, Ariel Fuentes [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] Export subsets of Spatial Points Data Frame to images
Frede, This is the reproducible example: date - seq(as.Date(2015/1/1), as.Date(2015/1/5), days) stops - c(aa, bb, cc, dd, ee) F_Up - c(1:10)[-seq(from = 4, to = 8, by = 1)] x - c(342328.0, 342374.5, 342413.2, 342348.6, 342394.6) y - c(6308284, 6308123, 6307915, 6307903, 6307915) df - data.frame(date, stops, F_Up, x, y) coordinates(df) - ~ x + y proj4string(obj = df) - CRS(+init=epsg:32719) df2 - split(df, f = df$date) for (i in df2) { jpeg(paste(df2[[1]],.jpg,sep=)) bubble(df[i], F_Up, col=c(#00ff0088, #00ff0088), main = df2 ) dev.off() } 2015-01-05 3:22 GMT-04:00 Frede Aakmann Tøgersen fr...@vestas.com: Hi Ariel Please provide a reproducible example. Now I have to guess what the SB object is because you didn't provide any details about that. I guess that the group_by() and summarise() are from the dplyr package. I guess that when you have imported the csv file you have an object SB containing columns Fecha, CodPar, x, and y. If so, your calls to the two dplyr functions are not correct. As first argument they need a data object, which is supposed to be of a tbl type like e.g. data frame. Why didn't you get an error when issuing e.g. group_by(Fecha, CodPar, x, y) instead of group_by(SB, Fecha, CodPar, x, y)? Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: R-sig-Geo [mailto:r-sig-geo-boun...@r-project.org] On Behalf Of Ariel Fuentesdi Sent: 5. januar 2015 04:48 To: r-sig-geo@r-project.org Subject: [R-sig-Geo] Export subsets of Spatial Points Data Frame to images I have a csv file, which I converted it to Spatial Points Data Frame. And I want to split the spatial data and export each map to a jpg file. I did the following: SB - read.csv(SB_040914.csv, header=TRUE, sep = ;) SB - SB %% group_by(Fecha, CodPar, x, y) %% summarise(mean(Sube),mean(Evade), mean(Baja)) SB - data.frame(SB) SB - SB[complete.cases(SB),] coordinates(SB) - ~ x + y proj4string(obj = SB) - CRS(+init=epsg:32719) SB - split(SB, f = SB$Fecha) The Split function, shows me the next warnings: **Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf** And for trying to export I did this: for (i in SB) { jpeg(paste(SB[[1]],.jpg,sep=)) bubble(SB[[i]], mean.Evade., col=c(#00ff0088, #00ff0088), main = Evasión ) dev.off() } **Which shows me the next error: Error in as.character.default(S4 object of class SpatialPointsDataFrame) : no method for coercing this S4 class to a vector 6 as.character.default(S4 object of class structure(SpatialPointsDataFrame, package = sp)) 5 as.character(S4 object of class structure(SpatialPointsDataFrame, package = sp)) 4 paste(SB[[1]], .jpg, sep = ) 3 gsub(%%, , s) 2 checkIntFormat(filename) 1 jpeg(paste(SB[[1]], .jpg, sep = ))** [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] Export subsets of Spatial Points Data Frame to images
I have a csv file, which I converted it to Spatial Points Data Frame. And I want to split the spatial data and export each map to a jpg file. I did the following: SB - read.csv(SB_040914.csv, header=TRUE, sep = ;) SB - SB %% group_by(Fecha, CodPar, x, y) %% summarise(mean(Sube),mean(Evade), mean(Baja)) SB - data.frame(SB) SB - SB[complete.cases(SB),] coordinates(SB) - ~ x + y proj4string(obj = SB) - CRS(+init=epsg:32719) SB - split(SB, f = SB$Fecha) The Split function, shows me the next warnings: **Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf** And for trying to export I did this: for (i in SB) { jpeg(paste(SB[[1]],.jpg,sep=)) bubble(SB[[i]], mean.Evade., col=c(#00ff0088, #00ff0088), main = Evasión ) dev.off() } **Which shows me the next error: Error in as.character.default(S4 object of class SpatialPointsDataFrame) : no method for coercing this S4 class to a vector 6 as.character.default(S4 object of class structure(SpatialPointsDataFrame, package = sp)) 5 as.character(S4 object of class structure(SpatialPointsDataFrame, package = sp)) 4 paste(SB[[1]], .jpg, sep = ) 3 gsub(%%, , s) 2 checkIntFormat(filename) 1 jpeg(paste(SB[[1]], .jpg, sep = ))** [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] Help on Connecting R with Grass!
I need help to connect R with Grass. In RStudio when I send the line: loc - initGRASS(C:/Program Files/R/R-3.1.0/bin/i386, home=tempdir(), override=TRUE) and it says: Error in system(paste(g.dirseps.exe -g, shQuote(Sys.getenv(WINGISRC))), : 'g.dirseps.exe' not found Guys, can you help me? [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] UTM coordinates
Hello, I'm a beginner on R, and I have a shapefile with the coordinates WGS84 UTM19, Hemisphere South. The EPGS code is: 32719. And when I plot the map (density estimation), it shows a some strange scale. Plus, I'd like on the x and y axes. It shows the UTM scale. So, my problem is how to set the reference system. I have the next code: library(graphics) library(rgdal) library(shapefiles) library(maptools) library(sp) library(spatstat) #packages setwd(C:/Users/Administrador/Desktop/ppp ejemplo) #set directory *UTM19S - +proj=utm +zone=19 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84=0,0,0* S - readShapePoints(ejem.shp, proj4string = CRS(UTM19S)) SP - as(S, SpatialPoints) P - as(SP, ppp) #read and transform shape summary(SP) r - bw.diggle(P) plot(Kest(P)) plot(envelope(P,Kest, nsim = 100)) plot(density(P, r), col = heat.colors(12)[12:1], main = , xlab = Easting, ylab = Northing, aspect = 1:2) rm(list=ls()) #remove everything Regards, Ariel Fuentes [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] UTM coordinates
Hi, I'm a beginner on R, and I have a shapefile with the coordinates WGS84 UTM 19, Hemisphere South. The EPGS code is: 32719. And when I plot the map (density estimation), it shows a some strange scale. Plus, I'd like on the x and y axes. It shows the UTM scale. So, my problem is how to set the reference system. I have the next code: library(graphics) library(rgdal) library(shapefiles) library(maptools) library(sp) library(spatstat) setwd(C:/Users/Administrador/Desktop/ppp ejemplo) UTM19S - +proj=utm +zone=19 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84=0,0,0 S - readShapePoints(ejem.shp, proj4string = CRS(UTM19S)) SP - as(S, SpatialPoints) P - as(SP, ppp) #read and transform shape summary(SP) r - bw.diggle(P) plot(Kest(P)) plot(envelope(P,Kest, nsim = 100)) plot(density(P, r), col = heat.colors(12)[12:1], main = , xlab = Easting, ylab = Northing, aspect = 1:2) rm(list=ls()) Regards, Ariel Fuentes [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] help: density map
Thank you, Why sigma = 10?, what function can I use for choose the best sigma?. And I looked the info about density.ppp and it says it use the Gaussian Kernel. But, if we look on wikipedia: http://en.wikipedia.org/wiki/Kernel_(statistics) , it says, there are more kernel function than the Gaussian Kernel, so my question is how do I know wether I have to use for example a Gaussian kernel or a Tricube Kernel. Regards, Ariel 2013/7/4 Juan Tomas Sayago Gomez juantomas.say...@gmail.com Hello, you can use the commands in spatstat library(spatstat) summary(swedishpines) plot(density(swedishpines, sigma = 10)) then check the help in the spatstat command density.ppp Also check the material in this course http://www.csiro.au/resources/pf16h Juan On Thu, Jul 4, 2013 at 11:32 AM, Ariel Fuentesdi ariel.fuente...@usach.cl wrote: Hello, I have raingauges as points and I want to make an heatmap with those points. So, I understand I need to do a kernel density estimation, but, there are different kernel functions. Thus, my questions is: how do I know which kernel function I need to apply to my data? Do I need to run a previous test first? I believe I can select the function using grass, but how can I do it with R? Do I have to use the KernSmooth package? How Can I map that ? Regards, Ariel [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo -- Juan Tomás Sayago Gómez Graduate Research Assistant West Virginia University - RRI 886 Chestnut Ridge Road, Room 520 P.O. Box 6825 Morgantown, WV 26506-6825 [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo