Skip to content

Commit

Permalink
Merge pull request #38 from MathewBiddle/update_inventory
Browse files Browse the repository at this point in the history
Update inventory
  • Loading branch information
MathewBiddle authored Sep 20, 2023
2 parents cd1ff86 + 9aec1b9 commit b24ff34
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 50 deletions.
2 changes: 1 addition & 1 deletion website/asset_inventory_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"githubrepo": "https://github.com/ioos/ioos_metrics/",
"google_analytics": "https://tag_url.google.co",
"google_analytics_code": "some-code",
"location_of_metrics": "https://erddap.ioos.us/erddap/tabledap/processed_asset_inventory.geoJson?&Year=%222022%22",
"location_of_metrics": "https://erddap.ioos.us/erddap/tabledap/processed_asset_inventory.geoJson",
"main_title": "IOOS Asset Inventory"
}
146 changes: 98 additions & 48 deletions website/create_asset_inventory_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ def write_templates(configs, org_config):


def map_plot(gdf):

m = folium.Map(tiles=None,
zoom_start=1,
)
m = folium.Map(
tiles=None,
zoom_start=1,
)

# Base Layers
tiles = "https://server.arcgisonline.com/ArcGIS/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}"
gh_repo = "https://github.com/ioos/ioos_metrics"
attr = f"Tiles &copy; Esri &mdash; Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri | <a href=\"{gh_repo}\" target=\"_blank\">{gh_repo}</a>"
attr = f'Tiles &copy; Esri &mdash; Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri | <a href="{gh_repo}" target="_blank">{gh_repo}</a>'
folium.raster_layers.TileLayer(
name="Ocean",
tiles=tiles,
attr=attr,
).add_to(m)

folium.raster_layers.TileLayer(
'cartodbdark_matter',
"cartodbdark_matter",
name="CartoDB",
).add_to(m)

Expand All @@ -68,43 +68,79 @@ def map_plot(gdf):
).add_to(m)

columns = gdf.columns.tolist()
columns.remove('geometry')

# for name, group in gdf.groupby(by='RA'):
# #group["ref"] = [f"<a href=\"{url}\" target=\"_blank\">{url}</a>" for url in group["url"]]
#
# folium.GeoJson(
# data=group,
# name="{}".format(name),
# marker=folium.CircleMarker(radius=1, color='black'),
# tooltip=folium.features.GeoJsonTooltip(
# fields=["RA","station_long_name"],
# # aliases=["",""],
# ),
# popup=folium.features.GeoJsonPopup(
# fields=["RA","Latitude","Longitude","station_long_name","Platform","Operational","station_deployment","RA_Funded","Raw_Vars"]#columns,
# #aliases=[""],
# ), show=True,
# ).add_to(m)
layer = folium.GeoJson(
data=gdf,
marker=folium.CircleMarker(radius=1, color="black"),
tooltip=folium.features.GeoJsonTooltip(
fields=["RA","station_long_name"],
),
popup=folium.features.GeoJsonPopup(
fields=["RA","latitude","longitude","station_long_name","Platform","Operational","station_deployment","RA_Funded","Raw_Vars"]
), show=True,
).add_to(m)
columns.remove("geometry")

colormap = pd.DataFrame(
{
"RA": [
"AOOS",
"PACIOOS",
"NANOOS",
"CENCOOS",
"SCCOOS",
"GLOS",
"NERACOOS",
"MARACOOS",
"SECOORA",
"GCOOS",
"CARICOOS",
],
"color": [
"red",
"blue",
"orange",
"black",
"SlateBlue",
"magenta",
"brown",
"purple",
"DarkSlateGrey",
"grey",
"green",
],
}
)
gdf = gdf.merge(colormap, how="left", on="RA")

search_group = folium.FeatureGroup(control=False, show=False)
search_group.add_to(m)

for name, group in gdf.groupby(by="RA"):
color = group["color"].unique()[0]

folium.GeoJson(
data=group,
name='<span style="color: {};"><b>{}</b></span>'.format(color, name),
marker=folium.CircleMarker(
radius=3, fillColor=color, color=color, fillOpacity=1
),
tooltip=folium.features.GeoJsonTooltip(
fields=["RA", "station_long_name"],
),
popup=folium.features.GeoJsonPopup(
fields=[
"RA",
"latitude",
"longitude",
"station_long_name",
"Platform",
"Operational",
"station_deployment",
"RA_Funded",
"Raw_Vars",
]
),
show=True,
).add_to(m).add_to(search_group)

Search(
layer=layer,
geom_type="Point",
placeholder="Search for an station",
collapsed=False,
search_label="station_long_name",
weight=3,
).add_to(m)
layer=search_group,
geom_type="Point",
placeholder="Search for an station",
collapsed=False,
search_label="station_long_name",
weight=3,
).add_to(m)

folium.LayerControl(collapsed=True).add_to(m)

Expand All @@ -119,21 +155,35 @@ def map_plot(gdf):


def main(org_config):
configs = dict()

file = org_config["location_of_metrics"]

file = file + "?&Year=max(Year)" # only grab most recent year

gdf = geopandas.read_file(file)

gdf['longitude'] = gdf.get_coordinates()['x']
gdf['latitude'] = gdf.get_coordinates()['y']
gdf["longitude"] = gdf.get_coordinates()["x"]
gdf["latitude"] = gdf.get_coordinates()["y"]

fig = map_plot(gdf)

columns = ["RA","station_long_name","latitude","longitude","Platform","Operational","station_deployment","RA_Funded","Raw_Vars"]

configs = {'table': gdf.to_html(table_id="table", index=False, columns=columns),
'figure': fig}
columns = [
"Year",
"RA",
"station_long_name",
"latitude",
"longitude",
"Platform",
"Operational",
"station_deployment",
"RA_Funded",
"Raw_Vars",
]

configs = {
"table": gdf.to_html(table_id="table", index=False, columns=columns),
"figure": fig,
}

write_templates(configs, org_config)

Expand Down
24 changes: 23 additions & 1 deletion website/templates/asset_inventory_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,31 @@ <h1 class="header_title">NOAA Integrated Ocean Observing System Metrics</h1>
</div>
<div class="divider"></div>
<div class="mywrap">
<h2 class="title">{{org_config.general_title}} <a href="https://erddap.ioos.us/erddap/search/index.html?page=1&itemsPerPage=1000&searchFor=asset+inventory">here</a>
<h2 class="title">{{org_config.general_title}} data on <a href="https://erddap.ioos.us/erddap/search/index.html?page=1&itemsPerPage=1000&searchFor=asset+inventory">ERDDAP</a>.
</h2>
</div>
<div>
<h3>A brief description of the IOOS Asset Inventory:</h3>
<ol type="1">
<li>The IOOS Asset Inventory contains stationary observing systems that are/were operating at any time during the
calendar year (Jan 1 - Dec 31).</li>
<li>Stationary observing systems that are exposed through one or more web services
implemented by the RA. The asset must be discoverable through the IOOS
Catalog. This includes:
<ul>
<li>Assets for operations or research purposes as long as the data are publicly
disseminated.</li>
<li>Non-RA-funded stations operated by a local data provider (i.e. the RA only
has a data management/stewardship role).</li>
<li>Any federal stations that are supported (funded, operated, and/or
maintained) by the RA (e.g. CDIP buoys, NERRS stations).</li>
</ul>
</li>
<li>More details about the Asset Inventory can be found in the IOOS Guidance on Performance Progress
Reports found on <a href="https://ioos.noaa.gov/about/funding-opportunities/">this website</a>.
</li>
</ol>
</div>
<div>
<p>Definitions for each field can be found at the <a href="#field-definitions">bottom of this page.</a></p>
</div>
Expand Down

0 comments on commit b24ff34

Please sign in to comment.