[R-sig-Geo] Converting downloaded PNG images using RgoogleMaps to SpatialGridDataFrame class (proj4string?)
Tomislav Hengl
T.Hengl at uva.nl
Tue May 26 14:14:13 CEST 2009
Hi all,
Thanks to Markus Loecher and colleagues we can now easily obtain background maps from Google Earth
and use it for plotting/interpretation of spatial data.
This runs pretty smoothly (e.g. a map of the Netherlands):
> library(RgoogleMaps)
# obtain the API key and save into the home folder;
> MyMap <- GetMap.bbox(center=c(52.1551723,5.3872035), zoom=7, destfile="netherlands.png", maptype
="hybrid")
Read 1 item
[1] "http://maps.google.com/staticmap?center=52.1551723,5.3872035&zoom=7&size=640x640
+ &maptype=hybrid&format=png32&key=****&sensor=true"
trying URL 'http://maps.google.com/staticmap?center=52.1551723,5.3872035&zoom=7&size=640x640
+ &maptype=hybrid&format=png32&key=****=true'
Content type 'image/png' length 703541 bytes (687 Kb)
opened URL
downloaded 687 Kb
netherlands.png has GDAL driver PNG
and has 640 rows and 640 columns
> PlotOnStaticMap(MyMap, lat=52.1551723, lon=5.3872035)
But how to convert this image into a SpatialGridDataFrame to allow overlays, export to GIS formats
etc?
I am not even sure what the correct proj4string for this image is?
> str(MyMap) # this only gives coordinates of the centre
List of 4
$ : num 52.2
$ : num 5.39
$ : num 7
$ : num [1:640, 1:640] 187 60 66 1 66 202 151 1 214 220 ...
..- attr(*, "COL")= chr [1:256] "#88887C" "#887440" "#747838" "#0C1C20" ...
..- attr(*, "type")= chr "rgb"
> GDALinfo("netherlands.png")
# the coordinates are not embedded!
Thanks,
Tom Hengl
http://home.medewerker.uva.nl/t.hengl/
More information about the R-sig-Geo
mailing list