get a google map image into matplotlib?

Hello list -

There is a recent matlab script floating around that downloads an image from google map and plots it in a matlab figure.

Can we do the same? I am sure we can (not sure we want, as Google has been somewhat difficult to people writing scripts to manipulate images from google maps).

My second question is: Has someone done it and does he/she want to share?

Thanks, Mark

I tried doing something similar to this a while ago. You can use gdal to point
to your tile of interest (e.g.,
http://khm3.google.com/kh?v=30&hl=en&t=tqsrsstr), which is a JPG (or PNG,
can't remember), and then plot the RGB using imshow(). Difficulty is how to
get the tile (it is documented somewhere, but I don't know how to do it).
This is some sample code that seems to work, and hopefully gets the ball
rolling :slight_smile:

import osgeo.gdal as gdal

g = gdal.Open ("http://khm3.google.com/kh?v=30&hl=en&t=tqsrsstr"\)
R = g.GetRasterBand(1).ReadAsArray()
G =g.GetRasterBand(2).ReadAsArray()
B =g.GetRasterBand(3).ReadAsArray()
RGB = np.array((256,256,3)) # Clearly, there must be a better way of doing
this!
RGB[:,:,0] = R
RGB[:,:,1] = G
RGB[:,:,2] = B

[...]

ยทยทยท

On Tuesday 05 August 2008 22:25:30 Mark Bakker wrote:

Can we do the same? I am sure we can (not sure we want, as Google has been
somewhat difficult to people writing scripts to manipulate images from
google maps).

--
NERC Centre for Terrestrial Carbon Dynamics,
Department of Geography, University College London
Gower Street, London WC1E 6BT, UK