Skip to content

Possible bug in trim_osmdata() #253

Description

@Mashin6

There might be possibly a bug in how trim_osmdata() filters the data. It seems to be removing some objects that should be in the final dataset.

library(tidyverse)
library(sf)
#> Linking to GEOS 3.8.1, GDAL 3.2.1, PROJ 7.2.1
library(osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright

townsQ <- getbb("Southeastern Connecticut COG", featuretype = "boundary") %>% 
            opq()
townsQ$prefix <- '[out:xml][timeout:250];\n rel[name="Southeastern Connecticut COG"]; \n map_to_area->.a;(\n'
townsQ$features <- "[\"admin_level\"=\"8\"](area.a)"

towns <- townsQ %>% 
            osmdata_sf()

towns$osm_multipolygons |> ggplot() + geom_sf()

area <- getbb("Southeastern Connecticut COG", featuretype = "boundary", format_out = "polygon")
towns <- opq(bbox=area, timeout = 250) %>%
                add_osm_feature(key="admin_level", value="8") %>%
                osmdata_sf() %>%
                trim_osmdata(area)

towns$osm_multipolygons |> ggplot() + geom_sf()

packageVersion("osmdata")
#> [1] '0.1.8'
R.Version()$version.string
#> [1] "R version 4.1.1 (2021-08-10)"

Created on 2021-11-23 by the reprex package (v2.0.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions