Skip to content

Commit

Permalink
ups
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion committed Sep 8, 2022
1 parent 494a573 commit ef7189f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions oggm/utils/_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,11 +875,13 @@ def write_centerlines_to_shape(gdirs, *, path=True, to_tar=False,
odf = odf.sort_values(by='RGIID')
odf.crs = to_crs
# Sanity checks to avoid bad surprises
gtype = [g.type for g in odf.geometry]
if len(np.unique(gtype)) > 1:
errdf = odf.loc[gtype != 'LineString']
raise RuntimeError('Some geometries are not LineString at RGI Ids: '
f'{errdf.RGIID.values}')
gtype = np.array([g.type for g in odf.geometry])
if 'GeometryCollection' in gtype:
errdf = odf.loc[gtype == 'GeometryCollection']
if not np.all(errdf.length) == 0:
errdf = errdf.loc[errdf.length > 0]
raise RuntimeError('Some geometries are non-empty GeometryCollection '
f'at RGI Ids: {errdf.RGIID.values}')
_write_shape_to_disk(odf, path, to_tar=to_tar)


Expand Down

0 comments on commit ef7189f

Please sign in to comment.