-
Notifications
You must be signed in to change notification settings - Fork 10
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
Issue #117: links_on_spatial_condition failing for large spatial area #126
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -600,13 +600,20 @@ def retain_n_connected_subgraphs(self, n: int, mode: str): | |
self.remove_mode_from_links(diff_links, mode) | ||
|
||
def _find_ids_on_geojson(self, gdf, how, geojson_input): | ||
shapely_input = spatial.read_geojson_to_shapely(geojson_input) | ||
return self._find_ids_on_shapely_geometry(gdf=gdf, how=how, shapely_input=shapely_input) | ||
if how == 'intersect': | ||
geojson_input_gdf = gpd.read_file(geojson_input) | ||
return list(gpd.sjoin(gdf, geojson_input_gdf, how='inner', op='intersects')['id']) | ||
elif how == 'within': | ||
shapely_input = spatial.read_geojson_to_shapely(geojson_input) | ||
return list(gdf[gdf.within(shapely_input)]['id']) | ||
else: | ||
raise NotImplementedError('Only `intersect` and `contain` options for `how` param.') | ||
|
||
def _find_ids_on_shapely_geometry(self, gdf, how, shapely_input): | ||
if how == 'intersect': | ||
return list(gdf[gdf.intersects(shapely_input)]['id']) | ||
if how == 'within': | ||
geojson_input_gdf = gpd.GeoDataFrame(index=[0], crs=gdf.crs, geometry=[shapely_input]) | ||
return list(gpd.sjoin(gdf, geojson_input_gdf, how='inner', op='intersects')['id']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
elif how == 'within': | ||
return list(gdf[gdf.within(shapely_input)]['id']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this is at risk too and should be updated similarly to intersection? |
||
else: | ||
raise NotImplementedError('Only `intersect` and `contain` options for `how` param.') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as far as I understand that's the only line you need to change, the rest of the code falls in place