Tag Archive | google maps

Return coordinates of addresses in R

Georeferencing huge databases in R just became a little bit easier for me.
I found the nice ‘rjson‘ package, which allows to decompose json code retrieved from google maps for instance. My data table consists of columns with the zipcode, the city and the state and a custom value.
Here is the snippet which returns the point coordinates from a given address in R.


require(rjson) # load rjson package
getCoordinates <- function(address) {
url <- paste("http://maps.google.com/maps/geo?q=",address,"&output=json",sep="")
map_data <- fromJSON(paste(readLines(url),collapse=""))
coord <- map_data$Placemark[[1]]$Point$coordinates[1:2]
return(coord)
}

# example query
address <- paste(data$zip[1],"+",data$city[1],"+",data$state[1],sep="")
getCoordinates(address)

Advertisements
Sussex Research Hive

Supporting the research community at the University of Sussex

Small Pond Science

Research, teaching, and mentorship in the sciences

Landscape Ecology 2.0

intersecting landscape ecology, open science, and R

nexus

The Research Blog of IIASA

Jörg Steinkamps Blog

Mainly things about R, Linux and vegetation modeling

Amy Whitehead's Research

the ecological musings of a conservation biologist

Michael McCarthy's Research

School of BioSciences, The University of Melbourne

The Rostrum

science, statistics, policy and more

marionpfeifer

Environmental Change - Understand, Predict, Adapt

Dynamic Ecology

Multa novit vulpes

metvurst

METeorological Visualisation Utilities using R for Science and Teaching

A Birder´s Blog

"Everybody loves what they know"

BIOFRAG

A new metric to quantify biodiversity response to fragmentation

Trust Me, I'm a Geographer

Using Technology to Explore Our World

Duncan Golicher's weblog

Research, scripts and life in Chiapas