[R-sig-Geo] RgoogleMaps

Agustin Diez Castillo adiez at uv.es
Wed Mar 16 13:49:37 CET 2011


Following on  that I wish to download several single tiles. To do it I declare the tile extension I wish to download and adapting Robert's hint  I do the following
library(dismo)
#I need to load XML as well
library(XML)
library(maptools)
library(rgdal)
#declare the extent
e = extent(36.1195,36.1205,5.8725,5.8735)
#got the map, exp less than 1.0 zooms the result
r <- gmap(e, type="satellite", filename="mypath/mynumbered.gif", exp=1.0)
#check the result
plot(r)

The thing is that now I want to download several tiles getting the extent from a table that looks like that
       xmin     xmax     ymin     ymax num
1  36.09940 36.10340 5.671173 5.675173  10
2  36.19274 36.19674 5.665194 5.669194  15
3  36.17748 36.18148 5.820774 5.824774  19
4  36.19274 36.19674 5.665194 5.669194  43
5  36.09940 36.10340 5.671173 5.675173  44
6  36.17748 36.18148 5.820774 5.824774  46
so I want pass values from the table to 'extent' and get and numbered gif for each.
Any ideas?
Cheers
Agustin
sessionInfo
R version 2.11.1 Patched (2010-08-26 r52824)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US/en_US/en_US/C/en_US/en_US

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] maps_2.1-4      gpclib_1.5-1    maptools_0.7-38 lattice_0.18-8  foreign_0.8-40  XML_3.2-0       dismo_0.5-11    rJava_0.8-8     raster_1.7-29  
[10] rgdal_0.6-28    sp_0.9-76      

loaded via a namespace (and not attached):
[1] grid_2.11.1  tools_2.11.1



On Feb 3, 2011, at 9:12 PM, Robert Hijmans wrote:

> 
>> Dear all, 
>> I'm using the package RgoogleMaps to import google earth maps into R. The
>> object that is retrieved with function GetMap contains a number of slots
>> which I think can be used to translate the google picture into a geoTiff
>> to for example import into ArgGis. 
>> If anyone would have an example of how to accomplish that or what function
>> to use, I'd be very greatful. 
>> Best wishes, 
>> Erik Meesters 
>> 
> 
> Here is how you can get a single tile
> 
> library(dismo)
> library(maptools)
> library(rgdal)
> 
> # get a google map
> g <- gmap("Australia")
> plot(g)
> 
> # overlay boundaries, after projecting to Mercator
> data(wrld_simpl)
> w = wrld_simpl[wrld_simpl at data[,"NAME"] != "Antarctica", ]
> m = spTransform(w, projection(g, asText=F))
> plot(m, add=T)
> 
> # export to png
> filename <- 'oz.png'
> png(filename, width=ncol(g), height=nrow(g))
> par(mar=c(0,0,0,0))
> image(g, col=g at legend@colortable)
> dev.off()
> 
> # create 'world file' for georferencing png
> r <- raster(filename)
> extent(r) <- extent(g)
> hdr(r, 'worldfile', 'pgw')
> 
> # now open the file in ArcMap
> 
> -- 
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/RgoogleMaps-tp5989261p5990287.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 



More information about the R-sig-Geo mailing list