Skip to content

Instantly share code, notes, and snippets.

@cscheid
Forked from cpsievert/osm.R
Last active January 3, 2016 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cscheid/8443455 to your computer and use it in GitHub Desktop.
Save cscheid/8443455 to your computer and use it in GitHub Desktop.
setwd("~/Downloads")
obs <- XML2Obs("out.xml", url.map=TRUE)
unique(names(obs)) #you might want to re_name or add_key before collapsing
tmp = add_key(obs, parent="url1//osm//way", key.name="way_id")
tmp = add_key(tmp, parent="url1//osm//node", key.name="node_id")
tmp = add_key(tmp, parent="url1//osm//relation", key.name="relation_id")
tables <- collapse(obs) # holy crap this takes a long-ass time
write.table(tables$`url1//osm//way//nd`, "ways.csv", sep=",")
write.table(tables$`url1//osm//way//tag`, "way_tags.csv", sep=",")
write.table(tables$`url1//osm//node`, "nodes.csv", sep=",")
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment