sp2tmap

0th

Percentile

Convert SpatialPolygons object for Stata tmap command

The function converts a SpatialPolygons object for use with the Stata tmap command, by creating a data frame with the required columns.

Keywords
spatial
Usage
sp2tmap(SP)
Arguments
SP
a SpatialPolygons object
Value

  • a data frame with three columns:
  • _IDan integer vector of polygon identifiers in numeric order
  • _Xnumeric x coordinate
  • _Ynumeric y coordinate
  • and an ID_n attribute with the named polygon identifiers

References

http://www.stata.com/search.cgi?query=tmap

See Also

write.dta

Aliases
  • sp2tmap
Examples
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)) {
write.dta(tmapdf, file="NCmap.dta", version=7)
NCdf <- as(xx, "data.frame")
NCdf$ID_n <- attr(tmapdf, "ID_names")
write.dta(NCdf, file="NC.dta", version=7)
}
Documentation reproduced from package maptools, version 0.8-37, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.