Skip to content

Commit

Permalink
describe key-only queries in readme; closes #342
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Jul 17, 2024
1 parent 99a85f4 commit ae0cc48
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
Package: osmdata
Title: Import 'OpenStreetMap' Data as Simple Features or Spatial Objects
Version: 0.2.5.017
Version: 0.2.5.018
Authors@R: c(
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre")),
person("Bob", "Rudis", role = "aut"),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 10,7 @@

- Improved `get_bb(..., format_out = "sf_polygon")` to return full metadata
along with geometries (#338 thanks to @RegularnaMatrica)
- Mention key-only feature requests in README (#342 thanks to @joostschouppe)


0.2.5
Expand Down
15 changes: 13 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 157,29 @@ q <- opq ("portsmouth usa") %>%
add_osm_feature (key = "amenity", value = "restaurant") %>%
add_osm_feature (key = "amenity", value = "pub") # There are none of these
```

Features can also be requested by key only, in which case features with any
values for the specified key will be returned:
```{r key-val2}
q <- opq ("portsmouth usa") %>%
add_osm_feature (key = "amenity")
```
Such key-only queries can, however, translate into requesting very large data
sets, and should generally be avoided in favour of more precise key-value
specifications.

Negation can also be specified by pre-pending an exclamation mark so that the
following requests all amenities that are NOT labelled as restaurants and that
are not labelled as pubs:
```{r key-val2}
```{r key-val3}
q <- opq ("portsmouth usa") %>%
add_osm_feature (key = "amenity", value = "!restaurant") %>%
add_osm_feature (key = "amenity", value = "!pub") # There are a lot of these
```

Additional arguments allow for more refined matching, such as the following
request for all pubs with "irish" in the name:
```{r key-val3}
```{r key-val4}
q <- opq ("washington dc") %>%
add_osm_feature (key = "amenity", value = "pub") %>%
add_osm_feature (
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 60,8 @@ To load the package and check the version:
``` r
library (osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
```

``` r
packageVersion ("osmdata")
#> [1] '0.2.5.17'
#> [1] '0.2.5.16'
```

## Usage
Expand Down Expand Up @@ -133,9 130,6 @@ boxes:
b <- getbb ("bangalore", format_out = "polygon")
class (b)
#> [1] "matrix" "array"
```

``` r
head (b [[1]])
#> [1] 77.46005
```
Expand All @@ -158,6 152,18 @@ q <- opq ("portsmouth usa") %>%
add_osm_feature (key = "amenity", value = "pub") # There are none of these
```

Features can also be requested by key only, in which case features with
any values for the specified key will be returned:

``` r
q <- opq ("portsmouth usa") %>%
add_osm_feature (key = "amenity")
```

Such key-only queries can, however, translate into requesting very large
data sets, and should generally be avoided in favour of more precise
key-value specifications.

Negation can also be specified by pre-pending an exclamation mark so
that the following requests all amenities that are NOT labelled as
restaurants and that are not labelled as pubs:
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 11,7 @@
"codeRepository": "https://github.com/ropensci/osmdata/",
"issueTracker": "https://github.com/ropensci/osmdata/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.2.5.017",
"version": "0.2.5.018",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit ae0cc48

Please sign in to comment.