Python 地球引擎将文本或标签添加到动画gif
我发现了Eartengine python模块,并且能够使用Sentinel2图像创建NDVI动画来创建一些地方的时间点,但我需要在动画中添加特定NDVI帧的日期Python 地球引擎将文本或标签添加到动画gif,python,google-earth-engine,Python,Google Earth Engine,我发现了Eartengine python模块,并且能够使用Sentinel2图像创建NDVI动画来创建一些地方的时间点,但我需要在动画中添加特定NDVI帧的日期 def do_place_ndvi(place, start_date, end_date): ee_place = ee.Geometry.Polygon([place], None, False) image_collection = ee.ImageCollection('COPERNICUS/S2_SR')
def do_place_ndvi(place, start_date, end_date):
ee_place = ee.Geometry.Polygon([place], None, False)
image_collection = ee.ImageCollection('COPERNICUS/S2_SR')\
.filterDate(ee.Date(start_date), ee.Date(end_date))\
.filterBounds(ee_place)\
.filter(ee.Filter.lte('CLOUDY_PIXEL_PERCENTAGE', 25))
ndvi_collection = image_collection.map(
lambda image: image.addBands(image.normalizedDifference(['B8', 'B4']).rename('NDVI'))
)
film_args = {
'dimensions': 300,
'region': ee_place,
'palette': ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718',
'74A901', '66A000', '529400', '3E8601', '207401', '056201',
'004C00', '023B01', '012E01', '011D01', '011301'],
'framesPerSecond': 1
}
print(ndvi_collection.select('NDVI').sort('system:time_start', True).getVideoThumbURL(film_args))
def get_places_from_kml(input_file):
places = {}
with open(input_file) as f:
tree = ET.parse(f)
root = tree.getroot()
for place in root.findall('.//Placemark'):
print(place)
tmp_name = place.find('name').text
tmp_coords = place.find('.//coordinates').text
tmp_coords = tmp_coords.replace('\n', ' ')
real_coords = []
for c in tmp_coords.split(' '):
s = c.strip().split(',')
if len(s) == 3:
real_coords.append([float(s[0]), float(s[1])])
places[tmp_name] = real_coords
return places
我确实通过一个简单的xml解析从kml文件中获得了位置。到目前为止,这个效果很好。但是,在我的ndvi动画gif中,我想添加每帧的日期
我看到了一些js库,就像这里指出的:
如何使用python API执行类似的操作?这不应该是我用datetime文本创建的FeatureCollection,然后在渲染之前与ImageCollection合并吗?我错过了什么明显的东西吗
谢谢