I am able to take a spatialPolygonDataFrame and turn it into a dataframe, but how do I undo this conversion? Ie take a data.frame and convert it back to the original spatialPolygonDataFram:
Example taken from: https://github.com/tidyverse/ggplot2/wiki/plotting-polygon-shapefiles
utah = readOGR(dsn=".", layer="eco_l3_ut") ## class(utah) SpatialPolygonsDataFrame
utah@data$id = rownames(utah@data)
utah.points = fortify(utah, region="id")
utah.df = join(utah.points, utah@data, by="id")
How can I take utah.df
and make it identical to utah
again?