[R-sig-Geo] RgoogleMaps

Robert Hijmans r.hijmans at gmail.com
Thu Feb 3 21:12:50 CET 2011


> 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.



More information about the R-sig-Geo mailing list