I downloaded the TDWG level4 shape from http://www1.kew.org/gis/tdwg/index.html. This shape has a WGS84 projection. I need to reproject this layer to European LAEA or CRS("+init=epsg:3035").
I used the following code:
TDWG4 <- readOGR("D:/GIS/Administrative/world/TDWG/level4/level4.shp", layer="level4")
TDWG4.LAEA <- spTransform(TDWG4, CRS("+init=epsg:3035"))
and get the following error:
Error in .spTransform_Polygon(input[[i]], to_args = to_args, from_args = from_args, : failure in Polygons 37 Polygon 1 points In addition: Warning message: In .spTransform_Polygon(input[[i]], to_args = to_args, from_args = from_args, : 361 projected point(s) not finite
Any suggestions to solve this issue?
Use sf
as this has largely superseded rgdal/rgeos
:
# install.packages("sf")
library("sf")
tdwg4.laea = sf::read_sf("level4.shp") # assumes in project root
tdwg4.laea = sf::st_transform(tdwg4.laea, 3035)
We now have to clip the area because the 3035 EPSG is only relevant for Europe:
install.packages("rmapshaper")
library("rmapshaper")
tdwg4.laea = rmapshaper::ms_clip(
tdwg4.laea,
bbox = c(2426378.0132, 1528101.2618, 6293974.6215, 5446513.5222))
Bounding box for EPSG 3035 is from: http://spatialreference.org/ref/epsg/etrs89-etrs-laea/
Now plot:
plot(tdwg4.laea)