Skip to content

Commit

Permalink
add_lru_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Ines Elmufti authored and Ines Elmufti committed Feb 9, 2025
1 parent dbc3ca9 commit 0c03c84
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions instageo/apps/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import plotly.graph_objects as go
from dash import dcc, html
from dash.dependencies import Input, Output, State
from functools import lru_cache

import rasterio
import xarray as xr
import datashader as ds
Expand Down Expand Up @@ -43,6 +45,7 @@ def is_tile_in_viewport(tile_bounds: dict, viewport: dict, zoom: float) -> bool:
return not (tile_lat_max < lat_min or tile_lat_min > lat_max or
tile_lon_max < lon_min or tile_lon_min > lon_max)

@lru_cache(maxsize = 16)
def read_geotiff_to_xarray(filepath: str) -> tuple[xr.Dataset, CRS]:
"""Read GeoTIFF file into an xarray Dataset."""
xarr_dataset = xr.open_dataset(filepath).sel(band=1)
Expand Down

0 comments on commit 0c03c84

Please sign in to comment.