I am trying to export a shapefile from the ArcMap (Made in both 10.2 and 10.3; same problem) environment to be used in R. Unfortunately, it seems that the projection information is somehow not retained at some point during this process. The closest question I have been able to find related to this is Exporting point shapefile from ArcGIS for Desktop to R?, however the user was having problems on the R end of things. I believe my issue may be on the Arc side:
I have manually created a shapefile using the following steps:
- Import DEM of region.
- Manually georeference a scanned historical map using notable landforms
- Within ArcCatalog, create a new shapefile
- Select preferred XY coordinate system (WGS 1984 Complex UTM Zone 22N), and specify that it will be a polygon
- Enable the Editor toolbar
- Edit the new shapefile, as a polygon. Select points around the extent of the baselayer region of interest.
However, when bringing the shapefile into R, it seems that the only info that is retained is the extent of the object. I have used readOGR
, readShapePoly
, and read.shapefile
but all of the functions leave me in the same situation. It seems that using read.shapefile
brings the information in as a list:
> summer.s <- readOGR(dsn=".", layer="Trynagain")
OGR data source with driver: ESRI Shapefile
Source: ".", layer: "Trynagain"
with 1 features
It has 1 fields
> proj4string(summer.s)
[1] NA
> summer.s
class : SpatialPolygonsDataFrame
features : 1
extent : 494033.5, 532556.9, 7431381, 7452759 (xmin, xmax, ymin, ymax)
coord. ref. : NA
variables : 1
names : Id
min values : 0
max values : 0
No matter the import method I use, R just can't seem to figure out what's going on with the projection information. Yet, when I use the same files in Arc, it knows where and how to project properly. Does anyone have any suggestions for what I may be doing wrong?
ogrInfo(".", "summer.s")
?read.shapefile
, I get an error (rather than NA) forproj4string(summer.s)
, presumably related to the structure of the shapefile? It appears that the imported object is seen as a list rather than spatial object:> summer.s <- read.shapefile("Trynagain") > proj4string(summer.s) Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘proj4string’ for signature ‘"list"’
ogrInfo(".", "summer.s")
returns a "cannot open layer" error. However, runningogrInfo("Trynagain.shp", "Trynagain")
successfully locates the source (Trynagain.shp), layer (Trynagain), and Driver (ESRI Shapefile; number of rows: 1). It is a wkbPolygon with 2 dimensions, an LDID of 0 and 1 field which is only an Id with length 6 (yet I know there are 40 vertices in my polygon...)