GIF created using cartoee.get_image_collection_gif not downloading once hosted online

Hello Community,

I am working on a GIS web tool using Geemap and want to add an animation feature in the webtool using cartoee.get_image_collection_gif. I am sticking to this since I may need to add animations regarding pollutants etc as well. The code runs smoothly and the animation is downloaded in my C: drive when the app is run from a local server. When the same app is hosted on streamlit.io from github (https://github.com/NotnirwaN/Streamlit/blob/master/streamlit_mainmenu.py) the app runs but does not download anything. Not sure if it has anything to do with one of the variables defined in it. Here is the said part of the code: cartoee.get_image_collection_gif(
ee_ic=F_collection,
out_dir=os.path.expanduser(“~/Downloads/timelapse”),
out_gif=“animation.gif”,
vis_params=vizParams,
region=region,
fps=2,
mp4=True,
grid_interval=(1.0, 1.0),
plot_title=“Title”,
date_format=‘YYYY-MM-dd’,
fig_size=(10, 8),
dpi_plot=100,
file_format=“png”,
north_arrow_dict=north_arrow_dict,
scale_bar_dict=scale_bar_dict,
verbose=True
)

Hi @Nirwan

On this line, could you try changing ~/Downloads/timelapse to a relative path Downloads/timelapse

Additionally, you can also try enabling enableStaticServing = true in the config file (Static file serving - Streamlit Docs).

Hope this helps!

Thank you for the response @dataprofessor ,
But neither of the two ideas seems to work. The code runs without an issue but no animation is downloaded

Hi @Nirwan

The file to be generated is a GIF

however the file format is specified here as PNG

After running this function, please verify that the intended GIF file has been generated. Once it is generated, you can use st.image() along with the Image method from PIL to visualize the image (See the Docs page for more info st.image - Streamlit Docs).

Hope this helps

Hi @dataprofessor ,
Sorry for the late response but the out_gif defines the format of the animation, while file_format downloads all the frames in a png format as well. As I mentioned earlier the code works perfectly fine when hosted on a local system but the animation doesn’t download when the same is hosted on GitHub.

Hi @Nirwan

Taking a look at your cloud version app (https://github.com/NotnirwaN/Streamlit/blob/master/streamlit_app_Cloud.py) it seems that you may not have provide the image as a binary format (currently it seems to be a string) and also not defining the mime parameter based on the following from your code:

st.download_button('Download Image List', "['"+lst.to_string(index=False).replace('\n',"' , '")+"']")

Please see the code snippet examples in the Docs page for how to make the adjustments:

st.download_button(‘Download Image List’, “['”+lst.to_string(index=False).replace(‘\n’,“’ , '”)+“']”)

Hope this helps!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.