This is an example script on how to get data (loacations with altitude, colored image) from GoogleEarth into
a matlab surface.
Use this function as a script so comment the first line!
The code was tested with Matlab 2010a an GoogleEarth 6 (actual version) so download it or try your actual
Further help for GoogleEarthAPI you find under:
You need additional MCFE-files before script will run without errors:
ATTENTION: There is a heavy workaround to get an colored image from GE in line 70 (jmouseemu). Here it is
necessery to set the mousepointer in the actual GE-picture, so the x and y pixels must be in it! The
problem is, that it will not work in debug mode.
Depending of internetconnection speed you must play a little with the pause-times to get all needed data.
Programmed by Sven Koerner: koerner(underline)sven(add)gmx.de
Works great for me. I'm using Google Earth 5.2. I had to change the keyboard shortcut to copy the image to use CTRL+ALT+C...
I guess that is a limitation from google. I also tried to request a lot of values, however after a short time the anwser will last longer. So if you like to request more value, try to build in the pause-function of matlab, where you wait a second or two between the requested values. Normally it is not neccessary to reopen GE.
Otherwise you cqan try reopen GE from within Matlab:
I am having a problem when trying to loop the code over several locations without manually closing GE in between and when increasing the spatial resolution of the "meshgrid" (to f.ex. meshgrid(-1:(1/100):1, -1:(1/100):1). I'm not running the "get colored image" part of the code as I only need the X Y Z coordinates. For the first approx. 10 000 altitude values everything is quick and nice (0.001 s. pr fetched value), but after that it slows down to about 1.1 s. per fetched value. Clearing all Matlab variables dont help.
Have you experienced this kind of problems or have any suggestions for solutions? Could it be an alternative to close GE from within Matlab? If so, have you got any idea how to do this?
Thats the information that I nedeed.
In SetCameraParams means the 6 the speed of changing the view, where 6 is teleport.
The azimuth reference is here:
@Sven Körner: Thanks, I've other question, the azimut value should be changed?? and what represent the number 6 in this line: camPos.FocusPointAltitudeMode, camPos.Range,
camPos.Tilt, camPos.Azimuth, 6)??
go to your GE-Application and run it. Zoom to your region and modify the parameter for latidude and longitude as shown in the GE-Picture in the middle at the bottom in decimalgrad:
e.g. for Ecuador:
camPos.FocusPointLatitude = -1.831239;
camPos.FocusPointLongitude = -78.183406;
@Sven Körner: I was reviewing the scrip, now I understood first lines, I just have doubt with the Azimut, I not sure abourt this value, and I want to know what means the number six at the end of the following line:
camPos.Tilt, camPos.Azimuth, 6);
Is the first time that I'll use your script.Could you explain me the following lines, in order to I can use this in my region (Ecuador). What are the data that I should put here.
% teleport to location
camPos.FocusPointLatitude = 51.10719595658241;
camPos.FocusPointLongitude = 13.638689585783112;
camPos.FocusPointAltitude = 0.0;
camPos.FocusPointAltitudeMode = 'AbsoluteAltitudeGE';
camPos.Range = 11780.53549488341;
camPos.Tilt = 0;
camPos.Azimuth = 7; % 0 < Speed <5 --> Speed> 5: Teleport
ge_app.SetCameraParams(camPos.FocusPointLatitude, camPos.FocusPointLongitude, camPos.FocusPointAltitude, camPos.FocusPointAltitudeMode, camPos.Range,
camPos.Tilt, camPos.Azimuth, 6);
Thanks for your help. Now I know how to use your code now.
I need to run the code 2 times. The first time is that I need to use ctrl+alt+c and ctrl+shift+c to copy the map. (the first time will display a error on matlab window). After I run the code again, it is works.
@Sven Körner:Yea, same problem...waiting for fix it .......many thanks.....
@gong I have the same problem... my computer just accept keycombination "Ctrl+Alt+C".. I changed the command.. but it didnt work as well.. Did u try anything else??
@Sven Körner:Thank you for so patient. In my GE,I must press the keycombination "Ctrl+Alt+C" to take a snaphot of colored GE-image. The keycombination "Alt+C" doesn't work.
@GONG. When you run GoogleEarth normally - can you take a snaphot of colored GE-image with keycombination "ALT-C"? (Open GE, go anywhere, then press "ALT-C", then open a paint-program (e.g.) irfanview abd press crtl-V. Is there the image inside?
@Sven Körner: Thank you very much! But it could not solve the problem. The imdata is empty with char type. The problem is the same as before while I set the pause in line 74.
@GONG: set breakpoint in line 78. What is the type of imdata in Matlab-Workspace? If imdata is empty then modify the position of mousepointer in jmouseemu (line 72) and/ or set the pause in line 74 a littlbe bit longer. The given position must be anywhere in the google-earth picture on your monitor.
??? Error using ==> cq
First input must be a uint8 array.
Error in ==> rgb2ind at 91
[map,X] = cq(RGB,m);
Error in ==> ge_test1 at 78
[X2, map2] = rgb2ind(imdata, 256); % not more than 256 because of uint8 is necessary
Changed the link to the GoogleEarthAPI.
added help pdf
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.