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

revisit _points_as_gdf() #720

Merged
merged 4 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
- ci/38-BASE.yaml
- ci/39-BASE.yaml
- ci/310-BASE.yaml
- ci/310-DEV_shapely_dev.yaml
- ci/311-BARE.yaml
- ci/311-BASE.yaml
- ci/311-DEV.yaml
Expand Down
3 changes: 2 additions & 1 deletion ci/310-BASE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ dependencies:
- pytest-timeout
- pytest-xdist
# optional
- geopandas>=0.7.0
- geopandas>=0.12.0
- shapely>=2
23 changes: 0 additions & 23 deletions ci/310-DEV_shapely_dev.yaml

This file was deleted.

3 changes: 2 additions & 1 deletion ci/311-BASE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ dependencies:
- pytest-timeout
- pytest-xdist
# optional
- geopandas>=0.7.0
- geopandas>=0.12.0
- shapely>=2
# for docs build action (this env only)
- nbsphinx
- numpydoc
Expand Down
3 changes: 2 additions & 1 deletion ci/311-DEV.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ dependencies:
- pytest-timeout
- pytest-xdist
# optional
- geopandas>=0.9.0
- geopandas>=0.12.0
- shapely>=2
3 changes: 2 additions & 1 deletion ci/38-BASE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ dependencies:
- pytest-timeout
- pytest-xdist
# optional
- geopandas>=0.7.0
- geopandas>=0.12.0
- shapely>=2
3 changes: 2 additions & 1 deletion ci/39-BASE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ dependencies:
- pytest-timeout
- pytest-xdist
# optional
- geopandas>=0.7.0
- geopandas>=0.12.0
- shapely>=2
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
dependencies:
- python=3.10
- esda
- geopandas>=0.9.0
- geopandas>=0.12.0
- libspatialindex
- matplotlib
- matplotlib-scalebar
Expand All @@ -14,6 +14,7 @@ dependencies:
- rtree
- scipy>=1.0
- seaborn
- shapely>=2
- splot
- watermark
- pip
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ docs = [
"sphinx_bootstrap_theme",
]
plus = [
"geopandas>=0.7.0"
"geopandas>=0.12.0",
"shapely>=2",
]
tests = [
"pytest",
Expand Down
11 changes: 7 additions & 4 deletions spaghetti/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

try:
import geopandas
from shapely.geometry import LineString, Point
import shapely
from shapely.geometry import LineString
except ImportError:
msg = "geopandas/shapely not available. Some functionality will be disabled."
warn(msg)
Expand Down Expand Up @@ -718,9 +719,11 @@ def _points_as_gdf(
pts_dict = pp.snapped_coordinates

# instantiate geopandas.GeoDataFrame
pts_list = list(pts_dict.items())
points = geopandas.GeoDataFrame(pts_list, columns=[id_col, geom_col])
points.geometry = points[geom_col].map(lambda p: Point(p))
points = geopandas.GeoDataFrame(
pts_dict.keys(),
columns=[id_col],
geometry=shapely.points(numpy.asarray(list(pts_dict.values()))),
)

# additional columns
if not pp_name:
Expand Down