Skip to content

Commit cfdba2e

Browse files
Tomislav Henglcran-robot
authored andcommitted
version 0.6-0
1 parent 7e688cc commit cfdba2e

25 files changed

+1269
-1257
lines changed

DESCRIPTION

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: plotKML
2-
Version: 0.5-9
3-
Date: 2019-01-04
2+
Version: 0.6-0
3+
Date: 2019-11-10
44
Title: Visualization of Spatial and Spatio-Temporal Objects in Google
55
Earth
66
Authors@R: c(person("Tomislav", "Hengl", role = c("cre", "aut"),
@@ -11,9 +11,9 @@ Authors@R: c(person("Tomislav", "Hengl", role = c("cre", "aut"),
1111
person("Michael", "Blaschek", role = "ctb"))
1212
Maintainer: Tomislav Hengl <[email protected]>
1313
Depends: R (>= 2.13.0)
14-
Imports: methods, tools, utils, XML, sp, raster, rgdal, spacetime,
15-
colorspace, plotrix, dismo, aqp, pixmap, plyr, stringr,
16-
colorRamps, scales, gstat, zoo, RColorBrewer, RSAGA, classInt
14+
Imports: methods, tools, utils, XML, sp, raster, rgdal, aqp, spacetime,
15+
colorspace, plotrix, dismo, pixmap, plyr, stringr, colorRamps,
16+
scales, gstat, zoo, RColorBrewer, RSAGA, classInt
1717
Suggests: adehabitatLT, maptools, fossil, spcosa, rjson, animation,
1818
spatstat, RCurl, rgbif, Hmisc, GSIF, uuid, intervals, reshape,
1919
gdalUtils, snowfall, parallel
@@ -23,11 +23,11 @@ URL: http://plotkml.r-forge.r-project.org/
2323
LazyLoad: yes
2424
RoxygenNote: 6.0.1
2525
NeedsCompilation: no
26-
Packaged: 2019-01-09 16:24:32 UTC; tomislav
26+
Packaged: 2019-11-12 00:11:14 UTC; tomhe
2727
Author: Tomislav Hengl [cre, aut],
2828
Pierre Roudier [ctb],
2929
Dylan Beaudette [ctb],
3030
Edzer Pebesma [ctb],
3131
Michael Blaschek [ctb]
3232
Repository: CRAN
33-
Date/Publication: 2019-01-09 17:20:07 UTC
33+
Date/Publication: 2019-11-12 06:50:16 UTC

MD5

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
c4cc0cbf734a6f42c7d16d845412c041 *DESCRIPTION
1+
d0239243c2708e275ab7c3621c8b8cf6 *DESCRIPTION
22
022e76f1864c4f0f6acb3e4b37d3ddb9 *NAMESPACE
33
3ecbca33a6ab94e47c36e1903f83d21c *R/AAA-classes.R
44
72a2c0543a0138bef70c7d7f4892904f *R/AAA-md.R
5-
0a314138186dcbe36e5602df59adb764 *R/AAAA.R
5+
d8c0a86b600d757b0bfee00668d49ba9 *R/AAAA.R
66
9b3042cca6ffd388db738ff6ebfac960 *R/ZZZ.R
77
19df51a1044a318c93d5b957c4739e3e *R/aesthetics.R
88
4d8b8e2058e748fd6fbcba9a87596407 *R/altitude.R
99
755f560c42100896fc27833c0148279c *R/attributes.R
10-
9f684921ffd45e9ef2f978c0527cb6d5 *R/check_projection.R
10+
c05e848dc0540bb741f0635386604b95 *R/check_projection.R
1111
edd5fdd91e0ab07f9d67ea626644dc34 *R/col2kml.R
1212
0b12a90bbdd7ab82ff095d9f45fbbb57 *R/color_palettes.R
1313
b85a1ea8f127369d7625d2f14de296db *R/count.R
1414
58ce48644db42c09f8ad76aaf3c6c73f *R/export_metadata.R
1515
d7b801c2e1761fe713718b22a66a985b *R/geopath.R
1616
8635b63d107ac700584f9d8d315e7cde *R/getWikiMedia.ImageInfo.R
17-
f3f5312e617ccf7cc4275704a3b00d0b *R/grid2poly.R
18-
68f2bf17839165cae5dc24f6683c5326 *R/kml.R
17+
8b0058be14dead2423649c538e6194e2 *R/grid2poly.R
18+
f3279c6b719e7fe352ea84569d8a8151 *R/kml.R
1919
78a001bea12fa1fe7c42abcf226318f3 *R/kml.tiles.R
20-
b02f85c63a19b86bc0fc60d9f7f8d8d2 *R/kml_compress.R
20+
b76e9c556e86328bc7f8c24fea19cad0 *R/kml_compress.R
2121
35ddf8d43c9f0fd089b87608dfc18e52 *R/kml_description.R
2222
4367b88a3824db301fda6c6ea21ab449 *R/kml_metadata.R
23-
1c625305e2d5697421ec50891feb93af *R/kml_open.R
23+
ae4dad588f14b5b263d05a125a4f203e *R/kml_open.R
2424
d5db69a887712b4422730b8d433810d8 *R/kml_screen.R
2525
b0cc0361cba4a7dc748d7da4aab3e19e *R/layer.Raster.R
2626
18d953e1e9894bcd1c8915e39c2b629a *R/layer.RasterBrick.R
@@ -52,7 +52,7 @@ d42b596f16b685a58886e9153548bd4d *R/spPhoto.R
5252
b30ad7ee8a09c82aa44b949ec857ff2d *R/vect2rast.R
5353
7a542f5f40c3d99631a489e5749034a9 *R/whitening.R
5454
d41d8cd98f00b204e9800998ecf8427e *TODO
55-
d7ad19eec0c397d63ade246cdce18764 *build/vignette.rds
55+
8c30d6bfc1bf536d869ddfba8e744404 *build/vignette.rds
5656
9060c942e52ce8a1939e2f36d145cbd4 *data/HRprec08.rda
5757
33060527d47b9b9095e5d2e0551d8b80 *data/HRtemp08.rda
5858
9b21818fdf75dca5813a4e17cf540ce5 *data/LST.rda
@@ -63,7 +63,7 @@ b05a32b7374a03dd64f911c195de1f3b *data/R_pal.rda
6363
2ba799641325c0a3652d103dac49a655 *data/barstr.rda
6464
945ce77e22468dec50ac9fa1a90b8119 *data/barxyz.rda
6565
4d03498deeaa6bc34b0089ed66747818 *data/bigfoot.rda
66-
8149fc98745217a36e9671aa1fa843d2 *data/datalist
66+
3b7f2ec646e6b4faae0b54e94a7c5f36 *data/datalist
6767
a92978c15fd0ae9d9887aab747ce5911 *data/eberg.rda
6868
39c39172a917ebd09656ee53d0a312ce *data/eberg_contours.rda
6969
97773caa72560db04d92e603040d6aef *data/eberg_grid.rda
@@ -74,21 +74,21 @@ b1ba3820cca7175ef48406658569892c *data/fmd.rda
7474
e1ff1d118f2673d37f72ee014fd1b046 *data/northcumbria.rda
7575
bc4f0691e7de86b5b80b0f7f2d539c00 *data/worldgrids_pal.rda
7676
80d6393cfbb9cecc294291f63177b712 *demo/00Index
77-
db711d76c2f8dd266469396e64ae4702 *demo/plotKML.R
77+
c9d5efa8d4d2143734ced275f9efa254 *demo/plotKML.R
7878
019df2dab449e35ebc97a078639e1c2f *inst/CITATION
7979
4e57d54acb8d3d76b983cf8ac2d2ce1a *inst/FGDC.xml
8080
b90137d302edc916b41e9377eeefa78c *inst/INSPIRE_ISO19139.xml
8181
d41d8cd98f00b204e9800998ecf8427e *inst/NEWS
82-
f72486b61431c8f96a3d2d407dcbb279 *inst/doc/jss1079.R
82+
83ce254a012f24868233278ca985f12e *inst/doc/jss1079.R
8383
ae021f1564a08f85fd2c9d38e4c1c891 *inst/doc/jss1079.Rnw
84-
30ea2051f2c1dace634d85d4d172c751 *inst/doc/jss1079.pdf
84+
74b50c32ef73a8e671688c2e91a984dc *inst/doc/jss1079.pdf
8585
c4c84fc61344519d27e5b9ee06f4845e *inst/eberg.xml
8686
762124c8e05e5dbf332ec2acadb0af18 *inst/gpx.xsd
8787
28da50b2a17e0848877f44470a66db5b *inst/mdnames.csv
8888
2ec8bcb160dd1559958abb4086b3feee *inst/ogckml22.xsd
89-
6fa256dca44ae4400ec73742288f3f8e *man/HRprec08.Rd
90-
f0ccd6da414e12983b5191abc9c507ca *man/HRtemp08.Rd
91-
33144e10edf83bb2138a2a1c4ca3b654 *man/LST.Rd
89+
a640027fc28da4a620414eb6505b4705 *man/HRprec08.Rd
90+
8f34866cb731c198087d663a782d9c15 *man/HRtemp08.Rd
91+
cc8a82ff70a5deec35b2b505ee63af15 *man/LST.Rd
9292
585465677f16ef69b9a1d6baa05cb3da *man/RasterBrickSimulations.Rd
9393
628418248bebb5c972c07acada304887 *man/RasterBrickTimeSeries.Rd
9494
48467f6bcda520872ea0cdf067497432 *man/SAGA_pal.Rd
@@ -105,16 +105,16 @@ e3b1ca364e72200fb2bf44cf7a2ecef6 *man/check_projection.Rd
105105
18c0d336ccd4efe6040a723cc7abcaa7 *man/col2kml.Rd
106106
1cafdb859f4ffcff810da94451d955fb *man/count.GridTopology.Rd
107107
4892e73b7225b5fdcc93c44c81da41b1 *man/display.pal.Rd
108-
d59f39a04f1c381e7f8173ac1e0731b9 *man/eberg.Rd
108+
7f15503868c47f7cefedb0d7b37d7c71 *man/eberg.Rd
109109
282e65fef67e40d550ce4592a466d1c8 *man/fmd.Rd
110-
a1ba81a666f26d1da3715bab3c08cae5 *man/geopath.rd
111-
ba33af50257b909b7b3b465f3c1d8f23 *man/getCRS.Rd
110+
592a6a21bf72533ed28f8db2a7f8b656 *man/geopath.rd
111+
cb21add11ca471cecb29a649fc931d3d *man/getCRS.Rd
112112
f3c2a57ec1818e1f8e9bd9b23fae9d88 *man/getWikimedia.Rd
113113
2679116e985f4a9bca53859613b6231b *man/gpxbtour.Rd
114114
a728fa2a64a0b4bb6bec8cac0605c434 *man/grid2poly.Rd
115115
2e0bd8fb69aa40b7b5d73fe0cc768564 *man/kml.Rd
116116
fd0c3692112a3069f8b848f38c5e5ba1 *man/kml.tiles.Rd
117-
8cb08e931d350f65a2667263a2df7220 *man/kml_compress.Rd
117+
2882d667d1b77357f883b09892bff5f0 *man/kml_compress.Rd
118118
d5303eb2b21a793be8e30c2890a0c3d0 *man/kml_description.Rd
119119
9a636172d39a8da22750a3c64839ad1f *man/kml_layer.Rd
120120
95e0f1de8029e6eb4d9a083f28ec3e4f *man/kml_legend.bar.Rd
@@ -126,11 +126,11 @@ ff005c4253ce937f4f00c5bfc5989b96 *man/layer.RasterBrick.Rd
126126
91278a3622a63a22bc2740192c275ddb *man/layer.STIDF.Rd
127127
fa36700eefb4780e41729b34b8644363 *man/layer.STTDF.Rd
128128
907722312263e3081b46f0ae7d69a1b3 *man/layer.SoilProfileCollection.Rd
129-
00fabd1081e4aea6e43c609df51babd4 *man/layer.SpatialLines.Rd
129+
a7762800c2564778736e32a7df981356 *man/layer.SpatialLines.Rd
130130
1bd5ecda9d396041e86c3fd55181719e *man/layer.SpatialPhotoOverlay.Rd
131131
443f0028138e5f85b75b46c151ff50f5 *man/layer.SpatialPixels.Rd
132132
0082fbe6988d8535b8204f12e7c65150 *man/layer.SpatialPoints.Rd
133-
f4149a8945c1b624132250ac918124cd *man/layer.SpatialPolygons.Rd
133+
21a6f2e4c5ef0bd2e4b802506f2430f1 *man/layer.SpatialPolygons.Rd
134134
396ba7d0b002f5ea6c8bc54662285f6b *man/legend.whitening.Rd
135135
965fa2cf22945b4255baf5b88c6bdd49 *man/makeCOLLADA.Rd
136136
a1dce43a94fb62ce569ee12814d61a54 *man/metadata2SLD.Rd
@@ -139,13 +139,13 @@ ca181c1fc1f593708f0f34ba89728a09 *man/normalizeFilename.Rd
139139
ce9659fd3cb5a860c275b52639dfa7d7 *man/northcumbria.Rd
140140
ecc06f2651dd7e614090c43a5366f158 *man/plotKML-package.Rd
141141
c14783facc4673c990dcb6db6c214ae5 *man/plotKML.GDALobj.Rd
142-
441d39c0716f016229a3af9c4a8daa96 *man/plotKML.Rd
142+
512bfa99759aff4780eaa577d0809d1a *man/plotKML.Rd
143143
30b47712e1af15f3a1b08648c1c07563 *man/plotKML.env.Rd
144144
8c4443c0c9b49eb974b19708d1874d50 *man/readGPX.Rd
145145
4d504394627a1006b8fb52b12d4f05e3 *man/readKML.GBIFdensity.Rd
146146
f255a9d57b5a9ed009447b34661d5bce *man/reproject.Rd
147147
95b5e9a455650e91a094fbd3f4f8056c *man/sp.palette.Rd
148-
2a19864e57fab71a4f3ac7ada839ba69 *man/spMetadata.Rd
148+
571d35dbc6b817874a7af9dcc5886c31 *man/spMetadata.Rd
149149
ffa58c7d00b056fe1ecdc75903c2e396 *man/spPhoto.Rd
150150
ffcb7c435e854cfdfa78b7efe1f2edda *man/vect2rast.Rd
151151
b10b332eee900a8fcba5e6e8442729b6 *man/vect2rast.SpatialPoints.Rd

R/AAAA.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ plotKML.env <- function(
239239
brewer3 = c("#FEEDDE","#FDBE85","#FD8D3C","#E6550D","#A63603")
240240
#if(missing(colour_scale_svar)) { colour_scale_svar <- brewer.pal(n = 5, name = "Oranges") }
241241
if(missing(colour_scale_svar)) { colour_scale_svar <- brewer3 }
242-
if(missing(ref_CRS)) { ref_CRS <- "+proj=longlat +datum=WGS84" }
242+
if(missing(ref_CRS)) { ref_CRS <- "+proj=longlat +ellps=WGS84" }
243243
if(missing(NAflag)) { NAflag <- -99999 }
244244
if(missing(icon)) { icon <- "icon3.png" } # "http://maps.google.com/mapfiles/kml/shapes/donut.png"
245245
if(missing(LabelScale)) { LabelScale <- .5 }

R/check_projection.R

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
extractProjValue <- function(p4s_parameters, param){
44

55
# Locating the current PROJ4 parameter
6-
query <- ldply(p4s_parameters, str_locate, pattern = param)
6+
query <- plyr::ldply(p4s_parameters, stringr::str_locate, pattern = param)
77
idx <- which(!is.na(query[, 1]) & !is.na(query[, 2]))
88

99
# If the PROJ4 parameter is found we extract its value
@@ -13,8 +13,8 @@ extractProjValue <- function(p4s_parameters, param){
1313
# Extract the parameter value
1414
value <- strsplit(param_value, param)[[1]]
1515
value <- value[value != ""]
16-
}
17-
else { stop(paste("Proj4string does not contain", param, "parameter.\n Consider converting to the referent CRS", get("ref_CRS", envir = plotKML.opts),"manually."))
16+
} else {
17+
stop(paste("Proj4string does not contain", param, "parameter.\n Consider converting to the referent CRS", get("ref_CRS", envir = plotKML.opts),"manually."))
1818
}
1919

2020
return(value)
@@ -25,17 +25,17 @@ extractProjValue <- function(p4s_parameters, param){
2525
parse_proj4 <- function(p4s, params){
2626

2727
if(missing(params)) {
28-
ref_CRS = get("ref_CRS", envir = plotKML.opts)
29-
value <- strsplit(ref_CRS, "\\+")[[1]]
30-
value <- value[value != ""]
31-
param_names <- sapply(strsplit(value, "="), function(x){x[1]})
32-
params <- as.list(paste("\\+", sapply(strsplit(value, "="), function(x){x[1]}), "=", sep=""))
28+
ref_CRS = get("ref_CRS", envir = plotKML.opts)
29+
value <- strsplit(ref_CRS, "\\+")[[1]]
30+
value <- value[value != ""]
31+
param_names <- sapply(strsplit(value, "="), function(x){x[1]})
32+
params <- as.list(paste("\\+", sapply(strsplit(value, "="), function(x){x[1]}), "=", sep=""))
3333
}
3434

3535
# Splitting the whole PROJ4 string
36-
p4s_parameters <- str_split(p4s, " ")[[1]]
36+
p4s_parameters <- stringr::str_split(p4s, " ")[[1]]
3737
# Extraction of the values of parameters specified above
38-
x <- laply(params, extractProjValue, p4s_parameters = p4s_parameters)
38+
x <- plyr::laply(params, extractProjValue, p4s_parameters = p4s_parameters)
3939
# colnames for better looking result
4040
value <- sapply(sapply(params, strsplit, "\\+"), function(x){x[2]})
4141
param_names <- sapply(strsplit(value, "="), function(x){x[1]})
@@ -85,7 +85,7 @@ check_projection <- function(obj, control = TRUE, ref_CRS = get("ref_CRS", envir
8585
}
8686

8787
# First, check if it is in the metric system or unprojected:
88-
if(ref_CRS=="+proj=longlat +datum=WGS84"&is.projected(obj)){
88+
if(ref_CRS=="+proj=longlat +ellps=WGS84"&is.projected(obj)){
8989
ret = FALSE
9090
}
9191

R/grid2poly.R

Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,60 @@
1-
grid2poly <- function(obj, var.name = names(obj)[1], reproject = TRUE, method = c("sp", "raster", "RSAGA")[1], tmp.file = TRUE, saga_lib = "shapes_grid", saga_module = 3, silent = FALSE, ...){
2-
3-
# print warning:
4-
if(length(obj)>1e4){
5-
warning("Operation not recommended for large grids (>>1e4 pixels).", immediate. = TRUE)
6-
}
7-
8-
if(method=="raster"){
9-
r <- raster(obj[var.name])
10-
pol <- rasterToPolygons(r)
11-
names(pol) <- var.name
12-
}
13-
14-
else{
15-
if(method=="RSAGA"){
16-
if(!rsaga.env()[["cmd"]]=="NULL"){
17-
if(tmp.file==TRUE){
18-
tf <- tempfile()
19-
} else {
20-
tf <- var.name
21-
}
22-
23-
# first, write SGDF to a file:
24-
obj <- as(obj[var.name], "SpatialPixelsDataFrame")
25-
writeGDAL(obj[var.name], paste(tf, ".sdat", sep=""), "SAGA")
26-
# saga_lib name and saga_module might change in the future versions of SAGA!
27-
# SAGA GIS 2.0.8
28-
rsaga.geoprocessor(lib=saga_lib, module=saga_module, param=list(GRIDS=paste(tf, ".sgrd", sep=""), SHAPES=paste(tf, ".shp", sep=""), NODATA=TRUE, TYPE=1), show.output.on.console = silent)
29-
if(requireNamespace("maptools", quietly = TRUE)){
30-
pol <- maptools::readShapePoly(paste(tf, ".shp", sep=""), proj4string=obj@proj4string)
31-
} else {
32-
pol <- readOGR(paste(tf, ".shp", sep=""))
33-
}
34-
}
35-
36-
else { stop("SAGA GIS path could not be located. See 'rsaga.env()' for more info.") }
37-
}
38-
39-
else {
40-
obj <- as(obj[var.name], "SpatialPixelsDataFrame")
41-
# pol <- as.SpatialPolygons.SpatialPixels(obj) # EJP: deprecated
42-
# pol <- SpatialPolygonsDataFrame(pol, data=data.frame(var.name = obj@data[,var.name]), match.ID=FALSE)
43-
pol = as(obj, "SpatialPolygonsDataFrame")
44-
}
45-
}
46-
47-
# Checking projection:
48-
prj.check <- check_projection(pol, control = TRUE)
49-
50-
# Trying to reproject data if the check was not successful
51-
if (!prj.check&reproject==TRUE) { pol <- reproject(pol) }
52-
53-
# Convert to SPolyDF:
54-
dm <- data.frame(obj@data[,var.name])
55-
names(dm) <- var.name
56-
pol <- SpatialPolygonsDataFrame(pol, dm, match.ID=FALSE)
57-
58-
return(pol)
59-
}
60-
61-
# end of script;
1+
grid2poly <- function(obj, var.name = names(obj)[1], reproject = TRUE, method = c("sp", "raster", "RSAGA")[1], tmp.file = TRUE, saga_lib = "shapes_grid", saga_module = 3, silent = FALSE, ...){
2+
3+
# print warning:
4+
if(length(obj)>1e4){
5+
warning("Operation not recommended for large grids (>>1e4 pixels).", immediate. = TRUE)
6+
}
7+
8+
if(method=="raster"){
9+
r <- raster(obj[var.name])
10+
pol <- rasterToPolygons(r)
11+
names(pol) <- var.name
12+
}
13+
14+
else{
15+
if(method=="RSAGA"){
16+
if(!rsaga.env()[["cmd"]]=="NULL"){
17+
if(tmp.file==TRUE){
18+
tf <- tempfile()
19+
} else {
20+
tf <- var.name
21+
}
22+
23+
# first, write SGDF to a file:
24+
obj <- as(obj[var.name], "SpatialPixelsDataFrame")
25+
writeGDAL(obj[var.name], paste(tf, ".sdat", sep=""), "SAGA")
26+
# saga_lib name and saga_module might change in the future versions of SAGA!
27+
# SAGA GIS 2.0.8
28+
rsaga.geoprocessor(lib=saga_lib, module=saga_module, param=list(GRIDS=paste(tf, ".sgrd", sep=""), SHAPES=paste(tf, ".shp", sep=""), NODATA=TRUE, TYPE=1), show.output.on.console = silent)
29+
if(requireNamespace("maptools", quietly = TRUE)){
30+
pol <- maptools::readShapePoly(paste(tf, ".shp", sep=""), proj4string=obj@proj4string)
31+
} else {
32+
pol <- readOGR(paste(tf, ".shp", sep=""))
33+
}
34+
}
35+
36+
else { stop("SAGA GIS path could not be located. See 'rsaga.env()' for more info.") }
37+
}
38+
else {
39+
obj <- as(obj[var.name], "SpatialPixelsDataFrame")
40+
# pol <- as.SpatialPolygons.SpatialPixels(obj) # EJP: deprecated
41+
# pol <- SpatialPolygonsDataFrame(pol, data=data.frame(var.name = obj@data[,var.name]), match.ID=FALSE)
42+
pol = as(obj, "SpatialPolygonsDataFrame")
43+
}
44+
}
45+
46+
# Checking projection:
47+
prj.check <- check_projection(pol, control = TRUE)
48+
49+
# Trying to reproject data if the check was not successful
50+
if (!prj.check&reproject==TRUE) { pol <- reproject(pol) }
51+
52+
# Convert to SPolyDF:
53+
dm <- data.frame(obj@data[,var.name])
54+
names(dm) <- var.name
55+
pol <- SpatialPolygonsDataFrame(pol, dm, match.ID=FALSE)
56+
57+
return(pol)
58+
}
59+
60+
# end of script;

0 commit comments

Comments
 (0)