99# ' @param ... not used by this method
1010# ' @keywords internal
1111# ' @name fortify.sp
12- # ' @examples
13- # ' if (require("maptools")) {
14- # ' sids <- system.file("shapes/sids.shp", package="maptools")
15- # ' nc1 <- readShapePoly(sids,
16- # ' proj4string = CRS("+proj=longlat +datum=NAD27"))
17- # ' nc1_df <- fortify(nc1)
18- # ' }
1912NULL
2013
2114# ' @rdname fortify.sp
2215# ' @export
2316# ' @method fortify SpatialPolygonsDataFrame
2417fortify.SpatialPolygonsDataFrame <- function (model , data , region = NULL , ... ) {
18+ deprecate_warn0(" 3.4.4" ,
19+ I(" `fortify(<SpatialPolygonsDataFrame>)`" ),
20+ details = " Please migrate to sf."
21+ )
22+
2523 attr <- as.data.frame(model )
2624 # If not specified, split into regions based on polygons
2725 if (is.null(region )) {
28- coords <- lapply(model @ polygons ,fortify )
26+ # Suppress duplicated warnings
27+ withr :: with_options(list (lifecycle_verbosity = " quiet" ), {
28+ coords <- lapply(model @ polygons ,fortify )
29+ })
2930 coords <- vec_rbind0(!!! coords )
3031 cli :: cli_inform(" Regions defined for each Polygons" )
3132 } else {
32- cp <- sp :: polygons(model )
33-
34- # Union together all polygons that make up a region
35- unioned <- maptools :: unionSpatialPolygons(cp , attr [, region ])
36- coords <- fortify(unioned )
37- coords $ order <- 1 : nrow(coords )
33+ lifecycle :: deprecate_stop(" 3.4.4" ,
34+ I(" `fortify(<SpatialPolygonsDataFrame>, region = ...)` is defunct'" ),
35+ details = " Please migrate to sf."
36+ )
3837 }
3938 coords
4039}
@@ -43,14 +42,27 @@ fortify.SpatialPolygonsDataFrame <- function(model, data, region = NULL, ...) {
4342# ' @export
4443# ' @method fortify SpatialPolygons
4544fortify.SpatialPolygons <- function (model , data , ... ) {
46- polys <- lapply(model @ polygons , fortify )
45+ deprecate_warn0(" 3.4.4" ,
46+ I(" `fortify(<SpatialPolygons>)`" ),
47+ details = " Please migrate to sf."
48+ )
49+
50+ # Suppress duplicated warnings
51+ withr :: with_options(list (lifecycle_verbosity = " quiet" ), {
52+ polys <- lapply(model @ polygons , fortify )
53+ })
4754 vec_rbind0(!!! polys )
4855}
4956
5057# ' @rdname fortify.sp
5158# ' @export
5259# ' @method fortify Polygons
5360fortify.Polygons <- function (model , data , ... ) {
61+ deprecate_warn0(" 3.4.4" ,
62+ I(" `fortify(<Polygons>)`" ),
63+ details = " Please migrate to sf."
64+ )
65+
5466 subpolys <- model @ Polygons
5567 pieces <- lapply(seq_along(subpolys ), function (i ) {
5668 df <- fortify(subpolys [[model @ plotOrder [i ]]])
@@ -70,6 +82,11 @@ fortify.Polygons <- function(model, data, ...) {
7082# ' @export
7183# ' @method fortify Polygon
7284fortify.Polygon <- function (model , data , ... ) {
85+ deprecate_warn0(" 3.4.4" ,
86+ I(" `fortify(<Polygon>)`" ),
87+ details = " Please migrate to sf."
88+ )
89+
7390 df <- as.data.frame(model @ coords )
7491 names(df ) <- c(" long" , " lat" )
7592 df $ order <- 1 : nrow(df )
@@ -81,6 +98,11 @@ fortify.Polygon <- function(model, data, ...) {
8198# ' @export
8299# ' @method fortify SpatialLinesDataFrame
83100fortify.SpatialLinesDataFrame <- function (model , data , ... ) {
101+ deprecate_warn0(" 3.4.4" ,
102+ I(" `fortify(<SpatialLinesDataFrame>)`" ),
103+ details = " Please migrate to sf."
104+ )
105+
84106 lines <- lapply(model @ lines , fortify )
85107 vec_rbind0(!!! lines )
86108}
@@ -89,6 +111,11 @@ fortify.SpatialLinesDataFrame <- function(model, data, ...) {
89111# ' @export
90112# ' @method fortify Lines
91113fortify.Lines <- function (model , data , ... ) {
114+ deprecate_warn0(" 3.4.4" ,
115+ I(" `fortify(<Lines>)`" ),
116+ details = " Please migrate to sf."
117+ )
118+
92119 lines <- model @ Lines
93120 pieces <- lapply(seq_along(lines ), function (i ) {
94121 df <- fortify(lines [[i ]])
@@ -108,6 +135,11 @@ fortify.Lines <- function(model, data, ...) {
108135# ' @export
109136# ' @method fortify Line
110137fortify.Line <- function (model , data , ... ) {
138+ deprecate_warn0(" 3.4.4" ,
139+ I(" `fortify(<Line>)`" ),
140+ details = " Please migrate to sf."
141+ )
142+
111143 df <- as.data.frame(model @ coords )
112144 names(df ) <- c(" long" , " lat" )
113145 df $ order <- 1 : nrow(df )
0 commit comments