Import an ESRI Shapefile
importShapefile (fn, readDBF=TRUE, projection=NULL, zone=NULL, minverts=3, placeholes=FALSE, show.progress=FALSE)
fn |
|
readDBF |
|
projection |
|
zone |
|
minverts |
|
placeholes |
|
show.progress |
|
This routine imports an ESRI shapefile (.shp) into either a
PolySet or EventData, depending on the type of
shapefile. It supports types 1 (Point), 3 (PolyLine), and 5 (Polygon)
and imports type 1 into EventData and types 3 and 5 into a
PolySet. In addition to the shapefile (.shp), it
requires the related index file (.shx).
If a database containing feature attributes (.dbf) exists, it
also imports this database by default. For EventData, it binds
the database columns to the EventData object. For a
PolySet, it saves the database in a PolyData object and
attaches that object to the PolySet in an attribute named
“PolyData”.
If a .prj file exists, this information is attached as an attribute.
If the first 3 characters are ‘GEO’, then a geographic projection
is assumed and projection="LL". If the first 4 characters are
‘PROJ’, and ‘UTM’ occurs elsewhere in the string, then the
Universal Transverse Mercator projection is assumed and projection="UTM".
Otherwise, projection=1.
If an .xml file exists, this information is attached as an attribute.
Shapes of numeric shape type 5 exported from ArcView in geographic
projection identify solids as polygons with vertices following a clockwise
path and holes as polygons that follow a counter-clockwise path.
Unfortuantely, either the export from ArcView or the import using a C-routine
from the package maptools often does not report solids followed by their holes.
We employ a new R function placeHoles to do this for us.
Ideally, this routine should be rendered in C, but for now we use this
function if the user sets the argument placeholes=TRUE.
Depending on the size and complexity of your shapefile, the computation may take a while.
For points, EventData with columns EID, X, and
Y, possibly with other columns from the attribute database. For
polylines and polygons, a PolySet with columns PID,
SID, POS, X, Y and attribute projection.
Other attributes that may or may not be attached: parent.child
(boolean vector from original input), shpType (numeric shape
type: 1, 3, or 5), prj (projection information from .prj
file, xml (metadata from an .xml file), PolyData
(data from the attribute database .dbf), and zone (UTM zone).
Nicholas M. Boers, Associate Professor – Computer Science
MacEwan University, Edmonton AB
Rowan Haigh, Program Head – Offshore Rockfish
Pacific Biological Station (PBS), Fisheries & Oceans Canada (DFO), Nanaimo BC
opus locus: Institute of Ocean Sciences (IOS), Sidney BC
Last modified Rd: 2018-09-07
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.