def path_to_geom_dicts(path, skip_invalid=True):
interface = path.interface.datatype<EOL>if interface == '<STR_LIT>':<EOL><INDENT>return [row.to_dict() for _, row in path.data.iterrows()]<EOL><DEDENT>elif interface == '<STR_LIT>':<EOL><INDENT>return path.data<EOL><DEDENT>geoms = []<EOL>invalid = False<EOL>xdim, ydim = path.kdims<EOL>for i, path in enumerate(path.split(datatype='<STR_LIT>')):<EOL><INDENT>array = np.column_stack([path.pop(xdim.name), path.pop(ydim.name)])<EOL>splits = np.where(np.isnan(array[:, :<NUM_LIT:2>].astype('<STR_LIT:float>')).sum(axis=<NUM_LIT:1>))[<NUM_LIT:0>]<EOL>arrays = np.split(array, splits+<NUM_LIT:1>) if len(splits) else [array]<EOL>subpaths = []<EOL>for j, arr in enumerate(arrays):<EOL><INDENT>if j != (len(arrays)-<NUM_LIT:1>):<EOL><INDENT>arr = arr[:-<NUM_LIT:1>] <EOL><DEDENT>if len(arr) == <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>elif len(arr) == <NUM_LIT:1>:<EOL><INDENT>if skip_invalid:<EOL><INDENT>continue<EOL><DEDENT>g = Point(arr[<NUM_LIT:0>])<EOL>invalid = True<EOL><DEDENT>else:<EOL><INDENT>g = LineString(arr)<EOL><DEDENT>subpaths.append(g)<EOL><DEDENT>if invalid:<EOL><INDENT>geoms += [dict(path, geometry=sp) for sp in subpaths]<EOL>continue<EOL><DEDENT>elif len(subpaths) == <NUM_LIT:1>:<EOL><INDENT>geom = subpaths[<NUM_LIT:0>]<EOL><DEDENT>elif subpaths:<EOL><INDENT>geom = MultiLineString(subpaths)<EOL><DEDENT>path['<STR_LIT>'] = geom<EOL>geoms.append(path)<EOL><DEDENT>return geoms<EOL>
Converts a Path element into a list of geometry dictionaries,
preserving all value dimensions.