0

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

MrUpsidown
  • 21,592
  • 15
  • 77
  • 131
azyssd
  • 21
  • 1
  • 6

2 Answers2

1

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.

Kel Markert
  • 807
  • 4
  • 12
  • `{{z}}/{{x}}/{{y}}` is not a WMS format, WMS deals with bounding boxes, not tiles. This format is Web Map Tile service (WMTS) – user27874 Jan 15 '21 at 10:07
0

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

Isaac
  • 784
  • 10
  • 23
  • He wants to embed the GEE into Python Program, not a coding environment. – Angus Aug 15 '18 at 03:42
  • Particularly I wanted to be able to view Google Earth within the graphical user interface of the Python application. – azyssd Aug 17 '18 at 17:47