Skip to content

fortify problem with sp namespace #879

Closed
@seancarmody

Description

@seancarmody

This may be a bit obscure, but I have found a problem using fortify for a SpatialPolygonsDataFrame when sp has not been loaded. While that may seem an unlikely scenario, it came up for me when trying to plot map data which loaded from files created using save. Here is an artificial reproducible example of the error

bx <- rgeos::readWKT("POLYGON ((112.5 -44, 112.5 -9, 154 -9, 154 -44, + 112.5 -44))")
bx <- as(bx, "SpatialPolygonsDataFrame")
fortify(bx, region="dummy")
# Error in fortify.SpatialPolygonsDataFrame(bx, region = "dummy") : 
#  could not find function "polygons"

If I run library(sp) first the error goes away, but should fortify use sp::polygons rather than polygons to avoid the error altogether?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions