Skip to content

Error opening SHP file (maptools)

4 messages · gerickes at earthlink.net, Paul Hiemstra, Don MacQueen +1 more

#
I am having difficulty loading a points shapefile (1600 records) I generated from ArcGIS as a PointsSpatialDataFrame using the maptools readShapePoints function.

library(maptools)
surveypts <- readShapePoints(system.file("C:/temp/survey.shp", package="maptools")[1]
Error in getinfo.shape(filen) : Error opening SHP file

I've tried numerous re-exports and renames of the dataset, to no avail. I've also tried placing the shapefile in the library's shapefile folder, with the example dataset (see example below). 

x <- readShapePoints(system.file("shapes/survey.shp", package="maptools")[1]

No luck there either. I'm quite new to R, but I can follow a manual and google well enough. However, I haven't seen anything to help me. The example point datasets load fine. I figure that I'm missing on some familiarity with R and that I don't know the tricks yet. Any help?

Thanks in advance.

Gericke Cook
USDA-APHIS-PPQ
#
gerickes at earthlink.net schreef:
Hi Gericke,

Why do you use system.file? Probably it will look for survey.shp in the 
maptools package. Try instead:

surveypts <- readShapePoints("C:/temp/survey.shp")

For these kind of geographic questions, the r-sig-geo mailing list is 
maybe a better way to get good answers.

cheers and hth,
Paul
#
The help page for readShapePoints says that the file name that you 
supply should not include the extension.

The "system.file" part of the example in the help page is only to use 
the example file that came with the package. Since you want to open 
your own file you omit the system.file() bit.

Do something like:

    readShapePoints( 'C:/path_to_my_file/filename')

Hope this helps.
-Don
At 12:05 PM -0600 3/11/08, gerickes at earthlink.net wrote:

  
    
#
Don MacQueen <macq <at> llnl.gov> writes:
You may also - for safety's sake - say:

list.files(path="C:/path_to_my_file", pattern="filename")

to make sure that at least the minimum three files that make up a 
"shapefile" are present: filename.dbf, filename.shp, and filename.shx. 
Note that in Windows you can also use the file chooser, by saying:

readShapePoints(file.choose())

which will let you navigate to, and "see" the file name for yourself.

Roger

PS. As Paul mentioned, the R-sig-geo list is well suited to this 
kind of question.