geocode: Geocode a string using the openstreet maps API

Description Usage Arguments Value Examples

View source: R/geocode.R

Description

Geocodes a string using the OSM API. Has the ability to return additional information such as the geoJSON string and converting the geojson string to a spatial object.

Usage

1
geocode(x, geojson=T, sp=F, verbose=F, ...)

Arguments

x

str, a location name to geocode in the form of a character vector of length 1.

geojson

bool, should the geoJSON information also be retrieved

sp

bool, should the geoJSON data be converted to spatial objects

verbose

bool, verbose argument passed to readOGR

...

, additional parameters passed to readOGR

Value

A dataframe with the reults from the OSM geotag call.

A dataframe with the results from the OSM geotag call. This dataframe may include lists of coordinates and spatial objects depending on the parameters specified

Examples

1
2
3
4
5
6
# Get results for the
mexicoTags <- geocode("Mexico", geojson=TRUE, sp=TRUE)

# plot the first result that seems like its a polygon
firstPoly <- grep("Polygon", mexicoTags$geoJSONtype)[1]
sp::plot(mexicoTags$shape[[firstPoly]])

nmmarquez/shapecode documentation built on May 29, 2019, 9:15 a.m.