maptools: Tools for Reading and Handling Spatial Objects

空間オブジェクトの読み込み・操作ツール

> library(maptools)
Checking rgeos availability: TRUE

バージョン: 0.8.37


関数名 概略
CCmaps Conditioned choropleth maps
ContourLines2SLDF Converter functions to build SpatialLinesDataFrame objects
GE_SpatialGrid Create SpatialGrid for PNG output to GE
Rgshhs Read GSHHS data into sp object
SpatialLines2PolySet Convert sp line and polygon objects to
PBSmapping PolySet objects
SpatialLinesMidPoints Line midpoints
SplashDams Data for Splash Dams in western Oregon
as.owin.SpatialGridDataFrame coercion between sp objects and spatstat objects
checkPolygonsHoles Check holes in Polygons objects
crepuscule Methods for sun ephemerides calculations
dotsInPolys Put dots in polygons
elide-methods Methods for Function elide in Package 'maptools'
gcDestination Find destination in geographical coordinates
getKMLcoordinates Get a list of coordinates out of a KML file
getinfo.shape Get shapefile header information
gpcholes Hisaji Ono's lake/hole problem
gzAzimuth Find azimuth for geographical coordinates
kmlLine Create and write a KML file on the basis of a
given Lines object
kmlLines Create and write a KML file on the basis of a
given Lines object
kmlOverlay Create and write KML file for PNG image overlay
kmlPoints Create and write a KML file on the basis of a
given Points object
kmlPolygon Create and write a KML file on the basis of a
given Polygons object
kmlPolygons Create and write a KML file on the basis of a
given Polygons object or list of Polygons or SpatialPolygonsDataFrame
leglabs Make legend labels
lineLabel Line label placement with spplot and lattice.
map2SpatialPolygons Convert map objects to sp classes
nearestPointOnLine Get the nearest point on a line to a given point
nearestPointOnSegment Get the nearest point on a segment to a given point
nowrapRecenter Break polygons at meridian for recentering
nowrapSpatialLines Split SpatialLines components at offset
pal2SpatialPolygons Making SpatialPolygons objects from RArcInfo input
panel.pointLabel Label placement with spplot and lattice.
pointLabel Label placement for points to avoid overlaps
ppp-class Virtual class "ppp"
readAsciiGrid read/write to/from (ESRI) asciigrid format
readGPS GPSbabel read interface
readShapeLines Read arc shape files into SpatialLinesDataFrame objects
readShapePoints Read points shape files into SpatialPointsDataFrame objects
readShapePoly Read polygon shape files into SpatialPolygonsDataFrame objects
readShapeSpatial Read shape files into Spatial*DataFrame objects
readSplus Read exported WinBUGS maps
snapPointsToLines Snap a set of points to a set of lines
sp2Mondrian write map data for Mondrian
sp2WB Export SpatialPolygons object as S-Plus map for WinBUGS
sp2tmap Convert SpatialPolygons object for Stata tmap command
spCbind-methods cbind for spatial objects
spRbind-methods rbind for spatial objects
state.vbm US State Visibility Based Map
symbolsInPolys Place grids of points over polygons
thinnedSpatialPoly Douglas-Peuker line generalization for Spatial Polygons
unionSpatialPolygons Aggregate Polygons in a SpatialPolygons object
wrld_simpl Simplified world country polygons

readShapePol

ポリゴンシェイプファイルをSpatialPolygonsDataFrameオブジェクトとして読み込む

> xx <- data.frame()
> system.file("shapes/sids.shp", package = "maptools")[1] %>% 
+   readShapePoly(IDvar       = "FIPSNO", 
+                 proj4string = CRS("+proj=longlat +ellps=clrk66")) %>% {
+                   xx <<- .
+                   print(class(.))
+                   dim(.)
+                 }
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"
[1] 100  14
> as(xx, "data.frame")[1:5, 1:6]
       AREA PERIMETER CNTY_ CNTY_ID      NAME  FIPS
37001 0.111     1.392  1904    1904  Alamance 37001
37003 0.066     1.070  1950    1950 Alexander 37003
37005 0.061     1.231  1827    1827 Alleghany 37005
37007 0.138     1.621  2096    2096     Anson 37007
37009 0.114     1.442  1825    1825      Ashe 37009
> names(xx)
 [1] "AREA"      "PERIMETER" "CNTY_"     "CNTY_ID"   "NAME"     
 [6] "FIPS"      "FIPSNO"    "CRESS_ID"  "BIR74"     "SID74"    
[11] "NWBIR74"   "BIR79"     "SID79"     "NWBIR79"
> # map <- fortify(xx)
> # ggplot(data = map, 
> #        aes(map_id = id, x = long, y = lat)) + 
> #   geom_map(map = map, color = "black", fill = "white") +
> #