[R-sig-Geo] plotKML organizing folders

Anthony Fischbach afischbach at usgs.gov
Fri Sep 12 20:14:24 CEST 2014


I wish to allow users of my kml to select specific classes of entities by
folders within the virtual globe display.
For example (using the standard plotKML dataset) I wish to allow users to
select 'class A' and 'class B' bigfoot sightings by selecting folders that
have intuitive names.

## Toy example:
require(plotKML)
require(sp)
data(bigfoot) ## Load standard dataframe 
bigfootA<-head(bigfoot) ## grab the top of the dataframe, which has class A
sightings
bigfootB<-tail(bigfoot)  ## grab the bottom of the dataframe, which has
class B sightings
## cast both dataframes into spatialPointsDataFrames with defined coordinate
reference systems
coordinates(bigfootA)<-c('Lon','Lat') ## Cast as spatial points dataframe
proj4string(bigfootA)<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84
+no_defs")  ## assign a coordinate reference system
coordinates(bigfootB)<-c('Lon','Lat') ## Cast as spatial points dataframe
proj4string(bigfootB)<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84
+no_defs")  ## assign a coordinate reference system

kml_open(file.name='BigWithFolders.kml', folder.name = 'Big Foot',
kml_visibility=TRUE )
	## Build the points by each class
		kml_layer.SpatialPoints(obj=bigfootA, points_names=bigfootA at data$NAMES, 
			colour='green',  LabelScale=0.8, 
			shape='http://plotkml.r-forge.r-project.org/3Dballyellow.png',
			alpha=0.6, balloon=TRUE) ##  
		kml_layer.SpatialPoints(obj=bigfootB, points_names=bigfootB at data$NAMES, 
			colour='yellow',  LabelScale=0.8, 
			shape='http://plotkml.r-forge.r-project.org/3Dballyellow.png',
			alpha=0.6, balloon=TRUE) ##  
			
kml_close(file.name='BigWithFolders.kml')
### End Toy example

This produces the kml with two folders, both named 'SpatialPointsDataFrame'.
Is there a way to set the names of each subordinate folder?



-----
Tony Fischbach, Wildlife Biologist
Walrus Research Program
Alaska Science Center
U.S. Geological Survey
4210 University Drive
Anchorage, AK 99508-4650

AFischbach at usgs.gov
http://alaska.usgs.gov/science/biology/walrus
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/plotKML-organizing-folders-tp7587119.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list