There is a delay in loading data for every request in the function where_is_point.
...
land_shp = gpd.read_file('./data/natural_earth/land/ne_10m_land.shp')
...
water_shp = gpd.GeoDataFrame(pd.concat([gpd.read_file(shp) for shp in water_shp_files], ignore_index=True))
same for loading clima model data.
I suggest loading data during the initial phase, while the question is being typed or the coordinates are being selected. Here is an example, thanks to 4o:
import threading
import time
# Function to load data in the background
def load_data():
print("Loading data...")
time.sleep(5) # Simulate a delay in data loading
print("Data loading completed.")
# Start the data loading thread
data_thread = threading.Thread(target=load_data)
data_thread.start()
# Handle user input in the main thread
user_input = input("Please enter something: ")
print(f"User input: {user_input}")
# Ensure the data loading thread has completed
data_thread.join()
print("Main thread is done.")
Pre loading data make sense, as we need them for every call anyway. I would constantly try to optimise the loading sown the road, as there is nothing worse than a slow app :)
There is a delay in loading data for every request in the function where_is_point.
same for loading clima model data. I suggest loading data during the initial phase, while the question is being typed or the coordinates are being selected. Here is an example, thanks to 4o: