Re: [R-sig-Geo] shortestPath in a loop
Generically independent of R, A graph and the connectivity between points needs defined before a shortest path algorithm can be applied. If it assumes all points are connected, than the shortest path will be a straight line. What you are looking for is some sort of minimum spanning tree for the vertices. Eric On Thu, Jan 12, 2017 at 11:17 AM, marta azoreswrote: > Dear forum members, > > I would like to know how join several points with the aim to track a ship. > > After reading the documentation of some packages, I decided to use the > function shortestPath, but I only got the line between the first and the > last location of my points list. I need the complete survey, including also > the middle points. I try a loop to build the survey of the boats using > their locations, but It didn't work to me. > > > Any idea? > > Thanks in advance, > > Marta > > #script# it's also attached in a R.file: question loop2.R > ## > # > #raster# it's attached > azoTS1<- raster("C:/Users/Documents/azoTS1.tif")#wgs84 > # > #10 points# it's attached > boat <- read.table("C:/Users/Documents/10pontos.csv", header=TRUE, > sep=",", na.strings="NA", dec=".", strip.white=TRUE)# > head(boat) > > #raster to transitionlayer > trCostS4<- transition(1/azoTS1, mean, directions=4) > > # points to spatialpointsdataframe > x=boat$Long1 > y=boat$Lat1 > coords = cbind(x, y) > plot(coords) > sp = SpatialPoints(coords, proj4string=CRS("+proj=longlat +ellps=WGS84 > +datum=WGS84"), bbox = NULL) > sp > spdf=SpatialPointsDataFrame(sp,boat) > spdf > nrow(spdf) > plot(sp,axes=TRUE) > plot(spdf,add=TRUE, axes=TRUE) > > #shortestpath > > ## 1) this script only join the first point of the list and the last one, > and the points in the middle are not used. > CostpathSPdf <- shortestPath(trCostS4, spdf[1,], spdf[10,], > output="SpatialLines") > plot(CostpathSPdf,add=TRUE,axes=TRUE,col=2)#R_plot1.png (it's attached) > > ## 2) this script didn't work to me > > #first way from website: http://stackoverflow.com/ > questions/8127066/loop-or-sapply-function-for-multiple- > least-cost-analysis-in-r?answertab=active#tab-top > for(i in 1:nrow(spdf)) { > # Computation > Costpath <- shortestPath(trCostS4, spdf[i,], spdf[10,], > output="SpatialLines") > plot(Costpath) > > } > > #Error in validObject(.Object) : > #invalid class “SpatialLines” object: bbox should never contain infinite > values > > ___ > 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] Proj4string for NASA GPW v3 and Blue Marble world city light map?
They also have this page: http://sedac.ciesin.columbia.edu/data/set/gpw-v3-population-density/metadata On Thu, May 7, 2015 at 11:11 AM, Shaun Walbridge swalbri...@esri.com wrote: The specific projection information is contained within the raster datasets you download, in the related ASCII, Bil or GRID file. The metadata you see on that page is just a human readable representation of the data coverage, not intended to directly map to the full spatial reference. -- Shaun Walbridge GIS Developer On 5/7/15, 5:15 AM, Ziyu Ma paul.ziyu...@gmail.com wrote: Dear all, I was working with a project concerning human population, using data from the Population Density Grid, version 3. I have hard time understanding the spatial reference from this metadata page: http://sedac.ciesin.columbia.edu/data/set/gpw-v3-population-density/metada ta Can I translate this into a proj4string so that I can use it as a CRS in R? Also, just out of curiosity, what it the spatial reference for NASA's Blue Marble maps, like the famous world city light map? Can I also use a proj4string to describe it? Thank you very much. Cheers, Ma Ziyu Ma PhD Student Ecoinformatics Biodiversity, Department of Bioscience, Aarhus University Ny Munkegade 114, DK-8000 Aarhus C, Denmark [[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 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] generating large, non-repeating, color palates for world maps
200 colors seems extreme but Cubehelix will generate a ramp of that size. http://www.mrao.cam.ac.uk/~dag/CUBEHELIX/cubetry.html Eric -Original Message- From: r-sig-geo-boun...@r-project.org [mailto:r-sig-geo-boun...@r-project.org] On Behalf Of Damian Maddalena Sent: Wednesday, August 21, 2013 4:57 PM To: r-sig-geo@r-project.org Subject: [R-sig-Geo] generating large, non-repeating, color palates for world maps I am mapping regions generated using k-means clustering of ecological variables at a global scale. I need to generate large random color ramps (200 and 500 colors, for example) that do not repeat and implement them in such a way as to minimize adjacency of similar colors. I am generating my plots using spplot. Currently, I generate my color ramps using rainbow() with the number of categories in the spplot call as follows: #df is a sp object of all land surface at .5 degree resolution. I am mapping df$clusternum, a category that ranges from 1-n, where n is the number of clusters. n-200 spplot(df,zcol=clusternum,col.regions=rainbow(n,start=1/6,end=1),at=0:n) Is there a better way to do this where I can a.) randomize the colors and b.) minimize adjacency of similar colors? Thank you. -Damian ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo