0
votes

Is there a way to embed Google Earth or Google Earth Engine in a Python desktop application?

As of now, I've created a kml file with longitude/latitude data that can be manually dropped into Google Earth Pro to trace the path of the GPS.

I've seen a lot of forum posts where Google Earth was embedded in webpages but not desktop applications so I was wondering if it could be done.

Any suggestions would be appreciated

2

2 Answers

1
votes

Yes, you can add Google Earth Engine results to a desktop application as long as it supports WMS tile layers, images, or graphs.

Here are some examples assuming your have already gone through these preprocesing steps:

import ee
ee.Initialize() # note: may have initialize with a service account within an application

# ee Image object of the Global SRTM data
img = ee.Image("USGS/SRTMGL1_003")

Get WMS tiles:

# get map tile id and token with specific color palette
# arguments into "getMapId" are the same as the JavaScript API "Map.addLayer"
result = img.getMapId({'min': 0, 'max': 3000})
url = "https://earthengine.googleapis.com/map/{mapid}/{{z}}/{{x}}/{{y}}?token={token}"
tiles = url.format(**result)
print(tiles)

 # visualize in your favorite application that supports WMS

Get static Image:

# Generate a URL that displays a static Image from Global DEM
url = img.getThumbUrl({'min':0, 'max':3000})

# create a file-like object from the url
import urllib2
f = urllib2.ulropen(url)

# Display the image using matplotlib
import matplotlib.pyplot as plt
result = plt.imread(f)
plt.imshow(result)
plt.show()

Displaying a time series graph may be a little more involved:

# get a collection with time series
collection = ee.ImageCollection('MODIS/006/MOD11A2')\
                 .filterDate('2016-01-01','2018-01-01')

# create a geometry of area to show time series
atl = ee.Geometry.Point([-84.3880,33.7490])

# get a time series over the point
result = collection.select('LST_Day_1km').getRegion(atl,1000).getInfo()

# turn the result into a pandas dataframe and manipulate results for plotting
import pandas as pd
df = pd.DataFrame(result[1:])
df.columns = result[0]

# convert epoch time to a format for pandas
dates = [pd.Timestamp(t*1000000) for t in df.time]
# make new pandas series object with scaled LST values
ts = pd.Series(np.array(df.LST_Day_1km)*0.02-273.15,index=dates,name='lst')
ts.index.name = 'Date'

# finally display results
ts.plot()

There are probably more efficient ways to get the results and display in an application, however, this may be a way to get you started.

0
votes

Two second google search found this! So in answer to your question, yes you can use Google Earth in Python

https://developers.google.com/earth-engine/python_install