Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added local hazard visualization #147

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ tests/.incorepw

# incore download data or test data
tests/data/
tests/pyincore_viz/data/
cache_data/
original/

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- Local hazard visualization [#143](https://github.com/IN-CORE/pyincore-viz/issues/143)

### Changed
- Clean dependencies [#145](https://github.com/IN-CORE/pyincore-viz/issues/145)

Expand Down
93 changes: 93 additions & 0 deletions pyincore_viz/geoutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,99 @@ def get_ipyleaflet_heatmap(locations=None, radius=10, blur=10, max=1, name=""):

return heatmap

@staticmethod
def plot_local_earthquake(eq_dataset):
"""
Plot local earthquake data on the map
"""
demand_type = eq_dataset.demand_type
ywkim312 marked this conversation as resolved.
Show resolved Hide resolved
demand_units = eq_dataset.demand_units
hazard_type = eq_dataset.hazard_type
period = eq_dataset.period
title = "Demand Type: " + demand_type.upper() + ", Demand Units: " + demand_units + ", Period: " + \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an aesthetic suggestion, not necessary... but we can use .title() instead of .upper() for the title so the resulting title is not all in uppercase?

str(period) + ", Hazard Type: " + hazard_type
raster_file_path = eq_dataset.dataset.local_file_path

GeoUtil.plot_raster_file_with_legend(raster_file_path, title)

@staticmethod
def plot_local_tsunami(tsu_dataset):
"""
Plot local tsunami data on the map

args:
tsu_dataset (obj): pyincore TsunamiDataset object

returns:
none
"""
demand_type = tsu_dataset.demand_type
demand_units = tsu_dataset.demand_units
hazard_type = tsu_dataset.hazard_type
title = "Demand Type: " + demand_type.upper() + ", Demand Units: " + str(demand_units) + \
", Hazard Type: " + hazard_type
raster_file_path = tsu_dataset.dataset.local_file_path

GeoUtil.plot_raster_file_with_legend(raster_file_path, title)

@staticmethod
def plot_local_flood(flood_dataset):
"""
Plot local tsunami data on the map

args:
tsu_dataset (obj): pyincore TsunamiDataset object

returns:
none
"""
demand_type = flood_dataset.demand_type
demand_units = flood_dataset.demand_units
hazard_type = flood_dataset.hazard_type
title = "Demand Type: " + demand_type.upper() + ", Demand Units: " + str(demand_units) + \
", Hazard Type: " + hazard_type
raster_file_path = flood_dataset.dataset.local_file_path

GeoUtil.plot_raster_file_with_legend(raster_file_path, title)

@staticmethod
def plot_local_hurricane(hur_dataset):
"""
Plot local hurricane data on the map

args:
hur_dataset (obj): pyincore HurricaneDataset object

returns:
none
"""
demand_type = hur_dataset.demand_type
demand_units = hur_dataset.demand_units
hazard_type = hur_dataset.hazard_type
title = "Demand Type: " + demand_type.upper() + ", Demand Units: " + str(demand_units) + \
", Hazard Type: " + hazard_type
raster_file_path = hur_dataset.dataset.local_file_path

GeoUtil.plot_raster_file_with_legend(raster_file_path, title)

@staticmethod
def plot_local_tornado(tornado):
"""
Plot local tornado data on the map

args:
dataset (obj): pyincore TornadoDataset object

returns:
outmap (obj): ipyleaflet map object
"""
gdf = tornado.hazardDatasets[0].dataset.get_dataframe_from_shapefile()
id_field = tornado.EF_RATING_FIELD

outmap = GeoUtil.plot_gdf_map(gdf, id_field)

return outmap

@staticmethod
def plot_multiple_vector_dataset(dataset_list):
"""Plot multiple vector datasets on the same map.
Expand Down
Loading