I'm working (in R) with a SpatialPolygonsDataFrame describing US historical counties, and I would like to calculate great circle distances between centroids of counties (polygons).
I've looked into functions like spDists
from the sp
package, gDistance
from rgeos
, and distGeo
from geosphere
, but I'm confused about what exactly they're calculating. For instance, the documentation for spDists
states that it calculates Euclidean distance if the spatial object is not projected, and great circle distance if the spatial object is projected. Similarly, gDistance
rejects my data because it "expects planar coordinates". This is my first source of confusion because I would think it should be the opposite, eg isn't it more natural to calculate Euclidean distance from projected data because it is embedded in two-dimensional space? Similarly, shouldn't it be easier to calculate great circle distance from longitudes and latitudes (my data) than from coordinates for some projection that may have distorted distance?
I don't mind projecting my data to use these functions, but I'm not sure exactly what comprises a "projection." The output of proj4string
for my data is
> proj4string(US)
[1] "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
I've seen in online tutorials that there's usually a "+init=..." component. Is that why it's not projected? Does it matter what "init" value I use to project it?