2017-09-25 66 views
1

我从http://www1.kew.org/gis/tdwg/index.html下载了TDWG level4形状。此形状具有WGS84投影。我需要将此图层重新投影到欧洲LAEA或CRS(“+ init = epsg:3035”)。R spTransform投影点不是有限的

我用下面的代码:

TDWG4 <- readOGR("D:/GIS/Administrative/world/TDWG/level4/level4.shp", layer="level4") 
TDWG4.LAEA <- spTransform(TDWG4, CRS("+init=epsg:3035")) 

,并出现以下错误:

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

任何建议来解决这个问题?

回答

0

使用sf,因为这已经在很大程度上取代了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) 

我们现在有裁剪的区域,因为3035 EPSG是唯一相关的欧洲:

install.packages("rmapshaper") 
library("rmapshaper") 
tdwg4.laea = rmapshaper::ms_clip(
    tdwg4.laea, 
    bbox = c(2426378.0132, 1528101.2618, 6293974.6215, 5446513.5222)) 

为EPSG 3035包围盒来自:http://spatialreference.org/ref/epsg/etrs89-etrs-laea/

现在情节:

plot(tdwg4.laea) 

Plot of Europe

+0

几乎在那里。我尝试绘制使用以下图形聚焦于欧洲的转换后的形状: plot(TDWG4.LAEA ['Level4_cod'],xlim = c(943611,8500000),ylim = c(600000,7800000)) 但得到以下错误: 错误POLYPATH(p_bind(L),边界=边界[I],LTY = LTY [I],LWD随钻测井= [I]:无效的图形路径 任何建议 –

+0

@NielsRaes你ggplot尝试,而不是的基本情节?'devtools :: install_github(“tidyverse/ggplot2”)','library(“ggplot2”)#需要dev版本的ggplot2','ggplot(data = TDWG4.LAEA)+ geom_sf()'? – Phil

+0

while打开使用devtools安装的ggplot2我得到这个错误:_Error:在get(Info [i,1],envir = env)中'ggplot2'的包或命名空间加载失败: lazy-loa d数据库'D:/R/library/ggplot2/R/ggplot2.rdb'已损坏。当使用常规的ggplot2库和'ggplot2 :: ggplot(data = TDWG4)+ geom_sf()'时我得到错误:geom_sf()中的_Error:找不到函数“geom_sf”_。还有什么建议? –