nismod / open-gira

Open-data Global Infrastructure Risk/Resilience Analysis
https://nismod.github.io/open-gira/
MIT License
12 stars 3 forks source link

discard ways which are external to bbox but touch it #110

Closed thomas-fred closed 1 year ago

thomas-fred commented 1 year ago

When executing:

snakemake --cores 1 results/geoparquet/wales-latest_filter-road/raw/slice-6_edges.geoparquet

Workflow fails with:

2022-10-10 15:16:00,990 Converting results/slices/wales-latest_filter-road/slice-6.osm.pbf to .geoparquet.
/data/ouce-gri-jba/anaconda/envs/3dd73d90448108951cb5f5a7e8fe3984/lib/python3.9/site-packages/shapely/ops.py:567: ShapelyDeprecationWarning: GeometryTypeError will derive from ShapelyError and not TypeError or ValueError in Shapely 2.0.
  raise GeometryTypeError("Splitting %s geometry is not supported" % geom.type)
Traceback (most recent call last):
  File "/data/ouce-gri-jba/cenv0899/open-gira/.snakemake/scripts/tmpjbtppffn.osm_to_pq.py", line 239, in <module>
    h.apply_file(pbf_path, locations=True)
  File "/data/ouce-gri-jba/cenv0899/open-gira/.snakemake/scripts/tmpjbtppffn.osm_to_pq.py", line 134, in way
    segments = shape_ops.split(lines, shared_points)
  File "/data/ouce-gri-jba/anaconda/envs/3dd73d90448108951cb5f5a7e8fe3984/lib/python3.9/site-packages/shapely/ops.py", line 567, in split
    raise GeometryTypeError("Splitting %s geometry is not supported" % geom.type)
shapely.errors.GeometryTypeError: Splitting Point geometry is not supported

With the standard config.yml, here is a way in Brecon, wales-latest.osm.pbf that touches bbox of slice 6 like so:

   |
 __|_
 |   |
 |___|

It gets cut down from a LineString to a Point and the subsequent code fails.

Change is to check for Point and return in this case.