9
9
# ' @param ... not used by this method
10
10
# ' @keywords internal
11
11
# ' @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
- # ' }
19
12
NULL
20
13
21
14
# ' @rdname fortify.sp
22
15
# ' @export
23
16
# ' @method fortify SpatialPolygonsDataFrame
24
17
fortify.SpatialPolygonsDataFrame <- function (model , data , region = NULL , ... ) {
18
+ deprecate_warn0(" 3.4.4" ,
19
+ I(" `fortify(<SpatialPolygonsDataFrame>)`" ),
20
+ details = " Please migrate to sf."
21
+ )
22
+
25
23
attr <- as.data.frame(model )
26
24
# If not specified, split into regions based on polygons
27
25
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
+ })
29
30
coords <- vec_rbind0(!!! coords )
30
31
cli :: cli_inform(" Regions defined for each Polygons" )
31
32
} 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
+ )
38
37
}
39
38
coords
40
39
}
@@ -43,14 +42,27 @@ fortify.SpatialPolygonsDataFrame <- function(model, data, region = NULL, ...) {
43
42
# ' @export
44
43
# ' @method fortify SpatialPolygons
45
44
fortify.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
+ })
47
54
vec_rbind0(!!! polys )
48
55
}
49
56
50
57
# ' @rdname fortify.sp
51
58
# ' @export
52
59
# ' @method fortify Polygons
53
60
fortify.Polygons <- function (model , data , ... ) {
61
+ deprecate_warn0(" 3.4.4" ,
62
+ I(" `fortify(<Polygons>)`" ),
63
+ details = " Please migrate to sf."
64
+ )
65
+
54
66
subpolys <- model @ Polygons
55
67
pieces <- lapply(seq_along(subpolys ), function (i ) {
56
68
df <- fortify(subpolys [[model @ plotOrder [i ]]])
@@ -70,6 +82,11 @@ fortify.Polygons <- function(model, data, ...) {
70
82
# ' @export
71
83
# ' @method fortify Polygon
72
84
fortify.Polygon <- function (model , data , ... ) {
85
+ deprecate_warn0(" 3.4.4" ,
86
+ I(" `fortify(<Polygon>)`" ),
87
+ details = " Please migrate to sf."
88
+ )
89
+
73
90
df <- as.data.frame(model @ coords )
74
91
names(df ) <- c(" long" , " lat" )
75
92
df $ order <- 1 : nrow(df )
@@ -81,6 +98,11 @@ fortify.Polygon <- function(model, data, ...) {
81
98
# ' @export
82
99
# ' @method fortify SpatialLinesDataFrame
83
100
fortify.SpatialLinesDataFrame <- function (model , data , ... ) {
101
+ deprecate_warn0(" 3.4.4" ,
102
+ I(" `fortify(<SpatialLinesDataFrame>)`" ),
103
+ details = " Please migrate to sf."
104
+ )
105
+
84
106
lines <- lapply(model @ lines , fortify )
85
107
vec_rbind0(!!! lines )
86
108
}
@@ -89,6 +111,11 @@ fortify.SpatialLinesDataFrame <- function(model, data, ...) {
89
111
# ' @export
90
112
# ' @method fortify Lines
91
113
fortify.Lines <- function (model , data , ... ) {
114
+ deprecate_warn0(" 3.4.4" ,
115
+ I(" `fortify(<Lines>)`" ),
116
+ details = " Please migrate to sf."
117
+ )
118
+
92
119
lines <- model @ Lines
93
120
pieces <- lapply(seq_along(lines ), function (i ) {
94
121
df <- fortify(lines [[i ]])
@@ -108,6 +135,11 @@ fortify.Lines <- function(model, data, ...) {
108
135
# ' @export
109
136
# ' @method fortify Line
110
137
fortify.Line <- function (model , data , ... ) {
138
+ deprecate_warn0(" 3.4.4" ,
139
+ I(" `fortify(<Line>)`" ),
140
+ details = " Please migrate to sf."
141
+ )
142
+
111
143
df <- as.data.frame(model @ coords )
112
144
names(df ) <- c(" long" , " lat" )
113
145
df $ order <- 1 : nrow(df )
0 commit comments