Skip to content

Commit

Permalink
Create a one main plotting for local hazard (#155)
Browse files Browse the repository at this point in the history
* Added plot local hazard

* added tornado visualization

* removed duplicated import

* Revert "removed duplicated import"

This reverts commit 2a88bde.

---------

Co-authored-by: Ya-Lan Yang <[email protected]>
  • Loading branch information
ywkim312 and ylyangtw committed Jan 31, 2024
1 parent 88561e2 commit d2c3939
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 10 deletions.
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)

0 comments on commit d2c3939

Please sign in to comment.