Skip to content

Commit d1cba89

Browse files
Tomislav Henglcran-robot
authored andcommitted
version 0.5-6
1 parent fea23c3 commit d1cba89

13 files changed

Lines changed: 51 additions & 41 deletions

DESCRIPTION

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: plotKML
2-
Version: 0.5-5
3-
Date: 2015-12-24
2+
Version: 0.5-6
3+
Date: 2016-05-02
44
Title: Visualization of Spatial and Spatio-Temporal Objects in Google
55
Earth
66
Authors@R: c(person("Tomislav", "Hengl", role = c("cre", "aut"),
@@ -22,11 +22,11 @@ License: GPL
2222
URL: http://plotkml.r-forge.r-project.org/
2323
LazyLoad: yes
2424
NeedsCompilation: no
25-
Packaged: 2016-01-06 18:04:31 UTC; hengl001
25+
Packaged: 2016-05-02 22:05:43 UTC; hengl001
2626
Author: Tomislav Hengl [cre, aut],
2727
Pierre Roudier [ctb],
2828
Dylan Beaudette [ctb],
2929
Edzer Pebesma [ctb],
3030
Michael Blaschek [ctb]
3131
Repository: CRAN
32-
Date/Publication: 2016-01-06 20:29:41
32+
Date/Publication: 2016-05-03 01:51:20

MD5

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
4d5a1b946642cdba969a776978993766 *DESCRIPTION
1+
8dff4209d9f0e12eda8dfa1615f6069c *DESCRIPTION
22
022e76f1864c4f0f6acb3e4b37d3ddb9 *NAMESPACE
33
6fecfa4c8923c389076de1208ca076c1 *R/AAA-classes.R
44
b6c2a2b782f06f072cce201506e333e6 *R/AAA-md.R
@@ -31,12 +31,12 @@ b9dbe890ec9a9d87b08e8748d0671a96 *R/layer.Raster.R
3131
75b9c1616a5e2ef98eebba82e10fe1d5 *R/layer.SpatialPhotoOverlay.R
3232
089e2126393f406ddc136fe20b1dd923 *R/layer.SpatialPixels.R
3333
b3a0d81d553bd806f14eca109fabcaf6 *R/layer.SpatialPoints.R
34-
c25f6581e9c210a3b485cbb067ac8bf6 *R/layer.SpatialPolygons.R
35-
eabaf6db8056e161f83321b8cad06423 *R/legend.bar.R
34+
df4703baa31b87943d69fedd887babbf *R/layer.SpatialPolygons.R
35+
bb24604989ce540ef3902266a327883f *R/legend.bar.R
3636
34a328e9b91844e33beadc506697bfef *R/legend.whitening.R
3737
b473017c4be29900e1e70ed3d7a36598 *R/normalizeFilename.R
3838
bf72e0121dcfaca5a1ea08d91e35ac8c *R/plot.SpatialPredictions.R
39-
958284c563360fd4458f3522a765c939 *R/plotKML.GDALobj.R
39+
78213e2733b84f335abc4e1675019599 *R/plotKML.GDALobj.R
4040
aa7a9065385240f6bef35237350ec635 *R/plotKML.RasterBrickSimulations.R
4141
5bb9cd98e143fc20234f853f27b56258 *R/plotKML.RasterBrickTimeSeries.R
4242
32077a2f23b710fbbbdec13969c3ed50 *R/plotKML.SpatialMaxEntOutput.R
@@ -52,7 +52,7 @@ d2f358102c7ece20e8fe455ca2485e3c *R/spPhoto.R
5252
0948a41ebb52fc91b1eb39f7a468265e *R/vect2rast.R
5353
fd0b4f5656c15bae85cc1b76d0575787 *R/whitening.R
5454
d41d8cd98f00b204e9800998ecf8427e *TODO
55-
fd733e875865f3bb00d26f924174011c *build/vignette.rds
55+
c4b93a6c368c9bff1f5495bd3873cc57 *build/vignette.rds
5656
9060c942e52ce8a1939e2f36d145cbd4 *data/HRprec08.rda
5757
33060527d47b9b9095e5d2e0551d8b80 *data/HRtemp08.rda
5858
9b21818fdf75dca5813a4e17cf540ce5 *data/LST.rda
@@ -81,7 +81,7 @@ cd540f046ef463f7aef867e19213b991 *inst/INSPIRE_ISO19139.xml
8181
d41d8cd98f00b204e9800998ecf8427e *inst/NEWS
8282
52489fc4bbffc35a73c93fdc6c74abda *inst/doc/jss1079.R
8383
f231fc62841c0f1bc4f2714d2914601e *inst/doc/jss1079.Rnw
84-
154b2bd412a02a55428df7e49acc97e3 *inst/doc/jss1079.pdf
84+
fb18d969a71b135b81dd43f2a34134c2 *inst/doc/jss1079.pdf
8585
c4c84fc61344519d27e5b9ee06f4845e *inst/eberg.xml
8686
762124c8e05e5dbf332ec2acadb0af18 *inst/gpx.xsd
8787
28da50b2a17e0848877f44470a66db5b *inst/mdnames.csv
@@ -117,7 +117,7 @@ fd0c3692112a3069f8b848f38c5e5ba1 *man/kml.tiles.Rd
117117
8cb08e931d350f65a2667263a2df7220 *man/kml_compress.Rd
118118
d5303eb2b21a793be8e30c2890a0c3d0 *man/kml_description.Rd
119119
9a636172d39a8da22750a3c64839ad1f *man/kml_layer.Rd
120-
0b7a065e595da3a0d46160595e51eb33 *man/kml_legend.bar.Rd
120+
95e0f1de8029e6eb4d9a083f28ec3e4f *man/kml_legend.bar.Rd
121121
26e699d6651b4a7acc0c5351aedd96d2 *man/kml_metadata.Rd
122122
4017103b4c048e1ab6902c3542ac4383 *man/kml_open.Rd
123123
d202d839ea71f8fe430aba599595c91f *man/kml_screen.Rd
@@ -130,23 +130,23 @@ ddb0af4d3d2cec35f37e59e547ab1b81 *man/layer.SoilProfileCollection.Rd
130130
264607a394020b7da71e413c5940f2c7 *man/layer.SpatialPhotoOverlay.Rd
131131
0fec1aabe6c9f48cea4116f8ab1bb37b *man/layer.SpatialPixels.Rd
132132
0082fbe6988d8535b8204f12e7c65150 *man/layer.SpatialPoints.Rd
133-
854127d4437b6690407cc39f25c8a712 *man/layer.SpatialPolygons.Rd
133+
f4149a8945c1b624132250ac918124cd *man/layer.SpatialPolygons.Rd
134134
396ba7d0b002f5ea6c8bc54662285f6b *man/legend.whitening.Rd
135135
439119d540e5b186ba72d6e3ae9760e9 *man/makeCOLLADA.Rd
136136
dac02f6b63e58406d0d2ca79490d038d *man/metadata2SLD.Rd
137137
7e3b8648810f2eec52f3bd7b9f8bffff *man/metadata2SLD.SpatialPixels.Rd
138138
ca181c1fc1f593708f0f34ba89728a09 *man/normalizeFilename.Rd
139139
ce9659fd3cb5a860c275b52639dfa7d7 *man/northcumbria.Rd
140140
0145cbf5e3070c43798fa47c37d35f75 *man/plotKML-package.Rd
141-
a8b855f44ed2e0c9d35a8d314b2c11b7 *man/plotKML.GDALobj.Rd
141+
c14783facc4673c990dcb6db6c214ae5 *man/plotKML.GDALobj.Rd
142142
3b739f9c007b0cc5b8b5a300e7c64209 *man/plotKML.Rd
143143
03cee90bc9311d2578dcf0eaa97dbffd *man/plotKML.env.Rd
144-
7ffcaceb7db5064cb3ce190489be0fec *man/readGPX.Rd
145-
cca62d3193f2a1ccebd89e21e4687865 *man/readKML.GBIFdensity.Rd
144+
8c4443c0c9b49eb974b19708d1874d50 *man/readGPX.Rd
145+
cbab17ed45e9d18a77c48031a0928cc4 *man/readKML.GBIFdensity.Rd
146146
c98b2048da547cc8b8fb0e960e68fd21 *man/reproject.Rd
147147
95b5e9a455650e91a094fbd3f4f8056c *man/sp.palette.Rd
148148
4f276545f0f6101e61d4d57d216a2b58 *man/spMetadata.Rd
149-
6d5142f43f450bb55fcac48c0f7b9209 *man/spPhoto.Rd
149+
ffa58c7d00b056fe1ecdc75903c2e396 *man/spPhoto.Rd
150150
6ceadaef90cdee97418505d2175529d6 *man/vect2rast.Rd
151151
b10b332eee900a8fcba5e6e8442729b6 *man/vect2rast.SpatialPoints.Rd
152152
e1337bf48784762bc6e68fbc6500dbbc *man/whitening.Rd

R/layer.SpatialPolygons.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ kml_layer.SpatialPolygons <- function(
161161
if(all(is.null(unlist(TimeSpan.begin.l))) & all(is.null(unlist(TimeSpan.end.l)))){
162162
if(all(is.null(unlist(when.l)))){
163163
# time span undefined:
164-
txt <- sprintf('<Placemark><name>%s</name><styleUrl>#poly%s</styleUrl><description><![CDATA[%s]]></description><Polygon><extrude>%.0f</extrude><tessellate>%.0f</tessellate><altitudeMode>%s</altitudeMode><outerBoundaryIs><LinearRing><coordinates>%s</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark>', unlist(poly_names.l), 1:paste(unlist(coords)), unlist(html.table.l), rep(as.numeric(extrude), sum(unlist(pvn))), rep(as.numeric(tessellate), sum(unlist(pvn))), rep(altitudeMode, sum(unlist(pvn))), paste(unlist(coords)))
164+
txt <- sprintf('<Placemark><name>%s</name><styleUrl>#poly%s</styleUrl><description><![CDATA[%s]]></description><Polygon><extrude>%.0f</extrude><tessellate>%.0f</tessellate><altitudeMode>%s</altitudeMode><outerBoundaryIs><LinearRing><coordinates>%s</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark>', unlist(poly_names.l), 1:sum(unlist(pvn)), unlist(html.table.l), rep(as.numeric(extrude), sum(unlist(pvn))), rep(as.numeric(tessellate), sum(unlist(pvn))), rep(altitudeMode, sum(unlist(pvn))), paste(unlist(coords)))
165165
} else {
166166
txt <- sprintf('<Placemark><name>%s</name><styleUrl>#poly%s</styleUrl><TimeStamp><when>%s</when></TimeStamp><description><![CDATA[%s]]></description><Polygon><extrude>%.0f</extrude><tessellate>%.0f</tessellate><altitudeMode>%s</altitudeMode><outerBoundaryIs><LinearRing><coordinates>%s</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark>', unlist(poly_names.l), 1:sum(unlist(pvn)), unlist(when.l), unlist(html.table.l), rep(as.numeric(extrude), sum(unlist(pvn))), rep(as.numeric(tessellate), sum(unlist(pvn))), rep(altitudeMode, sum(unlist(pvn))), paste(unlist(coords)))
167167
}} else {

R/legend.bar.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Note : 1D legend with min max and avg values;
66

77

8-
kml_legend.bar <- function(x, width, height, pointsize = 14, legend.file, legend.pal, z.lim = range(x, na.rm = TRUE, finite = TRUE), factor.labels){
8+
kml_legend.bar <- function(x, width, height, pointsize = 14, legend.file, legend.pal, z.lim = range(x, na.rm = TRUE, finite = TRUE), factor.labels, png.type = "cairo-png"){
99

1010
## Factor-type variables:
1111
if(class(x) == "factor" | class(x) == "character") {
@@ -37,7 +37,7 @@ kml_legend.bar <- function(x, width, height, pointsize = 14, legend.file, legend
3737
} # 20 pix per class
3838
}
3939

40-
png(filename=legend.file, width=width, height=height, bg="transparent", pointsize=pointsize)
40+
png(filename=legend.file, width=width, height=height, bg="transparent", pointsize=pointsize, type=png.type)
4141
# c(bottom, left, top, right)
4242
par(mar=c(.5,0,.5,1))
4343
plot(x=rep(1, col.no), y=1:col.no, axes=FALSE, xlab='', ylab='', pch=15, cex=4, col=legend.pal, xlim=c(0,.6*width))

R/plotKML.GDALobj.R

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Note : Implemented for parallel processing. SuperOverlay file (https://developers.google.com/kml/documentation/kml_21tutorial?csw=1#superoverlays);
66

77

8-
plotKML.GDALobj <- function(obj, file.name, block.x, tiles=NULL, tiles.sel=NULL, altitude=0, altitudeMode="relativeToGround", colour_scale, z.lim=NULL, breaks.lst=NULL, kml.logo, overwrite=TRUE, cpus, home.url=".", desc=NULL, open.kml=TRUE){
8+
plotKML.GDALobj <- function(obj, file.name, block.x, tiles=NULL, tiles.sel=NULL, altitude=0, altitudeMode="relativeToGround", colour_scale, z.lim=NULL, breaks.lst=NULL, kml.logo, overwrite=TRUE, cpus, home.url=".", desc=NULL, open.kml=TRUE, CRS=attr(obj, "projection"), plot.legend=TRUE){
99

1010
if(!class(obj)=="GDALobj"){
1111
stop("Object of class \"GDALobj\" required.")
@@ -20,6 +20,9 @@ plotKML.GDALobj <- function(obj, file.name, block.x, tiles=NULL, tiles.sel=NULL,
2020
if(!is.null(breaks.lst)&length(breaks.lst)<15){
2121
stop("'breaks.lst' must contain at least 15 elements")
2222
}
23+
if(is.na(CRS)){
24+
stop("'projection' missing or 'NA'")
25+
}
2326

2427
if(!length(colour_scale)==(length(breaks.lst)-1)&!is.null(breaks.lst)){ stop("'length(colour_scale)' and 'length(breaks.lst)-1' of equal length required") }
2528
GDALobj.file <- attr(obj, "file")
@@ -38,14 +41,14 @@ plotKML.GDALobj <- function(obj, file.name, block.x, tiles=NULL, tiles.sel=NULL,
3841
if(requireNamespace("parallel", quietly = TRUE)&requireNamespace("snowfall", quietly = TRUE)){
3942
if(missing(cpus)){ cpus <- parallel::detectCores(all.tests = FALSE, logical = FALSE) }
4043
snowfall::sfInit(parallel=TRUE, cpus=cpus)
41-
snowfall::sfExport("GDALobj.file", "tiles", "tiles.sel", "breaks.lst", "altitude", "altitudeMode", "colour_scale", "z.lim", "overwrite")
44+
snowfall::sfExport("GDALobj.file", "tiles", "tiles.sel", "breaks.lst", "altitude", "altitudeMode", "colour_scale", "z.lim", "overwrite", "CRS")
4245
snowfall::sfLibrary(package="rgdal", character.only=TRUE)
4346
snowfall::sfLibrary(package="sp", character.only=TRUE)
4447
snowfall::sfLibrary(package="plotKML", character.only=TRUE)
4548
snowfall::sfLibrary(package="XML", character.only=TRUE)
4649
snowfall::sfLibrary(package="RSAGA", character.only=TRUE)
4750
snowfall::sfLibrary(package="raster", character.only=TRUE)
48-
lst <- snowfall::sfLapply(tiles.sel, .kml_SpatialGrid_tile, GDALobj.file=GDALobj.file, tiles=tiles, altitude=altitude, altitudeMode=altitudeMode, colour_scale=colour_scale, breaks.lst=breaks.lst, z.lim=z.lim, overwrite=overwrite)
51+
lst <- snowfall::sfLapply(tiles.sel, .kml_SpatialGrid_tile, GDALobj.file=GDALobj.file, tiles=tiles, altitude=altitude, altitudeMode=altitudeMode, colour_scale=colour_scale, breaks.lst=breaks.lst, z.lim=z.lim, overwrite=overwrite, CRS=CRS)
4952
snowfall::sfStop()
5053
lst <- do.call(rbind, lst)
5154
} else {
@@ -87,15 +90,17 @@ plotKML.GDALobj <- function(obj, file.name, block.x, tiles=NULL, tiles.sel=NULL,
8790
</NetworkLink>', unlist(lst[["kml.tile"]]), unlist(lst[["north"]]), unlist(lst[["south"]]), unlist(lst[["east"]]), unlist(lst[["west"]]), paste(home.url, unlist(lst[["kml.tile"]]), sep="/"))
8891
parseXMLAndAdd(network_txt, parent=kml.out[["Document"]])
8992
assign('kml.out', kml.out, envir=plotKML.fileIO)
90-
## add logo and a legend:
91-
kml.legend <- paste0(strsplit(file.name, ".kml")[[1]][1], "_legend.png")
92-
if(is.null(breaks.lst)){
93-
kml_legend.bar(x=signif(seq(z.lim[1], z.lim[2], length.out=25), 3), legend.file=kml.legend, legend.pal=colour_scale)
94-
} else {
95-
breaks.s <- seq(1, length(breaks.lst), length.out=15)
96-
kml_legend.bar(x=as.factor(signif(breaks.lst[breaks.s], 2)), legend.file=kml.legend, legend.pal=colour_scale[breaks.s])
93+
## add legend and/or logo:
94+
if(plot.legend==TRUE){
95+
kml.legend <- paste0(strsplit(file.name, ".kml")[[1]][1], "_legend.png")
96+
if(is.null(breaks.lst)){
97+
kml_legend.bar(x=signif(seq(z.lim[1], z.lim[2], length.out=25), 3), legend.file=kml.legend, legend.pal=colour_scale)
98+
} else {
99+
breaks.s <- seq(1, length(breaks.lst), length.out=15)
100+
kml_legend.bar(x=as.factor(signif(breaks.lst[breaks.s], 2)), legend.file=kml.legend, legend.pal=colour_scale[breaks.s])
101+
}
102+
kml_screen(image.file = kml.legend, position = "UL", sname = "legend")
97103
}
98-
kml_screen(image.file = kml.legend, position = "UL", sname = "legend")
99104
if(!missing(kml.logo)){ kml_screen(image.file = kml.logo, position = "UR", sname = "logo") }
100105
kml_close(file.name)
101106
if(open.kml==TRUE){
@@ -106,11 +111,12 @@ plotKML.GDALobj <- function(obj, file.name, block.x, tiles=NULL, tiles.sel=NULL,
106111
}
107112

108113
## auxiliary function:
109-
.kml_SpatialGrid_tile <- function(i, GDALobj.file, colour, tiles, breaks.lst, colour_scale, altitude, altitudeMode, z.lim, N.min=4, overwrite){
114+
.kml_SpatialGrid_tile <- function(i, GDALobj.file, colour, tiles, breaks.lst, colour_scale, altitude, altitudeMode, z.lim, N.min=4, overwrite, CRS){
110115
if(any(!c("offset.x", "offset.y", "region.dim.x", "region.dim.y") %in% names(tiles))){ stop("Missing columns in the 'tiles' object. See ?GSIF::tile") }
111116
kml.tile <- set.file.extension(paste0(strsplit(basename(GDALobj.file), "\\.")[[1]][1], "_T", i), ".kml")
112117
raster_name = set.file.extension(paste0(strsplit(basename(GDALobj.file), "\\.")[[1]][1], "_T", i), ".png")
113118
r <- readGDAL(GDALobj.file, offset=c(tiles$offset.y[i], tiles$offset.x[i]), region.dim=c(tiles$region.dim.y[i], tiles$region.dim.x[i]), silent=TRUE)
119+
proj4string(r) = CRS
114120
if(sum(!is.na(r@data[,1]))>N.min){
115121
prj.check <- check_projection(r, control = TRUE)
116122
if(!prj.check) { suppressMessages( r <- reproject(r) ) }

build/vignette.rds

-1 Bytes
Binary file not shown.

inst/doc/jss1079.pdf

2 Bytes
Binary file not shown.

man/kml_legend.bar.Rd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
\description{Produces a PNG file that can be used as a screen overlay --- legend bar for numeric and factor type variables.}
55
\usage{
66
kml_legend.bar(x, width, height, pointsize = 14, legend.file, legend.pal,
7-
z.lim = range(x, na.rm=TRUE, finite=TRUE), factor.labels)
7+
z.lim = range(x, na.rm=TRUE, finite=TRUE), factor.labels, png.type = "cairo-png")
88
}
99
\arguments{
1010
\item{x}{numeric or factor-type vector}
@@ -15,6 +15,7 @@ kml_legend.bar(x, width, height, pointsize = 14, legend.file, legend.pal,
1515
\item{legend.pal}{character; color palette}
1616
\item{z.lim}{numeric; lower and upper limits}
1717
\item{factor.labels}{character; class names if applicable}
18+
\item{png.type}{character; PNG type}
1819
}
1920
\author{Tomislav Hengl, Pierre Roudier, and Dylan Beaudette}
2021
\details{When exporting raster layers to KML the legend bar is generated by default. If the width and height are not provided, the function will try to estimate them automatically.}

man/layer.SpatialPolygons.Rd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ library(rgdal)
4040
library(sp)
4141
data(eberg_zones)
4242
names(eberg_zones)
43-
\dontrun{# visualize zones using random colors:
43+
## visualize zones using random colors:
4444
kml(eberg_zones, colorMode = "random")
45-
# with labels:
46-
kml(eberg_zones, colour = ZONES, plot.labpt = TRUE, labels = ZONES, kmz = TRUE)
47-
}
45+
## with labels:
46+
kml(eberg_zones, colour = ZONES, plot.labpt = TRUE,
47+
labels = ZONES, kmz = TRUE, balloon=TRUE)
4848
}
4949
\keyword{spatial}

man/plotKML.GDALobj.Rd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
plotKML.GDALobj(obj, file.name, block.x, tiles=NULL,
77
tiles.sel=NULL, altitude=0, altitudeMode="relativeToGround", colour_scale,
88
z.lim=NULL, breaks.lst=NULL, kml.logo, overwrite=TRUE, cpus,
9-
home.url=".", desc=NULL, open.kml=TRUE)
9+
home.url=".", desc=NULL, open.kml=TRUE, CRS=attr(obj, "projection"),
10+
plot.legend=TRUE)
1011
}
1112
\arguments{
1213
\item{obj}{\code{"GDALobj"} object i.e. a pointer to a spatial layer}
@@ -25,6 +26,8 @@ plotKML.GDALobj(obj, file.name, block.x, tiles=NULL,
2526
\item{home.url}{character; optional web-directory where the PNGs will be stored}
2627
\item{desc}{character; optional layer description}
2728
\item{open.kml}{logical; specifies whether to open the KML file after writing}
29+
\item{CRS}{character; projection string (if missing)}
30+
\item{plot.legend}{logical; indicate whether to plot summary legend}
2831
}
2932
\value{Returns a list of KML files.}
3033
\note{This operation can be time-consuming for processing very large rasters e.g. more than 10,000 by 10,000 pixels. To speed up writing of KMLs, use the snowfall package.}

0 commit comments

Comments
 (0)