I've fixed some of the merge errors in my previous PR #48 and I'm using a different branch so I opened a new PR and shut the old one. The following is the text from my last PR.
Some geometry was removed, even through it was partially in the perimeter such as in issue #46 where not all the river was visible because the last bit partially went out of the perimeter. This seemed to happen when a perimeter was provided and not a point or radius.
If geometries = geometries.intersection(perimeter) is changed to geometries = geometries.intersection(perimeter).buffer(0) it seems to have behaviour that would be expected.
Before change
After change
Also the buffer on the perimeter in get_geometries() and get_streets() was being performed on the longitude and latitude in degrees, not meters. It now projects it, buffers it in meters, then turns it back into degrees for the ox.geometries_from_polygon()/ox.graph_from_polygon().
The get_streets() function would have streets going over the perimeter when only used with a perimeter. This was because the intersection code wasn't running when only a perimeter was used, and the perimeter was still a GeoDataFrame because the line perimeter = unary_union(ox.project_gdf(perimeter).geometry) was missing.
There was also an issue with some roads disappearing like in the case of #53 . This is because highway is sometimes a list e.g.
['residential', 'footway']
Because this does not equal residential or footway it was being excluded when the highways are being assigned a width. It has been changed to check if the highway being widened is in any of the values, so 'residential' is in ['residential','footway']
I've fixed some of the merge errors in my previous PR #48 and I'm using a different branch so I opened a new PR and shut the old one. The following is the text from my last PR.
Some geometry was removed, even through it was partially in the perimeter such as in issue #46 where not all the river was visible because the last bit partially went out of the perimeter. This seemed to happen when a perimeter was provided and not a point or radius.
If
geometries = geometries.intersection(perimeter)
is changed togeometries = geometries.intersection(perimeter).buffer(0)
it seems to have behaviour that would be expected.Before change![image](https://user-images.githubusercontent.com/55803987/131852790-446a7f5c-0752-4a72-a190-d27f18698a81.png)
After change![image](https://user-images.githubusercontent.com/55803987/131852562-f1b531ba-abd8-41e0-8767-21f8b7cd1cbd.png)
Also the buffer on the perimeter in
get_geometries()
andget_streets()
was being performed on the longitude and latitude in degrees, not meters. It now projects it, buffers it in meters, then turns it back into degrees for theox.geometries_from_polygon()
/ox.graph_from_polygon()
.The
get_streets()
function would have streets going over the perimeter when only used with aperimeter
. This was because the intersection code wasn't running when only aperimeter
was used, and theperimeter
was still aGeoDataFrame
because the lineperimeter = unary_union(ox.project_gdf(perimeter).geometry)
was missing.There was also an issue with some roads disappearing like in the case of #53 . This is because
highway
is sometimes a list e.g.Because this does not equal
residential
orfootway
it was being excluded when the highways are being assigned a width. It has been changed to check if thehighway
being widened is in any of the values, so'residential'
is in['residential','footway']