[R-sig-Geo] [FORGED] Create a Spatial Weight Matrix based on road distance
Dear Rolando, OSRM (Open Source Routing Machine) is a routing engine designed to run on OpenStreetMap data. There is a public instance of the engine, a demo server. This server has limitations (https://github.com/Project-OSRM/osrm-backend/wiki/Demo-server) like the number of requests/minute, or in your case the maximum size of a requested distance matrix (1, meaning 100 origines x 100 destinations). As they say :"he demo server usage is restricted to reasonable, non-commercial use-cases. We provide no guarantees wrt. uptime, latency, or data updates." A solution is to run your own instance of the server to get rid of these limitations. The prefered and simplest way to run an instance is to use a Docker container (https://github.com/Project-OSRM/osrm-backend#quick-start). When launching the Docker you'll have to set a large value for the --max-table-size parameter. Something like: docker run -t -i -p 5000:5000 -v "${PWD}:/data" osrm/osrm-backend osrm-routed --algorithm mld --max-table-size 900 /data/berlin-latest.osrm The osrm R package is an interface between R and OSRM. The default server used by the package is the OSRM demo server. But you can change the default server with : options(osrm.server = "http://0.0.0.0:5000/;, osrm.profile = "driving") Cheers, Timothée [[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 needed regarding package OSRM
Hi, osrmRoute() requests a route between 2 points, it can return a SpatialLinesDataFrame of the route with travel time (minutes) and travel distance (kilometers) in its data slot. osrmTable() requests a travel time matrix between a set of points, it can return a matrix in minutes between sources and destinations. The OSRM server cannot return a travel distance matrix (in km). Thus, the only solution I see for now is to use a loop (or apply or whatever) with osrmRoute() : devtools::install_github("rCarto/osrm") library(osrm) data("com") mat <- data.frame(i = character(), j = character (), time = numeric(), distance = numeric(), stringsAsFactors = F) k = 1 for (i in 1:2){ for (j in 6:8){ rout <- osrmRoute(src = com[i, c("comm_id", "lon","lat")], dst = com[j, c("comm_id", "lon","lat")], sp = T) mat[k, ] <- as.vector(rout@data[1,]) k <- k + 1 Sys.sleep(0.5) } } mat Note that I use the github version of the package. This version is adapted to last changes made on the demo server. Note also that I use a Sys.sleep(0.5)instruction in the loop to be gentle with the public OSRM demo server. If you use your own OSRM server, the CRAN version will work and the Sys.sleep() instruction is useless. Timothée Giraud ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] Making an hexagonal grid using spsample
Hi, I understand you find a solution via hextess from spatstat. However, this is a solution with spsample from sp. Actually, the cellsize argument of spsample defines the distance between the center of consecutives hexagons. So it is the length of 2 medians of one of the 6 equilateral triangles composing the hexagon. You can obtain the correct cellsize with: - the formula that calculates the median length for a given equilateral triangle length size, - the formula that calculate the area of an hexagon with a given side length. library(sp) data(meuse.grid) gridded(meuse.grid) = ~x+y plot(meuse.grid) # targeted area in meters A <- 1 # Corresponding cellsize : CS <- 2 * sqrt(A/((3*sqrt(3)/2))) * sqrt(3)/2 # hexagons HexPts <-spsample(x = meuse.grid, type = "hexagonal", cellsize = CS) HexPols <- HexPoints2SpatialPolygons(HexPts) plot(HexPols, add=TRUE) # check rgeos::gArea(HexPols, byid = T)[1:10] Since you asked me about getGridLayer via PM, this function of the cartography package uses spsample with its cellsize argument, maybe I should add a "targeted area" argument... ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] Geographic/Spatial Clustering - pyCluster for R?
Hello, You could have a look at the ClustGeo package : >ClustGeo: Clustering of Observations with Geographical Constraints >Functions which allow to integrate geographical constraints in Ward hierarchical clustering. Geographical maps of typologies obtained can be displayed with the use of shapefiles. ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] mapcircles help
Hi, As maintainer of the rCarto package, my advice would be to switch to the cartography package (of which I am also maintainer) and the propSymbolsLayer function in it. Examples and the vignette will help you through the mapping process. My turn to ask for an advice: rCarto was my first package and after a while we decide to build an other, better, thematic mapping package (i.e. the cartography package). cartography is much more R-ish in its use of the graphic device, offers more kinds of maps and has more options to customize the maps. So my question is: what should I do with rCarto? Remove it from CRAN? Deprecate all functions in it? Add a visible comment to incite users to switch to cartography? Any advice is greatly appreciated. Thanks, Tim Le 11/01/2016 10:56, Mistry, Krishan a écrit : Dear Sirs/Madame, I have a spatial polygons data frame and want to map proportional circles on it. I have tried using the map circles function in rCarto as seen below but it doesn't seem to work an continues to show errors. Do I need to convert the spatial polygons data frame to a shapefile if so I would I do this? mapCircles(shpFile, shpId, df, dfId, var, fixedNorm =ALSE, shareOfCircles = 0.02, radiusMax =.5, valueMax = max(df[, var], na.rm = TRUE), lgdRnd =, posLeg = "bottomleft", circleCol =#FD8D3C", baseCol = "#FFEDA0", title =ar, legend = var, author = "author", sources = "sources", scalebar =ALSE, scalebarSize, scalebarText, northArrow =ALSE, northArrowSize, width =ULL, height = NULL, txtCex = NULL) Any advice is greatly appreciated. Many Thanks Krish [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo