## Converting latitude and longitude to x-y coordinates
## The 49th county is Marion, where Indianapolis is located.
if (FALSE) ltln2xy <- function(latlon,latlon0) {
lat <- latlon[,1]*pi/180; lon <- latlon[,2]*pi/180
lt0 <- latlon0[1]*pi/180; ln0 <- latlon0[2]*pi/180
x <- cos(lt0)*sin(lon-ln0); y <- sin(lat-lt0)
cbind(x,y)
}
data(ColoCan)
latlon <- as.matrix(ColoCan[,c("lat","lon")])
ltln2xy(latlon,latlon[49,])
## Clean up
rm(ltln2xy,ColoCan,latlon)
Run the code above in your browser using DataLab