sp2tmap.Rd
The function converts a SpatialPolygons object for use with the Stata tmap command, by creating a data frame with the required columns.
sp2tmap(SP)
SP | a SpatialPolygons object |
---|
a data frame with three columns:
an integer vector of polygon identifiers in numeric order
numeric x coordinate
numeric y coordinate
https://www.stata.com/search.cgi?query=tmap
Roger Bivand
if (FALSE) { xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66")) plot(xx, border="blue", axes=TRUE, las=1) tmapdf <- sp2tmap(as(xx, "SpatialPolygons")) if (require(foreign)) { td <- tempdir() write.dta(tmapdf, file=file.path(td, "NCmap.dta"), version=7) NCdf <- as(xx, "data.frame") NCdf$ID_n <- attr(tmapdf, "ID_names") write.dta(NCdf, file=file.path(td, "NC.dta"), version=7) } }