Learn R Programming

R2G2 (version 1.0-2)

Shapes2GE: Producing 3D regular polygons in Google Earth

Description

This function produces 3D regular polygons in Google Earth.

Usage

Shapes2GE(center, nesting = 0, goo = "Shapes2GE.kml", nedges = 20, orient = 0, colors = "blue", maxAlt = 10000, radius = 50000)

Arguments

center
An array of geographical position for pies (lines = pies, columns = longitude and latitude in decimal degrees).
nesting
Vector for grouping the shapes into handy folders / subfolders (optional). Must correspond to "center" and the groups should be designated as numbers.
goo
Name of the KML file to that will be saved into the working directory (use getwd() to find it).
nedges
The number of edges, defining the general shape of the polygon (3 -> triangle, 4 -> square, etc).
orient
the rotation factor of the pie-chart (in degrees).
maxAlt
the height (ceiling altitude) of the pies.
radius
The pie radius (in meters).
colors
Vector of colors (will correspond to nesting groups, so define one color per group, and not one color per shape), must be defined as hexadecimal values (as produced by usual R color palettes); leave to "auto" to get rainbow colors.

Value

A KML file is produced in the current working directory.

See Also

GetEdges, Hist2GE, Pies2GE GetEdges Hist2GE Pies2GE

Examples

Run this code

######Demo script
#Preparing fake matrix
center = cbind(1:6, 1:6)
nesting = rep(1:3, each = 2)

# data to be displayed
fakedata = cbind(nesting, center)
fakedata

#Producing KML - the easy way
Shapes2GE(center = fakedata[, 2:3], 
	  nesting = 1, 
	  colors = "#0000FFFF",
	  goo = "Shapes2GE_V1.kml", 
	  nedges = 20, 
	  orient = 0, 
	  maxAlt = 1e4, 
	  radius = 5e4)

#Producing KML - the very easy way
Shapes2GE(center = fakedata[, 2:3], 
	  nesting = fakedata[, 1], 
	  colors = "auto", #just define your groups and let it get the colors
	  goo = "Shapes2GE_V1b.kml", 
	  nedges = 20, 
	  orient = 0, 
	  maxAlt = 1e4, 
	  radius = 5e4)

#Producing KML - one param per shape
Shapes2GE(center = fakedata[, 2:3], 
	  nesting = c(1, 1, 2, 3, 3, 3), 
	  colors = c("#0F00FFFF","#00FF00FF","#FF0000FF"), #do it yourself
	  goo = "Shapes2GE_V2.kml", 
	  nedges = c(3, 3, 4, 4, 5, 5), 
	  orient = 0, 
	  maxAlt = 1e4, 
	  radius = 5e4)

Run the code above in your browser using DataLab