Mar*_*ler 12 r shapefile rgdal
我已经readShapePoly在maptools包中读取了shapefile ,但无法读取同一个文件readOGR.我希望有人可以帮助我阅读shapefile readOGR.
我orcounty.shp从这里下载了文件:http://geography.uoregon.edu/geogr/topics/maps.htm
我也下载了相关文件:orcounty.shx,orcounty.sbx,orcounty.sbn,和orcounty.dbf,并把所有五个文件的文件夹中:c:/users/mark w miller/gis_in_R/shapefile_example/
以下代码读取shapefile并显示一些属性:
library(maptools)
setwd('c:/users/mark w miller/gis_in_R/shapefile_example/')
# Oregon county census data (polygons)
orcounty.poly <- readShapePoly('orcounty.shp', proj4string=CRS("+proj=longlat"))
orcounty.line <- readShapeLines('orcounty.shp', proj4string=CRS("+proj=longlat"))
# see projection
summary(orcounty.poly)
Object of class SpatialPolygonsDataFrame
Coordinates:
min max
x -124.55840 -116.46944
y 41.98779 46.23626
Is projected: FALSE
proj4string : [+proj=longlat]
Data attributes:
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用以下代码读取相同的shapefile时,我收到一个错误:
library(rgdal)
# read shapefile
oregon.map <- readOGR(dsn="c:/users/mark w miller/gis_in_R/shapefile_example/", layer="orcounty")
# convert to dataframe
oregon.map_df <- fortify(oregon.map)
Run Code Online (Sandbox Code Playgroud)
错误消息说:
Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv) :
Cannot open file
Run Code Online (Sandbox Code Playgroud)
我可以使用以下方法阅读Natural Earth http://www.naturalearthdata.com/ shapefiles:
library(rgdal)
setwd("c:/users/mark w miller/gis_in_R/")
# read shapefile
wmap <- readOGR(dsn="ne_110m_physical", layer="ne_110m_land")
Run Code Online (Sandbox Code Playgroud)
所以,显然天然地球形状文件和俄勒冈形状文件之间存在差异orcounty.shp.
感谢您对如何阅读任何意见orcounty.shp与readOGR.我的问题类似于这里的问题:rgdal/readOGR - 无法从.zip读取shapefile
Pau*_*oso 13
尝试从文件路径中删除最后一个'/'.
readOGR(dsn = 'c:/users/mark w miller/gis_in_R/shapefile_example',
layer = 'orcounty')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21647 次 |
| 最近记录: |