【问题标题】:Embedding Google Earth with Python用 Python 嵌入 Google 地球
【发布时间】:2019-01-21 16:15:41
【问题描述】:

有没有办法在 Python 桌面应用程序中嵌入 Google 地球或 Google 地球引擎?

到目前为止,我已经创建了一个包含经度/纬度数据的 kml 文件,可以手动将其放入 Google 地球专业版中以追踪 GPS 的路径。

我看到很多论坛帖子都将 Google 地球嵌入网页而不是桌面应用程序,所以我想知道是否可以这样做。

任何建议将不胜感激

【问题讨论】:

    标签: python google-earth google-earth-engine


    【解决方案1】:

    两秒谷歌搜索发现这个!因此,在回答您的问题时,是的,您可以在 Python 中使用 Google 地球

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

    【讨论】:

    • 他想将 GEE 嵌入到 Python 程序中,而不是编码环境中。
    • 我特别希望能够在 Python 应用程序的图形用户界面中查看 Google 地球。
    【解决方案2】:

    是的,您可以将 Google 地球引擎结果添加到桌面应用程序,只要它支持 WMS 切片图层、图像或图表。

    以下是一些示例,假设您已经完成了这些预处理步骤:

    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")
    

    获取 WMS 磁贴:

    # 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
    

    获取静态图片:

    # 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()
    

    显示时间序列图可能会涉及更多内容:

    # 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()
    

    可能有更有效的方法来获取结果并在应用程序中显示,但是,这可能是一种帮助您入门的方法。

    【讨论】:

    • {{z}}/{{x}}/{{y}} 不是 WMS 格式,WMS 处理边界框,而不是图块。此格式为 Web 地图切片服务 (WMTS)
    猜你喜欢
    • 2017-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多