Skip to content

Commit

Permalink
Fix issues with smoothed centerlines (#1469)
Browse files Browse the repository at this point in the history
* Fix issues with smoothed centerlines

* ups

* ups
  • Loading branch information
fmaussion committed Sep 8, 2022
1 parent b8b8abe commit 4d7c3bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/assets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ These data are tabular summary from available global datasets:

- https://cluster.klima.uni-bremen.de/~oggm/rgi/rgi62_stats.h5: the global RGI stripped from the geometries
- https://cluster.klima.uni-bremen.de/~oggm/g2ti/rgi62_itmix_df.h5: ice volumes from [Farinotti_etal_2019]_ in tabular form
- https://cluster.klima.uni-bremen.de/~oggm/geodetic_ref_mb/hugonnet_2021_ds_rgi60_pergla_rates_10_20_worldwide_filled.hdf: glacier geodetic mass balance data from `Hugonnet et al., 2021 <https://www.nature.com/articles/s41586-021-03436-z>_` corrected for RGI region 12 and missing glaciers, in tabular form
- https://cluster.klima.uni-bremen.de/~oggm/geodetic_ref_mb/hugonnet_2021_ds_rgi60_pergla_rates_10_20_worldwide_filled.hdf: glacier geodetic mass balance data from `Hugonnet et al., 2021 <https://www.nature.com/articles/s41586-021-03436-z>`_ corrected for RGI region 12 and missing glaciers, in tabular form
- `an example of OGGM output summary <https://cluster.klima.uni-bremen.de/~oggm/gdirs/oggm_v1.4/L3-L5_files/ERA5/elev_bands/qc3/pcp1.6/no_match/RGI62/b_040/L5/summary/>`_
from the pre-processed directories. Useful outputs include terminus position, topographical
variables, etc.
Expand Down
8 changes: 4 additions & 4 deletions oggm/tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def up_to_climate(reset=False, use_mp=None):
cfg.initialize()

# Use multiprocessing
if use_mp is None:
cfg.PARAMS['use_multiprocessing'] = use_multiprocessing()
else:
cfg.PARAMS['use_multiprocessing'] = use_mp
# if use_mp is None:
# cfg.PARAMS['use_multiprocessing'] = use_multiprocessing()
# else:
# cfg.PARAMS['use_multiprocessing'] = use_mp

# Working dir
cfg.PATHS['working_dir'] = _TEST_DIR
Expand Down
10 changes: 9 additions & 1 deletion oggm/utils/_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ def get_centerline_lonlat(gdir,

# Intersect with exterior geom
line = line.intersection(exterior)
if line.type == 'MultiLineString':
if line.type in ['MultiLineString', 'GeometryCollection']:
# Take the longest
lens = [il.length for il in line.geoms]
line = line.geoms[np.argmax(lens)]
Expand Down Expand Up @@ -874,6 +874,14 @@ def write_centerlines_to_shape(gdirs, *, path=True, to_tar=False,
odf = gpd.GeoDataFrame(itertools.chain.from_iterable(olist))
odf = odf.sort_values(by='RGIID')
odf.crs = to_crs
# Sanity checks to avoid bad surprises
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 4d7c3bc

Please sign in to comment.