[R-sig-eco] Export Google Maps Route to R and get kilometers coordinates

Levy, Yair yair.levy at mow.vlaanderen.be
Tue Sep 18 16:18:04 CEST 2012


Hi everyone,


May bei t would be more simple to use function:

identify(x = coordinates(coordinate object argument)[, 1], y = coordinates(coordinate object argument)[, 2], labels = Whatever)

You would only need to click next to the points of interest to make the coordinates appear.


Personally, I have a much more direct problem with package "RgoogleMaps". Most of the time the function GetMap sends an error message saying that the opening failed because the HTTP status was "403 forbidden". Sometimes, the very same commands do function. Any idea?

Best regards,





Yaïr Levy
Researcher
Flemish Government
Mobility and Public Works Department
Flanders' Hydraulics
Berchemlei 115 - 2140 Antwerpen
T. 03 224 61 89 - G. 0476 75 47 25 - F. 03 224 60 36
www.watlab.be 

Before printing, think about the environment!



-----Oorspronkelijk bericht-----
Van: r-sig-ecology-bounces at r-project.org [mailto:r-sig-ecology-bounces at r-project.org] Namens David Valentim Dias
Verzonden: mardi 18 septembre 2012 05:30
Aan: r-sig-ecology at r-project.org
Onderwerp: Re: [R-sig-eco] Export Google Maps Route to R and get kilometers coordinates

Hi Ribas,

You can try using package rgdal for directly loading but I recommend opening in another GIS software (like Quantum GIS free like R) and exporting in .shp. You can create a node in each KM plate so you can loop in R getting lat and long from each node.

2012/9/17 Augusto Ribas <ribas.aca at gmail.com>

> Hello. I have the following problem.
> I have some data of fauna hit on a road in Brasil. The Road ES-060.
>
> The data is something like this:
>
> > head(dados)
>   species km
> 1    Sp 6 27
> 2    Sp 6 21
> 3    Sp 1 44
> 4    Sp 2 47
> 5    Sp 5 39
> 6    Sp 5 20
>
> Each line represent one dead individual, and has a register of it 
> species and the kilometer of the road where it was found dead.
> I would like to do a plot of the deaths on a map, but i don't have the 
> coordinates (latitude and longitude) of where km 27 is, for example.
> But looking in google maps, i was able to find the road, and i know 
> some points of where the road is and its respective kilometer.
> Like this:
>
> > dados.pos
>         Lon       Lat            Local
> 1 -40.32012 -20.39675 Begin
> 2 -40.32477 -20.40193 KM 12
> 3 -40.39341 -20.54320 KM 30
> 4 -40.51056 -20.63095 KM 49
> 5 -40.55583 -20.73349 KM 66
> 6 -40.55161 -20.73921   End
>
> So Begin is around kilometer 11, end is around kilometer 67 (the range 
> of the data), and using google street view, i could see plaques on the 
> road telling me which kilometer some places is, so i can get some 
> coordinates and which kilometer it represent.
>
> So if i could import a route from google maps as a polygon, from end 
> to begin, i could try to determinate the coordinate of each kilometer.
> But i could not figure out how to export from google maps to R such 
> information.
> These points i saved on google maps as an kml file and loaded on R, 
> using getKMLcoordinates {maptools} function. But i'm stuck on how to 
> proceed to the the coordinates of each kilometer of the road.
> Does anyone have some idea how would i be able to do something like 
> this, if it is possible?
>
> Here goes some example data and a plot of the road and the points i 
> show
> above:
>
> library(RgoogleMaps)
>
> #example of how data is organized
> species<-paste("Sp",1:6)
> km<-seq(11,67,by=1)
>
> dados<-data.frame(species=NA,km=NA)
> for(i in 1:20) {
>   dados[i,1]<-sample(species,1)
>   dados[i,2]<-sample(km,1)
>   }
>
> head(dados)
>
> #some points coordinates that i know
> dados.pos<-structure(list(Lon = c(-40.3201206572012, 
> -40.3247698942156, -40.3934139596311, -40.5105609306218, 
> -40.5558289282114, -40.551610815962), Lat = c(-20.3967530595136, 
> -20.4019278830141, -20.5432001637965, -20.6309481844606, 
> -20.733489883797, -20.7392078853725), Local = c("Begin", "KM 12", "KM 
> 30", "KM 49", "KM 66", "End")), .Names = c("Lon", "Lat", "Local"), 
> row.names = c(NA, -6L), class = "data.frame")
>
> dados.pos
>
> #one plot of the road and the know points lat = dados.pos[c(1,6),2] 
> lon = dados.pos[c(1,6),1] center = c(lat=mean(lat), lon=mean(lon)) 
> zoom <- min(MaxZoom(range(lat), range(lon)))
>
> MyMap <- GetMap(center=center,zoom=zoom,maptype ="roadmap")
>
> PlotOnStaticMap(MyMap)
> TextOnStaticMap(MyMap,dados.pos[,2],dados.pos[,1],labels = 
> dados.pos[,3])
>
> Thanks for your attention.
> Best Wishes - Augusto Ribas
>
>
>
>
> --
> Grato
> Augusto C. A. Ribas
>
> Site Pessoal: http://augustoribas.heliohost.org
> Lattes: http://lattes.cnpq.br/7355685961127056
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>



--
Currículo: http://lattes.cnpq.br/7541377569511492

	[[alternative HTML version deleted]]



More information about the R-sig-ecology mailing list