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.

If reading a shapefile, the data source name (dsn= argument) is the folder (directory) where the shapefile is, and the layer is the name of the shapefile (without the .shp extension). For example to read bounds.shp from C:/Maps, do map <- readOGR(dsn="C:/Maps", layer="bounds"). The logic behind this is that typically one keeps all the shapefiles for a project in one folder (directory).

As noted below, for other file type drivers, the dsn= argument is interpreted differently, and may be the file name itself, as for example with the GPX driver for reading GPS data as layer="tracks" lines or layer="track_points" points.

readOGR(dsn, layer, verbose = TRUE, p4s=NULL, 
 stringsAsFactors=as.logical(NA), 
 drop_unsupported_fields=FALSE,
 pointDropZ=FALSE, dropNULLGeometries=TRUE,
 useC=TRUE, disambiguateFIDs=FALSE, addCommentsToPolygons=TRUE,
 encoding=NULL, use_iconv=FALSE, swapAxisOrder=FALSE, require_geomType = NULL,
 integer64="no.loss", GDAL1_integer64_policy=FALSE, morphFromESRI = NULL,
 dumpSRS = FALSE, enforce_xy = NULL, D3_if_2D3D_points=FALSE, missing_3D=0)
ogrInfo(dsn, layer, encoding=NULL,
 use_iconv=FALSE, swapAxisOrder=FALSE, require_geomType = NULL,
 morphFromESRI = NULL, dumpSRS = FALSE, enforce_xy = NULL,
 D3_if_2D3D_points=FALSE)
ogrFIDs(dsn, layer)
ogrDrivers()
OGRSpatialRef(dsn, layer, morphFromESRI=NULL, dumpSRS = FALSE, driver = NULL,
 enforce_xy = NULL)
ogrListLayers(dsn)
# S3 method for ogrinfo
print(x, ...)

Arguments

dsn

data source name (interpretation varies by driver --- for some drivers, dsn is a file name, but may also be a folder)

layer

layer name (varies by driver, may be a file name without extension). From rgdal 1.2.*, layer may be missing, in which case ogrListLayers examines the dsn, and fails if there are no layers, silently reads the only layer if only one layer is found, and reads the first layer if multiple layers are present, issuing a warning that layer should be given explicitly.

verbose

report progress

p4s

PROJ4 string defining CRS, if default NULL, the value is read from the OGR data set

stringsAsFactors

logical: should character vectors be converted to factors? Default NA, which uses the deprecated default.stringsAsFactors() in R < 4.1.0 (see link[base]{data.frame}). Before R 4, strings were converted to factors by default, as argument value TRUE. See https://developer.r-project.org/Blog/public/2020/02/16/stringsasfactors/index.html for details of changes.

drop\_unsupported\_fields

default FALSE, if TRUE skip fields other than String, Integer, and Real; Date, Time and DateTime are converted to String

pointDropZ

default FALSE, if TRUE, discard third coordinates for point geometries; third coordinates are alway discarded for line and polygon geometries

dropNULLGeometries

default TRUE, drop both declared NULL geometries, and empty geometries with no coordinates; if FALSE, return a data frame with the attribute values of the NULL and empty geometries. From 1.3-6, setting FALSE also works when there are no geometries at all, returning a data.frame including all FIDs

useC

default TRUE, if FALSE use original interpreted code in a loop

disambiguateFIDs

default FALSE, if TRUE, and FID values are not unique, they will be set to unique values 1:N for N features; problem observed in GML files

addCommentsToPolygons

default TRUE, may be set FALSE for legacy behaviour; used to indicate which interior rings are holes in which exterior rings in conformance with OGC SFS specifications

encoding

default NULL, if set to a character string, and the driver is “ESRI Shapefile”, and use_iconv is FALSE, it is passed to the CPL Option “SHAPE_ENCODING” immediately before reading the DBF of a shapefile. If use_iconv is TRUE, and encoding is not NULL, it will be used to convert input strings from the given value to the native encoding for the system/platform.

use_iconv

default FALSE; if TRUE and encoding is not NULL, it will be used to convert input strings from the given value to the native encoding for the system/platform.

swapAxisOrder

default FALSE, if TRUE, treat y coordinate as Easting, x as Northing, that is the opposite to the assumed order; this may be needed if some OGR read drivers do not behave as expected

require_geomType

, default NULL, if one of: c("wkbPoint", "wkbLineString", "wkbPolygon"), then in input with multiple geometry types, the chosen type will be read

integer64

default “no.loss” (from rgdal 1.2.*). From GDAL 2, fields to be read may also take Integer64 values. As R has no such storage mode, three options are offered, analogous with type.convert for numeric conversion: “allow.loss” which clamps to 32-bit signed integer (default < rgdal 1.2), “warn.loss” - as “allow.loss” but warns when clamping occurs, and “no.loss”, which reads as a character string using the formatting applied by default by GDAL (default >= rgdal 1.2). The use of 64-bit integers is usually a misunderstanding, as such data is almost always a long key ID.

GDAL1_integer64_policy

default FALSE, if TRUE, Integer64 fields are read as doubles

morphFromESRI

default NULL, morph from ESRI WKT1 dialect

dumpSRS

dump SRS to stdout from inside GDAL to debug conversion - developer use only

enforce_xy

(PROJ6+/GDAL3+) either use global setting (default NULL) or override policy for coordinate ordering easting/x as first axis, northing/y as second axis.

D3_if_2D3D_points

https://github.com/r-spatial/sf/issues/1683 case of mixed 2D/3D track points - set TRUE to 3D to pass

missing_3D

default 0, may be finite real numbers; https://github.com/r-spatial/sf/issues/1683

driver

default NULL, driver found using ogrListLayers from the data source; otherwise already known and passed through from a calling function

x

ogrinfo object

...

other arguments to print method

Details

The drivers available will depend on the installation of GDAL/OGR, and can vary; the ogrDrivers() function shows which are available, and which may be written (but all are assumed to be readable). Note that stray files in data source directories (such as *.dbf) may lead to suprious errors that accompanying *.shp are missing.

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.

References

https://gdal.org/drivers/vector/index.html, https://resources.oreilly.com/examples/9780596008659

Author

Roger Bivand

Note

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.

Please note that the OGR drivers used may not handle missing data gracefully, and be prepared to have to correct for this manually. From rgdal 0.5-27, missing value handling has been improved, and OGR unset field values are set to NA in R, but drivers and external files may vary in their representations of missing values.

In addition, from 0.6-9 date and time fields are read as strings rather than being treated as unsupported; NULL geometries are identified and dropped. There are differences in the reporting of NULL geometries between ogrInfo and readOGR - in ogrInfo, only declared NULL geometries are reported, but in readOGR, any line or polygon geometries with no coordinates are assigned NULL geometry status as well. An attempt is made to close unclosed rings in polygon geometries.

For reading GPX files, refer to the OGR GPX format documentation for the use of layer tags: “waypoints”, “tracks”, “routes”, “track_points” and “route_points” - reading GPX files requires a build of GDAL/OGR with the expat XML library.

From 0.6-10, attempts are made to detect deleted features still present in the layer, but not read. Apparently features deleted in Qgis are only marked as deleted, but are still in the layer. These are not NULL geometries, but still need to be handled. An attempt is made to check the FID values, and ogrFIDs now returns attributes permitting this oddity to be detected. Such deleted features were seen as NULL in 0.6-9, but are not such.

From 0.7-24, if the layer has no fields, a single field containing the FID values is placed in the data slot of the returned object.

From 0.7-24, attempts are begun to provide users with arguments to control reading from OGR/shapefile driver when the encoding is inappropriate (especially the setting of LDID in shapefile DBFs, and the SHAPE_ENCODING environment variable).

While there is no certainty, newer drivers such as KML, GML, SQLite and Geopackage (GPKG) may encode string fields as UTF-8. Users are advised to explore this on a case to case basis using Encoding on string fields of input objects.

Because of the representation of DateTime data in OGR, decimal seconds in input data are rounded to integer seconds, see: https://trac.osgeo.org/gdal/ticket/2680.

Because some drivers support reading string, integer and real list fields, support has been introduced into ogrInfo from version 0.9-1 to report their presence and the maximum counts of list items. This may lead to the introduction of the -splitlistfields facility from the command line utility ogrinfo. In addition, ogrInfo reports that there are no features when counting FIDs in a while loop over features in ogrFIDs never enters the loop, despite the layer feature count reporting at least one feature.

See also

Examples

set_thin_PROJ6_warnings(TRUE) ogrDrivers()
#> name long_name write #> 1 AmigoCloud AmigoCloud TRUE #> 2 ARCGEN Arc/Info Generate FALSE #> 3 AVCBin Arc/Info Binary Coverage FALSE #> 4 AVCE00 Arc/Info E00 (ASCII) Coverage FALSE #> 5 BAG Bathymetry Attributed Grid TRUE #> 6 CAD AutoCAD Driver FALSE #> 7 Carto Carto TRUE #> 8 Cloudant Cloudant / CouchDB TRUE #> 9 CouchDB CouchDB / GeoCouch TRUE #> 10 CSV Comma Separated Value (.csv) TRUE #> 11 CSW OGC CSW (Catalog Service for the Web) FALSE #> 12 DGN Microstation DGN TRUE #> 13 DXF AutoCAD DXF TRUE #> 14 EDIGEO French EDIGEO exchange format FALSE #> 15 EEDA Earth Engine Data API FALSE #> 16 Elasticsearch Elastic Search TRUE #> 17 ESRI Shapefile ESRI Shapefile TRUE #> 18 ESRIC Esri Compact Cache FALSE #> 19 ESRIJSON ESRIJSON FALSE #> 20 FlatGeobuf FlatGeobuf TRUE #> 21 Geoconcept Geoconcept TRUE #> 22 GeoJSON GeoJSON TRUE #> 23 GeoJSONSeq GeoJSON Sequence TRUE #> 24 Geomedia Geomedia .mdb FALSE #> 25 GeoRSS GeoRSS TRUE #> 26 GML Geography Markup Language (GML) TRUE #> 27 GPKG GeoPackage TRUE #> 28 GPSBabel GPSBabel TRUE #> 29 GPSTrackMaker GPSTrackMaker TRUE #> 30 GPX GPX TRUE #> 31 HTTP HTTP Fetching Wrapper FALSE #> 32 Idrisi Idrisi Vector (.vct) FALSE #> 33 JML OpenJUMP JML TRUE #> 34 JP2OpenJPEG JPEG-2000 driver based on OpenJPEG library FALSE #> 35 KML Keyhole Markup Language (KML) TRUE #> 36 LVBAG Kadaster LV BAG Extract 2.0 FALSE #> 37 MapInfo File MapInfo File TRUE #> 38 MapML MapML TRUE #> 39 MBTiles MBTiles TRUE #> 40 Memory Memory TRUE #> 41 MSSQLSpatial Microsoft SQL Server Spatial Database TRUE #> 42 MVT Mapbox Vector Tiles TRUE #> 43 MySQL MySQL TRUE #> 44 netCDF Network Common Data Format TRUE #> 45 NGW NextGIS Web TRUE #> 46 OAPIF OGC API - Features FALSE #> 47 ODBC ODBC TRUE #> 48 ODS Open Document/ LibreOffice / OpenOffice Spreadsheet TRUE #> 49 OGCAPI OGCAPI FALSE #> 50 OGR_GMT GMT ASCII Vectors (.gmt) TRUE #> 51 OGR_PDS Planetary Data Systems TABLE FALSE #> 52 OGR_SDTS SDTS FALSE #> 53 OGR_VRT VRT - Virtual Datasource FALSE #> 54 OpenFileGDB ESRI FileGDB FALSE #> 55 OSM OpenStreetMap XML and PBF FALSE #> 56 PCIDSK PCIDSK Database File TRUE #> 57 PDF Geospatial PDF TRUE #> 58 PDS4 NASA Planetary Data System 4 TRUE #> 59 PGDUMP PostgreSQL SQL dump TRUE #> 60 PGeo ESRI Personal GeoDatabase FALSE #> 61 PLSCENES Planet Labs Scenes API FALSE #> 62 PostgreSQL PostgreSQL/PostGIS TRUE #> 63 REC EPIInfo .REC FALSE #> 64 S57 IHO S-57 (ENC) TRUE #> 65 Selafin Selafin TRUE #> 66 SQLite SQLite / Spatialite TRUE #> 67 SVG Scalable Vector Graphics FALSE #> 68 SXF Storage and eXchange Format FALSE #> 69 TIGER U.S. Census TIGER/Line TRUE #> 70 TopoJSON TopoJSON FALSE #> 71 UK .NTF UK .NTF FALSE #> 72 VDV VDV-451/VDV-452/INTREST Data Format TRUE #> 73 VFK Czech Cadastral Exchange Data Format FALSE #> 74 VICAR MIPL VICAR file TRUE #> 75 Walk Walk FALSE #> 76 WAsP WAsP .map format TRUE #> 77 WFS OGC WFS (Web Feature Service) FALSE #> 78 XLSX MS Office Open XML spreadsheet TRUE #> copy isVector #> 1 FALSE TRUE #> 2 FALSE TRUE #> 3 FALSE TRUE #> 4 FALSE TRUE #> 5 TRUE TRUE #> 6 FALSE TRUE #> 7 FALSE TRUE #> 8 FALSE TRUE #> 9 FALSE TRUE #> 10 FALSE TRUE #> 11 FALSE TRUE #> 12 FALSE TRUE #> 13 FALSE TRUE #> 14 FALSE TRUE #> 15 FALSE TRUE #> 16 FALSE TRUE #> 17 FALSE TRUE #> 18 FALSE TRUE #> 19 FALSE TRUE #> 20 FALSE TRUE #> 21 FALSE TRUE #> 22 FALSE TRUE #> 23 FALSE TRUE #> 24 FALSE TRUE #> 25 FALSE TRUE #> 26 FALSE TRUE #> 27 TRUE TRUE #> 28 FALSE TRUE #> 29 FALSE TRUE #> 30 FALSE TRUE #> 31 FALSE TRUE #> 32 FALSE TRUE #> 33 FALSE TRUE #> 34 TRUE TRUE #> 35 FALSE TRUE #> 36 FALSE TRUE #> 37 FALSE TRUE #> 38 FALSE TRUE #> 39 TRUE TRUE #> 40 FALSE TRUE #> 41 FALSE TRUE #> 42 FALSE TRUE #> 43 FALSE TRUE #> 44 TRUE TRUE #> 45 TRUE TRUE #> 46 FALSE TRUE #> 47 FALSE TRUE #> 48 FALSE TRUE #> 49 FALSE TRUE #> 50 FALSE TRUE #> 51 FALSE TRUE #> 52 FALSE TRUE #> 53 FALSE TRUE #> 54 FALSE TRUE #> 55 FALSE TRUE #> 56 FALSE TRUE #> 57 TRUE TRUE #> 58 TRUE TRUE #> 59 FALSE TRUE #> 60 FALSE TRUE #> 61 FALSE TRUE #> 62 FALSE TRUE #> 63 FALSE TRUE #> 64 FALSE TRUE #> 65 FALSE TRUE #> 66 FALSE TRUE #> 67 FALSE TRUE #> 68 FALSE TRUE #> 69 FALSE TRUE #> 70 FALSE TRUE #> 71 FALSE TRUE #> 72 FALSE TRUE #> 73 FALSE TRUE #> 74 TRUE TRUE #> 75 FALSE TRUE #> 76 FALSE TRUE #> 77 FALSE TRUE #> 78 FALSE TRUE
dsn <- system.file("vectors", package = "rgdal")[1] ogrListLayers(dsn)
#> [1] "trin_inca_pl03" "scot_BNG" #> [3] "kiritimati_primary_roads" "cities" #> attr(,"driver") #> [1] "ESRI Shapefile" #> attr(,"nlayers") #> [1] 4
ogrInfo(dsn)
#> Warning: First layer trin_inca_pl03 read; multiple layers present in #> /tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors, check layers with ogrListLayers()
#> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors", layer: "trin_inca_pl03" #> Driver: ESRI Shapefile; number of rows: 3 #> Feature type: wkbPolygon with 2 dimensions #> Extent: (-87.09465 5.499074) - (-79.01339 10.11906) #> Null geometry IDs: 3 #> LDID: 87 #> Number of fields: 12 #> name type length typeName #> 1 ENGL_NAME 4 50 String #> 2 SCI_NAME 4 50 String #> 3 AUTHORITY 4 50 String #> 4 FAMILY 4 50 String #> 5 PRESENCE 0 2 Integer #> 6 ORIGIN 0 2 Integer #> 7 COMPILER 4 50 String #> 8 SCALE 4 50 String #> 9 TAX_COM 4 250 String #> 10 DIST_COM 4 250 String #> 11 REFERENCES 4 250 String #> 12 REVIEWERS 4 250 String
ogrInfo(dsn=dsn, layer="cities")
#> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors", layer: "cities" #> Driver: ESRI Shapefile; number of rows: 606 #> Feature type: wkbPoint with 2 dimensions #> Extent: (-165.27 -53.15) - (177.1302 78.2) #> CRS: +proj=longlat +datum=WGS84 +no_defs #> LDID: 0 #> Number of fields: 4 #> name type length typeName #> 1 NAME 4 40 String #> 2 COUNTRY 4 12 String #> 3 POPULATION 12 11 Integer64 #> 4 CAPITAL 4 1 String
owd <- getwd() setwd(dsn) ogrInfo(dsn="cities.shp")
#> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/cities.shp", layer: "cities" #> Driver: ESRI Shapefile; number of rows: 606 #> Feature type: wkbPoint with 2 dimensions #> Extent: (-165.27 -53.15) - (177.1302 78.2) #> CRS: +proj=longlat +datum=WGS84 +no_defs #> LDID: 0 #> Number of fields: 4 #> name type length typeName #> 1 NAME 4 40 String #> 2 COUNTRY 4 12 String #> 3 POPULATION 12 11 Integer64 #> 4 CAPITAL 4 1 String
ogrInfo(dsn="cities.shp", layer="cities")
#> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/cities.shp", layer: "cities" #> Driver: ESRI Shapefile; number of rows: 606 #> Feature type: wkbPoint with 2 dimensions #> Extent: (-165.27 -53.15) - (177.1302 78.2) #> CRS: +proj=longlat +datum=WGS84 +no_defs #> LDID: 0 #> Number of fields: 4 #> name type length typeName #> 1 NAME 4 40 String #> 2 COUNTRY 4 12 String #> 3 POPULATION 12 11 Integer64 #> 4 CAPITAL 4 1 String
setwd(owd) ow <- options("warn")$warn options("warn"=1) cities <- readOGR(dsn=dsn, layer="cities")
#> OGR data source with driver: ESRI Shapefile #> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors", layer: "cities" #> with 606 features #> It has 4 fields #> Integer64 fields read as strings: POPULATION
str(slot(cities, "data"))
#> 'data.frame': 606 obs. of 4 variables: #> $ NAME : chr "Murmansk" "Arkhangelsk" "Saint Petersburg" "Magadan" ... #> $ COUNTRY : chr "Russia" "Russia" "Russia" "Russia" ... #> $ POPULATION: chr "468000" "416000" "5825000" "152000" ... #> $ CAPITAL : chr "N" "N" "N" "N" ...
if (new_proj_and_gdal()) comment(slot(cities, "proj4string"))
#> [1] "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"latitude\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"longitude\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4326]]"
cities$POPULATION <- type.convert(as.character(cities$POPULATION), na.strings="-99", numerals="no.loss")
#> Warning: 'as.is' should be specified by the caller; using TRUE
str(slot(cities, "data"))
#> 'data.frame': 606 obs. of 4 variables: #> $ NAME : chr "Murmansk" "Arkhangelsk" "Saint Petersburg" "Magadan" ... #> $ COUNTRY : chr "Russia" "Russia" "Russia" "Russia" ... #> $ POPULATION: int 468000 416000 5825000 152000 1160000 1620000 2025000 1800000 1140000 1325000 ... #> $ CAPITAL : chr "N" "N" "N" "N" ...
cities <- readOGR(dsn=dsn, layer="cities", GDAL1_integer64_policy=TRUE)
#> OGR data source with driver: ESRI Shapefile #> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors", layer: "cities" #> with 606 features #> It has 4 fields #> Integer64 fields read as doubles: POPULATION
str(slot(cities, "data"))
#> 'data.frame': 606 obs. of 4 variables: #> $ NAME : chr "Murmansk" "Arkhangelsk" "Saint Petersburg" "Magadan" ... #> $ COUNTRY : chr "Russia" "Russia" "Russia" "Russia" ... #> $ POPULATION: num 468000 416000 5825000 152000 1160000 ... #> $ CAPITAL : chr "N" "N" "N" "N" ...
options("warn"=ow) summary(cities)
#> Object of class SpatialPointsDataFrame #> Coordinates: #> min max #> coords.x1 -165.27 177.1302 #> coords.x2 -53.15 78.2000 #> Is projected: FALSE #> proj4string : [+proj=longlat +datum=WGS84 +no_defs] #> Number of points: 606 #> Data attributes: #> NAME COUNTRY POPULATION CAPITAL #> Length:606 Length:606 Min. : -99 Length:606 #> Class :character Class :character 1st Qu.: 243744 Class :character #> Mode :character Mode :character Median : 710447 Mode :character #> Mean : 1411999 #> 3rd Qu.: 1536250 #> Max. :23620000
table(Encoding(as.character(cities$NAME)))
#> #> unknown #> 606
ogrInfo(dsn=dsn, layer="kiritimati_primary_roads")
#> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors", layer: "kiritimati_primary_roads" #> Driver: ESRI Shapefile; number of rows: 35 #> Feature type: wkbLineString with 2 dimensions #> Extent: (667587.7 187716.6) - (704048 226051.2) #> CRS: +proj=utm +zone=4 +datum=WGS84 +units=m +no_defs #> LDID: 87 #> Number of fields: 1 #> name type length typeName #> 1 Id 0 6 Integer
OGRSpatialRef(dsn=dsn, layer="kiritimati_primary_roads")
#> [1] "+proj=utm +zone=4 +datum=WGS84 +units=m +no_defs"
kiritimati_primary_roads <- readOGR(dsn=dsn, layer="kiritimati_primary_roads")
#> OGR data source with driver: ESRI Shapefile #> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors", layer: "kiritimati_primary_roads" #> with 35 features #> It has 1 fields
summary(kiritimati_primary_roads)
#> Object of class SpatialLinesDataFrame #> Coordinates: #> min max #> x 667587.7 704048.0 #> y 187716.6 226051.2 #> Is projected: TRUE #> proj4string : #> [+proj=utm +zone=4 +datum=WGS84 +units=m +no_defs] #> Data attributes: #> Id #> Min. :0 #> 1st Qu.:0 #> Median :0 #> Mean :0 #> 3rd Qu.:0 #> Max. :0
if (new_proj_and_gdal()) comment(slot(kiritimati_primary_roads, "proj4string"))
#> [1] "PROJCRS[\"WGS 84 / UTM zone 4N\",\n BASEGEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4326]],\n CONVERSION[\"UTM zone 4N\",\n METHOD[\"Transverse Mercator\",\n ID[\"EPSG\",9807]],\n PARAMETER[\"Latitude of natural origin\",0,\n ANGLEUNIT[\"Degree\",0.0174532925199433],\n ID[\"EPSG\",8801]],\n PARAMETER[\"Longitude of natural origin\",-159,\n ANGLEUNIT[\"Degree\",0.0174532925199433],\n ID[\"EPSG\",8802]],\n PARAMETER[\"Scale factor at natural origin\",0.9996,\n SCALEUNIT[\"unity\",1],\n ID[\"EPSG\",8805]],\n PARAMETER[\"False easting\",500000,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8806]],\n PARAMETER[\"False northing\",0,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8807]]],\n CS[Cartesian,2],\n AXIS[\"(E)\",east,\n ORDER[1],\n LENGTHUNIT[\"metre\",1]],\n AXIS[\"(N)\",north,\n ORDER[2],\n LENGTHUNIT[\"metre\",1]],\n ID[\"EPSG\",32604]]"
ogrInfo(dsn=dsn, layer="scot_BNG")
#> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors", layer: "scot_BNG" #> Driver: ESRI Shapefile; number of rows: 56 #> Feature type: wkbPolygon with 2 dimensions #> Extent: (7094.552 529495) - (468285.5 1218342) #> CRS: +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +units=m +no_defs #> LDID: 0 #> Number of fields: 13 #> name type length typeName #> 1 SP_ID 4 5 String #> 2 NAME 4 13 String #> 3 ID_x 2 19 Real #> 4 COUNT 2 19 Real #> 5 SMR 2 19 Real #> 6 LONG 2 19 Real #> 7 LAT 2 19 Real #> 8 PY 2 19 Real #> 9 EXP_ 2 19 Real #> 10 AFF 2 19 Real #> 11 X_COOR 2 19 Real #> 12 Y_COOR 2 19 Real #> 13 ID_y 2 19 Real
OGRSpatialRef(dsn=dsn, layer="scot_BNG")
#> [1] "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +units=m +no_defs"
scot_BNG <- readOGR(dsn=dsn, layer="scot_BNG")
#> OGR data source with driver: ESRI Shapefile #> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors", layer: "scot_BNG" #> with 56 features #> It has 13 fields
summary(scot_BNG)
#> Object of class SpatialPolygonsDataFrame #> Coordinates: #> min max #> x 7094.552 468285.5 #> y 529495.039 1218342.5 #> Is projected: TRUE #> proj4string : #> [+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 #> +y_0=-100000 +ellps=airy +units=m +no_defs] #> Data attributes: #> SP_ID NAME ID_x COUNT #> Length:56 Length:56 Min. : 1.00 Min. : 0.000 #> Class :character Class :character 1st Qu.:14.75 1st Qu.: 4.750 #> Mode :character Mode :character Median :28.50 Median : 8.000 #> Mean :28.50 Mean : 9.571 #> 3rd Qu.:42.25 3rd Qu.:11.000 #> Max. :56.00 Max. :39.000 #> SMR LONG LAT PY #> Min. : 0.0 Min. :54.94 Min. :1.430 Min. : 27075 #> 1st Qu.: 49.6 1st Qu.:55.78 1st Qu.:3.288 1st Qu.: 100559 #> Median :111.5 Median :56.04 Median :4.090 Median : 182333 #> Mean :152.6 Mean :56.40 Mean :4.012 Mean : 267498 #> 3rd Qu.:223.0 3rd Qu.:57.02 3rd Qu.:4.730 3rd Qu.: 313845 #> Max. :652.2 Max. :60.24 Max. :6.800 Max. :2316353 #> EXP_ AFF X_COOR Y_COOR #> Min. : 1.100 Min. : 0.000 Min. :112892 Min. : 561163 #> 1st Qu.: 4.050 1st Qu.: 1.000 1st Qu.:256624 1st Qu.: 649520 #> Median : 6.300 Median : 7.000 Median :287577 Median : 681524 #> Mean : 9.575 Mean : 8.661 Mean :288524 Mean : 723127 #> 3rd Qu.:10.125 3rd Qu.:11.500 3rd Qu.:333948 3rd Qu.: 794380 #> Max. :88.700 Max. :24.000 Max. :442244 Max. :1168904 #> ID_y #> Min. : 1.00 #> 1st Qu.:14.75 #> Median :28.50 #> Mean :28.50 #> 3rd Qu.:42.25 #> Max. :56.00
if (new_proj_and_gdal()) comment(slot(scot_BNG, "proj4string"))
#> [1] "PROJCRS[\"OSGB36 / British National Grid\",\n BASEGEOGCRS[\"OSGB36\",\n DATUM[\"Ordnance Survey of Great Britain 1936\",\n ELLIPSOID[\"Airy 1830\",6377563.396,299.3249646,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4277]],\n CONVERSION[\"British National Grid\",\n METHOD[\"Transverse Mercator\",\n ID[\"EPSG\",9807]],\n PARAMETER[\"Latitude of natural origin\",49,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8801]],\n PARAMETER[\"Longitude of natural origin\",-2,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8802]],\n PARAMETER[\"Scale factor at natural origin\",0.9996012717,\n SCALEUNIT[\"unity\",1],\n ID[\"EPSG\",8805]],\n PARAMETER[\"False easting\",400000,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8806]],\n PARAMETER[\"False northing\",-100000,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8807]]],\n CS[Cartesian,2],\n AXIS[\"(E)\",east,\n ORDER[1],\n LENGTHUNIT[\"metre\",1]],\n AXIS[\"(N)\",north,\n ORDER[2],\n LENGTHUNIT[\"metre\",1]],\n USAGE[\n SCOPE[\"Engineering survey, topographic mapping.\"],\n AREA[\"United Kingdom (UK) - offshore to boundary of UKCS within 49°45'N to 61°N and 9°W to 2°E; onshore Great Britain (England, Wales and Scotland). Isle of Man onshore.\"],\n BBOX[49.75,-9,61.01,2.01]],\n ID[\"EPSG\",27700]]"
if ("GML" %in% ogrDrivers()$name) { dsn <- system.file("vectors/airports.gml", package = "rgdal")[1] airports <- try(readOGR(dsn=dsn, layer="airports")) if (!inherits(airports, "try-error")) { summary(airports) if (new_proj_and_gdal()) comment(slot(airports, "proj4string")) } }
#> OGR data source with driver: GML #> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/airports.gml", layer: "airports" #> with 13 features #> It has 6 fields
#> NULL
dsn <- system.file("vectors/ps_cant_31.MIF", package = "rgdal")[1] ogrInfo(dsn=dsn, layer="ps_cant_31")
#> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/ps_cant_31.MIF", layer: "ps_cant_31" #> Driver: MapInfo File; number of rows: 44 #> Feature type: wkbPolygon with 2 dimensions #> Extent: (0.449114 42.69196) - (2.048339 43.91861) #> CRS: +proj=longlat +a=6378137.01 +rf=298.257223563 +no_defs +type=crs #> Number of fields: 8 #> name type length typeName #> 1 CODE 4 5 String #> 2 NOM 4 40 String #> 3 POP 2 0 Real #> 4 SUP 2 0 Real #> 5 Longitude 2 0 Real #> 6 Latitude 2 0 Real #> 7 Pseudo_c 4 5 String #> 8 DEP 4 5 String
ps_cant_31 <- readOGR(dsn=dsn, layer="ps_cant_31")
#> OGR data source with driver: MapInfo File #> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/ps_cant_31.MIF", layer: "ps_cant_31" #> with 44 features #> It has 8 fields
summary(ps_cant_31)
#> Object of class SpatialPolygonsDataFrame #> Coordinates: #> min max #> x 0.449114 2.048339 #> y 42.691957 43.918612 #> Is projected: FALSE #> proj4string : #> [+proj=longlat +a=6378137.01 +rf=298.257223563 +no_defs +type=crs] #> Data attributes: #> CODE NOM POP SUP #> Length:44 Length:44 Min. : 3188 Min. : 635 #> Class :character Class :character 1st Qu.: 4748 1st Qu.:10234 #> Mode :character Mode :character Median : 9205 Median :15826 #> Mean : 21043 Mean :14478 #> 3rd Qu.: 22392 3rd Qu.:19007 #> Max. :358598 Max. :31161 #> Longitude Latitude Pseudo_c DEP #> Min. : 518350 Min. : 1838600 Length:44 Length:44 #> 1st Qu.: 4777200 1st Qu.:16575363 Class :character Class :character #> Median : 6403225 Median :22660600 Mode :character Mode :character #> Mean : 6717604 Mean :24264069 #> 3rd Qu.: 9209718 3rd Qu.:34440138 #> Max. :14086469 Max. :54508151
sapply(as(ps_cant_31, "data.frame"), class)
#> CODE NOM POP SUP Longitude Latitude #> "character" "character" "numeric" "numeric" "numeric" "numeric" #> Pseudo_c DEP #> "character" "character"
if (new_proj_and_gdal()) comment(slot(ps_cant_31, "proj4string"))
#> [1] "GEOGCRS[\"unnamed\",\n DATUM[\"MIF 0\",\n ELLIPSOID[\"WGS 84 (MAPINFO Datum 0)\",6378137.01,298.257223563,\n LENGTHUNIT[\"metre\",1,\n ID[\"EPSG\",9001]]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433,\n ID[\"EPSG\",9122]]],\n CS[ellipsoidal,2],\n AXIS[\"latitude\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433,\n ID[\"EPSG\",9122]]],\n AXIS[\"longitude\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433,\n ID[\"EPSG\",9122]]]]"
ps_cant_31 <- readOGR(dsn=dsn, layer="ps_cant_31", stringsAsFactors=FALSE)
#> OGR data source with driver: MapInfo File #> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/ps_cant_31.MIF", layer: "ps_cant_31" #> with 44 features #> It has 8 fields
summary(ps_cant_31)
#> Object of class SpatialPolygonsDataFrame #> Coordinates: #> min max #> x 0.449114 2.048339 #> y 42.691957 43.918612 #> Is projected: FALSE #> proj4string : #> [+proj=longlat +a=6378137.01 +rf=298.257223563 +no_defs +type=crs] #> Data attributes: #> CODE NOM POP SUP #> Length:44 Length:44 Min. : 3188 Min. : 635 #> Class :character Class :character 1st Qu.: 4748 1st Qu.:10234 #> Mode :character Mode :character Median : 9205 Median :15826 #> Mean : 21043 Mean :14478 #> 3rd Qu.: 22392 3rd Qu.:19007 #> Max. :358598 Max. :31161 #> Longitude Latitude Pseudo_c DEP #> Min. : 518350 Min. : 1838600 Length:44 Length:44 #> 1st Qu.: 4777200 1st Qu.:16575363 Class :character Class :character #> Median : 6403225 Median :22660600 Mode :character Mode :character #> Mean : 6717604 Mean :24264069 #> 3rd Qu.: 9209718 3rd Qu.:34440138 #> Max. :14086469 Max. :54508151
sapply(as(ps_cant_31, "data.frame"), class)
#> CODE NOM POP SUP Longitude Latitude #> "character" "character" "numeric" "numeric" "numeric" "numeric" #> Pseudo_c DEP #> "character" "character"
dsn <- system.file("vectors/Up.tab", package = "rgdal")[1] ogrInfo(dsn=dsn, layer="Up")
#> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/Up.tab", layer: "Up" #> Driver: MapInfo File; number of rows: 81 #> Feature type: wkbPolygon with 2 dimensions #> Extent: (598047.2 781652.7) - (619791.4 812944.4) #> CRS: +proj=utm +zone=23 +south +ellps=aust_SA +units=m +no_defs #> Number of fields: 52 #> name type length typeName #> 1 ID 0 0 Integer #> 2 unid_planejamento 4 4 String #> 3 codigo2 4 4 String #> 4 descricao 4 100 String #> 5 Area 2 20 Real #> 6 densidade_pop 2 0 Real #> 7 POPULACAO 2 0 Real #> 8 Idademed 2 8 Real #> 9 Med_estu 2 11 Real #> 10 Idosoper 2 8 Real #> 11 Crianca 2 8 Real #> 12 THomCor_95 2 0 Real #> 13 THomCor_96 2 0 Real #> 14 THomCor_97 2 0 Real #> 15 THomCor_98 2 0 Real #> 16 THomCor_99 2 0 Real #> 17 HomCor_95 2 0 Real #> 18 HomCor_96 2 0 Real #> 19 HomCor_97 2 0 Real #> 20 HomCor_98 2 0 Real #> 21 HomCor_99 2 0 Real #> 22 RouboCor_95 2 0 Real #> 23 RouboCor_96 2 0 Real #> 24 RouboCor_97 2 0 Real #> 25 RouboCor_98 2 0 Real #> 26 RouboCor_99 2 0 Real #> 27 RMACor_95 2 0 Real #> 28 RMACor_96 2 0 Real #> 29 RMACor_97 2 0 Real #> 30 RMACor_98 2 0 Real #> 31 RMACor_99 2 0 Real #> 32 CRpesCor_95 2 0 Real #> 33 CRpesCor_96 2 0 Real #> 34 CRpesCor_97 2 0 Real #> 35 CRpesCor_98 2 0 Real #> 36 CRpesCor_99 2 0 Real #> 37 PatriCor_95 2 0 Real #> 38 PatriCor_96 2 0 Real #> 39 PatriCor_97 2 0 Real #> 40 PatriCor_98 2 0 Real #> 41 PatriCor_99 2 0 Real #> 42 RENDA 2 0 Real #> 43 IndIFU 2 0 Real #> 44 IndASU 2 0 Real #> 45 HomTent9599 2 0 Real #> 46 Hom9599 2 0 Real #> 47 Roub9599 2 0 Real #> 48 RMA9599 2 0 Real #> 49 RMA9599_2 2 0 Real #> 50 CRpes9599 2 0 Real #> 51 Patri9599 2 0 Real #> 52 PERAREAC 2 0 Real
Up <- readOGR(dsn=dsn, layer="Up")
#> OGR data source with driver: MapInfo File #> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/Up.tab", layer: "Up" #> with 81 features #> It has 52 fields
summary(Up)
#> Object of class SpatialPolygonsDataFrame #> Coordinates: #> min max #> x 598047.2 619791.4 #> y 781652.7 812944.4 #> Is projected: TRUE #> proj4string : #> [+proj=utm +zone=23 +south +ellps=aust_SA +units=m +no_defs] #> Data attributes: #> ID unid_planejamento codigo2 descricao #> Min. : 1 Length:81 Length:81 Length:81 #> 1st Qu.:21 Class :character Class :character Class :character #> Median :41 Mode :character Mode :character Mode :character #> Mean :41 #> 3rd Qu.:61 #> Max. :81 #> Area densidade_pop POPULACAO Idademed #> Min. :0.078 Min. : 0 Min. : 0 Min. : 0.00 #> 1st Qu.:0.827 1st Qu.:10075 1st Qu.:10194 1st Qu.:26.03 #> Median :1.477 Median :21796 Median :23208 Median :27.68 #> Mean :1.566 Mean :21522 Mean :25819 Mean :28.30 #> 3rd Qu.:2.161 3rd Qu.:26710 3rd Qu.:39991 3rd Qu.:30.92 #> Max. :5.912 Max. :84872 Max. :69631 Max. :39.81 #> Med_estu Idosoper Crianca THomCor_95 #> Min. : 0.000 Min. : 0.000 Min. : 0.00 Min. : 10.76 #> 1st Qu.: 6.240 1st Qu.: 3.280 1st Qu.:19.22 1st Qu.: 30.67 #> Median : 7.680 Median : 4.140 Median :23.12 Median : 44.05 #> Mean : 8.191 Mean : 5.204 Mean :22.44 Mean : 56.20 #> 3rd Qu.:10.180 3rd Qu.: 6.580 3rd Qu.:25.67 3rd Qu.: 61.41 #> Max. :14.390 Max. :17.060 Max. :35.87 Max. :302.07 #> THomCor_96 THomCor_97 THomCor_98 THomCor_99 #> Min. : 6.666 Min. : 8.014 Min. : 7.664 Min. : 4.718 #> 1st Qu.: 17.531 1st Qu.: 21.695 1st Qu.: 36.839 1st Qu.: 21.568 #> Median : 29.530 Median : 30.585 Median : 51.769 Median : 33.460 #> Mean : 35.833 Mean : 43.619 Mean : 66.024 Mean : 43.566 #> 3rd Qu.: 40.434 3rd Qu.: 52.297 3rd Qu.: 76.805 3rd Qu.: 48.819 #> Max. :204.495 Max. :203.096 Max. :270.214 Max. :303.179 #> HomCor_95 HomCor_96 HomCor_97 HomCor_98 #> Min. : 2.661 Min. : 1.325 Min. : 1.830 Min. : 3.516 #> 1st Qu.: 4.388 1st Qu.: 3.667 1st Qu.: 4.183 1st Qu.: 8.403 #> Median : 5.529 Median : 5.910 Median : 5.699 Median :11.136 #> Mean : 6.183 Mean : 6.868 Mean : 6.861 Mean :13.718 #> 3rd Qu.: 6.961 3rd Qu.: 8.363 3rd Qu.: 7.559 3rd Qu.:15.192 #> Max. :14.883 Max. :24.932 Max. :28.544 Max. :50.005 #> HomCor_99 RouboCor_95 RouboCor_96 RouboCor_97 #> Min. : 1.573 Min. : 0.448 Min. : 0.419 Min. : 0.421 #> 1st Qu.: 4.735 1st Qu.: 17.262 1st Qu.: 16.796 1st Qu.: 21.774 #> Median : 8.003 Median : 32.894 Median : 33.230 Median : 48.739 #> Mean :10.923 Mean : 109.019 Mean : 116.590 Mean : 149.269 #> 3rd Qu.:13.558 3rd Qu.: 64.300 3rd Qu.: 70.542 3rd Qu.: 128.858 #> Max. :48.515 Max. :3522.697 Max. :3750.638 Max. :4018.214 #> RouboCor_98 RouboCor_99 RMACor_95 RMACor_96 #> Min. : 0.135 Min. : 1.304 Min. : 12.19 Min. : 13.10 #> 1st Qu.: 25.430 1st Qu.: 34.056 1st Qu.: 44.62 1st Qu.: 66.37 #> Median : 85.449 Median : 70.152 Median : 81.87 Median : 101.54 #> Mean : 797.151 Mean : 192.016 Mean : 118.86 Mean : 140.81 #> 3rd Qu.: 276.336 3rd Qu.: 135.308 3rd Qu.: 145.88 3rd Qu.: 173.36 #> Max. :23590.153 Max. :6039.410 Max. :1163.74 Max. :1025.96 #> RMACor_97 RMACor_98 RMACor_99 CRpesCor_95 #> Min. : 29.87 Min. : 46.06 Min. : 37.27 Min. : 11.08 #> 1st Qu.: 102.07 1st Qu.: 149.83 1st Qu.: 170.47 1st Qu.: 32.13 #> Median : 162.84 Median : 238.22 Median : 275.80 Median : 47.09 #> Mean : 207.57 Mean : 277.97 Mean : 346.77 Mean : 62.63 #> 3rd Qu.: 242.06 3rd Qu.: 328.98 3rd Qu.: 399.75 3rd Qu.: 68.42 #> Max. :1390.62 Max. :1746.30 Max. :3116.97 Max. :320.40 #> CRpesCor_96 CRpesCor_97 CRpesCor_98 CRpesCor_99 #> Min. : 7.327 Min. : 8.834 Min. : 7.939 Min. : 5.102 #> 1st Qu.: 20.669 1st Qu.: 25.715 1st Qu.: 42.795 1st Qu.: 26.299 #> Median : 34.913 Median : 37.315 Median : 64.888 Median : 39.858 #> Mean : 43.303 Mean : 51.280 Mean : 80.662 Mean : 54.977 #> 3rd Qu.: 51.315 3rd Qu.: 58.731 3rd Qu.: 87.589 3rd Qu.: 64.697 #> Max. :234.966 Max. :246.821 Max. :323.035 Max. :322.595 #> PatriCor_95 PatriCor_96 PatriCor_97 PatriCor_98 #> Min. : 4.388 Min. : 4.903 Min. : 14.04 Min. : 61.46 #> 1st Qu.: 58.596 1st Qu.: 71.210 1st Qu.: 130.01 1st Qu.: 214.91 #> Median : 110.455 Median : 135.437 Median : 228.21 Median : 363.27 #> Mean : 227.274 Mean : 256.954 Mean : 361.39 Mean : 939.99 #> 3rd Qu.: 204.408 3rd Qu.: 249.147 3rd Qu.: 367.02 3rd Qu.: 680.89 #> Max. :4722.555 Max. :4809.846 Max. :5449.27 Max. :14505.94 #> PatriCor_99 RENDA IndIFU IndASU #> Min. : 12.28 Min. : 104.7 Min. :-2.61604 Min. :-0.12455 #> 1st Qu.: 205.34 1st Qu.: 206.5 1st Qu.:-0.75862 1st Qu.:-0.07015 #> Median : 350.86 Median : 291.6 Median :-0.07413 Median : 0.04219 #> Mean : 554.31 Mean : 516.7 Mean :-0.30299 Mean : 0.33239 #> 3rd Qu.: 552.92 3rd Qu.: 591.3 3rd Qu.: 0.19614 3rd Qu.: 0.35495 #> Max. :9205.57 Max. :3994.5 Max. : 0.61122 Max. : 5.29971 #> HomTent9599 Hom9599 Roub9599 RMA9599 #> Min. : 9.842 Min. : 1.332 Min. : 1.327 Min. : 14.35 #> 1st Qu.: 23.818 1st Qu.: 5.014 1st Qu.: 33.661 1st Qu.: 112.86 #> Median : 40.110 Median : 7.213 Median : 75.000 Median : 176.85 #> Mean : 49.598 Mean : 9.348 Mean : 306.451 Mean : 223.02 #> 3rd Qu.: 58.499 3rd Qu.:11.752 3rd Qu.: 169.146 3rd Qu.: 272.95 #> Max. :285.429 Max. :37.327 Max. :6819.439 Max. :1708.28 #> RMA9599_2 CRpes9599 Patri9599 PERAREAC #> Min. : 14.35 Min. : 9.933 Min. : 46.16 Min. : 0.0000 #> 1st Qu.: 112.86 1st Qu.: 28.946 1st Qu.: 165.24 1st Qu.: 0.1419 #> Median : 176.85 Median : 44.519 Median : 243.87 Median : 0.5484 #> Mean : 223.02 Mean : 59.188 Mean : 528.77 Mean : 1.1358 #> 3rd Qu.: 272.95 3rd Qu.: 66.983 3rd Qu.: 413.41 3rd Qu.: 1.3150 #> Max. :1708.28 Max. :317.845 Max. :7271.53 Max. :17.5547
if (new_proj_and_gdal()) comment(slot(Up, "proj4string"))
#> [1] "PROJCRS[\"unnamed\",\n BASEGEOGCRS[\"unnamed\",\n DATUM[\"South American Datum 1969\",\n ELLIPSOID[\"South American\",6378160,298.25,\n LENGTHUNIT[\"metre\",1,\n ID[\"EPSG\",9001]]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433,\n ID[\"EPSG\",9122]]]],\n CONVERSION[\"Transverse Mercator\",\n METHOD[\"Transverse Mercator\",\n ID[\"EPSG\",9807]],\n PARAMETER[\"Latitude of natural origin\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8801]],\n PARAMETER[\"Longitude of natural origin\",-45,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8802]],\n PARAMETER[\"Scale factor at natural origin\",0.9996,\n SCALEUNIT[\"unity\",1],\n ID[\"EPSG\",8805]],\n PARAMETER[\"False easting\",500000,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8806]],\n PARAMETER[\"False northing\",10000000,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8807]]],\n CS[Cartesian,2],\n AXIS[\"(E)\",east,\n ORDER[1],\n LENGTHUNIT[\"metre\",1,\n ID[\"EPSG\",9001]]],\n AXIS[\"(N)\",north,\n ORDER[2],\n LENGTHUNIT[\"metre\",1,\n ID[\"EPSG\",9001]]]]"
dsn <- system.file("vectors/test_trk2.gpx", package = "rgdal")[1] test_trk2 <- try(readOGR(dsn=dsn, layer="tracks"))
#> OGR data source with driver: GPX #> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/test_trk2.gpx", layer: "tracks" #> with 2 features #> It has 12 fields
if (!inherits(test_trk2, "try-error")) { summary(test_trk2) if (new_proj_and_gdal()) comment(slot(test_trk2, "proj4string")) }
#> [1] "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4326]]"
test_trk2pts <- try(readOGR(dsn=dsn, layer="track_points"))
#> OGR data source with driver: GPX #> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/test_trk2.gpx", layer: "track_points" #> with 27 features #> It has 28 fields
if (!inherits(test_trk2pts, "try-error")) { summary(test_trk2pts) if (new_proj_and_gdal()) comment(slot(test_trk2pts, "proj4string")) }
#> [1] "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4326]]"
dsn <- system.file("vectors", package = "rgdal")[1] ogrInfo(dsn=dsn, layer="trin_inca_pl03")
#> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors", layer: "trin_inca_pl03" #> Driver: ESRI Shapefile; number of rows: 3 #> Feature type: wkbPolygon with 2 dimensions #> Extent: (-87.09465 5.499074) - (-79.01339 10.11906) #> Null geometry IDs: 3 #> LDID: 87 #> Number of fields: 12 #> name type length typeName #> 1 ENGL_NAME 4 50 String #> 2 SCI_NAME 4 50 String #> 3 AUTHORITY 4 50 String #> 4 FAMILY 4 50 String #> 5 PRESENCE 0 2 Integer #> 6 ORIGIN 0 2 Integer #> 7 COMPILER 4 50 String #> 8 SCALE 4 50 String #> 9 TAX_COM 4 250 String #> 10 DIST_COM 4 250 String #> 11 REFERENCES 4 250 String #> 12 REVIEWERS 4 250 String
birds <- readOGR(dsn=dsn, layer="trin_inca_pl03")
#> OGR data source with driver: ESRI Shapefile #> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors", layer: "trin_inca_pl03" #> with 3 features #> It has 12 fields
#> Warning: Dropping null geometries: 3
summary(birds)
#> Object of class SpatialPolygonsDataFrame #> Coordinates: #> min max #> x -87.094650 -79.01339 #> y 5.499074 10.11906 #> Is projected: NA #> proj4string : [NA] #> Data attributes: #> ENGL_NAME SCI_NAME AUTHORITY FAMILY #> Length:2 Length:2 Length:2 Length:2 #> Class :character Class :character Class :character Class :character #> Mode :character Mode :character Mode :character Mode :character #> #> #> #> PRESENCE ORIGIN COMPILER SCALE #> Min. :1 Min. :3 Length:2 Length:2 #> 1st Qu.:1 1st Qu.:3 Class :character Class :character #> Median :1 Median :3 Mode :character Mode :character #> Mean :1 Mean :3 #> 3rd Qu.:1 3rd Qu.:3 #> Max. :1 Max. :3 #> TAX_COM DIST_COM REFERENCES REVIEWERS #> Length:2 Length:2 Length:2 Length:2 #> Class :character Class :character Class :character Class :character #> Mode :character Mode :character Mode :character Mode :character #> #> #>
if (new_proj_and_gdal()) comment(slot(birds, "proj4string"))
#> NULL
dsn <- system.file("vectors/PacoursIKA2.TAB", package = "rgdal")[1] try(ogrInfo(dsn, "PacoursIKA2"))
#> Error in ogrInfo(dsn, "PacoursIKA2") : #> Multiple incompatible geometries: wkbPoint: 4; wkbLineString: 1
ogrInfo(dsn, "PacoursIKA2", require_geomType="wkbPoint")
#> NOTE: keeping only 4 wkbPoint of 5 features #> note that extent applies to all features
#> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/PacoursIKA2.TAB", layer: "PacoursIKA2" #> Driver: MapInfo File; number of rows: 5 #> selected geometry type: wkbPoint with 4 rows #> Feature type: wkbPoint with 2 dimensions #> Extent: (899389.2 2221931) - (903680.7 2227011) #> CRS: +proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.999877420000019 +x_0=600000 +y_0=2200000.0000003 +ellps=clrk80ign +pm=paris +units=m +no_defs #> Number of fields: 2 #> name type length typeName #> 1 NomParcours 4 25 String #> 2 Longueur 4 25 String
plot(readOGR(dsn, "PacoursIKA2", require_geomType="wkbLineString"), col="red")
#> OGR data source with driver: MapInfo File #> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/PacoursIKA2.TAB", layer: "PacoursIKA2" #> with 5 features; #> Selected wkbLineString feature type, with 1 rows #> It has 2 fields
#> NOTE: keeping only 1 wkbLineString of 5 features
plot(readOGR(dsn, "PacoursIKA2", require_geomType="wkbPoint"), add=TRUE)
#> OGR data source with driver: MapInfo File #> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/PacoursIKA2.TAB", layer: "PacoursIKA2" #> with 5 features; #> Selected wkbPoint feature type, with 4 rows #> It has 2 fields
#> NOTE: keeping only 4 wkbPoint of 5 features
odir <- getwd() setwd(system.file("vectors", package = "rgdal")[1]) ow <- options("warn")$warn options("warn"=1) ogrInfo("test64.vrt", "test64")
#> Source: "/tmp/Rtmpu1yWGf/temp_libpathfa5c0298539de/rgdal/vectors/test64.vrt", layer: "test64" #> Driver: OGR_VRT; number of rows: 1 #> Feature type: wkbPoint with 2 dimensions #> Extent: (0 0) - (0 0) #> CRS: +proj=longlat +datum=WGS84 +no_defs #> Number of fields: 4 #> name type length typeName #> 1 Longitude 0 0 Integer #> 2 Latitude 0 0 Integer #> 3 id 0 0 Integer #> 4 val 12 0 Integer64
str(readOGR("test64.vrt", "test64", verbose=FALSE, integer64="allow.loss")$val)
#> int 2147483647
str(readOGR("test64.vrt", "test64", verbose=FALSE, integer64="warn.loss")$val)
#> Warning: Integer64 value clamped: feature 0
#> int 2147483647
str(readOGR("test64.vrt", "test64", verbose=FALSE, integer64="no.loss")$val)
#> chr "987654321000"
str(readOGR("test64.vrt", "test64", verbose=FALSE, stringsAsFactors=FALSE, integer64="no.loss")$val)
#> chr "987654321000"
setwd(odir) options("warn"=ow)