# GIS

#### noetsi

##### Fortran must die
Is there an R package that will tell you the distance between two points in the US if you put in the address (essentially GIS software).

#### Dason

How many addresses do you need to do this for

#### noetsi

##### Fortran must die
I am not clear on this. It could be as high as 40k, but probably a lot less.

#### hlsmith

##### Not a robit
As a bird flies or Manhattan distances. Sas will do it if you have lat / longitudes.

#### Dason

Yeah that's easy to do. Mapping actual addresses is a bit more challenging though

#### noetsi

##### Fortran must die
I don't have longitude and latitude. I have addresses.

#### trinker

##### ggplot2orBust
Is zip to zip accurate enough? Looking up addresses is slightly harder. Looking up zip to zip is easier.

#### trinker

##### ggplot2orBust
If you need the addresses as lat an long....There's lots of ways to do this. This is one approach: https://github.com/trinker/mapit/blob/master/R/geo_code.R (if it still works). This approach requires authentication and tokens but isn't too bad to do. You're just restricted on the number of requests per time period. Do small batches (If I remember correctly like 5K a pop) and save the results to an .rds and then read in all at once and combine.

If zips distances are fine then the zip package has you covered.

Once you have the long and lats it's a matter of the distance formula: https://stackoverflow.com/questions...-distance-between-two-points-lat-long-using-r

#### trinker

##### ggplot2orBust
Tried this and it still works so:

Code:
install.packages('devtools')
library(devtools)
install_github('trinker/mapit')
library(mapit)

wh <- geo_code(
street = '1600 Pennsylvania Ave',
city = 'Washington',
state = 'DC',
zip = '20500',
api.key = 'signup to get yours free'
)

##   latitude longitude
## 1 38.89768 -77.03655
This is a pay it forward from bryan goodrich who helped me with GIS stuff when I was interested

Last edited: