Description Usage Arguments Value Examples
This function is capable of plotting polygons, referenced by its id number. These can be filled with colors acording to a given variate.
1 |
arc |
The data returned by a call to get.arcdata |
bnd |
The data returned by a call to get.bnddata |
pal |
The data returned by a call to get.paldata |
index |
IDs of the polygon to be plotted. If it is 'NULL' then all the polygons are plotted. |
col |
Colors to be used when filling the polygons |
border |
Colors used for the lines of the polygons. If it's not set, it is set to the value of 'col'. |
xratio |
Controls x-axis ratio. It can take any value from 0 to 1. |
yratio |
Controls x-axis ratio. It can take any value from 0 to 1. |
... |
Options to be passed to a call to the function plot when creating the display (i. e., window or file). |
Thins function returns nothing, but plots a nice map. :-D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #This example is the same as the one provided under the test directory
#1.- Create temporary directory (if needed)
#1.- Extract the E00 file form a ZIP file
#2.- Create an Arc/Info binary coverage
#3.- Create the map
#get current working directory
cwd<-getwd()
#Create tmp directory.
tmpdir<-tempdir()
datadir<-system.file("exampleData",package="RArcInfo")
setwd(datadir)
file.copy(c("valencia.zip", "data_valencia.csv"), tmpdir, overwrite = TRUE)
setwd(tmpdir)
#Convert E00 file to a binary covertage to be imported into R
#Comment this line if the file valencia.e00 already exists
unzip(zipfile="valencia.zip", file="valencia.e00")
#Comments this lines if the binary coverage already exists
library(RArcInfo)
e00toavc("valencia.e00", "valencia")
#Read map data
arcsmuni<-get.arcdata(".", "valencia")
palmuni<-get.paldata(".", "valencia")
bnd.muni<-get.bnddata("info/", "VALENCIA.BND")
patmuni<-get.tabledata("./info", "VALENCIA.PAT")
#Number of polygons
nmuni<-length(palmuni[[1]][[1]])
municipios<-data.frame(1:nmuni, patmuni$"VALENCIA-ID")
names(municipios)<-c("INDEX", "CODMUNICI")
#Datafiles to be used
unemp<-read.table(file="data_valencia.csv", sep=";",
dec = ",",skip=1)
unemp<-unemp[,c(1,3)]
names(unemp)<-c("CODMUNICI", "UNEMP")
breaks<-quantile(unemp[,2], c(0, .025,.2, .8, .975, 1))
unemp<-cbind(unemp, CAT=as.ordered(cut(unemp[,2], breaks, include.lowest = TRUE) ))
library(RColorBrewer)
#Colors to be used in maps
#colors<-brewer.pal(5, "Oranges")
colors<-brewer.pal(5, "Greens")
ldata<-merge(unemp, municipios, by.x="CODMUNICI", by.y="CODMUNICI")
#Valencia
idx<-(ldata$"CODMUNICI">=46000)
bnd.muni<-c(626679.9, 4250000, 760000, 4460000)
p<-par()
pin<-1.5*p$pin
main<-"Rate of unemployment"
plotpoly(arc=arcsmuni, pal=palmuni, bnd=bnd.muni,
index=ldata$INDEX[idx], col=colors[ldata$CAT][idx],
xlab="", ylab="", main=main,
xaxt="n", yaxt="n", bty="n")
#Set legend
l<-levels(unemp$CAT)
l[1]<-"[0.00,1.26]"
legend(700000, 4460000, fill=colors,
legend=l, bty="n", cex=1)
setwd(cwd)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.