spChFIDs-methods: change feature IDs in spatial objects

Description Methods Note Author(s) See Also Examples

Description

When the feature IDs need to be changed in SpatialLines* or SpatialPolygons* objects, these methods may be used. The new IDs should be a character vector of unique IDs of the correct length.

Methods

obj = "SpatialLines", x = "character"

replace IDs in a SpatialLines object

obj = "SpatialLinesDataFrame", x = "character"

replace IDs in a SpatialLinesDataFrame object

obj = "SpatialPolygons", x = "character"

replace IDs in a SpatialPolygons object

obj = "SpatialPolygonsDataFrame", x = "character"

replace IDs in a SpatialPolygonsDataFrame object

Note

It is usually sensible to keep a copy of the original feature IDs in the object, but this should be done by the user.

Author(s)

Roger Bivand

See Also

spCbind-methods, spRbind-methods

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
require(maptools)
xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], 
  IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
row.names(as(xx, "data.frame"))
xx1 <- spChFIDs(xx, as.character(xx$CNTY_ID))
row.names(as(xx1, "data.frame"))

## End(Not run)

Example output

Loading required package: maptools
Checking rgeos availability: TRUE
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
Warning message:
use rgdal::readOGR or sf::st_read 
  [1] "37001" "37003" "37005" "37007" "37009" "37011" "37013" "37015" "37017"
 [10] "37019" "37021" "37023" "37025" "37027" "37029" "37031" "37033" "37035"
 [19] "37037" "37039" "37041" "37043" "37045" "37047" "37049" "37051" "37053"
 [28] "37055" "37057" "37059" "37061" "37063" "37065" "37067" "37069" "37071"
 [37] "37073" "37075" "37077" "37079" "37081" "37083" "37085" "37087" "37089"
 [46] "37091" "37093" "37095" "37097" "37099" "37101" "37103" "37105" "37107"
 [55] "37109" "37111" "37113" "37115" "37117" "37119" "37121" "37123" "37125"
 [64] "37127" "37129" "37131" "37133" "37135" "37137" "37139" "37141" "37143"
 [73] "37145" "37147" "37149" "37151" "37153" "37155" "37157" "37159" "37161"
 [82] "37163" "37165" "37167" "37169" "37171" "37173" "37175" "37177" "37179"
 [91] "37181" "37183" "37185" "37187" "37189" "37191" "37193" "37195" "37197"
[100] "37199"
  [1] "1904" "1950" "1827" "2096" "1825" "1892" "2004" "1905" "2162" "2241"
 [11] "1988" "1958" "2042" "1932" "1834" "2156" "1838" "1986" "1973" "2088"
 [21] "1887" "2109" "2032" "2232" "2119" "2090" "1831" "2000" "1951" "1948"
 [31] "2100" "1908" "1928" "1900" "1897" "2068" "1835" "2056" "1840" "2016"
 [41] "1903" "1846" "2030" "1996" "2047" "1833" "2097" "2099" "1947" "2039"
 [51] "1989" "2091" "2026" "2065" "2034" "1964" "2082" "1946" "1937" "2041"
 [61] "1927" "2044" "2040" "1913" "2238" "1832" "2146" "1907" "2085" "1848"
 [71] "2185" "1881" "1841" "1984" "2071" "1968" "2107" "2150" "1839" "1980"
 [81] "2027" "2083" "2123" "2045" "1837" "1828" "2013" "2067" "1963" "2095"
 [91] "1842" "1938" "1836" "1962" "1880" "2029" "1874" "1979" "1893" "1936"

sp documentation built on Feb. 29, 2020, 1:07 a.m.