I have a long list of points covering all of North America for which I would like to calculate the centroid (by grouping points based on the "Name" column).
My approach is to take the WGS84 co-ordinates and project them into North America Equidistant Conic; and then use gCentroid from rgeos to calculate the centres, like so:
#Using: http://www.spatialreference.org/ref/esri/102010/ we get the Proj4js format
no_am_eq_co <- "+proj=eqdc +lat_0=0 +lon_0=0 +lat_1=20 +lat_2=60 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"
wgs84 <- "+proj=longlat +datum=WGS84"
# FROM: Coordinates are geographic latitude/longitudes
coordinates(in_data) <- c("lon", "lat")
proj4string(in_data) <- CRS(wgs84)
# TO: Project into North America Equidistant Conic
df <- spTransform(in_data, CRS(no_am_eq_co))
# Get centroids
ctrs <- lapply(unique(df$Name), function(x) gCentroid(df[df$Name==x,]))
ctrsout <- setNames( ctrs , unique(df$Name ) )
# Create data frame
df <- do.call(rbind, lapply(ctrsout, data.frame, stringsAsFactors=FALSE))
coordinates(df) <- c("x", "y")
proj4string(df) <- CRS(no_am_eq_co)
df <- as.data.frame(spTransform(df, CRS(wgs84)))
names(df) <- c("longitude", "latitude")
However, I wonder if using for example the lambert projection would be better (i.e. more accurate centroids)?
It is my understanding that the equidistant conic minimises distance distortions(which is what I think I need to get centroids), compared to the lambert conformal conic which minimises shape distortions.