Skip to content

Commit

Permalink
Merge pull request #96 from peterrrock2/master
Browse files Browse the repository at this point in the history
Fix issue in from_records not tracking crs correctly in intersections function
  • Loading branch information
peterrrock2 authored Feb 22, 2024
2 parents d71150f + e4b5d37 commit 7c45373
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions maup/intersections.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ def intersections(sources, targets, output_type="geoseries", area_cutoff=None):
)
]

df = GeoDataFrame.from_records(records, columns=["source", "target", "geometry"])
df = GeoDataFrame(records, columns=["source", "target", "geometry"], crs=sources.crs)
df = df.sort_values(by=["source", "target"]).reset_index(drop=True)
df.crs = sources.crs

geometries = df.set_index(["source", "target"]).geometry
geometries.sort_index(inplace=True)
geometries.crs = sources.crs

if area_cutoff is not None:
df = df[df.area > area_cutoff].reset_index(drop=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_intersections.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def manually_compute_intersections(sources, targets):
records.append((i, j, intersection))

expected = (
geopandas.GeoDataFrame.from_records(
geopandas.GeoDataFrame(
records, columns=["source", "target", "geometry"]
)
.set_index(["source", "target"])
Expand Down

0 comments on commit 7c45373

Please sign in to comment.