3

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?

  • 2
    Does your shapefile have an associated .prj file? What happens when you run the following command ogrInfo(".", "summer.s")? – Aaron Feb 15 '16 at 19:07
  • Potentially relevant: When using the read.shapefile, I get an error (rather than NA) for proj4string(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"’ – JepsonNomad Feb 15 '16 at 19:16
  • @Aaron Running ogrInfo(".", "summer.s") returns a "cannot open layer" error. However, running ogrInfo("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...) – JepsonNomad Feb 15 '16 at 19:50
  • 1
    ok i projected it with proj4string(test) <- CRS("+init=espg:32622") and it took that ok. however something isnt right, it doesnt behave how you'd expect when exploring the shapefile. Sure it isnt corrupted during editing? – Sam Feb 15 '16 at 20:24
  • 2
    If you think this is an ArcGIS for Desktop problem then I think you should list the precise steps you performed to do that at the beginning of your question. For example, you say that you "trace the range" but do not describe how that "range" came to be in ArcMap. There is an edit button beneath it that will let you revise it with more details at any time. – PolyGeo Feb 15 '16 at 23:09
2

I think that you should go back to this step:

  • Manually georeference a scanned historical map using notable landforms

and make sure that your scanned historical map (or a copy of it) has, after this step, a coordinate system that looks right, and that when displayed in a new blank map has coordinates at bottom right that also look right.

  • I have re-georeferenced the historical basemap, in an appropriate coordinate system (WGS84 UTM 22N), projected in a dataframe with the same projection info, re-created the shapefiles using once again the same spatial reference, and yet again: No proj4string in the shapefile... – JepsonNomad Feb 16 '16 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.