[R] Reading shape files in R

Roger Bivand Roger.bivand at nhh.no
Sun Jun 16 14:24:44 CEST 2013


jickngea alexand <jickneba <at> yahoo.ie> writes:

> 
> Hi everyone,
>                        I am new with spatial data analysis in R and I'm
not able
> to read a shape because of this error message but the shapefile is in my
work directory.  Here are my
> commands; ogrLireadstLayers("border.shp"),
border=OGR("border.shp","border"). What does it
> mean?. Any help?

Yes, read the help files for the function you are using, and try out the
examples using shapefiles provided with the package. If still in doubt, look
at the OGR formats page to see how OGR reads shapefiles:

http://www.gdal.org/ogr/drv_shapefile.html

where you also need dsn and layer arguments. Almost certainly:

ogrListLayers(".")

will list the shapefile layers in your working directory, and 

border=OGR(".", "border")

will read the file if it is complete. Always also include the output of
sessionInfo() in questions, as the answer may depend on the version(s) of
package(s) - here rgdal, but not mentioned by you. Even better, give a
worked example of your problem - in constructing the question, you would
certainly have answered it yourself.

Other questions on spatial and spatio-temporal matters may be answered
faster on R-sig-geo.

> Error in file(paste(dsn, .Platform$file.sep, layer, ".dbf", sep = ""),  :
 cannot open the connection In
> addition: Warning message: In file(paste(dsn, .Platform$file.sep, layer,
".dbf", sep = ""),  : cannot
> open file 'border.shp/border.dbf': No such file or directory
> 
> Alexand
> Msc.agriScs
> 
> 	[[alternative HTML version deleted]]
> 

Only post plain text!

Roger

> 
>



More information about the R-help mailing list