Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osmdata_sf and relation type=route #182

Closed
mgageo opened this issue Aug 6, 2019 · 3 comments
Closed

osmdata_sf and relation type=route #182

mgageo opened this issue Aug 6, 2019 · 3 comments

Comments

@mgageo
Copy link

mgageo commented Aug 6, 2019

Hello,

I analyse this query "(relation[network='TILT'][type=route][route=bus];>>;);out meta;" with osmdata_sf.
In osm_multilines, I have a variable "role", and some osm_id in double.
It's then there is lines like ' '
The type of a platform is not only node.
Is it an issue ?
Marc

@mpadge
Copy link
Member

mpadge commented Aug 7, 2019

Could you please provide some reproducible code to demonstrate the issue here, preferably through using the reprex package?

@mgageo
Copy link
Author

mgageo commented Aug 7, 2019

Before I try to use reprex, a script
there is only one relation but two multilines
library(osmdata) library(tidyverse) dsn <- 'https://framagit.org/mgageo/osmdata/raw/master/OSMDATA/osmdata.osm' fic <- tempfile('osmdata', fileext='.osm') download.file(dsn, fic, mode = "wb") print(sprintf("fic: %s size: %s", fic, file.size(fic))) q <- opq(bbox = c(51.1, 0.1, 51.2, 0.2)) osm.sf <- osmdata_sf(q, fic) %>% glimpse()

@mpadge
Copy link
Member

mpadge commented Oct 29, 2019

This is not an issue with the osmdata package. The following code demonstrates a reprex, and shows that everything is fine:

library (sf)
#> Linking to GEOS 3.7.2, GDAL 3.0.1, PROJ 6.1.0
library(osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright
dsn <- 'https://framagit.org/mgageo/osmdata/raw/master/OSMDATA/osmdata.osm'
fic <- tempfile('osmdata', fileext='.osm')
download.file(dsn, fic, mode = "wb")
print(sprintf("fic: %s size: %s", fic, file.size(fic)))
#> [1] "fic: /tmp/RtmpcWPBFD/osmdata772620bb7504.osm size: 143566"
q <- opq(bbox = c(51.1, 0.1, 51.2, 0.2))
osm.sf <- osmdata_sf(q, fic)
osm.sf$osm_multilines
#> Simple feature collection with 2 features and 11 fields
#> geometry type:  MULTILINESTRING
#> dimension:      XY
#> bbox:           xmin: -3.473424 ymin: 48.70417 xmax: -3.44802 ymax: 48.75911
#> epsg (SRID):    4326
#> proj4string:    +proj=longlat +datum=WGS84 +no_defs
#>                    osm_id                        name      role  colour
#> 2087687-(no role) 2087687 Bus A : Aéroport -> Hôpital (no role) #A50235
#> 2087687-platform  2087687 Bus A : Aéroport -> Hôpital  platform #A50235
#>                       from network ref route
#> 2087687-(no role) Aéroport    TILT   A   bus
#> 2087687-platform  Aéroport    TILT   A   bus
#>                                                         source      to
#> 2087687-(no role) Lannion-Trégor Agglomération;local knowledge Hôpital
#> 2087687-platform  Lannion-Trégor Agglomération;local knowledge Hôpital
#>                    type                       geometry
#> 2087687-(no role) route MULTILINESTRING ((-3.470799...
#> 2087687-platform  route MULTILINESTRING ((-3.461181...

# you've got 2 versions of the multiline in your result, presumably because
# you've manually specified your query - this behaviour is due to your query passed
# directly to overpass, and not the osmdata package.

# Use 'osmdata' to find that object directly:
x <- opq_osm_id ("2087687", type = "relation") %>%
    opq_string () %>%
    osmdata_sf ()
x$osm_multilines
#> Simple feature collection with 1 feature and 13 fields
#> geometry type:  MULTILINESTRING
#> dimension:      XY
#> bbox:           xmin: -3.473424 ymin: 48.70417 xmax: -3.44802 ymax: 48.75911
#> epsg (SRID):    4326
#> proj4string:    +proj=longlat +datum=WGS84 +no_defs
#>                    osm_id                        name      role  colour
#> 2087687-(no role) 2087687 Bus A : Aéroport -> Hôpital (no role) #F15A22
#>                       from network operator public_transport.version ref
#> 2087687-(no role) Aéroport    TILT     TILT                        2   A
#>                   route text_colour      to  type
#> 2087687-(no role)   bus     #FFFFFF Hôpital route
#>                                         geometry
#> 2087687-(no role) MULTILINESTRING ((-3.470799...
# ---> only one line

# or use the standard 'osmdata' interface to specify multiple key-value pairs:
x <- opq ("lannion france") %>%
    add_osm_feature (key = "network", value = "TILT") %>%
    add_osm_feature (key = "type", value = "route") %>%
    add_osm_feature (key = "route", value = "bus") %>%
    osmdata_sf ()
#> Error in curl::curl_fetch_memory(url, handle = handle): Timeout was reached: [nominatim.openstreetmap.org] Operation timed out after 10001 milliseconds with 0 out of 0 bytes received
x$osm_multilines
#> Simple feature collection with 1 feature and 13 fields
#> geometry type:  MULTILINESTRING
#> dimension:      XY
#> bbox:           xmin: -3.473424 ymin: 48.70417 xmax: -3.44802 ymax: 48.75911
#> epsg (SRID):    4326
#> proj4string:    +proj=longlat +datum=WGS84 +no_defs
#>                    osm_id                        name      role  colour
#> 2087687-(no role) 2087687 Bus A : Aéroport -> Hôpital (no role) #F15A22
#>                       from network operator public_transport.version ref
#> 2087687-(no role) Aéroport    TILT     TILT                        2   A
#>                   route text_colour      to  type
#> 2087687-(no role)   bus     #FFFFFF Hôpital route
#>                                         geometry
#> 2087687-(no role) MULTILINESTRING ((-3.470799...
# ---> again: only one line

Created on 2019-10-29 by the reprex package (v0.3.0)

@mpadge mpadge closed this as completed Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants