Skip to content

Harden fl_valley_confine() against XYZM streams from fwapg #36

@NewGraphEnvironment

Description

@NewGraphEnvironment

Problem

fl_valley_confine() calls sf::st_buffer() internally for the channel_buffer feature (R/fl_valley_confine.R:202). When streams are pulled from fwapg (e.g., via fresh::frs_stream_fetch()), the geometries are XYZM — route measures live in M. GEOS rejects XYZM:

Error: GEOS does not support XYM or XYZM geometries; use st_zm() to drop M

Every caller pulling from fwapg has to remember to sf::st_zm(streams) before calling fl_valley_confine(). Surfaced during #34 work; for now the data-raw script (data-raw/wsg_vignette_data.R) has an explicit sf::st_zm() workaround.

fl_dem_aoi() was hardened the same way during #34 (drops Z/M internally before sf::st_buffer()).

Proposed Solution

One-line fix in fl_valley_confine(): drop Z/M at the top of the function once streams is identified as sf. Mirrors what fl_dem_aoi() does.

if (inherits(streams, "sf")) {
  streams <- sf::st_zm(streams)
  ...
}

Also worth a test: pass an XYZM streams sf and assert it runs end-to-end without erroring.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions