\HeaderA{readOGR}{Read OGR vector maps into Spatial objects}{readOGR}
\aliasA{ogrFIDs}{readOGR}{ogrFIDs}
\aliasA{ogrInfo}{readOGR}{ogrInfo}
\keyword{spatial}{readOGR}
\begin{Description}\relax
The function reads an OGR data source and layer into a suitable Spatial vector object. It can only handle layers with conformable geometry features (not mixtures of points, lines, or polygons in a single layer). It will set the spatial reference system if the layer has such metadata.
\end{Description}
\begin{Usage}
\begin{verbatim}
readOGR(dsn, layer, verbose = TRUE)
ogrInfo(dsn, layer)
ogrFIDs(dsn, layer)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{dsn}] data source name (interpretation varies by driver --- for some drivers, dsn is a file name, but may also be a folder)
\item[\code{layer}] layer name (varies by driver, may be a file name without extension)
\item[\code{verbose}] report progress
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The drivers available will depend on the installation of GDAL/OGR, and can vary. Note that stray files in data source directories (such as *.dbf) may lead to suprious errors that accompanying *.shp are missing.
\end{Details}
\begin{Value}
A Spatial object is returned suiting the vector data source, either a SpatialPointsDataFrame (using an AttributeList for its data slot directly), a SpatialLinesDataFrame, or a SpatialPolygonsDataFrame.
\end{Value}
\begin{Note}\relax
The bases for this implementation are taken from functions in Barry Rowlingson's draft Rmap package, and from Radim Blazek's v.in.ogr program in GRASS.
\end{Note}
\begin{Author}\relax
Roger Bivand
\end{Author}
\begin{References}\relax
\url{http://www.remotesensing.org/gdal/ogr/index.html}, \url{http://www.remotesensing.org/gdal/ogr/ogr_formats.html}, \url{http://examples.oreilly.com/webmapping/}
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{SpatialPointsDataFrame-class}{SpatialPointsDataFrame.Rdash.class}}, \code{\LinkA{SpatialLinesDataFrame-class}{SpatialLinesDataFrame.Rdash.class}}, \code{\LinkA{SpatialPolygonsDataFrame-class}{SpatialPolygonsDataFrame.Rdash.class}}, \code{\LinkA{readShapePoly}{readShapePoly}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
cities <- readOGR(system.file("vectors", package = "rgdal")[1], "cities")
summary(cities)
kiritimati_primary_roads <- readOGR(system.file("vectors", package = "rgdal")[1], "kiritimati_primary_roads")
summary(kiritimati_primary_roads)
scot_BNG <- readOGR(system.file("vectors", package = "rgdal")[1], "scot_BNG")
summary(scot_BNG)
places <- try(readOGR(system.file("vectors/places.gml", package = "rgdal")[1], "places"))
if (class(places) != "try-error") summary(places)
ps_cant_31 <- readOGR(system.file("vectors/ps_cant_31.MIF", package = "rgdal")[1], "ps_cant_31")
summary(ps_cant_31)
Up <- readOGR(system.file("vectors/Up.tab", package = "rgdal")[1], "Up")
summary(Up)
\end{ExampleCode}
\end{Examples}

