readOGR() cannot open file

后端 未结 6 933
臣服心动
臣服心动 2020-12-08 00:50
wmap <- readOGR(dsn=\"~/R/funwithR/data/ne_110m_land\", layer=\"ne_110m_land\")

This code is not loading the shape file and error is generated a

6条回答
  •  不知归路
    2020-12-08 01:37

    You could have shown that you have the right path with:

    list.files('~/R/funwithR/data/ne_110m_land', pattern='\\.shp$')
    file.exists('~/R/funwithR/data/ne_110m_land/ne_110m_land.shp')
    

    perhaps try:

    readOGR(dsn=path.expand("~/R/funwithR/data/ne_110m_land"), layer="ne_110m_land")
    

    or a simpler alternative that is wrapped around that:

    library(raster)
    s <- shapefile("~/R/funwithR/data/ne_110m_land/ne_110m_land.shp")
    

提交回复
热议问题