GEE随缘学习(一)

最近在摸索怎么把GEE服务应用于网站开发。。头大_(:3_ヽ)_

今天学习搭建GEE的python开发环境

这里附上大神的搭建过程-https://zhuanlan.zhihu.com/p/29186942

  • 中间有一步pip install pyCrypto,换了各种方法,但一直是安装失败,于是跳过这一步,但运行pip install earthengine-api会提示:No module named oauth2client.client。于是安装:
pip install oauth2client
  • 运行如下代码:
#!/usr/bin/env python

"""Filter an image collection by date and region to make a median composite.



See also: Clipped composite, which crops the output image

instead of filtering the input collection.

"""



import datetime

import ee

import ee.mapclient



ee.Initialize()

ee.mapclient.centerMap(-110, 40, 5)



# Filter to only include images within the colorado and utah boundaries.

polygon = ee.Geometry.Polygon([[

    [-109.05, 37.0], [-102.05, 37.0], [-102.05, 41.0],   # colorado

    [-109.05, 41.0], [-111.05, 41.0], [-111.05, 42.0],   # utah

    [-114.05, 42.0], [-114.05, 37.0], [-109.05, 37.0]]])



# Create a Landsat 7 composite for Spring of 2000, and filter by

# the bounds of the FeatureCollection.

collection = (ee.ImageCollection('LANDSAT/LE07/C01/T1')

              .filterDate(datetime.datetime(2000, 4, 1),

                          datetime.datetime(2000, 7, 1))

              .filterBounds(polygon))



# Select the median pixel.

image1 = collection.median()



# Select the red, green and blue bands.

image = image1.select('B3', 'B2', 'B1')

ee.mapclient.addToMap(image, {'gain': [1.4, 1.4, 1.1]})

会提示如下错误:No module named PIL(这里是缺少图像处理库无法加载地理图像)。于是安装:

pip install Pillow

再运行代码,最后得到如下结果:

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_21567935/article/details/83717153
今日推荐