Commit dffb0540 authored by Andreas Tille's avatar Andreas Tille

New upstream version 0.7-7+dfsg

parent 7b7e8ace
Package: sf
Version: 0.7-6
Version: 0.7-7
Title: Simple Features for R
Authors@R:
c(person(given = "Edzer",
......@@ -50,7 +50,7 @@ Depends: methods, R (>= 3.3.0)
Imports: classInt (>= 0.2-1), DBI (>= 0.8), graphics, grDevices, grid,
magrittr, Rcpp (>= 0.12.18), stats, tools, units (>= 0.6-0),
utils
Suggests: blob, covr, dplyr (>= 0.8-0), ggplot2, knitr, lwgeom (>=
Suggests: blob, covr, dplyr (>= 0.8-3), ggplot2, knitr, lwgeom (>=
0.1-5), maps, maptools, mapview, microbenchmark, odbc, pillar,
pool, raster, rgdal, rgeos, rlang, rmarkdown, RPostgres (>=
1.1.0), RPostgreSQL, RSQLite, sp (>= 1.2-4), spatstat, stars
......@@ -71,7 +71,7 @@ Collate: 'RcppExports.R' 'init.R' 'crs.R' 'bbox.R' 'read.R' 'db.R'
'stars.R' 'crop.R' 'gdal_utils.R' 'nearest.R' 'normalize.R'
'deprecated.R'
NeedsCompilation: yes
Packaged: 2019-07-05 07:47:37 UTC; edzer
Packaged: 2019-07-22 14:08:52 UTC; edzer
Author: Edzer Pebesma [aut, cre] (<https://orcid.org/0000-0001-8049-7069>),
Roger Bivand [ctb] (<https://orcid.org/0000-0003-2392-6140>),
Etienne Racine [ctb],
......@@ -85,4 +85,4 @@ Author: Edzer Pebesma [aut, cre] (<https://orcid.org/0000-0001-8049-7069>),
Thomas Lin Pedersen [ctb]
Maintainer: Edzer Pebesma <edzer.pebesma@uni-muenster.de>
Repository: CRAN
Date/Publication: 2019-07-05 12:30:08 UTC
Date/Publication: 2019-07-24 10:30:02 UTC
d96ddff3b6189a153d08e3949c0c915e *DESCRIPTION
295a99ac0513b87ebfd8142ac888af51 *DESCRIPTION
4a78446d70c280450433a761050c7013 *LICENSE
b43db98344139ee1b59fc962044bb4c6 *NAMESPACE
18ca12fb1ca2549f3f2ee2b7de372d1f *NEWS.md
6017f5144cd42c6cad170ab4cca4b798 *R/RcppExports.R
246be28587b3728b3f32fc0e381d687f *NEWS.md
d7f9f2c0a85dc288a2aab8c44d87eca5 *R/RcppExports.R
c6cf55695cc280f192d1bacdd2f67bdd *R/aggregate.R
ecbd6b1aec0f5973ad716755dca8a5e0 *R/agr.R
a314eca1a18283ae3c04cc37b2cf8928 *R/arith.R
f79b0ebe9b2607f6feebc94321a2bd7d *R/bbox.R
e84bad6bdb90e6cab9051fcd37f1cbec *R/bind.R
3f7f74d1582d799d461d82bec26f642a *R/bind.R
c1ce6c9e15ca9e9ae98978855a4949f7 *R/cast_sfc.R
0f6f95d530e236cdb531d83eb9e2a7cd *R/cast_sfg.R
ab683be94a7f0962178ddc8d528867d3 *R/collection_extract.R
......@@ -17,7 +17,7 @@ e6e01727c51ae71213054847bba6c645 *R/datasets.R
48adbdaaccb310528bd9cda73b62816f *R/db.R
0616e907ffdc4d75b6787e75fbd6cb7b *R/deprecated.R
661f2417ac41236af740ac863cdc4092 *R/gdal_utils.R
435deed581790cc934e4bf36a2b19377 *R/geom.R
4ab69e2671f346f0a3df863daed9581c *R/geom.R
4890fa3e49760223312537a68d24424e *R/graticule.R
cab75aa4957850b29d08501bc0af3bb1 *R/grid.R
7ab2ac10e6e740d0615ce6c9b9cf47e7 *R/init.R
......@@ -26,12 +26,12 @@ ea911034d64db19e323e9cd954264ce6 *R/jitter.R
10d82d40da3edbcdea3d364f7d6f6602 *R/maps.R
706d75caea557361e026074f202febc7 *R/nearest.R
3c3bc9c507783331fd8d801026bea59f *R/normalize.R
def015f3775f948e86f40e109ddb6c75 *R/plot.R
c29a0673653181d62336a4b46c08b01b *R/read.R
cc883dccaf585a190126afe088d33699 *R/plot.R
396b4175e49cfc05ada3cf58b130d905 *R/read.R
53bc83fff23ff3e18b1f4d974f9e74d0 *R/sample.R
95f18005d17de9d2dc8352230b03977f *R/sf.R
a08aded2978dc61a972a211aaed81d6e *R/sf.R
03f06726a22888661e38f11028527b5b *R/sfc.R
a199b54b78b71bd05f527b5f8982bfdf *R/sfg.R
49c14f49a0f5c06f0d67e302b5c3af77 *R/sfg.R
19cf057906f8fd30d1b60f0fd1cb0d2c *R/sgbp.R
54c03e52a9237fb7fd515ec7e12f4979 *R/sp.R
24c8ebe1caec64ab17d6db1ac6794c2d *R/spatstat.R
......@@ -41,10 +41,10 @@ a2c7b11f25d3794c0fa186ed81c8bfe5 *R/transform.R
78959f85d1908fe9b8220124994295a2 *R/valid.R
cd89dc71de0124ad1e9563eed5ece870 *R/wkb.R
fc6070cd2cdfc27af6bcfa64e51c444c *R/wkt.R
e7209e24130e1fa9a778d2bc338e4898 *build/vignette.rds
e818a9e1787ec5f3fd77cd8916b94d10 *build/vignette.rds
dd4f1013f2be29d7fa4350d6acb34595 *cleanup
500c4b0e60d23d7397e02bd29a0a4828 *configure
60422753d6e27cda384117b26a505d7a *configure.ac
2f6567fcf91c54353a351df31ad764b6 *configure
4584d0293621fdd4f11b01df7edd89d3 *configure.ac
1699be0a484d4b97d19b2a6cccc89134 *demo/00Index
51541d79f81c8a8fa828116c32bf57ac *demo/affine.R
5a227a20ab0500ca03ad4d9d41adcc6e *demo/basic.R
......@@ -58,22 +58,22 @@ cfc39be689e038e7168e501129a658bb *demo/twitter.R
cf82547c5941aa8cca487b66dde26bbb *inst/csv/pt.csv
e6c6882c78db2a8211197c28ee89b940 *inst/doc/sf1.R
e269d1a1a3acefeb22ad9930e31171b2 *inst/doc/sf1.Rmd
5b48d8b9a819bb2f8db9cf1236f7ee8a *inst/doc/sf1.html
a00dc31b618d268d3c44a6a1567b9af7 *inst/doc/sf1.html
e88f10d88fd54fd6c5d67fd9e6a6a8db *inst/doc/sf2.R
562cd2851ced897f4a8b8ffff5a330dc *inst/doc/sf2.Rmd
4d31f72491f26b77ddc3859335dba31c *inst/doc/sf2.html
38f235219e2c83d4d7ce031707e55717 *inst/doc/sf2.html
6a663c114114723bc7d2a4c01b16b2ce *inst/doc/sf3.R
dc0dc94cd1855220f60667d85814c528 *inst/doc/sf3.Rmd
48f734d3acafc0c4d2bccbc4668232ac *inst/doc/sf3.html
53d81f4a3eb00dca3685bb19860bbf7b *inst/doc/sf4.R
eb7a0ce5f83492994b9b14d26b9fba0c *inst/doc/sf4.Rmd
86b22dbadc99f60f10145362cc6b547e *inst/doc/sf4.html
8381e40f672dc65e062f61b4ed5ab950 *inst/doc/sf5.R
8b919067b9953c5a1fb957d694d47712 *inst/doc/sf5.Rmd
09c6a1b60d93492439266eeb74c4e248 *inst/doc/sf5.html
14e8056e5f952e520b92482f8b5de1c7 *inst/doc/sf4.html
eaff30c47474a0e30ca97801715224f8 *inst/doc/sf5.R
990bd8b87895e2fc9653aa9d60a7bfa1 *inst/doc/sf5.Rmd
6e582fd9acb353e30d76c5e5ba4ecc44 *inst/doc/sf5.html
74224a3499aac4e51eb2867bad6078e4 *inst/doc/sf6.R
66982aa23978d9b2e8a089eccc5fddbe *inst/doc/sf6.Rmd
2892f34608d986c44328852cc7baa94d *inst/doc/sf6.html
4db8b6edbcfc209fa776e7c0a942d0b5 *inst/doc/sf6.html
7debb389249aa7410b6ee8aaadfe1404 *inst/docker/base/Dockerfile
44b2d86af9f8a768fd03d0b07fc9a084 *inst/docker/cran/Dockerfile
e8ee0e26c8e78fb47e226de5971995ec *inst/docker/custom/Dockerfile
......@@ -118,7 +118,7 @@ d234e53dd8bc4ada321586499a737a83 *inst/sqlite/test3.sqlite
b577a2c1d01ff7bc9d875606e39d8c67 *inst/tif/geomatrix.tif
50feb20606384a04d652091ed8609cf5 *man/Ops.Rd
55b792cd546f607638d8399ad40a897f *man/aggregate.sf.Rd
ce2b83003fc8161e76c67bd1c1fdd0e2 *man/bind.Rd
c673cf0cbe2a3b20c6293177c2edf40a *man/bind.Rd
9d8e3b44c47075fd3a7a437da9c40d5f *man/coerce-methods.Rd
f2bb4646a541ca25fc6784a6cad5098d *man/dbDataType.Rd
f611b8bcd2b45cde605b62e8ff43bec0 *man/db_drivers.Rd
......@@ -129,7 +129,7 @@ a2f948df97eab20f5bb06bab3b6be658 *man/gdal_utils.Rd
d615862d451a07bbf2ab10e9c8dfc5fb *man/geos_binary_ops.Rd
b8fd4d59bf70d479e36d00a5e315d85c *man/geos_binary_pred.Rd
0e268d1809eda698e9a9aec66578daba *man/geos_combine.Rd
3cece2e33a614df1979b4a4dec6db8ac *man/geos_measures.Rd
abc7a781d0df7764669b1021f524061f *man/geos_measures.Rd
e8205981057bd40699606cb9c3e46159 *man/geos_query.Rd
332bb847d6cf2e24dda5755aec7f5a61 *man/geos_unary.Rd
f0e103081dac6fe2ef9ad6dd4ba8eea6 *man/internal.Rd
......@@ -138,7 +138,7 @@ aab6905c2dce1681583aee67f6fdad43 *man/is_driver_available.Rd
fef644d130c7ffd67976056562dfbecc *man/is_geometry_column.Rd
f3a77ef0d669c91d44a802c79c5f0f51 *man/merge.sf.Rd
a92b636dae98b8f71bbe0f6b3766b426 *man/nc.Rd
190b03bebcae388ec2cbd8a588dcb439 *man/plot.Rd
60e1435a8ce6b71cae51a18aa4e88773 *man/plot.Rd
11665d1ea4b871f8afc370a1f1c67a1d *man/prefix_map.Rd
e93ede7b8cb92443501e8f6cd012071b *man/rawToHex.Rd
3408ae9c671f9e26f3a934c3dcf7ab93 *man/reexports.Rd
......@@ -162,7 +162,7 @@ cadb27159d0e9cd72c64dace275c820f *man/st_cast_sfc_default.Rd
f556eb2f6efe600b4aba798a9a596240 *man/st_coordinates.Rd
83e7306db8f7ad92f5d39e2f705ac6aa *man/st_crop.Rd
c16a3ee1a46407a030ba008c51e54fbf *man/st_crs.Rd
7fe02f27864bafebf1dbb3dda2b7c4e1 *man/st_drivers.Rd
5161d2c33a79402fb7c7092ec9df3349 *man/st_drivers.Rd
2fdff0d42057fc878a031db6c66c3509 *man/st_geometry.Rd
84fa4ecc2c16c9f5a8f5861eaefdc858 *man/st_geometry_type.Rd
d3d7e935c1f5376148b6ecbfab1ae978 *man/st_graticule.Rd
......@@ -178,7 +178,7 @@ a33b59b00664998fbc1be2878bbc7963 *man/st_make_grid.Rd
5e78e3db410bd6caa3820f10b497341e *man/st_nearest_points.Rd
0470b329213cc24e6b51686a625fee3f *man/st_normalize.Rd
ae8710abc1fe8c95785064f036c829b5 *man/st_precision.Rd
a5b04eec2a95985bc6bc0700294c96c2 *man/st_read.Rd
4ba9b65ec335d037934aabdb2acf8884 *man/st_read.Rd
5538dff4e2ad1c334605654510e7b49d *man/st_relate.Rd
6930d32e7664a6028a4603a7cd84cff4 *man/st_sample.Rd
76a5fef591ea0d24c9987b5d32595c34 *man/st_transform.Rd
......@@ -191,13 +191,13 @@ d853494df6205717ba8152b34394f75f *man/st_viewport.Rd
f7f6b01b87c119a65058901105fd652b *man/tidyverse.Rd
adc2fba1a7a36b617329645392cf6777 *src/Makevars.in
0a351c2c787a8f7e6584010d5978051e *src/Makevars.win
318624efaf43e65b616f46911a53d35b *src/RcppExports.cpp
24553dcf07f31138222d8f5b1182af86 *src/RcppExports.cpp
762ff668d473a149c930760d9fb0f6db *src/bbox.cpp
ddb39e942012b27960eb47d6a99dbdea *src/bbox.h
769e2fd89ce7df69eee1df1602bda0c8 *src/gdal.cpp
97ba6f5ed72c83cbc2b458eddc842962 *src/gdal.h
3293edf128d729b93e8e0eb46701fc12 *src/gdal_geom.cpp
a7eb5e92605a50c83269c6a6ba0e7b4e *src/gdal_read.cpp
6f46a7d3e49326a7c8c3481f142c45cf *src/gdal_read.cpp
870ae6ab130c308f6a6e620f386ee662 *src/gdal_read.h
88017d7a5029b520ffd89aafd7b3ce9f *src/gdal_sf_pkg.h
2d0aa67a73ee8300db85cf1fa21c490d *src/gdal_utils.cpp
......@@ -231,7 +231,7 @@ df75d38bec84946b9c5c7a33065d0523 *tests/empty.R
6c01469eaca508ab0c47f202cd17db76 *tests/gdal_geom.R
4677fb04ef7f79f3780fbcad4558e83b *tests/gdal_geom.Rout.save
3c8d3c9bc20a54f5402229a423eb0ee5 *tests/geos.R
e6d751a34c71d44e38cea14f858d4ac6 *tests/geos.Rout.save
c860f01a002d5de8f39e3c8bc62dc63f *tests/geos.Rout.save
8513101bfa8796f73735298fe030f907 *tests/graticule.R
f5115a273878ebdf3c127c6c26ea1188 *tests/graticule.Rout.save
2f9a2262102cdf5000bc93f6d03662df *tests/grid.R
......@@ -239,15 +239,15 @@ c7f1724d45f2b60c8d040bbb3f1a6ea0 *tests/grid.Rout.save
2ad3bb0d43dc55520b613bd39e3d4dc9 *tests/plot.R
21d2b2b27a89c0bd7ab88bcac9d176c2 *tests/plot.Rout.save
fccc98b46ad0dead9c97cbfec03da728 *tests/read.R
ec880bc038fddabd81e9c7aafdf97f87 *tests/read.Rout.save
422b8f803677b15a3becd926c2934368 *tests/read.Rout.save
2671562e9e9ed86ed8d87466fc99e333 *tests/roundtrip.R
8d3e5e2fe8482feaa5ab2c133b689032 *tests/roundtrip.Rout.save
de932f73d8b09840aaf4e86bee792457 *tests/sfc.R
c68e83d8bc257ca4a374f957f7f71bb5 *tests/sfc.Rout.save
3afb38da973458c160b162e40675fc9a *tests/sfc.R
2824c45c3e9a545c26876da9c86a11dc *tests/sfc.Rout.save
59800da9625398964d0a417c0c5e0a76 *tests/sfg.R
69e1697e583d6d727ec8e80f6a27aafe *tests/sfg.Rout.save
9c6c4fbbe3fdab77f14341b665d035fa *tests/stars.R
fb8d36955539d10edc4ca68a22470232 *tests/stars.Rout.save
d56e805a42342143d10bff0a27e76660 *tests/stars.Rout.save
b84d8e1054d74516c6f100e6d0ac015e *tests/testthat.R
42635bbea94a3aa10beca77b1b526491 *tests/testthat.Rout.save
b21262bf4a2db5557d6081e0cb2728a7 *tests/testthat/deprecated-db.R
......@@ -263,7 +263,7 @@ b5135266c23af6b611292b01fd73182e *tests/testthat/test_geos.R
cead46bb36d583bf54605b6e73cffd3a *tests/testthat/test_postgis_ODBC.R
575ab413ce8e6b395e8331c7215d541c *tests/testthat/test_postgis_RPostgreSQL.R
c97a015604c8e309a889205a143d654b *tests/testthat/test_postgis_RPostgres.R
67949e51f9bf4b57d551e1c26a66cf4d *tests/testthat/test_read.R
7172d2c7bd94db11bd4f7ef75440863d *tests/testthat/test_read.R
8ae97bbe1d1b1a268ceda75ada1e0e07 *tests/testthat/test_sample.R
7927908a7f28f45b75a88946ceec3d39 *tests/testthat/test_sf.R
c610a7940b6d93f46fdf1f5a9623c6f2 *tests/testthat/test_sfc.R
......@@ -288,6 +288,6 @@ e269d1a1a3acefeb22ad9930e31171b2 *vignettes/sf1.Rmd
8e72ae22e7224c2d2f495534447b920a *vignettes/sf2.png
dc0dc94cd1855220f60667d85814c528 *vignettes/sf3.Rmd
eb7a0ce5f83492994b9b14d26b9fba0c *vignettes/sf4.Rmd
8b919067b9953c5a1fb957d694d47712 *vignettes/sf5.Rmd
990bd8b87895e2fc9653aa9d60a7bfa1 *vignettes/sf5.Rmd
66982aa23978d9b2e8a089eccc5fddbe *vignettes/sf6.Rmd
ddae15bb07146a113fa2217a7a155d8c *vignettes/sf_xfig.png
# version 0.7-7
* `plot()` handles `POSIXct` values in legend
* constructor functions like `st_linestring()` check and break on `NA` coordinates; #1101
# version 0.7-6
* have examples of `st_write` write only to the temporary R session directory
# version 0.7-5
* `as(x, "Spatial")` now gives a proper error message on empty geometries; #1093
......
......@@ -101,8 +101,8 @@ CPL_get_layers <- function(datasource, options, do_count = FALSE) {
.Call('_sf_CPL_get_layers', PACKAGE = 'sf', datasource, options, do_count)
}
CPL_read_ogr <- function(datasource, layer, query, options, quiet, toTypeUser, fid_column_name, promote_to_multi = TRUE, int64_as_string = FALSE) {
.Call('_sf_CPL_read_ogr', PACKAGE = 'sf', datasource, layer, query, options, quiet, toTypeUser, fid_column_name, promote_to_multi, int64_as_string)
CPL_read_ogr <- function(datasource, layer, query, options, quiet, toTypeUser, fid_column_name, promote_to_multi = TRUE, int64_as_string = FALSE, dsn_exists = TRUE, dsn_isdb = FALSE) {
.Call('_sf_CPL_read_ogr', PACKAGE = 'sf', datasource, layer, query, options, quiet, toTypeUser, fid_column_name, promote_to_multi, int64_as_string, dsn_exists, dsn_isdb)
}
CPL_gdalinfo <- function(obj, options) {
......
......@@ -59,6 +59,12 @@ cbind.sf = function(..., deparse.level = 1, sf_column_name = NULL) {
#' @export
#' @details \code{st_bind_cols} is deprecated; use \code{cbind} instead.
st_bind_cols = function(...) {
.Deprecated("cbind") # nocov
cbind.sf(...) # nocov
# nocov start
.Deprecated("cbind",
msg = paste0("Use 'cbind' instead when all arguments",
" to be binded are of class sf.\n",
"If you need to cbind a data.frame to an sf,",
" use 'st_sf' or 'dplyr::bind_cols' (see the examples)."))
cbind.sf(...)
# nocov end
}
......@@ -170,7 +170,9 @@ st_geos_binop = function(op, x, y, par = 0.0, pattern = NA_character_,
#' st_distance(p, p)
#' st_distance(p, p, by_element = TRUE)
#' @export
st_distance = function(x, y, ..., dist_fun, by_element = FALSE, which = "Euclidean", par = 0.0, tolerance = 0.0) {
st_distance = function(x, y, ..., dist_fun, by_element = FALSE,
which = ifelse(isTRUE(st_is_longlat(x)), "Great Circle", "Euclidean"),
par = 0.0, tolerance = 0.0) {
if (missing(y))
y = x
else
......@@ -185,6 +187,8 @@ st_distance = function(x, y, ..., dist_fun, by_element = FALSE, which = "Euclide
if (isTRUE(st_is_longlat(x))) {
if (! requireNamespace("lwgeom", quietly = TRUE))
stop("lwgeom required: install first?")
if (which != "Great Circle")
stop("for non-great circle distances, data should be projected; see st_transform()")
units(tolerance) = as_units("m")
if (by_element) {
crs = st_crs(x)
......
......@@ -102,12 +102,15 @@ plot.sf <- function(x, y, ..., main, pal = NULL, nbreaks = 10, breaks = "pretty"
if (logz)
values = log10(values)
if (is.character(breaks)) { # compute breaks from values:
n.unq = length(unique(na.omit(values)))
v0 = na.omit(as.numeric(values))
n.unq = length(unique(v0))
breaks = if (! all(is.na(values)) && n.unq > 1)
classInt::classIntervals(na.omit(values), min(nbreaks, n.unq),
classInt::classIntervals(v0, min(nbreaks, n.unq),
breaks, warnSmallN = FALSE)$brks
else
range(values, na.rm = TRUE) # lowest and highest!
if (inherits(values, "POSIXct"))
breaks = as.POSIXct(breaks, origin = as.POSIXct("1970-01-01"))
nbreaks = length(breaks) - 1
}
}
......@@ -152,8 +155,8 @@ plot.sf <- function(x, y, ..., main, pal = NULL, nbreaks = 10, breaks = "pretty"
if (is.list(values))
stop("plotting list-columns not supported") # nocov
if (inherits(values, "POSIXt"))
values = as.numeric(values)
# if (inherits(values, "POSIXt"))
# values = as.numeric(values)
if (is.character(values))
values = as.factor(values)
......@@ -175,14 +178,18 @@ plot.sf <- function(x, y, ..., main, pal = NULL, nbreaks = 10, breaks = "pretty"
pal
colors[as.numeric(values)]
} else {
if (! inherits(values, "POSIXt"))
values = as.numeric(values) # drop units, if any
if (is.character(breaks)) { # compute breaks from values:
n.unq = length(unique(na.omit(values)))
v0 = na.omit(as.numeric(values))
n.unq = length(unique(v0))
breaks = if (! all(is.na(values)) && n.unq > 1)
classInt::classIntervals(na.omit(values), min(nbreaks, n.unq),
classInt::classIntervals(v0, min(nbreaks, n.unq),
breaks, warnSmallN = FALSE)$brks
else
range(values, na.rm = TRUE) # lowest and highest!
if (inherits(values, "POSIXt"))
breaks = as.POSIXct(breaks, origin = as.POSIXct("1970-01-01"))
}
# this is necessary if breaks were specified either as character or as numeric
# "pretty" takes nbreaks as advice only:
......@@ -534,7 +541,7 @@ plot.sfg = function(x, ...) {
#'
plot_sf = function(x, xlim = NULL, ylim = NULL, asp = NA, axes = FALSE, bgc = par("bg"), ...,
xaxs, yaxs, lab, setParUsrBB = FALSE, bgMap = NULL, expandBB = c(0,0,0,0), graticule = NA_crs_,
col_graticule = 'grey') {
col_graticule = 'grey', border) {
# sp's bbox: matrix
# min max
......@@ -795,9 +802,9 @@ bb2merc = function(x, cls = "ggmap") { # return bbox in the appropriate "web mer
c(offset,offset,0,0))
for(i in seq_along(poly)) {
if (key.pos %in% c(1,3))
polygon(poly[[i]], c(0, 0, 1, 1) + offs, col=col[i], border=NA)
polygon(poly[[i]], c(0, 0, 1, 1) + offs, col = col[i], border = NA)
if (key.pos %in% c(2,4))
polygon(c(0, 0, 1, 1) + offs, poly[[i]], col=col[i], border=NA)
polygon(c(0, 0, 1, 1) + offs, poly[[i]], col = col[i], border = NA)
}
# box() now would draw around [0,1]:
......@@ -809,6 +816,8 @@ bb2merc = function(x, cls = "ggmap") { # return bbox in the appropriate "web mer
labels = if (logz)
parse(text = paste0("10^", at))
else if (inherits(breaks, "POSIXt"))
format(at)
else
TRUE
......
......@@ -61,6 +61,9 @@ set_utf8 = function(x) {
#' without warnings. \code{promote_to_multi} is handled on a per-geometry column
#' basis; \code{type} may be specified for each geometry column.
#'
#' Note that stray files in data source directories (such as \code{*.dbf}) may
#' lead to spurious errors that accompanying \code{*.shp} are missing.
#'
#' In case of problems reading shapefiles from USB drives on OSX, please see
#' \url{https://github.com/r-spatial/sf/issues/252}.
#'
......@@ -79,6 +82,7 @@ set_utf8 = function(x) {
#' contain a single layer, an object of class \code{sf_layers} is returned
#' with the layer names, each with their geometry type(s). Note that the
#' number of layers may also be zero.
#' @seealso \link{st_layers}, \link{st_drivers}
#' @examples
#' nc = st_read(system.file("shape/nc.shp", package="sf"))
#' summary(nc) # note that AREA was computed using Euclidian area on lon/lat degrees
......@@ -194,20 +198,23 @@ st_read.character = function(dsn, layer, ..., query = NA, options = NULL, quiet
character(0)
else
enc2utf8(layer)
if (length(dsn) == 1 && file.exists(dsn))
if (nchar(dsn) < 1) {
stop("`dsn` must point to a source, not an empty string.", call. = FALSE)
}
dsn_exists = file.exists(dsn)
dsn_isdb = is_db_driver(dsn)
if (length(dsn) == 1 && dsn_exists && !dsn_isdb)
dsn = enc2utf8(normalizePath(dsn))
if (length(promote_to_multi) > 1)
stop("`promote_to_multi' should have length one, and applies to all geometry columns")
x = CPL_read_ogr(dsn, layer, query, as.character(options), quiet, type, fid_column_name,
promote_to_multi, int64_as_string)
promote_to_multi, int64_as_string, dsn_exists, dsn_isdb)
process_cpl_read_ogr(x, quiet, check_ring_dir = check_ring_dir,
stringsAsFactors = stringsAsFactors, geometry_column = geometry_column, ...)
}
#' @name st_read
#' @export
#' @details \code{read_sf} and \code{write_sf} are aliases for \code{st_read} and \code{st_write}, respectively, with some
......@@ -433,13 +440,17 @@ write_sf <- function(..., quiet = TRUE, delete_layer = TRUE) {
#' Get GDAL drivers
#'
#' Get a list of the available GDAL drivers
#' @param what character: "vector" or "raster", anything else will return all drivers.
#' @details The drivers available will depend on the installation of GDAL/OGR, and can vary; the \code{st_drivers()}
#' function shows which are available, and which may be written (but all are assumed to be readable). Note that stray
#' files in data source directories (such as *.dbf) may lead to spurious errors that accompanying *.shp are missing.
#' @return a \code{data.frame} with driver metadata
#' @details field \code{vsi} refers to the driver's capability to read/create datasets through the VSI*L API.
#' @param what character: `"vector"` or `"raster"`, anything else will return all
#' drivers.
#' @details The drivers available will depend on the installation of GDAL/OGR,
#' and can vary; the `st_drivers()` function shows all the drivers that are
#' readable, and which may be written. The field `vsi` refers to the driver's
#' capability to read/create datasets through the VSI*L API. [See GDAL website
#' for additional details on driver
#' support](https://gdal.org/drivers/vector/index.html).
#' @return A `data.frame` with driver metadata.
#' @export
#' @md
#' @examples
#' st_drivers()
st_drivers = function(what = "vector") {
......@@ -502,7 +513,7 @@ guess_driver = function(dsn) {
# find match: try extension first
drv = extension_map[tolower(tools::file_ext(dsn))]
if (any(grep(":", gsub(":[/\\]", "/", dsn))))
if (is_db_driver(dsn))
drv = prefix_map[tolower(strsplit(dsn, ":")[[1]][1])]
drv <- unlist(drv)
......@@ -514,6 +525,10 @@ guess_driver = function(dsn) {
drv
}
is_db_driver = function(dsn) {
any(grep(":", gsub(":[/\\]", "/", dsn)))
}
guess_driver_can_write = function(dns, drv = guess_driver(dns)) {
if(is.na(drv)) {
stop("Could not guess driver for ", dns, call. = FALSE)
......
......@@ -262,8 +262,14 @@ st_sf = function(..., agr = NA_agr_, row.names,
as.data.frame(x[-all_sfc_columns],
stringsAsFactors = stringsAsFactors, optional = TRUE))
if (check_ring_dir) { # process:
for (i in seq_along(all_sfc_names))
df[[ all_sfc_names[i] ]] = st_sfc(x[[ all_sfc_columns[i] ]], check_ring_dir = check_ring_dir)
df[[ all_sfc_names[i] ]] = st_sfc(x[[ all_sfc_columns[i] ]],
check_ring_dir = check_ring_dir)
} else { # copy:
for (i in seq_along(all_sfc_names))
df[[ all_sfc_names[i] ]] = x[[ all_sfc_columns[i] ]]
}
if (! missing(precision))
attr(df[[sfc_name]], "precision") = precision
......
......@@ -11,11 +11,12 @@ getClassDim = function(x, d, dim = "XYZ", type) {
else stop(paste(d, "is an illegal number of columns for a", type))
}
is_numeric_matrix = function(x)
stopifnot(is.numeric(x) && is.matrix(x))
valid_numeric_matrix = function(x) {
stopifnot(is.numeric(x), is.matrix(x), !anyNA(x))
}
Mtrx = function(x, dim = "XYZ", type) {
is_numeric_matrix(x)
valid_numeric_matrix(x)
structure(x, class = getClassDim(x, ncol(x), dim, type))
}
......@@ -26,7 +27,7 @@ MtrxSet = function(x, dim = "XYZ", type, needClosed = FALSE) {
nc = unique(vapply(x, ncol, 0L))
if (length(nc) != 1)
stop("matrices have unequal numbers of columns")
lapply(x, is_numeric_matrix)
lapply(x, valid_numeric_matrix)
NotClosed = function(y) any(y[1, ] != y[nrow(y), ])
if (needClosed && any(vapply(x, NotClosed, TRUE)))
stop("polygons not (all) closed")
......@@ -45,7 +46,7 @@ MtrxSetSet = function(x, dim = "XYZ", type, needClosed = FALSE) {
nc = unique(unlist(lapply(x, function(y) vapply(y, ncol, 0L))))
if (length(nc) != 1)
stop("matrices have unequal numbers of columns")
lapply(x, function(y) lapply(y, is_numeric_matrix))
lapply(x, function(y) lapply(y, valid_numeric_matrix))
NotClosed = function(y) any(y[1, ] != y[nrow(y), ])
if (needClosed && any(unlist(lapply(x, function(y) vapply(y, NotClosed, TRUE)))))
stop("polygons not (all) closed")
......
No preview for this file type
......@@ -4166,7 +4166,7 @@ GEOS_VERSION=`${GEOS_CONFIG} --version`
$as_echo "$as_me: GEOS: ${GEOS_VERSION}" >&6;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking GEOS version >= 3.4.0" >&5
$as_echo_n "checking GEOS version >= 3.4.0... " >&6; } # GDAL 2.0.1 requires GEOS 3.1.0
GEOS_VER_DOT=`echo $GEOS_VERSION | tr -d "."`
GEOS_VER_DOT=`echo $GEOS_VERSION | tr -d ".[:alpha:]"`
if test ${GEOS_VER_DOT} -lt 340 ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
......
......@@ -674,7 +674,7 @@ fi
GEOS_VERSION=`${GEOS_CONFIG} --version`
AC_MSG_NOTICE([GEOS: ${GEOS_VERSION}])
AC_MSG_CHECKING([GEOS version >= 3.4.0]) # GDAL 2.0.1 requires GEOS 3.1.0
GEOS_VER_DOT=`echo $GEOS_VERSION | tr -d "."`
GEOS_VER_DOT=`echo $GEOS_VERSION | tr -d ".[[:alpha:]]"`
if test ${GEOS_VER_DOT} -lt 340 ; then
AC_MSG_RESULT(no)
AC_MSG_ERROR([upgrade GEOS to 3.4.0 or later])
......
## ----echo=FALSE, include=FALSE-------------------------------------------
knitr::opts_chunk$set(collapse = TRUE)
mostly_off = Sys.getenv("USER") == "edzer"
## ------------------------------------------------------------------------
library(sf)
......@@ -68,42 +69,37 @@ plot(usa, graticule = g, key.pos = NULL, axes = TRUE,
## ------------------------------------------------------------------------
methods(st_as_grob)
## ---- eval=FALSE---------------------------------------------------------
# devtools::install_github("tidyverse/ggplot2")
## ------------------------------------------------------------------------
library(ggplot2)
if (utils::packageVersion("ggplot2") > "2.2.1")
ggplot() + geom_sf(data = usa)
ggplot() + geom_sf(data = usa)
## ------------------------------------------------------------------------
if (utils::packageVersion("ggplot2") > "2.2.1")
ggplot() + geom_sf(data = nc, aes(fill = BIR74)) + scale_y_continuous(breaks = 34:36)
ggplot() +
geom_sf(data = nc, aes(fill = BIR74)) +
scale_y_continuous(breaks = 34:36)
## ------------------------------------------------------------------------
library(dplyr)
library(tidyr)
nc2 <- nc %>% select(SID74, SID79, geom) %>% gather(VAR, SID, -geom)
if (utils::packageVersion("ggplot2") > "2.2.1")
ggplot() + geom_sf(data = nc2, aes(fill = SID)) + facet_wrap(~VAR, ncol = 1) +
ggplot() +
geom_sf(data = nc2, aes(fill = SID)) +
facet_wrap(~VAR, ncol = 1) +
scale_y_continuous(breaks = 34:36)
## ------------------------------------------------------------------------
## ----eval=mostly_off-----------------------------------------------------
library(mapview)
if (Sys.getenv("USER") %in% c("edzer", "travis"))
mapview(nc["BIR74"], col.regions = sf.colors(10))
mapview(nc["BIR74"], col.regions = sf.colors(10))
## ------------------------------------------------------------------------
library(tmap)
qtm(nc)
## ------------------------------------------------------------------------
## ----eval=mostly_off-----------------------------------------------------
tmap_mode("view")
if (Sys.getenv("USER") != "CRAN")
tm_shape(nc) + tm_fill("BIR74", palette = sf.colors(5))
tm_shape(nc) + tm_fill("BIR74", palette = sf.colors(5))
## ------------------------------------------------------------------------
## ----eval=mostly_off-----------------------------------------------------
ttm()
if (Sys.getenv("USER") != "CRAN")
last_map()
last_map()
......@@ -15,6 +15,7 @@ vignette: >
```{r echo=FALSE, include=FALSE}
knitr::opts_chunk$set(collapse = TRUE)
mostly_off = Sys.getenv("USER") == "edzer"
```
This vignette describes the functions in `sf` that can help to plot
simple features. It tries to be complete about the plot methods
......@@ -161,23 +162,18 @@ which convert simple simple feature objects into `grob` ("graphics objects") obj
## ggplot2
The `ggplot2` version to be released after 2.2.1 (on CRAN), which currently has to be installed by
```{r, eval=FALSE}
devtools::install_github("tidyverse/ggplot2")
```
contains a geom specially for simple feature objects, with support for graticule white lines in the background using `sf::st_graticule`. Support is currently good for polygons; for lines or points your milage may vary.
```{r}
library(ggplot2)
if (utils::packageVersion("ggplot2") > "2.2.1")
ggplot() + geom_sf(data = usa)
ggplot() + geom_sf(data = usa)
```
polygons can be colored using `aes`:
```{r}
if (utils::packageVersion("ggplot2") > "2.2.1")
ggplot() + geom_sf(data = nc, aes(fill = BIR74)) + scale_y_continuous(breaks = 34:36)
ggplot() +
geom_sf(data = nc, aes(fill = BIR74)) +
scale_y_continuous(breaks = 34:36)
```
and sets of maps can be plotted as facet plots after rearranging the `sf` object, e.g. by
......@@ -185,8 +181,9 @@ and sets of maps can be plotted as facet plots after rearranging the `sf` object
library(dplyr)
library(tidyr)
nc2 <- nc %>% select(SID74, SID79, geom) %>% gather(VAR, SID, -geom)
if (utils::packageVersion("ggplot2") > "2.2.1")
ggplot() + geom_sf(data = nc2, aes(fill = SID)) + facet_wrap(~VAR, ncol = 1) +
ggplot() +
geom_sf(data = nc2, aes(fill = SID)) +
facet_wrap(~VAR, ncol = 1) +
scale_y_continuous(breaks = 34:36)
```
......@@ -194,10 +191,9 @@ if (utils::packageVersion("ggplot2") > "2.2.1")
Package `mapview` creates interactive maps in html pages, using package `leaflet` as a work horse. Extensive examples are found [here](https://r-spatial.github.io/mapview/).
```{r}
```{r,eval=mostly_off}
library(mapview)
if (Sys.getenv("USER") %in% c("edzer", "travis"))
mapview(nc["BIR74"], col.regions = sf.colors(10))
mapview(nc["BIR74"], col.regions = sf.colors(10))
```
gives a map which is interactive: you can zoom and pan, and query features by clicking on them.
......@@ -212,16 +208,13 @@ qtm(nc)
```
`tmap` also has interactive leaflet maps:
```{r}
```{r,eval=mostly_off}
tmap_mode("view")
if (Sys.getenv("USER") != "CRAN")
tm_shape(nc) + tm_fill("BIR74", palette = sf.colors(5))
tm_shape(nc) + tm_fill("BIR74", palette = sf.colors(5))
```
replotting the last map in non-interactive mode is as simple as:
```{r}
```{r,eval=mostly_off}
ttm()
if (Sys.getenv("USER") != "CRAN")
last_map()
last_map()
```
......@@ -12,7 +12,8 @@ st_area(x, ...)
st_length(x)
st_distance(x, y, ..., dist_fun, by_element = FALSE,
which = "Euclidean", par = 0, tolerance = 0)
which = ifelse(isTRUE(st_is_longlat(x)), "Great Circle", "Euclidean"),
par = 0, tolerance = 0)
}
\arguments{
\item{x}{object of class \code{sf}, \code{sfc} or \code{sfg}}
......
......@@ -58,7 +58,7 @@ get_key_pos(x, ...)
plot_sf(x, xlim = NULL, ylim = NULL, asp = NA, axes = FALSE,
bgc = par("bg"), ..., xaxs, yaxs, lab, setParUsrBB = FALSE,
bgMap = NULL, expandBB = c(0, 0, 0, 0), graticule = NA_crs_,
col_graticule = "grey")
col_graticule = "grey", border)
sf.colors(n = 10, cutoff.tails = c(0.35, 0.2), alpha = 1,
categorical = FALSE)
......
......@@ -7,20 +7,20 @@
st_drivers(what = "vector")
}
\arguments{
\item{what}{character: "vector" or "raster", anything else will return all drivers.}
\item{what}{character: \code{"vector"} or \code{"raster"}, anything else will return all
drivers.}
}
\value{
a \code{data.frame} with driver metadata
A \code{data.frame} with driver metadata.
}
\description{
Get a list of the available GDAL drivers
}
\details{
The drivers available will depend on the installation of GDAL/OGR, and can vary; the \code{st_drivers()}
function shows which are available, and which may be written (but all are assumed to be readable). Note that stray
files in data source directories (such as *.dbf) may lead to spurious errors that accompanying *.shp are missing.
field \code{vsi} refers to the driver's capability to read/create datasets through the VSI*L API.
The drivers available will depend on the installation of GDAL/OGR,
and can vary; the \code{st_drivers()} function shows all the drivers that are
readable, and which may be written. The field \code{vsi} refers to the driver's
capability to read/create datasets through the VSI*L API. \href{https://gdal.org/drivers/vector/index.html}{See GDAL website for additional details on driver support}.
}
\examples{
st_drivers()
......
......@@ -107,6 +107,9 @@ other way around (type=3), secondary rings from MULTIPOLYGONS may be dropped
without warnings. \code{promote_to_multi} is handled on a per-geometry column
basis; \code{type} may be specified for each geometry column.
Note that stray files in data source directories (such as \code{*.dbf}) may
lead to spurious errors that accompanying \code{*.shp} are missing.
In case of problems reading shapefiles from USB drives on OSX, please see
\url{https://github.com/r-spatial/sf/issues/252}.
......@@ -182,3 +185,6 @@ if (exists("conn") && !inherits(conn, "try-error")) {
}
}
}
\seealso{
\link{st_layers}, \link{st_drivers}
}
......@@ -289,8 +289,8 @@ BEGIN_RCPP
END_RCPP
}
// CPL_read_ogr
Rcpp::List CPL_read_ogr(Rcpp::CharacterVector datasource, Rcpp::CharacterVector layer, Rcpp::CharacterVector query, Rcpp::CharacterVector options, bool quiet, Rcpp::NumericVector toTypeUser, Rcpp::CharacterVector fid_column_name, bool promote_to_multi, bool int64_as_string);
RcppExport SEXP _sf_CPL_read_ogr(SEXP datasourceSEXP, SEXP layerSEXP, SEXP querySEXP, SEXP optionsSEXP, SEXP quietSEXP, SEXP toTypeUserSEXP, SEXP fid_column_nameSEXP, SEXP promote_to_multiSEXP, SEXP int64_as_stringSEXP) {
Rcpp::List CPL_read_ogr(Rcpp::CharacterVector datasource, Rcpp::CharacterVector layer, Rcpp::CharacterVector query, Rcpp::CharacterVector options, bool quiet, Rcpp::NumericVector toTypeUser, Rcpp::CharacterVector fid_column_name, bool promote_to_multi, bool int64_as_string, bool dsn_exists, bool dsn_isdb);
RcppExport SEXP _sf_CPL_read_ogr(SEXP datasourceSEXP, SEXP layerSEXP, SEXP querySEXP, SEXP optionsSEXP, SEXP quietSEXP, SEXP toTypeUserSEXP, SEXP fid_column_nameSEXP, SEXP promote_to_multiSEXP, SEXP int64_as_stringSEXP, SEXP dsn_existsSEXP, SEXP dsn_isdbSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
......@@ -303,7 +303,9 @@ BEGIN_RCPP
Rcpp::traits::input_parameter< Rcpp::CharacterVector >::type fid_column_name(fid_column_nameSEXP);
Rcpp::traits::input_parameter< bool >::type promote_to_multi(promote_to_multiSEXP);
Rcpp::traits::input_parameter< bool >::type int64_as_string(int64_as_stringSEXP);
rcpp_result_gen = Rcpp::wrap(CPL_read_ogr(datasource, layer, query, options, quiet, toTypeUser, fid_column_name, promote_to_multi, int64_as_string));