Saturday, June 20, 2009

Capturing Image From Google Earth


Please note that images from Google Earth may be copy right protected, so you should carefully check before using such images.

Easiest way is - if you have a stand alone Google Earth application, start it and move to the decired location. This can be done through opening a KML file. Then use a screen capture program to take the screen shot (Or just use PrintScrn button)

What if there is no stand alone application available? Google static maps comes to the rescue.
Just load the url in a browser it will load the curresponding image.

Let us see how to do this from Java .

Use a url string.

String url = "http://maps.google.com/staticmap?center=%LAT%,%LON%&zoom=%ZOOM%&size=512x512&maptype=satellite&key=%KEY%";
Replace the place holders
%LAT% - Latitude
%LON% - Longitude
%ZOOM% - Zoom level
%KEY% - Google map key

//
// Load the image from url.
url = new URL(uri);
BufferedImage bi = ImageIO.read(url);
ImageIO.write(bi,"PNG",new File("image.PNG"));









No comments:

Post a Comment