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

Keep up fixes #318

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
89 changes: 56 additions & 33 deletions notebooks/08_point_pattern_analysis.ipynb

Large diffs are not rendered by default.

17 changes: 5 additions & 12 deletions notebooks/08_point_pattern_analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.14.5
jupytext_version: 1.15.2
kernelspec:
display_name: Python 3 (ipykernel)
display_name: GDS-10.0
language: python
name: python3
name: gds
---

```python tags=["remove-cell"]
Expand Down Expand Up @@ -380,19 +380,12 @@ plt.legend();

We will cover three more bounding shapes, all of them rectangles or circles. First, two kinds of **minimum bounding rectangles**. They both are constructed as the tightest *rectangle* that can be drawn around the data that contains all of the points. One kind of minimum bounding rectangle can be drawn just by considering vertical and horizontal lines. However, diagonal lines can often be drawn to construct a rectangle with a smaller area. This means that the **minimum rotated rectangle** provides a tighter rectangular bound on the point pattern, but the rectangle is askew or rotated.

For the minimum rotated rectangle, we will use the `minimum_rotated_rectangle` function from the `pygeos` module, which constructs the minimum rotated rectangle for an input *multi-point* object. This means that we will need to collect our points together into a single multi-point object and then compute the rotated rectangle for that object.
For the minimum rotated rectangle, we will use the `minimum_rotated_rectangle` property from `geopandas`, which constructs the minimum rotated rectangle for an input *multi-point* object. This means that we will need to collect our points together into a single multi-point object and then compute the rotated rectangle for that object.

```python
from pygeos import minimum_rotated_rectangle, from_shapely, to_shapely

point_array = geopandas.points_from_xy(x=user.x, y=user.y)

min_rot_rect = minimum_rotated_rectangle(
from_shapely(
point_array.unary_union()
)
)
min_rot_rect = to_shapely(min_rot_rect)
min_rot_rect = point_array.unary_union().minimum_rotated_rectangle
```

And, for the minimum bounding rectangle without rotation, we will use the `minimum_bounding_rectangle` function from the `pointpats` package.
Expand Down
41 changes: 21 additions & 20 deletions notebooks/09_spatial_inequality.ipynb

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions notebooks/09_spatial_inequality.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.14.5
jupytext_version: 1.15.2
kernelspec:
display_name: Python 3 (ipykernel)
display_name: GDS-10.0
language: python
name: python3
name: gds
---

```python tags=["remove-cell"]
Expand Down Expand Up @@ -566,7 +566,8 @@ rmeans = (
by="Region_Name"
# Calculate mean by region and save only year columns
)
.mean()[years]
[years]
.mean()
)
```

Expand Down
126 changes: 63 additions & 63 deletions notebooks/10_clustering_and_regionalization.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions notebooks/10_clustering_and_regionalization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.14.5
jupytext_version: 1.15.2
kernelspec:
display_name: Python 3 (ipykernel)
display_name: GDS-10.0
language: python
name: python3
name: gds
---

```python tags=["remove-cell"]
Expand Down Expand Up @@ -974,7 +974,7 @@ results = pandas.DataFrame(
ami_scores, columns=["source", "target", "similarity"]
)
# and spread the dataframe out into a square
results.pivot("source", "target", "similarity")
results.pivot(columns="source", index="target", values="similarity")
```

From this, we can see that the K-means and Ward clusterings are the most self-similar, and the two regionalizations are slightly less similar to one another than the clusterings. The regionalizations are generally *not* very similar to the clusterings, as would be expected from our discussions above.
Expand Down