Skip to content

Commit

Permalink
added tornado visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
ywkim312 committed Jan 5, 2024
1 parent 16a0835 commit 15883e7
Showing 1 changed file with 10 additions and 41 deletions.
51 changes: 10 additions & 41 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 @@ -1474,33 +1468,6 @@ def create_choro_data_from_pd(pd, key):

return choro_data

@staticmethod
def plot_hazard(dataset_id, client):
"""Plot hazard dataset on the map
args:
hazard_dataset (obj): pyincore HazardDataset object
dataset_id (str): ID of tornado hazard.
client (obj): pyincore service Client Object.
returns:
none
"""
metadata = DataService(client).get_dataset_metadata(dataset_id)
# metadata = DataService(client)
title = metadata['title']

dataset = Dataset.from_data_service(dataset_id, DataService(client))
raster_file_path = Path(dataset.local_file_path). \
joinpath(dataset.metadata['fileDescriptors'][0]['filename'])

GeoUtil.plot_raster_file_with_legend(raster_file_path, title)
hazard_type = hazard_dataset.hazard_type
title = "Hazard Type: " + hazard_type
raster_file_path = hazard_dataset.dataset.local_file_path

GeoUtil.plot_raster_file_with_legend(raster_file_path, title)

@staticmethod
def plot_local_hazard(dataset):
"""Plot hazard dataset on the map
Expand Down Expand Up @@ -1538,7 +1505,9 @@ def plot_local_hazard(dataset):
else:
GeoUtil.plot_local_hurricane(dataset.hazardDatasets[0])
elif hazard_type.lower() == "tornado":
print("The given hazard type is not supported because tornado is a shapefile.")
print("Please use plot_local_tornado method instead.")

title = "Hazard Type: " + hazard_type
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 15883e7

Please sign in to comment.