Formdatei mit readOGR-Versen lesen readShapePoly
Ich habe ein Shapefile mit gelesenreadShapePoly
in demmaptools
Paket, kann aber nicht die gleiche Datei mit lesenreadOGR
. Ich hoffe, dass mir jemand beim Lesen des Shapefiles helfen kannreadOGR
.
Ich habe die Datei heruntergeladenorcounty.shp
von hier:http://geography.uoregon.edu/geogr/topics/maps.htm
Ich habe auch die zugehörigen Dateien heruntergeladen:orcounty.shx
, orcounty.sbx
, orcounty.sbn
, undorcounty.dbf
und lege alle fünf Dateien in den Ordner:c:/users/mark w miller/gis_in_R/shapefile_example/
Der folgende Code liest das Shapefile und zeigt einige Attribute an:
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:
Wenn ich jedoch versuche, dasselbe Shapefile mit dem folgenden Code zu lesen, wird eine Fehlermeldung angezeigt:
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)
Die Fehlermeldung lautet:
Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv) :
Cannot open file
Ich kann Natural Earth lesenhttp://www.naturalearthdata.com/ Shapefiles mit:
library(rgdal)
setwd("c:/users/mark w miller/gis_in_R/")
# read shapefile
wmap <- readOGR(dsn="ne_110m_physical", layer="ne_110m_land")
Anscheinend gibt es also einen Unterschied zwischen den Shapefiles von Natural Earth und dem Shapefile von Oregonorcounty.shp
.
Vielen Dank für Ratschläge zum Lesenorcounty.shp
mitreadOGR
. Meine Frage ähnelt der hier gestellten Frage:rgdal / readOGR - Shapefile aus .zip kann nicht gelesen werden