Extracts the archive to a temporary directory and reads each KML layer with
sf::read_sf() after sf::st_layers(). Multiple KML files or multiple
layers yield one row per layer; layer_name is simplified when there is only
one layer in one file.
read_kmz(path, quiet = TRUE, by_bbox = NULL, ...)Path to a .kmz file.
Passed to sf::read_sf().
If NULL (default), every feature is read. Otherwise an
sf, sfc, bbox or named numeric vector (xmin, ymin, xmax,
ymax) whose bounding box limits the features read: only features that
intersect it are returned, filtered by GDAL at read time through the
wkt_filter argument of sf::st_read(). The bounding box is
reprojected to each layer's CRS; if it has no CRS, its coordinates are
assumed to be in the layer's CRS. If the layer has no CRS it can be
reprojected to (no .prj, or an undefined LOCAL_CS), the coordinates
are used as-is with a warning. Features with empty geometry are
dropped. Layers without a geometry column (e.g. a shapefile made of a
.dbf only, or an attribute table in a GeoPackage) cannot be filtered:
they are read in full with a warning. When set, nrows_aka_features
reports the number of features read, not the layer total. Cannot be
combined with wkt_filter in ....
Additional arguments passed to sf::read_sf().
A tibble with the same columns as read_gdb(). Here fpath is the
path to the original .kmz (not the temporary .kml), and file_type is
typically "kmz". Metadata columns still come from sf::st_layers() on the
extracted KML file used for reading.
Other geo-io:
clean_geo(),
read_gdb(),
read_geo(),
read_sf_zip()
# \donttest{
kmz <- system.file("extdata", "misc_example.kmz", package = "misc")
if (nzchar(kmz) && file.exists(kmz)) read_kmz(kmz)
#> # A tibble: 1 × 8
#> fpath file_type layer_name geometry_type nrows_aka_features ncols_aka_fields
#> <chr> <chr> <chr> <chr> <int> <int>
#> 1 /home/… kmz doc "" 1 12
#> # ℹ 2 more variables: crs_name <chr>, data <list>
# }