[R-sig-Geo] plotKML organizing folders
Tomislav Hengl
hengl at spatial-analyst.net
Tue Oct 7 16:31:56 CEST 2014
Hi Tony,
The easiest thing is that you set the size using actual numeric vectors
(or a constant value):
R> require(plotKML)
R> require(sp)
R> data(bigfoot)
R> bigfootA <- head(bigfoot)
R> bigfootB <- tail(bigfoot)
R> coordinates(bigfootA) <- c('Lon','Lat')
R> proj4string(bigfootA) <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84
+no_defs")
R> coordinates(bigfootB) <- c('Lon','Lat')
R> proj4string(bigfootB) <- bigfootA at proj4string
R> shape <- 'http://plotkml.r-forge.r-project.org/3Dballyellow.png'
R> kml_open(file.name='BigWithFolders.kml', folder.name='Big Foot',
kml_visibility=TRUE)
KML file opened for writing...
R> kml_layer.SpatialPoints(obj=bigfootA, subfolder.name='A',
points_names=bigfootA at data$NAMES, size=3, colour='green', LabelScale=0.8
.... [TRUNCATED]
Writing to KML...
R> kml_layer.SpatialPoints(obj=bigfootB, subfolder.name='B',
points_names=bigfootB at data$NAMES, size=1, colour='green', LabelScale=0.8
.... [TRUNCATED]
Writing to KML...
R> kml_close(file.name='BigWithFolders.kml')
Closing BigWithFolders.kml
I've also added functionality to plotKML v0.4-6 which you can install
from R-forge:
R> install.packages("plotKML", repos="http://R-Forge.R-project.org",
type="source")
I will soon commit the v0.4-6 also to CRAN.
all the best with your work,
T. Hengl
On 3-10-2014 21:32, Anthony Fischbach wrote:
> This is very helpful having the ability to specify folder names.
> It would be helpful to have this facility for all the spatial classes
> handled by plotKML.
>
> Now I wish to apply differing sizes for points based on their properties.
> This should be possibly by specifying the size parameter. However this
> appears to fail when applied to individual folders within a multi-part kml.
> The example below fails to create the unique points sizes.
>
> ## KML_Folder_problem.r
> require(plotKML)
> require(sp)
> setwd('D:/Walrus/Haulout_Locations/rCode') ## house keeping specify working
> directory
> data(bigfoot) ## Load a data frame with point features
> bigfootA<-head(bigfoot)
> bigfootB<-tail(bigfoot)
> coordinates(bigfootA)<-c('Lon','Lat') ## Cast a spatial points dataframe
> proj4string(bigfootA)<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84
> +no_defs") ## assign a coordinate reference system
> bigfootA at data$SymbolSize<-3 ## Assign the symbol size to a variable
> coordinates(bigfootB)<-c('Lon','Lat') ## Cast a spatial points dataframe
> proj4string(bigfootB)<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84
> +no_defs") ## assign a coordinate reference system
> bigfootB at data$SymbolSize<-1 ## Assign the symbol size to a variable
>
> kml_open(file.name='BigWithFolders.kml', folder.name = 'Big Foot',
> kml_visibility=TRUE )
> ## Build the points by each class
>
> kml_layer.SpatialPoints(obj=bigfootA, subfolder.name= 'A',
> points_names=bigfootA at data$NAMES, size=SymbolSize, ## specify the symbol
> size
> 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, subfolder.name= 'B',
> points_names=bigfootB at data$NAMES, size=SymbolSize,
> 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')
> #
>
> The resultant kml has all points specified with a symbol size of 1.5.
>
>
>
> -----
> 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-tp7587119p7587229.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
More information about the R-sig-Geo
mailing list