Skip to content

Commit

Permalink
Estimate Localized Economic Impacts in Tourism (#18)
Browse files Browse the repository at this point in the history
* Add visits notebook

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks"

This reverts commit aa824e3.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
g4brielvs and pre-commit-ci[bot] committed Apr 3, 2024
1 parent 1108d6d commit 3c39cbf
Show file tree
Hide file tree
Showing 10 changed files with 2,116 additions and 7 deletions.
3 changes: 3 additions & 0 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ parts:
- file: notebooks/spill/spillover-README
sections:
- file: notebooks/spill/spill.ipynb
- file: notebooks/mobility/README.md
sections:
- file: notebooks/mobility/visits.ipynb
- caption: Insights and Indicators
chapters:
- file: notebooks/indicators/conflict-and-trade.ipynb
Expand Down
21 changes: 21 additions & 0 deletions notebooks/mobility/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Economic Impacts in Tourism

Understanding where and when population movement occurs can help inform disaster response and public policy, especially during crises.

(mobility-data)=

## Data

The project team acquired longitudinal human mobility data. The mobility data was provided pro-bono by [Veraset](https://veraset.com) through the proposal [Measure Activity Levels on Tourism Sites Affected by the 2023 Red Sea Crisis](https://portal.datapartnership.org/readableproposal/565) via the [Development Data Partnership](https://datapartnership.org). During the project’s execution, [Veraset Movement](https://www.veraset.com/products/movement/)’s global daily data feed was ingested and processed through the [Mobility](https://docs.datapartnership.org/collections/mobility/README.html) pipeline maintained by the [Development Data Partnership](https://datapartnership.org/). For additional information, please refer to the [Mobility Documentation](https://docs.datapartnership.org/collections/mobility/README.html) accessible to all World Bank staff.

### Data Availability Statement

Data are available upon request through the [Development Data Partnership](https://datapartnership.org). Licensing and access information for all other datasets are included in the documentation.

## Methodology

```{caution}
The following working methodologies are a work in progress and awaiting review.
```

- [Estimating Activity Through Point of Interest Visits Using Mobility Data](./visits.ipynb)
1,968 changes: 1,968 additions & 0 deletions notebooks/mobility/visits.ipynb

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "red-sea-monitoring"
dynamic = ["version"]
description = ""
readme = { file = "README.md", content-type = "text/markdown" }
license = { file = "LICENSE" }
Expand All @@ -18,7 +19,12 @@ classifiers = [
"Topic :: Scientific/Engineering",
]
requires-python = ">=3.10"
dynamic = ["version"]
dependencies = [
"bokeh>3,<4",
"geopandas>=0.12",
"pandas",
"requests",
]

[project.optional-dependencies]
docs = [
Expand All @@ -36,7 +42,7 @@ ignore-regex = '^\s*"image\/png":\s.*'
ignore-words-list = "gost,"

[tool.hatch.build.targets.wheel]
packages = ["src/red-sea-monitoring"]
packages = ["src/red_sea_monitoring"]

[tool.hatch.version]
source = "vcs"
Expand Down
1 change: 0 additions & 1 deletion src/red-sea-monitoring/__init__.py

This file was deleted.

7 changes: 7 additions & 0 deletions src/red_sea_monitoring/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from importlib.metadata import version, PackageNotFoundError

try:
__version__ = version("red-sea-monitoring")
except PackageNotFoundError:
# package is not installed
pass
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
from bokeh.plotting import figure, ColumnDataSource
from bokeh.models import Legend, Span, Label
from bokeh.layouts import column
import datetime

from bokeh.core.validation import silence
from bokeh.core.validation.warnings import EMPTY_LAYOUT

from bokeh.layouts import column
from bokeh.models import HoverTool, Label, Legend, Span, Title
from bokeh.plotting import ColumnDataSource, figure

# Use the silence function to ignore the EMPTY_LAYOUT warning
silence(EMPTY_LAYOUT, True)

COLORS = [
"#4E79A7", # Blue
"#F28E2B", # Orange
"#E15759", # Red
"#76B7B2", # Teal
"#59A14F", # Green
"#EDC948", # Yellow
"#B07AA1", # Purple
"#FF9DA7", # Pink
"#9C755F", # Brown
"#BAB0AC", # Gray
"#7C7C7C", # Dark gray
"#6B4C9A", # Violet
"#D55E00", # Orange-red
"#CC61B0", # Magenta
"#0072B2", # Bright blue
"#329262", # Peacock green
"#9E5B5A", # Brick red
"#636363", # Medium gray
"#CD9C00", # Gold
"#5D69B1", # Medium blue
]


def get_bar_chart(
dataframe,
Expand Down Expand Up @@ -244,3 +268,84 @@ def _create_title_figure(text, width, height, font_size, font_style="bold"):
title_fig.axis.minor_tick_line_color = None
title_fig.outline_line_color = None
return title_fig


def plot_visits(data, title="Points of Interest Visit Trends"):
"""Plot number of visits to OSM points of interest"""

p = figure(
title=title,
width=750,
height=750,
x_axis_label="Date",
x_axis_type="datetime",
y_axis_label="Count of Devices",
y_axis_type="log",
y_range=(0.75, 5 * 10**3),
tools="pan,reset,save,box_select",
)
p.add_layout(Legend(), "right")
p.add_layout(
Title(
text="Count of Devices Identified with OpenStreetMap tag",
text_font_size="12pt",
text_font_style="italic",
),
"above",
)
p.add_layout(
Title(
text=f"Source: Veraset Movement. Creation date: {datetime.datetime.today().strftime('%d %B %Y')}. Feedback: [email protected].",
text_font_size="10pt",
text_font_style="italic",
),
"below",
)

# plot spans
p.renderers.extend(
[
Span(
location=datetime.datetime(2023, 10, 7),
dimension="height",
line_color="grey",
line_width=2,
line_dash=(4, 4),
),
Span(
location=datetime.datetime(2023, 11, 17),
dimension="height",
line_color="grey",
line_width=2,
line_dash=(4, 4),
),
]
)

# plot lines
for i, (col, color) in enumerate(zip(data.columns, COLORS)):
try:
r = p.line(
data.index,
data[col],
legend_label=col,
line_color=color,
line_width=2,
)
if i != 0:
r.muted = True
except KeyError:
pass

p.add_tools(
HoverTool(
tooltips=[("Date", "@x{%F}"), ("Count", "@y")],
formatters={"@x": "datetime"},
)
)

p.legend.location = "bottom_left"
p.legend.click_policy = "mute"
p.title.text_font_size = "16pt"
p.sizing_mode = "scale_both"
return p

0 comments on commit 3c39cbf

Please sign in to comment.