get_tiles: A user-friendly way to get USGS National Map data tiles for...

Description Usage Arguments Value Available Datasources Additional Arguments See Also Examples

View source: R/get_tiles.R

Description

This function splits the area contained within a bounding box into a set of tiles, and retrieves data from the USGS National map for each tile.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
get_tiles(
  data,
  output_prefix = tempfile(),
  side_length = NULL,
  resolution = 1,
  services = "elevation",
  verbose = FALSE,
  georeference = TRUE,
  ...
)

## S3 method for class 'sf'
get_tiles(
  data,
  output_prefix = tempfile(),
  side_length = NULL,
  resolution = 1,
  services = "elevation",
  verbose = FALSE,
  georeference = TRUE,
  ...
)

## S3 method for class 'sfc'
get_tiles(
  data,
  output_prefix = tempfile(),
  side_length = NULL,
  resolution = 1,
  services = "elevation",
  verbose = FALSE,
  georeference = TRUE,
  ...
)

## S3 method for class 'Raster'
get_tiles(
  data,
  output_prefix = tempfile(),
  side_length = NULL,
  resolution = 1,
  services = "elevation",
  verbose = FALSE,
  georeference = TRUE,
  ...
)

## S3 method for class 'list'
get_tiles(
  data,
  output_prefix = tempfile(),
  side_length = NULL,
  resolution = 1,
  services = "elevation",
  verbose = FALSE,
  georeference = TRUE,
  ...
)

## S3 method for class 'terrainr_bounding_box'
get_tiles(
  data,
  output_prefix = tempfile(),
  side_length = NULL,
  resolution = 1,
  services = "elevation",
  verbose = FALSE,
  georeference = TRUE,
  ...
)

Arguments

data

An 'sf' or 'Raster' object; tiles will be downloaded for the full extent of the provided object.

output_prefix

The file prefix to use when saving tiles.

side_length

The length, in meters, of each side of tiles to download. If NULL, defaults to the maximum side length permitted by the least permissive service requested.

resolution

How many meters are represented by each pixel? The default value of 1 means that 1 pixel = 1 meter, while a value of 2 means that 1 pixel = 2 meters, and so on.

services

A character vector of services to download data from. Current options include "3DEPElevation", "USGSNAIPPlus", and "nhd". Users can also use short codes to download a specific type of data without specifying the source; current options for short codes include "elevation" (equivalent to "3DEPElevation"), "ortho" (equivalent to "USGSNAIPPlus), and "hydro" ("nhd"). Short codes are not guaranteed to refer to the same source across releases. Short codes are converted to their service name and then duplicates are removed, so any given source will only be queried once per tile.

verbose

Logical: should tile retrieval functions run in verbose mode?

georeference

Logical: should tiles be downloaded as PNGs without georeferencing, or should they be downloaded as georeferenced TIFF files? This option does nothing when only elevation data is being downloaded.

...

Additional arguments passed to [hit_national_map_api]. These can be used to change default query parameters or as additional options for the National Map services. See below for more details.

Value

A list of the same length as the number of unique services requested, containing named vectors of where data files were saved to. Returned invisibly.

Available Datasources

The following services are currently available (with short codes in parentheses where applicable). See links for API documentation.

* [3DEPElevation](https://elevation.nationalmap.gov/arcgis/rest/services/3DEPElevation/ImageServer) (short code: elevation) * [USGSNAIPPlus](https://services.nationalmap.gov/arcgis/rest/services/USGSNAIPPlus/MapServer) (short code: ortho) * [nhd](https://hydro.nationalmap.gov/arcgis/rest/services/nhd/MapServer) (short code: hydro) * [govunits](https://carto.nationalmap.gov/arcgis/rest/services/govunits/MapServer) * [contours](https://carto.nationalmap.gov/arcgis/rest/services/contours/MapServer) * [geonames](https://carto.nationalmap.gov/arcgis/rest/services/geonames/MapServer) * [NHDPlus_HR](https://hydro.nationalmap.gov/arcgis/rest/services/NHDPlus_HR/MapServer) * [structures](https://carto.nationalmap.gov/arcgis/rest/services/structures/MapServer) * [transportation](https://carto.nationalmap.gov/arcgis/rest/services/transportation/MapServer) * [wbd](https://hydro.nationalmap.gov/arcgis/rest/services/wbd/MapServer) ("short code": watersheds)

Additional Arguments

The '...' argument can be used to pass additional arguments to the National Map API or to edit the hard-coded defaults used by this function. More information on common arguments to change can be found in [hit_national_map_api]. Note that '...' can also be used to change the formats returned by the server, but that doing so while using this function will likely cause the function to error (or corrupt the output data). To download files in different formats, use [hit_national_map_api].

See Also

Other data retrieval functions: hit_national_map_api()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
simulated_data <- data.frame(
  id = seq(1, 100, 1),
  lat = runif(100, 44.04905, 44.17609),
  lng = runif(100, -74.01188, -73.83493)
)

simulated_data <- sf::st_as_sf(simulated_data, coords = c("lng", "lat"))

get_tiles(simulated_data, tempfile())

## End(Not run)

terrainr documentation built on Feb. 23, 2021, 9:06 a.m.