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

overpass_query doesn't seem to return polygons when it should #7

Closed
Robinlovelace opened this issue Nov 1, 2016 · 7 comments
Closed

Comments

@Robinlovelace
Copy link
Member

Example, from which I was expecting to get Lovell park as a polygon as it is:

screenshot from 2016-11-01 22-34-24

b = tmap::bb("Leeds")
q = opq(bbox = b) %>% 
  add_feature("leisure", "park")
p = overpass_query(query = q)
library(sp)
plot(p$osm_points)
mapview::mapview(p$osm_points)
plot(p$osm_polygons)

Instead I get just points of the border by the look of it:

screenshot from 2016-11-01 22-29-45

@Robinlovelace
Copy link
Member Author

Interestingly, neither does QGIS which makes me think it's an issue at the GDAL level.

Another, smaller parky example:

u = "http://overpass-api.de/api/interpreter?data=%2F*%0AThis%20has%20been%20generated%20by%20the%20overpass-turbo%20wizard.%0AThe%20original%20search%20was%3A%0A%E2%80%9Cleisure%3Dpark%E2%80%9D%0A*%2F%0A%5Bout%3Axml%5D%2F*fixed%20by%20auto%20repair*%2F%5Btimeout%3A25%5D%3B%0A%2F%2F%20gather%20results%0A%28%0A%20%20%2F%2F%20query%20part%20for%3A%20%E2%80%9Cleisure%3Dpark%E2%80%9D%0A%20%20node%5B%22leisure%22%3D%22park%22%5D%2853.794871619441025%2C-1.5554237365722654%2C53.81063582424263%2C-1.5232372283935547%29%3B%0A%20%20way%5B%22leisure%22%3D%22park%22%5D%2853.794871619441025%2C-1.5554237365722654%2C53.81063582424263%2C-1.5232372283935547%29%3B%0A%20%20relation%5B%22leisure%22%3D%22park%22%5D%2853.794871619441025%2C-1.5554237365722654%2C53.81063582424263%2C-1.5232372283935547%29%3B%0A%29%3B%0A%2F%2F%20print%20results%0Aout%20meta%3B%2F*fixed%20by%20auto%20repair*%2F%0A%3E%3B%0Aout%20meta%20qt%3B%2F*fixed%20by%20auto%20repair*%2F"
download.file(url = u, destfile = "test.osm")
psf_o = st_read("test.osm", "multipolygons")


## Reading layer multipolygons from data source test.osm using driver "OSM"
## features:       3
## fields:         25
## proj4string:    +proj=longlat +datum=WGS84 +no_defs 

Yet there are clearly more from JOSM (it doesn't even load in QGIS!):

screenshot from 2016-11-01 23-45-27

Related to r-spatial/sf#45

@mpadge
Copy link
Member

mpadge commented Nov 2, 2016

Yeah, I've not yet got on to full polygon testing, but shall do so sometime next week at the latest. I'll let you know.

@Robinlovelace
Copy link
Member Author

Cheers, hope those test parks are useful - will be useful for my (real life!) explorations of the parks of Leeds.

@Robinlovelace
Copy link
Member Author

Then it will be able to do things that sfr cannot I think... Seems even QGIS needs an intermediate sqlite stage to properly load osm data - have you seen that?

@mpadge
Copy link
Member

mpadge commented Nov 3, 2016

Yeah, I'm poring over the GDAL code which is spectacularly well written, and it seems the speed is due to dumping the initial read straight into sqlite and then reading components from there. I've set up a direct GDAL read (in C++) to enable comparison and to ensure results for osmdata are strictly identical. (This also enables me to constantly compare output of sf, which is handy ...)

@Robinlovelace
Copy link
Member Author

Awesome. Do I sense a PR into GDAL brewing so it can handle .osm files better? How about osm's .pbf format? Maybe there's a way to download data as .pbfs? All very speculative without looking at any actual code. Thanks for doing the coding btw.

@mpadge
Copy link
Member

mpadge commented Dec 7, 2016

Finally got on to this one. The sp::SpatialPolygonDataFrame objects weren't quite being constructed properly (in Rcpp). Now they are, and it looks like this:

b = tmap::bb("Leeds")                                                               
q = opq(bbox = b) %>% add_feature("leisure", "park")                                
p = overpass_query(query = q)
sp::plot (p$osm_polygons)

leeds-parks

@mpadge mpadge closed this as completed Dec 7, 2016
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