Code Monkey home page Code Monkey logo

Comments (3)

mpadge avatar mpadge commented on August 17, 2024

Yeah, it should be entirely possible in current state, and it'd be great to have an example in the vignette. Relations are stored either in osm_multipolygons or osm_multilinestrings, depending on their nature, but all relational data should be accessible from there. It'd be great if you could flesh out a nice example in the vignette, and report here on how it goes.

from osmdata.

mpadge avatar mpadge commented on August 17, 2024

You can't specifically search for relations, but nor can you specifically search for ways. Relations will simply be returned either as osm_multilinestrings or osm_multipolygons objects, and ways will be returned either as osm_lines or osm_polygons. Specifically getting relations just requires knowing, for example, what they're called. Here's your canonical example:

> q <- opq ('greater london uk')
> q1 <- add_feature (q, key="name", value="London.Cycle.Network.Route.9", exact=FALSE)
> osmdata_sf (q1)
Object of class 'osmdata' with:
                 $bbox : 51.2867602,-0.510375,51.6918741,0.3340155
        $overpass_call : The call submitted to the overpass API
            $timestamp : [ Mon Feb 27 16:55:41 2017 ]
           $osm_points : 'sf' Simple Features Collection with 1006 points
            $osm_lines : 'sf' Simple Features Collection with 246 linestrings
         $osm_polygons : 'sf' Simple Features Collection with 0 polygons
       $osm_multilines : 'sf' Simple Features Collection with 3 multilinestrings
    $osm_multipolygons : 'sf' Simple Features Collection with 0 multipolygons

The osm_lines contain all of the individual components which make up the route, while the osm_multilines are the actual relations. There are three of them because

> d <- osmdata_sf (q1)
> d1$osm_multilines$name
           1429834-(no role)             1429834-backward 
London Cycle Network Route 9 London Cycle Network Route 9 
             1429834-forward 
London Cycle Network Route 9 
Levels: London Cycle Network Route 9

... and that serves to support Edzer's thoughts on factors - without the factors that key information would be much harder to extract.

Now note this:

> q1 <- add_feature (q, key="name", value="London.Cycle.Network.route.9", exact=FALSE)
> osmdata_sf (q1)

... returns no data, because queries are still case sensitive even with exact=FALSE. The only way (at present) to make a truly case-insensitive query would be the standard overpass way:

> q1 <- add_feature (q, key="name", value="[Ll]ondon.[Cc]ycle.[Nn]etwork.[Rr]oute.9", 
                     exact=FALSE)

It'd be pretty easy to modify add_feature, so exact=FALSE also automatically added the relevant case options immediately following all spaces or periods, but note that that would remove any ability not to specify that, which is a bit of a negative side effect. What do you think?

from osmdata.

Robinlovelace avatar Robinlovelace commented on August 17, 2024

Will add that to the vignette - great work, can't wait to test this.

from osmdata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.