Skip to content

Commit

Permalink
Add README example (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
fnattino authored Dec 16, 2024
1 parent 8dbfdd9 commit 05399c7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,49 @@ Rscript -e 'devtools::install()'

## Example

This is a basic example which shows you how to solve a common problem:
Given the street network of the city of Bucharest (data source: [OpenStreetMap][osm])

``` r
library(rcoins)
## basic example code
streets <- bucharest$streets
```

<details>

<summary> Plot streets </summary>

``` r
plot(sf::st_geometry(streets),
col = sf::sf.colors(n = nrow(streets), categorical = TRUE),
lwd = 5, xlim = c(418500, 437500), ylim = c(4909800, 4931500))
```

</details>

<img src="./img/streets.png" alt="Bucharest streets" width="500"/>

Determine continuous lines in the network as:

``` r
continuous_streets <- stroke(streets)
```

<details>

<summary> Plot continuous streets </summary>

``` r
plot(continuous_streets,
col = sf::sf.colors(n = length(continuous_streets), categorical = TRUE),
lwd = 5, xlim = c(418500, 437500), ylim = c(4909800, 4931500))
```

</details>

<img src="./img/continuous-streets.png" alt="Bucharest continuous streets" width="500"/>

[osm]: https://www.openstreetmap.org/

## Development

When modifying the R source code, load the library as:
Expand Down
Binary file added img/continuous-streets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/streets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 05399c7

Please sign in to comment.