【发布时间】:2021-11-06 21:25:46
【问题描述】:
我正在探索 Google 地球引擎并尝试一些乐队操作。我使用两种方法计算了 NDVI,
- 使用 normalizedDifference 函数计算
- 使用正常波段操作进行计算。
但是我检查了两者返回的结果不同,为什么会这样?是不是和归一化差分函数中运行的操作一样。
这是我的代码。
#Import earth engine
import ee
# Trigger the authentication flow.
ee.Authenticate()
# Initialize the library.
ee.Initialize()
# Load two 5 year Landsat 7 composite
landsat2008 = ee.Image('LANDSAT/LE7_TOA_5YEAR/2008_2012')
# Compute NDVI using normalizedDifference
ndvi2008_m1 = landsat2008.normalizedDifference(["B4", 'B3'])
##NDVI using method2
diff=landsat2008.select('B4').subtract(landsat2008.select('B3'))
added=landsat2008.select('B4').add(landsat2008.select('B3'))
ndvi2008_m2 = diff.divide(added)
ndvi2008_m2==ndvi2008_m1
ndviParams = {'palette': ["#d73027", "#f46d43", "#fdae61", "#fee08b", "#d9ef8b", '#a6d96a', '#66bd63', '#1a9850']}
# Import the Folium library.
import folium
# Define a method for displaying Earth Engine image tiles to folium map.
def add_ee_layer(self, ee_image_object, vis_params, name):
map_id_dict = ee.Image(ee_image_object).getMapId(vis_params)
folium.raster_layers.TileLayer(
tiles = map_id_dict['tile_fetcher'].url_format,
attr = 'Map Data © <a href="https://earthengine.google.com/">Google Earth Engine</a>',
name = name,
overlay = True,
control = True
).add_to(self)
# Add EE drawing method to folium.
folium.Map.add_ee_layer = add_ee_layer
# Create a folium map object.
my_map = folium.Map(location=[9, 39], zoom_start = 2)
# Add the layer to the map object.
my_map.add_ee_layer(ndvi2008_m1, ndviParams, 'ndvi2008_m1')
my_map.add_ee_layer(ndvi2008_m2, ndviParams, 'ndvi2008_m2')
# Add a layer control panel to the map.
my_map.add_child(folium.LayerControl())
# Display the map.
display(my_map)
【问题讨论】:
标签: python google-earth-engine