Skip to content

Commit

Permalink
Update change dataset function
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Sep 13, 2023
1 parent cbe193f commit 9d76428
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion pages/01_morocco.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,18 @@ def add_widgets(m):
)

def change_dataset(change):
default_geojson = f'{url}/datasets/{change.new}.geojson'
default_geojson = f'{url}/datasets/{change.new}_union.geojson'
m.layers = m.layers[:2]
m.controls = m.controls[:-1]
basename = os.path.basename(default_geojson)
tempdir = tempfile.gettempdir()
tmp_geojson = os.path.join(tempdir, basename)
if os.path.exists(tmp_geojson):
default_geojson = tmp_geojson
else:
leafmap.download_file(default_geojson, tmp_geojson, quiet=True)
m.add_geojson(default_geojson, layer_name='Footprint', zoom_to_layer=True)

image.options = get_catalogs(change.new)

dataset.observe(change_dataset, names='value')
Expand Down
10 changes: 9 additions & 1 deletion pages/02_libya.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,18 @@ def add_widgets(m):
)

def change_dataset(change):
default_geojson = f'{url}/datasets/{change.new}.geojson'
default_geojson = f'{url}/datasets/{change.new}_union.geojson'
m.layers = m.layers[:2]
m.controls = m.controls[:-1]
basename = os.path.basename(default_geojson)
tempdir = tempfile.gettempdir()
tmp_geojson = os.path.join(tempdir, basename)
if os.path.exists(tmp_geojson):
default_geojson = tmp_geojson
else:
leafmap.download_file(default_geojson, tmp_geojson, quiet=True)
m.add_geojson(default_geojson, layer_name='Footprint', zoom_to_layer=True)

image.options = get_catalogs(change.new)

dataset.observe(change_dataset, names='value')
Expand Down

0 comments on commit 9d76428

Please sign in to comment.