https://github.com/elipousson/streetmixr
🛣️♻️ A R package for accessing the Streetmix API
https://github.com/elipousson/streetmixr
civic-tech r-package streetmix urban-planning
Last synced: 8 months ago
JSON representation
🛣️♻️ A R package for accessing the Streetmix API
- Host: GitHub
- URL: https://github.com/elipousson/streetmixr
- Owner: elipousson
- License: gpl-3.0
- Created: 2022-03-05T02:59:28.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-11T01:33:05.000Z (11 months ago)
- Last Synced: 2025-02-01T06:11:44.437Z (8 months ago)
- Topics: civic-tech, r-package, streetmix, urban-planning
- Language: R
- Homepage: https://elipousson.github.io/streetmixr/
- Size: 5.01 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE.md
Awesome Lists containing this project
README
---
output: github_document
editor_options:
markdown:
wrap: 72
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# streetmixr
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[](https://www.repostatus.org/#wip)The goal of streetmixr is to provide access to the Streetmix API. What
is Streetmix? [Streetmix](https://streetmix.net/) is a web-based
open-source tool that enables people to "design, remix, and share"
street designs. Users can "add bike paths, widen sidewalks or traffic
lanes" and learn how street design impacts communities.Streetmix uses [the Axios
library](https://docs.streetmix.net/contributing/code/reference/helpers)
to support the following end-points:- getStreet,
- deleteStreetImage
- getGalleryForUser
- getGalleryForAllStreets
- getSentimentSurveyStreet
- postSentimentSurveyVote
- putSentimentSurveyCommentThe get_streets function supports getStreet (using url or street_id),
getGalleryForUser (using user_id), and getGalleryForAllStreets (using
the count parameter).This package also provides an index of the [Streetmix
illustrations](https://github.com/streetmix/illustrations/) available
under a [CC-BY-SA
license](https://github.com/streetmix/illustrations/blob/main/LICENSE).
I also hope to develop some utility functions to support visualization
of street segment data and add them to this package in the future.Issues, pull requests, or feedback are all welcome.
Note that this package is an independent project by me, Eli Pousson, and
is not directly sponsored or supported by the Streetmix development
team. Please consider supporting the Streetmix project [on
OpenCollective](https://opencollective.com/streetmix) or by signing up
for the new [Streetmix+ subscription
service](https://docs.streetmix.net/user-guide/streetmix-plus/).## Installation
You can install the development version of streetmixr like so:
``` r
# pak::pkg_install("elipousson/streetmixr")
```## Example
```{r example, message=FALSE}
library(dplyr)
library(ggplot2)
library(streetmixr)
## basic example code
```The `get_street` function allows you to download data on a street using
a Streetmix url:```{r get_street}
# Get data on Streetmix street
street <-
get_street(
url = "https://streetmix.net/eli.pousson/6/harford-road-south-of-gorsuch-avenue-1950s",
return = "street"
)
```The segment data for a street can be analyzed or plotted, as this
example shows:```{r plot}
# Example showing plot based on segment width
street$segments %>%
group_by(type) %>%
summarise(
pct_width = sum(width) / street$width
) %>%
ggplot() +
geom_col(aes(x = type, y = pct_width)) +
scale_y_continuous(labels = scales::label_percent()) +
coord_flip() +
theme_minimal(base_size = 14)
```This data can also be combined with the illustration. This example uses
the [{ggsvg} package](https://github.com/coolbutuseless/ggsvg) to
display the illustrations in their approximate positions:```{r illustrations}
segments <- street$segments %>%
left_join(illustrations, by = c("type" = "name")) %>%
mutate(
position = cumsum(width)
)segments$url <- sapply(segments$url, function(x) {
paste(readLines(x), collapse = "\n")
})ggplot(data = segments) +
ggsvg::geom_point_svg(
mapping = aes(x = position, y = elevation / 4, svg = url), size = 18
) +
scale_y_continuous(
limits = c(-1, 4)
) +
labs(
title = street$location$label,
caption = "Illustrations courtesy Streetmix (CC-BY-SA-4.0)"
) +
theme_minimal()
```You can also get streets by user id or download a selection of recent
streets using the \`count\` parameter:```{r user_id}
get_street(user_id = "eli.pousson")$streets %>%
select(-c(creatorIp, data)) %>%
knitr::kable()
```