2017-09-25 65 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」_。還有什麼建議? –