SpatialEpi (version 1.1)

latlong2grid: Convert Coordinates from Latitude/Longitude to Grid

Description

Convert geographic latitude/longitude coordinates to kilometer-based grid coordinates.

Usage

latlong2grid(input)

Arguments

input
either an n x 2 matrix of longitude and latitude coordinates in decimal format or an object of class SpatialPolygons (See SpatialPolygons-class)

Value

  • Either a data frame with the corresponding (x,y) kilometer-based grid coordinates, or a SpatialPolygons object with the coordinates changed.

Details

Longitude/latitudes are not a grid-based coordinate system: latitudes are equidistant but the distance between longitudes varies.

Examples

Run this code
## Convert coordinates
coord <- data.frame(rbind(
# Montreal, QC:  Latitude: 45deg 28' 0" N (deg min sec), Longitude: 73deg 45' 0" W
c(-73.7500, 45.4667),
# Vancouver, BC:  Latitude: 45deg 39' 38" N (deg min sec), Longitude: 122deg 36' 15" W
c(-122.6042, 45.6605)
))
latlong2grid(coord)

## Convert SpatialPolygon
data(pennLC)
new <- latlong2grid(pennLC$spatial.polygon)
par(mfrow=c(1,2))
plot(pennLC$spatial.polygon,axes=TRUE)
title("Lat/Long")
plot(new,axes=TRUE)
title("Grid (in km)")

Run the code above in your browser using DataLab