Comments (16)
Thanks @agila5. I think you answered my question.
The reason why I mentioned st_read
was because osmextract::oe_read
depends on sf::st_read
to read the gpkg
, now I can also see the translation from .osm.pbf
to gpkg
happens in sf
, too. So I understand osmextract
a little more but still need to read more to understand better.
I hope I would not have to dive into GDAL to contribute to this package.
from trafficalmr.
The reason why I mentioned st_read was because osmextract::oe_read depends on sf::st_read to read the gpkg, now I can also see the translation from .osm.pbf to gpkg happens in sf, too. So I understand osmextract a little more but still need to read more to understand better.
👍 If you have any question feel free to ask!
from trafficalmr.
See here for how to get bumps etc: https://saferactive.github.io/traffiCalmr/reference/tc_get_osm.html
from trafficalmr.
@Robinlovelace and @mem48, two of you are involved in osmextract
:
- what should this function return? OSM objects like
osm_lines
? - why not embed this within
osmextract
?
The more I think about implementing this, the more I think it is suited to osmextract
with a generic key
parameter in even oe_get
. Please give me your quick thoughts and if we should do it here, I can get draft version on.
from trafficalmr.
This is the new website location: https://saferactive.github.io/trafficalmr/ answer soon...
from trafficalmr.
You can already do this with osmextract
, as shown below. I think a wrapper around oe_get()
, with default values for query and possibly functionality to combine LINESTRING and POINT layers, is the way forward to keep osmextract
general and with few domain-specific functions.
remotes::install_github("itsleeds/osmextract")
#> Using github PAT from envvar GITHUB_PAT
#> Skipping install of 'osmextract' from a github remote, the SHA1 (dac00af6) has not changed since last install.
#> Use `force = TRUE` to force installation
library(osmextract)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright.
#> Any product made from OpenStreetMap must cite OSM as the data source.
#> Geofabrik data are taken from https://download.geofabrik.de/
#> For usage details of bbbike data see https://download.bbbike.org/osm/
q = "SELECT * FROM 'lines' WHERE traffic_calming = 'cushion'"
p = "Isle of Wight"
e = c("traffic_calming", "maxspeed")
tc_lines = oe_get(place = p, extra_tags = e, query = q)
tc_lines
#> Simple feature collection with 4 features and 11 fields
#> geometry type: LINESTRING
#> dimension: XY
#> bbox: xmin: -1.540824 ymin: 50.67916 xmax: -1.305745 ymax: 50.70099
#> geographic CRS: WGS 84
#> osm_id name highway waterway aerialway barrier man_made
#> 1 1736381 Purdy Road residential <NA> <NA> <NA> <NA>
#> 2 117932154 Weston Road residential <NA> <NA> <NA> <NA>
#> 3 165544924 Sylvan Drive tertiary <NA> <NA> <NA> <NA>
#> 4 165545956 Fieldfare Road residential <NA> <NA> <NA> <NA>
#> traffic_calming maxspeed z_order
#> 1 cushion <NA> 3
#> 2 cushion 30 mph 3
#> 3 cushion <NA> 4
#> 4 cushion 20 mph 3
#> other_tags
#> 1 "lit"=>"yes","surface"=>"asphalt","prow_ref"=>"N54","designation"=>"public_footpath"
#> 2 "lit"=>"yes","surface"=>"asphalt"
#> 3 "lit"=>"yes","image"=>"80n:dsc03059.jpg","surface"=>"asphalt"
#> 4 "lit"=>"yes","surface"=>"asphalt"
#> geometry
#> 1 LINESTRING (-1.313662 50.69...
#> 2 LINESTRING (-1.540536 50.68...
#> 3 LINESTRING (-1.30621 50.700...
#> 4 LINESTRING (-1.315992 50.69...
nrow(tc_lines)
#> [1] 4
tc_points = oe_get(place = p, layer = "points", extra_tags = e, query = q)
tc_points # fail: should be linestring
#> Simple feature collection with 4 features and 11 fields
#> geometry type: LINESTRING
#> dimension: XY
#> bbox: xmin: -1.540824 ymin: 50.67916 xmax: -1.305745 ymax: 50.70099
#> geographic CRS: WGS 84
#> osm_id name highway waterway aerialway barrier man_made
#> 1 1736381 Purdy Road residential <NA> <NA> <NA> <NA>
#> 2 117932154 Weston Road residential <NA> <NA> <NA> <NA>
#> 3 165544924 Sylvan Drive tertiary <NA> <NA> <NA> <NA>
#> 4 165545956 Fieldfare Road residential <NA> <NA> <NA> <NA>
#> traffic_calming maxspeed z_order
#> 1 cushion <NA> 3
#> 2 cushion 30 mph 3
#> 3 cushion <NA> 4
#> 4 cushion 20 mph 3
#> other_tags
#> 1 "lit"=>"yes","surface"=>"asphalt","prow_ref"=>"N54","designation"=>"public_footpath"
#> 2 "lit"=>"yes","surface"=>"asphalt"
#> 3 "lit"=>"yes","image"=>"80n:dsc03059.jpg","surface"=>"asphalt"
#> 4 "lit"=>"yes","surface"=>"asphalt"
#> geometry
#> 1 LINESTRING (-1.313662 50.69...
#> 2 LINESTRING (-1.540536 50.68...
#> 3 LINESTRING (-1.30621 50.700...
#> 4 LINESTRING (-1.315992 50.69...
all_points = oe_get(place = p, layer = "points")
summary({sel = all_points$traffic_calming == "cushion"})
#> Mode FALSE TRUE NA's
#> logical 47 8 58916
tc_points = all_points[sel %in% TRUE, ]
nrow(tc_points)
#> [1] 8
plot(tc_points$geometry)
plot(tc_lines$geometry)
Created on 2020-09-04 by the reprex package (v0.3.0)
from trafficalmr.
wrapper around oe_get(), with default values for query and possibly functionality to combine LINESTRING and POINT layers
keep osmextract general
Agree.
From your example osmextract
does not do multi "layers". Alright, I can get a draft in with ...
passing everything else into osmextract
.
from trafficalmr.
Great, FYI this issue made me discover an upstream issue in osmextract
. Any ideas on that welcome, let us know here if you fancy giving it a bash: ropensci/osmextract#122 - reminds me of tricky stats19
issues!
Heads-up @agila5
from trafficalmr.
Hello from Italy! At the moment the following should work:
# update pkgs
remotes::install_github("itsleeds/osmextract")
#> Skipping install of 'osmextract' from a github remote, the SHA1 (dac00af6) has not changed since last install.
#> Use `force = TRUE` to force installation
# load pkgs
library(osmextract)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright.
#> Any product made from OpenStreetMap must cite OSM as the data source.
#> Geofabrik data are taken from https://download.geofabrik.de/
#> For usage details of bbbike data see https://download.bbbike.org/osm/
# Build args
q = "SELECT * FROM 'lines' WHERE traffic_calming = 'cushion'"
p = "Isle of Wight"
e = c("traffic_calming", "maxspeed")
tc_lines = oe_get(place = p, extra_tags = e, query = q)
sf::st_geometry_type(tc_lines)
#> [1] LINESTRING LINESTRING LINESTRING LINESTRING
#> 18 Levels: GEOMETRY POINT LINESTRING POLYGON MULTIPOINT ... TRIANGLE
q = "SELECT * FROM 'points' WHERE traffic_calming = 'cushion'"
tc_points = oe_get(place = p, layer = "points", extra_tags = e, query = q)
sf::st_geometry_type(tc_points)
#> [1] POINT POINT POINT POINT POINT POINT POINT POINT
#> 18 Levels: GEOMETRY POINT LINESTRING POLYGON MULTIPOINT ... TRIANGLE
mapview::mapview(tc_points, zcol = "traffic_calming")
Created on 2020-09-04 by the reprex package (v0.3.0)
Happy to discuss in the osmextract repo for a more user-friendly solution.
from trafficalmr.
Better say "Hi" to @agila5 :)
Right, I am not quite sure why I need e
in the functions above and in my draft of tc_traffic_calming
which is just committed. Would love to get your explanations on it or I will be reading st_read
more thoroughly as I work through this.
from trafficalmr.
I'm not sure what you mean by 'I am not quite sure why I need e in the functions above and in my draft of tc_traffic_calming which is just committed' but I will try to answer.
traffic_calming
is not one of the default tags that are explicitly added to an OSM file by GDAL (they are documented here, lines 33, 53 and so on), so you cannot create a query related to traffic_calming
field unless you specifically add that new field to the fields that are extracted by GDAL. Does it answer your question? I don't understand how or why it's related to st_read.
from trafficalmr.
Can we move on from here? Close? Improve? Rewrite?
from trafficalmr.
Can you paste an example with the latest version, starting with remotes::install_github("saferactive/trafficalmr")
that gets traffic calming interventions in a part of the world you know well? Just want to check the lines and points are in there. Then we can close it, just want to be sure. Sorry for being pedantic, I think this is fixed just want to be 100% sure.
from trafficalmr.
Could also be from IoW starting with
remotes::install_github("itsleeds/osmextract")
p = "Isle of Wight"
e = c("traffic_calming", "maxspeed")
tc_lines = ...
tc_lines # print the result
plot(tc_lines)
from trafficalmr.
Totally missed these coments @Robinlovelace.
library(trafficalmr)
pl = tc_traffic_calming(c(-1,53))
#> although coordinates are longitude/latitude, st_intersects assumes that they are planar
#> Warning in st_centroid.sfc(sf::st_geometry(matched_zones)): st_centroid does not
#> give correct centroids for longitude/latitude data
#> although coordinates are longitude/latitude, st_nearest_points assumes that they are planar
#> although coordinates are longitude/latitude, st_intersects assumes that they are planar
#> Warning in st_centroid.sfc(sf::st_geometry(matched_zones)): st_centroid does not
#> give correct centroids for longitude/latitude data
#> although coordinates are longitude/latitude, st_nearest_points assumes that they are planar
nrow(pl)
#> [1] 2340
Created on 2020-09-10 by the reprex package (v0.3.0)
from trafficalmr.
That is awesome Layik, looks great.
from trafficalmr.
Related Issues (20)
- Allow the user to specify their own recoding options in `tc_recode_vehicles()` HOT 3
- Markdown not working in package website HOT 1
- Improve readme
- Revert use of pkgdown branch
- Function to auto download cycleways HOT 8
- Function to recode maxspeed values from OSM HOT 4
- Function to recode highway tags in OSM
- Function to bulk download road traffic stats data HOT 3
- Compare maxspeed in OSM with other sources
- tc_join_stats19 should be more flexible HOT 11
- tc_upset bug HOT 5
- Function to preprocess roads in preparation to allocate crashes HOT 1
- Missing link in documentation
- Time to check package... HOT 2
- Error with osm_consolidate HOT 2
- segment argument in osm_consolidate does not work as expected HOT 2
- osm_get_junctions() places junctions where there are no junctions HOT 13
- Check issue associated with sf HOT 2
- Build is failing
- Comments on report 3 HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trafficalmr.