I read in a UTM shapefile to R using readOGR. I want to use the resulting SpatialPointsDataFrame to build a mesh in the INLA package, but I've been told that to help with numerical stability, I should convert the geometries to km from m.
So far, I've been using INLA:
grid2 <- readOGR(here::here("PNG_grid.shp"))
mycrs <- fm_sp_get_crs(grid2)
mycrs2 <- fm_crs_set_lengthunit(mycrs, "km")
grid3 <- inla.spTransform(grid2, crs0 = mycrs, crs2 = mycrs2)
...but get an error "Invalid target CRS for SpatialPointsDataFrame". Looking at mycrs2 it's pretty weird. The value in mycrs is "+proj=utm +zone=54 +south +ellps=WGS72 +units=m +no_defs", so I thought this might work:
grid3 <- inla.spTransform(grid2, crs0 = "+proj=utm +zone=54 +south +ellps=WGS72 +units=m +no_defs",
crs1 = "+proj=utm +zone=54 +south +ellps=WGS72 +units=km +no_defs")
...but I get the same error. Is there anything in sp or rgdal that would help me?