@@ -387,7 +387,7 @@ def cf_to_lines(ds: xr.Dataset):
387
387
It has the same dimension as the ``part_node_count`` or the coordinates variables, or
388
388
``'features'`` if those were not present in ``ds``.
389
389
"""
390
- from shapely import from_ragged_array , GeometryType
390
+ from shapely import GeometryType , from_ragged_array
391
391
392
392
# Shorthand for convenience
393
393
geo = ds .geometry_container .attrs
@@ -419,15 +419,19 @@ def cf_to_lines(ds: xr.Dataset):
419
419
part_node_count = xr .DataArray ([1 ] * xy .shape [0 ], dims = (feat_dim ,))
420
420
if feat_dim in ds .coords :
421
421
part_node_count = part_node_count .assign_coords ({feat_dim : ds [feat_dim ]})
422
-
422
+
423
423
geoms = lines
424
424
else :
425
425
part_node_count = ds [part_node_count_name ]
426
426
427
427
# get index of offset1 values that are edges for part_node_count
428
- offset2 = np .nonzero (np .isin (offset1 , np .insert (np .cumsum (part_node_count ), 0 , 0 )))[0 ]
429
- multilines = from_ragged_array (GeometryType .MULTILINESTRING , xy , offsets = (offset1 , offset2 ))
430
-
428
+ offset2 = np .nonzero (
429
+ np .isin (offset1 , np .insert (np .cumsum (part_node_count ), 0 , 0 ))
430
+ )[0 ]
431
+ multilines = from_ragged_array (
432
+ GeometryType .MULTILINESTRING , xy , offsets = (offset1 , offset2 )
433
+ )
434
+
431
435
# get items from lines or multilines depending on number of segments
432
436
geoms = np .where (np .diff (offset2 ) == 1 , lines [offset2 [:- 1 ]], multilines )
433
437
0 commit comments