Skip to content

Commit

Permalink
clarify dem= argument omit
Browse files Browse the repository at this point in the history
in README and Get Started.
#32
  • Loading branch information
temospena committed Aug 30, 2021
1 parent d903043 commit d9c40ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ we can calculate its gradient as a two step process, as follows.
**Step 1**: add elevations to each coordinate in the linestring (requires a [MapBox API](https://account.mapbox.com/access-tokens/) key):

```{r, eval=FALSE}
sf_linestring_xyz = elevation_add(sf_linestring)
sf_linestring_xyz = elevation_add(sf_linestring) # dem = NULL
#> Loading required namespace: ceramic
#> Preparing to download: 9 tiles at zoom = 18 from
#> https://api.mapbox.com/v4/mapbox.terrain-rgb/
Expand All @@ -117,6 +117,8 @@ sf_linestring_xyz = elevation_add(sf_linestring)
sf_linestring_xyz = lisbon_road_segment_xyz_mapbox
```

With the argument `dem = NULL`, the function downloads the necessary elevation information from Mapbox. You can use this argument with a local digital elevation model (`dem = ...`).

You can check the elevations added to the new `sf_linestring_xyz` object by printing its coordinates with `st_coordinates()`, or you can use the `z_` functions to extract such values, as follows:

```{r}
Expand Down Expand Up @@ -178,7 +180,7 @@ slope_raster(routes = sf_route,
dem = dem_lisbon_raster) #a raster dataset included in the package:
```
The result shows a 7.8% gradient *on average*.
As you can see, the retrieved result from elevation information available in mapbox and in this Digital Elevation Model, is quite similar. (See more about these differences in [Verification of slopes](https://itsleeds.github.io/slopes/articles/verification.html).)
As you can see, the retrieved result from elevation information available in Mapbox and in this Digital Elevation Model, is quite similar. (See more about these differences in [Verification of slopes](https://itsleeds.github.io/slopes/articles/verification.html).)

### Route with xyz coordinates

Expand Down Expand Up @@ -298,7 +300,7 @@ plot_slope(lisbon_route_xyz)

### Using `elevation_add()` with and without a `dem =` argument

If you do not have a raster dataset representing elevations, you can automatically download them by leaving the argument `dem = NULL` (a step that is automatically done in the function `elevation_add()` shown in the basic example above, results of the subsequent code chunk not shown):
If you do not have a raster dataset representing elevations, you can automatically download them by omitting the argument `dem = NULL` (a step that is automatically done in the function `elevation_add()` shown in the basic example above, results of the subsequent code chunk not shown):

```{r, message=FALSE, warning=FALSE, eval=FALSE}
dem_mapbox = elevation_get(lisbon_route)
Expand All @@ -320,7 +322,7 @@ lisbon_route_xyz_auto = lisbon_route_xyz_mapbox
plot_slope(lisbon_route_xyz_auto)
```

Note that the elevations shown in both plots differ, since the first is based on DEM elevation available, and the second is based in _mapbox_ elevation.
Note that the elevations shown in both plots differ, since the first is based on DEM elevation available, and the second is based in _Mapbox_ elevation.

## See more in vignettes

Expand Down
10 changes: 6 additions & 4 deletions vignettes/slopes.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ You can do this as a two step process as follows.
**Step 1**: add elevations to each coordinate in the linestring (requires a [MapBox API](https://account.mapbox.com/access-tokens/) key):

```{r, eval=FALSE}
sf_linestring_xyz = elevation_add(sf_linestring)
sf_linestring_xyz = elevation_add(sf_linestring) # dem = NULL
#> Loading required namespace: ceramic
#> Preparing to download: 9 tiles at zoom = 18 from
#> https://api.mapbox.com/v4/mapbox.terrain-rgb/
Expand All @@ -179,6 +179,8 @@ sf_linestring_xyz = elevation_add(sf_linestring)
sf_linestring_xyz = lisbon_road_segment_xyz_mapbox
```

With the argument `dem = NULL`, the function downloads the necessary elevation information from Mapbox. You can use this argument with a local digital elevation model (`dem = ...`).

You can check the elevations added to the new `sf_linestring_xyz` object by printing its coordinates, as follows (note the new Z column that goes from above 87 m above sea level to only 79 m in a short distance).

```{r}
Expand Down Expand Up @@ -253,7 +255,7 @@ slope_raster(routes = sf_route,
```

The result shows a 7.8% gradient *on average*.
As you can see, the retrieved result from elevation information available in mapbox and in this Digital Elevation Model, is quite similar. (See more about these differences in [Verification of slopes](https://itsleeds.github.io/slopes/articles/verification.html).)
As you can see, the retrieved result from elevation information available in Mapbox and in this Digital Elevation Model, is quite similar. (See more about these differences in [Verification of slopes](https://itsleeds.github.io/slopes/articles/verification.html).)

### Route with xyz coordinates

Expand Down Expand Up @@ -384,7 +386,7 @@ plot_slope(lisbon_route_xyz)

### Using `elevation_add()` with and without a `dem =` argument

If you do not have a raster dataset representing elevations, you can automatically download them by leaving the argument `dem = NULL` (a step that is automatically done in the function `elevation_add()` shown in the basic example above, results of the subsequent code chunk not shown):
If you do not have a raster dataset representing elevations, you can automatically download them by omitting the argument `dem = NULL` (a step that is automatically done in the function `elevation_add()` shown in the basic example above, results of the subsequent code chunk not shown):

```{r, message=FALSE, warning=FALSE, eval=FALSE}
dem_mapbox = elevation_get(lisbon_route)
Expand All @@ -405,7 +407,7 @@ lisbon_route_xyz_auto = lisbon_route_xyz_mapbox
plot_slope(lisbon_route_xyz_auto)
```

Note that the elevations shown in both plots differ, since the first is based on DEM elevation available, and the second is based in _mapbox_ elevation.
Note that the elevations shown in both plots differ, since the first is based on DEM elevation available, and the second is based in _Mapbox_ elevation.

## Commulative elevation change

Expand Down

0 comments on commit d9c40ca

Please sign in to comment.