Create pie charts data in form of SpatialPolygonsDataFrame.

Share:

Description

Create pie charts data in form of SpatialPolygonsDataFrame depending on few attributes.

Usage

1
2
3
4
5
6
pieSP(SPDF,
              zcol=1:length(SPDF@data),
              scalelist=TRUE, 
              max.radius=100,  
              do.sqrt = TRUE
             )

Arguments

SPDF

object of SpatialPointsDataFrame-class with associated coordinate reference systems

zcol

variable column names, or column numbers after removing spatial coordinates from x@data: 1 refers to the first non-coordinate column

scalelist

if TRUE circles are different in size, FALSE all circles have same radius

max.radius

value for maximum radius in meter

do.sqrt

logical; if TRUE the plotting symbol area (sqrt(diameter)) is proportional to the value of the z-variable; if FALSE, the symbol size (diameter) is proportional to the z-variable

Value

The function provide SpatialPolygonsDataFrame depending on few attributes, ready to use for plotGoogleMaps or spplot.

Author(s)

Milan Kilibarda kili@grf.bg.ac.rs

See Also

pieSP, elSPDF, bubbleSP

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Data preparation
data(meuse)
coordinates(meuse)<-~x+y
proj4string(meuse) <- CRS('+init=epsg:28992')

pies<-pieSP(meuse,zcol=c('zinc','lead','copper'), max.radius=120)
pies$pie=rep(c('zinc','lead','copper'),155)

m=plotGoogleMaps(pies, zcol='pie')

pies$pie2=rep(1:3,155)
spplot(pies, 'pie2')

pies2<-pieSP(meuse,zcol=c('zinc','dist.m'), max.radius=70,scalelist=FALSE)
pies2$pie=rep(c('zinc','dist.m'),155)

m=plotGoogleMaps(pies2, zcol='pie')

# plotKML(pies, col='pie')