sp (version 2.1-3)

spChFIDs-methods: change feature IDs in spatial objects

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.

Arguments

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

Author

Roger Bivand

Examples

Run this code
if (FALSE) {
if(require(sf)) {
xx <- as(st_read(system.file("shape/nc.shp", package="sf")[1]), "Spatial")
row.names(xx) <- as.character(xx$"FIPSNO")
row.names(as(xx, "data.frame"))
xx1 <- spChFIDs(xx, as.character(xx$CNTY_ID))
row.names(as(xx1, "data.frame"))
}}

Run the code above in your browser using DataCamp Workspace