Ask the community or our support engineers for answers to questions.
Hello everyone, I would like to download the fire data on GeoTiff format from Google Earth Engine. I am struggling to perform a download button. It gives me an error with " Invalid binary data format: <class ‘ee.image.Image’>". How can I make it work?Thank you! I would attach the error message and the code in the following:
import datetime
import ee
import streamlit as st
import geemap.foliumap as geemap
import os
import folium
Map = geemap.Map(locate_control=True)
col1, col2, col3, col4, col5= st.columns([1, 1, 1, 2, 2])
with col1:
longitude = st.number_input("Longitude", 102, 110, 105)
with col2:
latitude = st.number_input("Latitude", 10, 16, 12)
with col3:
zoom = st.number_input("Zoom", 0, 20, 7)
Map.setCenter(longitude, latitude, zoom)
with col4:
start = st.date_input("Start Date for Fire Forest: YYYY/MM/DD", datetime.date(2021, 1, 1))
with col5:
end = st.date_input("End Date for Fire Forest: YYYY/MM/DD", datetime.date(2021, 1, 3))
start_date = start.strftime("%Y-%m-%d")
end_date = end.strftime("%Y-%m-%d")
countries=ee.FeatureCollection("USDOS/LSIB_SIMPLE/2017")
country = countries.filter(ee.Filter.eq('country_na', 'Cambodia'));
esa = ee.ImageCollection("FIRMS").select('T21').filterBounds(country).filterDate(start_date,end_date).mosaic().clip(country)
esa_vis = {"min": 325,"max": 400,"palette": ['red', 'orange', 'yellow'],}
Map.addLayer(country,{}, name ="Cambodia Global Boundary")
Map.addLayer(esa, esa_vis, 'fire')
#To test export image
out_dir = os.path.join(os.path.expanduser('~'), 'Downloads')
filename = os.path.join(out_dir, 'fire.tiff')
# image = esa.clip(country).unmask()
date=(start_date,end_date)
geemap.ee_export_image(esa, filename=filename, scale=30, region=country, file_per_band=False)
st.download_button('Download fire Output (.tiff)',
esa,
file_name = "fire.tiff",
mime= "image/GeoTIFF")
#Add legend
labels = ['Fire Detection']
colors = ['#FF0000']
Map.add_legend(
title="Legend",
labels=labels,
colors=colors)
#Press on map and show lat and lng
Map.add_child(folium.LatLngPopup())
Map.to_streamlit(height=550)