[R-sig-Geo] Load point shape file

Ashton Shortridge ashton at msu.edu
Fri Oct 16 23:36:18 CEST 2009


I think it's better not to specify the .shp extension, too:

Assuming that test.shp, test.shx, and test.dbf are in your working directory 
(see setwd() for more on that):
library(maptools)
spdat <- readShapeSpatial('test')

On Friday 16 October 2009 15:42:33 Danlin Yu wrote:
> Sunny:
> 
> For the first case, you probably shall set the path to where you store
> your shapefiles in the R main menu. In addition, as the warning message
> indicates, the readShapeSpatial function probably is better for spatial
> data management than read.shape. For the second case, other than setting
> the path, you also need to load the package (after installing it) by
> using library(rgdal).
> 
> Hope this helps,
> 
> Cheers,
> Dr. Danlin Yu
> 
> Sunny ??:
> > I am trying to load my point shape file to R. I searched for hours and
> > found there are two ways, one is read.shape and the other one is readOGR.
> > I tried both but but can't do it successfully. Any help is appreciate.
> >
> >> x <- read.shape(system.file("test.shp", package="maptools")[1])
> >
> > Error in getinfo.shape(filen) : Error opening SHP file
> > In addition: Warning message:
> > use readShapeSpatial:
> > objects other than Spatial objects defined in the sp package are
> > deprecated
> >
> >> install.packages('rgdal')
> >> self<-readOGR(".","test")
> >
> > Error: could not find function "readOGR"
> >
> > 	[[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo at stat.math.ethz.ch
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Ashton Shortridge
Associate Professor			ashton at msu.edu
Dept of Geography			http://www.msu.edu/~ashton
235 Geography Building		ph (517) 432-3561
Michigan State University		fx (517) 432-1671



More information about the R-sig-Geo mailing list