Last active
October 2, 2015 18:55
-
-
Save andrewheiss/d24a2e838e143ffe29eb to your computer and use it in GitHub Desktop.
Mapzen and R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
library(jsonlite) | |
# API documentation: https://github.com/pelias/pelias-doc/blob/master/search.md | |
base_url <- "https://search.mapzen.com/v1/search" | |
res <- GET(base_url, query = list(text = "Durham, NC", api_key = "PUT KEY HERE")) | |
json <- content(res, as = "text") | |
results <- fromJSON(json)$features | |
head(results) | |
# type properties.id properties.gid properties.layer | |
# 1 Feature 14343:adm2:us:usa:durham_county qs:county:14343:adm2:us:usa:durham_county county | |
# 2 Feature 18174:locality:us:usa:durham qs:locality:18174:locality:us:usa:durham locality | |
# 3 Feature 4464368 gn:locality:4464368 locality | |
# 4 Feature 5051e55936bc4553bf759398ab959e94 oa:address:5051e55936bc4553bf759398ab959e94 address | |
# 5 Feature 56b3482a1ee34dab9a0c2a03dec89997 oa:address:56b3482a1ee34dab9a0c2a03dec89997 address | |
# 6 Feature 153d1fe5cff64ad784f7c59f16404965 oa:address:153d1fe5cff64ad784f7c59f16404965 address | |
# | |
# properties.source properties.name properties.country_a properties.country properties.region | |
# 1 qs Durham County USA United States North Carolina | |
# 2 qs Durham USA United States North Carolina | |
# 3 gn Durham USA United States North Carolina | |
# 4 oa 0 Durham Drive USA United States North Carolina | |
# 5 oa 0 Durham Road USA United States North Carolina | |
# 6 oa 0 Durham Road USA United States North Carolina | |
# | |
# properties.region_a properties.county properties.confidence properties.label | |
# 1 NC Durham County 0.898 Durham County, NC | |
# 2 NC Durham County 0.729 Durham, Durham County, NC | |
# 3 NC Durham County 0.729 Durham, Durham County, NC | |
# 4 NC Wake County 0.664 0 Durham Drive, Pinewinds, NC | |
# 5 NC Wake County 0.664 0 Durham Road, Wake County, NC | |
# 6 NC Wake County 0.664 0 Durham Road, Wake Forest, NC | |
# | |
# properties.locality properties.housenumber properties.street properties.postalcode | |
# 1 <NA> <NA> <NA> <NA> | |
# 2 <NA> <NA> <NA> <NA> | |
# 3 Durham <NA> <NA> <NA> | |
# 4 <NA> 0 Durham Drive 27529 | |
# 5 <NA> 0 Durham Road 00000 | |
# 6 Wake Forest 0 Durham Road 27587 | |
# | |
# properties.neighbourhood geometry.type geometry.coordinates | |
# 1 <NA> Point -78.87633, 36.03598 | |
# 2 <NA> Point -78.90511, 35.98051 | |
# 3 <NA> Point -78.89862, 35.99403 | |
# 4 Pinewinds Point -78.64472, 35.72532 | |
# 5 <NA> Point -78.66456, 35.98056 | |
# 6 Brookview Point -78.51777, 35.97947 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment