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

Create a one main plotting for local hazard #155

Merged
merged 5 commits into from
Jan 31, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- Plot method for local hazard [#153](https://github.com/IN-CORE/pyincore-viz/issues/153)

### Changed
- Refactor tornado and eq visualization due to hazard datasets added to model [#154](https://github.com/IN-CORE/pyincore-viz/issues/154)


## [1.9.0] - 2023-12-13
### Added
- Local hazard visualization [#143](https://github.com/IN-CORE/pyincore-viz/issues/143)
Expand Down
58 changes: 48 additions & 10 deletions pyincore_viz/geoutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,22 +1216,16 @@ def plot_local_hurricane(hur_dataset):
GeoUtil.plot_raster_file_with_legend(raster_file_path, title)

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

args:
dataset (obj): pyincore TornadoDataset object
tornado (obj): pyincore TornadoDataset object
id_field (str): id field name

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
GeoUtil.plot_map(tornado, id_field)

@staticmethod
def plot_multiple_vector_dataset(dataset_list):
Expand Down Expand Up @@ -1473,3 +1467,47 @@ def create_choro_data_from_pd(pd, key):
# # fill empty value as blank

return choro_data

@staticmethod
def plot_local_hazard(dataset):
"""Plot hazard dataset on the map

args:
dataset (obj): pyincore HazardDataset object

returns:
none
"""
hazard_type = dataset.hazard_type

if hazard_type.lower() == "earthquake":
if len(dataset.hazardDatasets) > 1:
for earthquake in dataset.hazardDatasets:
GeoUtil.plot_local_earthquake(earthquake)
else:
GeoUtil.plot_local_earthquake(dataset.hazardDatasets[0])
elif hazard_type.lower() == "tsunami":
if len(dataset.hazardDatasets) > 1:
for tsunami in dataset.hazardDatasets:
GeoUtil.plot_local_tsunami(tsunami)
else:
GeoUtil.plot_local_tsunami(dataset.hazardDataset[0])
elif hazard_type.lower() == "flood":
if len(dataset.hazardDatasets) > 1:
for flood in dataset.hazardDatasets:
GeoUtil.plot_local_flood(flood)
else:
GeoUtil.plot_local_flood(dataset.hazardDatasets[0])
elif hazard_type.lower() == "hurricane":
if len(dataset.hazardDatasets) > 1:
for hurricane in dataset.hazardDatasets:
GeoUtil.plot_local_hurricane(hurricane)
else:
GeoUtil.plot_local_hurricane(dataset.hazardDatasets[0])
elif hazard_type.lower() == "tornado":
id_field = dataset.EF_RATING_FIELD
if len(dataset.hazardDatasets) > 1:
for tornado in dataset.hazardDatasets:
GeoUtil.plot_local_tornado(tornado.dataset, id_field)
else:
GeoUtil.plot_local_tornado(dataset.hazardDatasets[0].dataset, id_field)
Loading