Я прочитал шейп-файл с помощью readShapePoly
в пакете maptools
, но не могу прочитать тот же файл с readOGR
. Я надеюсь, что кто-нибудь сможет помочь мне прочитать шейп-файл с помощью 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/
Следующий код считывает шейп-файл и отображает некоторые атрибуты:
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:
Однако когда я пытаюсь прочитать тот же шейп-файл с помощью следующего кода, я получаю сообщение об ошибке:
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)
В сообщении об ошибке говорится:
Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv) :
Cannot open file
Я могу читать шейп-файлы http://www.naturalearthdata.com/ Natural Earth, используя:
library(rgdal)
setwd("c:/users/mark w miller/gis_in_R/")
# read shapefile
wmap <- readOGR(dsn="ne_110m_physical", layer="ne_110m_land")
Итак, очевидно, есть разница между шейп-файлами Natural Earth и шейп-файлами Oregon orcounty.shp
.
Спасибо за любой совет, как читать orcounty.shp
с readOGR
. Мой вопрос аналогичен вопросу здесь: rgdal / readOGR - невозможно прочитать шейп-файл из ZIP-архива
readOGR(dsn = 'c:/users/mark w miller/gis_in_R/shapefile_example', layer = 'orcounty')
- person Paulo E. Cardoso   schedule 10.03.2014