Reading shape files
rgdal's
function
readOGR()
can be used to read
shape files.
readOGR
accepts two arguments: dsn
(data source name, a name of a directory) and layer
(the shape file's name without .shp
, .dbf
suffix).
library(rgdal)
shp <- readOGR(dsn = '.', layer = 'geo')
str(shp)
coords@bbox
shp@proj4string # content of .prj file?
head(shp@data , 10) # read data from dbf (dBASE) file
head(shp@coords , 10)
head(shp@polygons, 10)
head(shp@lines , 10)
plot(shp)
Misc
Building rgdal unter Mint,
Ubuntu or another
Debian based system requires the
libgdal libraries to be installed on the system. If they are not, the building process will say that it didn't find
proj_api.h
or something.
These libraries can be installed with sudo apt-get install libgdal1-dev libproj-dev
.