Title: | Collect And Investigate Street Views For Urban Science |
---|---|
Description: | A collection of functions to search and download street view imagery ('Mapilary' <https://www.mapillary.com/developer/api-documentation>) and to extract, quantify, and visualize visual features. Moreover, there are functions provided to generate Qualtrics survey in TXT format using the collection of street views for various research purposes. |
Authors: | Xiaohao Yang [aut, cre, cph], Derek Van Berkel [aut], Mark Lindquist [aut] |
Maintainer: | Xiaohao Yang <[email protected]> |
License: | GPL-3 |
Version: | 1.0.3 |
Built: | 2024-11-27 05:12:41 UTC |
Source: | https://github.com/billbillbilly/streetscape |
available_field provides a list of available fields.
available_filter provides a list of available filters.
available_field() available_filter()
available_field() available_filter()
Field and Filter List
dataframe, including field names and their descriptions.
dataframe, including filter names and their descriptions.
More information about fields and filter at https://www.mapillary.com/developer/api-documentation
convert Mapillary object detection into sf polygons
decode_detections(detections_string)
decode_detections(detections_string)
detections_string |
character, an endcoded string of semantic segmentation, for example, "Gmt4AgoGbXB5L==" |
sf polygon
detection <- readLines(system.file('detection.txt', package = 'streetscape')) streetscape::decode_detections(detection)
detection <- readLines(system.file('detection.txt', package = 'streetscape')) streetscape::decode_detections(detection)
install_mvt is a wrapped function of py_install in the reticulate package for installing the python package mapbox_vector_tile, which will be installed in a virtual environment - "r-mvt".
install_mvt(envname = "r-mvt", method = "auto")
install_mvt(envname = "r-mvt", method = "auto")
envname |
The name, or full path, of the environment in which Python packages are to be installed. |
method |
character, indicating installation method. |
None
streetscape dataframe
data(scdataframe)
data(scdataframe)
An object of class "StreetscapeDataFrame"
; see see_streetscape_class()
.
data(scdataframe)
data(scdataframe)
A function to call out help page of StreetscapeDataFrame
see_streetscape_class()
see_streetscape_class()
see_streetscape_class
No return value, called for side effects
User can also directly use ?StreetscapeDataFrame
see_streetscape_class()
see_streetscape_class()
The output of strview_search family functions is constructed in this data format - A specialized data frame for streetscape package for initializing the object with streetscape data and extracting and decoding segmentation information of streetscape dataframe.
data
A data frame containing metadata of Mapillary street view images
epsg
A numeric epsg code
decodeDetection()
Regenerate a dataframe with decoded segmentation. 'detections' column will be updated and a new column 'segmentation' will be added.
download_data(path, items)
Download street view images (and segmentations in sf format if applicable)
get_mask(index)
Convert the semantic segmentation of a street view image from the StreetscapeDataFrame into sf polygons
gvi(level)
Calculate green view index (GVI) for each collected image by segmenting green pixels and quantifing the percentage in street view images. This method adds a new column of greeness percetage to the dataframe
mapPreview(maptype = "meta", fields = c())
Plot data points in an ineractive map view
decodeDetection()
scdataframe$decodeDetection()
gvi()
scdataframe$gvi(level = 1)
level
numeric, indicating the resolution level of images for calculating the green view index. 1 - the 256px wide thumbnail; 2 - the 1024px wide thumbnail; 3 - the 2048px wide thumbnail; 4 - the original wide thumbnail. The default is level = 1
get_mask()
scdataframe$get_mask(index = 1)
index
numeric, the row index of the dataframe of StreetscapeDataFrame class
mapPreview()
scdataframe$mapPreview(maptype = 'meta')
maptype
character or character, specifying what type of information to be mapped: 'meta' - image meta, 'seg' - segmentation proportion, and 'gvi' - GVI".
fields
vector (optional), a vector of fields indicates the information of images to be included for the 'meta' map. The fields of 'id', 'is_pano', 'height', 'width', 'lon', and 'lat' are already included
download_data()
scdataframe$download_data(path = 'path/to/download',
items = c('image', 'mask'))
path
character, directory for downloading street view images or segmentation masks or both
items
character or vector, specifying what to download: 'image' - 'original street view image; 'mask' - semantic segmentation (sf objects in .geojson format)"
"StreetscapeDataFrame"
"The output of strview_search family functions is constructed in this data format - A specialized data frame for streetscape package for initializing the object with streetscape data and extracting and decoding segmentation information of streetscape dataframe."
All reference classes extend and inherit methods from "envRefClass"
.
data
:Object of class data.frame
~~
epsg
:Object of class numeric
~~
download_data(path, items)
:~~
get_mask(index)
:~~
gvi()
:~~
decodeDetection()
:~~
mapPreview(maptype, fields)
:~~
initialize(data, epsg)
:~~
"Xiaohao Yang"
showClass("StreetscapeDataFrame")
showClass("StreetscapeDataFrame")
strview_searchByGeo: Search for and download the meta information of street view images via Mapillary API (See detials) based on coordinates of a spatial point with a given distance or a bounding box.
strview_search_nnb: Search for the nearest (within 10m buffer) available street view images and download meta information via Mapillary API (See detials) given coordinates of a spatial point.
strview_search_osm: Search for street view images by sampling locations along the OSM road lines and download meta information via Mapillary API (See detials) given a bounding box.
strview_search_multi: Search for and download the meta information of street view images via Mapillary API (See detials) based on multiple coordinates
strview_searchByGeo( x, y, r, epsg, bbox, token = "", limit = 10, fields = c(), ... ) strview_search_nnb(x, y, epsg, token = "", fields = c(), ...) strview_search_osm(bbox, epsg, token, fields = c(), size, ...) strview_search_multi(viewpoints, epsg, token, fields = c(), ...)
strview_searchByGeo( x, y, r, epsg, bbox, token = "", limit = 10, fields = c(), ... ) strview_search_nnb(x, y, epsg, token = "", fields = c(), ...) strview_search_osm(bbox, epsg, token, fields = c(), size, ...) strview_search_multi(viewpoints, epsg, token, fields = c(), ...)
x |
numeric, indicating Longtitude degree of the center point. |
y |
numeric, indicating latitude degree of the center point. |
r |
numeric, indicating search distance (meter or feet) for LiDAR data. |
epsg |
numeric, the EPSG code specifying the coordinate reference system. |
bbox |
vector, a bounding box defining the geographical area for downloading data. |
token |
character, API token of Mapillary. |
limit |
numeric, indicating the number of returns. The maximum is 2000. |
fields |
vector, a vector of fields indicates the information of images to be retrieved (See details). 'is_pano', 'thumb_256_url', 'height', 'width', 'computed_geometry', 'computed_altitude', and 'detections' are retrieved as a default setting. |
... |
indicating filters (see details) |
size |
numeric, (approximate) number of locations sampled on OSM spatial lines (this is for strview_search_osm only). |
viewpoints |
sf or matrix, indicating multiple degress-based coordinates for searching available street views (this is for strview_search_multi only). |
strview_search
To request an API token of Mapillary, please create your access token at https://mapillary.com/developer. For 'fields', one can review all available fields in this package by calling streetscape::field_list().
For strview_searchByGeo(), a StreetscapeDataFrame returned combining a dataframe of the image information.
For strview_search_nnb(), a StreetscapeDataFrame with one-row dataframe will be returned if there is any available images near to the given point
For strview_search_osm(), a StreetscapeDataFrame that combines the information of street views from all sampled points along the OSM lines within the specified bounding box.
For strview_search_multi(), a StreetscapeDataFrame that combines the information of street views based on the coordinates of multiple spatial points
If there is no street view images within the search area, the function only returns an integer 0.
available_field()
available_filter()
see_streetscape_class()
bbox <- c(-83.751812,42.272984,-83.741255,42.279716) if (isTRUE(file.exists("streetscape_token.sysdata"))) { data <- streetscape::strview_searchByGeo(bbox = bbox, epsg = 2253, token = "", is_pano = TRUE) data <- streetscape::strview_searchByGeo(x = -83.741289, y = 42.270146, r = 100, epsg = 2253, token = "", is_pano = TRUE) } if (isTRUE(file.exists("streetscape_token.sysdata"))) { data <- streetscape::strview_search_nnb( x = -83.743460634278, y = 42.277848830294, epsg = 2253, token = '') } bbox <- c(-83.752041,42.274896,-83.740711,42.281945) if (isTRUE(file.exists("streetscape_token.sysdata"))) { data <- streetscape::strview_search_osm( bbox = bbox, epsg = 2253, token = '', size = 100) } x <- c(-83.752041, -83.740711) y <- c(42.274896, 42.281945) viewpoints <- cbind(x, y) if (isTRUE(file.exists("streetscape_token.sysdata"))) { data <- streetscape::strview_search_multi( viewpoints = viewpoints, epsg = 2253, token = '') }
bbox <- c(-83.751812,42.272984,-83.741255,42.279716) if (isTRUE(file.exists("streetscape_token.sysdata"))) { data <- streetscape::strview_searchByGeo(bbox = bbox, epsg = 2253, token = "", is_pano = TRUE) data <- streetscape::strview_searchByGeo(x = -83.741289, y = 42.270146, r = 100, epsg = 2253, token = "", is_pano = TRUE) } if (isTRUE(file.exists("streetscape_token.sysdata"))) { data <- streetscape::strview_search_nnb( x = -83.743460634278, y = 42.277848830294, epsg = 2253, token = '') } bbox <- c(-83.752041,42.274896,-83.740711,42.281945) if (isTRUE(file.exists("streetscape_token.sysdata"))) { data <- streetscape::strview_search_osm( bbox = bbox, epsg = 2253, token = '', size = 100) } x <- c(-83.752041, -83.740711) y <- c(42.274896, 42.281945) viewpoints <- cbind(x, y) if (isTRUE(file.exists("streetscape_token.sysdata"))) { data <- streetscape::strview_search_multi( viewpoints = viewpoints, epsg = 2253, token = '') }
strview2rate: pack street views as a Qualtrics survey file that can be imported to Qualtrics platform
strview2pwc: pack street views as a Qualtrics survey file for pair-wised comparison
strview2rate(df, header, questions, choices, file) strview2pwc(df, k, header, questions, file)
strview2rate(df, header, questions, choices, file) strview2pwc(df, k, header, questions, file)
df |
StreetscapeDataFrame |
header |
character, indicating the task for a question. For example, "Please review the following picture:" |
questions |
vector, a list of questions (see details) |
choices |
list, a list of choices (see details) (this is only for strview2rate) |
file |
character, indicating the directory and file name (without extension) for saving the Qualtrics survey file |
k |
numeric, indicating how many street views each street view will be paired with for pair-wised comparison (this is only for strview2pwc) |
strview2qualtrics
For strview2rate(), the lengths of questions and choices must match. For example, when questions = c('1. To what existence you can feel pleasant if you were in this environment', '2. To what existence you can feel safe if you were in this environment'), choices could be list(c('Unpleasant', 'Less pleasant', 'More pleasant', 'Pleasant'), c('Unsafe', 'Less safe', 'Safer', 'Safe')) For strview2pwc, the choices are always c('left', 'right') for the coparison purposes.
character if argument 'file' is not specified
character if argument 'file' is not specified
data('scdataframe') header <- "Please review the following picture(s):" questions <- c('1. To what extent you feel pleasant if you were in this environment', '2. To what extent you feel safe if you were in this environment') choices <- list(c('Unpleasant','Less pleasant', 'Pleasant', 'More pleasant'), c('Unsafe', 'Less safe','Safe', 'Safer')) txt <- streetscape::strview2rate(scdataframe, header, questions, choices) data('scdataframe') header <- "Please review the following picture(s):" questions <- 'which one is more beautiful?' txt <- streetscape::strview2pwc(scdataframe, k=1, header, questions)
data('scdataframe') header <- "Please review the following picture(s):" questions <- c('1. To what extent you feel pleasant if you were in this environment', '2. To what extent you feel safe if you were in this environment') choices <- list(c('Unpleasant','Less pleasant', 'Pleasant', 'More pleasant'), c('Unsafe', 'Less safe','Safe', 'Safer')) txt <- streetscape::strview2rate(scdataframe, header, questions, choices) data('scdataframe') header <- "Please review the following picture(s):" questions <- 'which one is more beautiful?' txt <- streetscape::strview2pwc(scdataframe, k=1, header, questions)