pyrosm
pyrosm copied to clipboard
GEOSException: IllegalArgumentException: Argument must be Polygonal or LinearRing
Describe the bug
osm.get_buildings()
throws a pygeos.GEOSException with what appears to be a valid boundary geometry.
To Reproduce Steps to reproduce the behavior:
- Please see reprex at bottom of issue.
Expected behavior
osm.get_buildings
to return the building features for the provided bounding box geometry.
Environment:
- OS: mac-os
- Python package source: PyPi, pyrosm==0.6.1
- Versions of Python: 3.9.7
Additional context Add any other context about the problem here.
Test data and/or script/notebook
import pyrosm
fp = pyrosm.get_data("wales", update=False)
osm = pyrosm.OSM(fp)
cardiff = osm.get_boundaries(name="Cardiff")
cardiff.plot() # plots fine
bbox_geom = cardiff["geometry"].values[0]
type(bbox_geom) # shapely.geometry.polygon.Polygon
bbox_geom.is_valid # True
bbox_geom.is_empty # False
bbox_geom.is_closed # True
osm = pyrosm.OSM(fp, bounding_box=bbox_geom)
cardiff_builds = osm.get_buildings() # GEOS exception
Error:
GEOSException Traceback (most recent call last) Cell In [57], line 1 ----> 1 cardiff_builds = osm.get_buildings()
File /opt/anaconda3/envs/pyrosm/lib/python3.9/site-packages/pyrosm/pyrosm.py:265, in OSM.get_buildings(self, custom_filter, extra_attributes) 262 if self._nodes is None or self._way_records is None: 263 self._read_pbf() --> 265 gdf = get_building_data( 266 self._node_coordinates, 267 self._way_records, 268 self._relations, 269 tags_as_columns, 270 custom_filter, 271 self.bounding_box, 272 ) 274 # Do not keep node information unless specifically asked for 275 # (they are in a list, and can cause issues when saving the files) 276 if not self.keep_node_info and gdf is not None:
File /opt/anaconda3/envs/pyrosm/lib/python3.9/site-packages/pyrosm/buildings.py:47, in get_building_data(node_coordinates, way_records, relations, tags_as_columns, custom_filter, bounding_box) 44 return None 46 # Prepare GeoDataFrame ---> 47 gdf = prepare_geodataframe( 48 nodes, ... 225 return self._tree.dwithin(geometry, distance) 227 predicate = BinaryPredicate.get_value(predicate) --> 228 return self._tree.query_bulk(geometry, predicate)
GEOSException: IllegalArgumentException: Argument must be Polygonal or LinearRing