I'm trying to find some centroids of a shapefile for Danish municipalities and afterwards find the driving time between them. I use R
's readShapePoly
function from maptools
combined with the gCentroid
function from rgeos
, and everything works. However, I get spatialpoints such as
SpatialPoints:
x y
1 571860.7 6225016
Coordinate Reference System (CRS) arguments: NA
Which is clearly not something I can use in Google to grab travel times. I'm looking for a way to convert these numbers to longitude-latitude, but have no idea how.
When I read the data using readOGR
from the rgdal
library I get the same coordinates but it tells me the following about what I assume is the projection (but the coordinates are the same)
Slot "proj4string":
CRS arguments:
+proj=utm +zone=32 +ellps=intl +units=m +no_defs
Reproducible example: I've put the data for the example here: https://github.com/sebastianbarfort/shapefiles
This should reproduce the problem:
library(maptools)
library(rgdal)
library(rgeos)
map = readShapePoly("~/Downloads/shapefiles-master/kommuner1983.shp")
centroid = gCentroid(map)
centroid