
Get area 311 service requests from Open Baltimore
Source:R/get_area_requests.R
get_area_requests.Rd
Get 311 service requests for a specific area. Service requests from 2011 to 2024 are available but larger multi-year requests may time-out or take a long time to complete. Duplicate requests are removed from the returned data. Requests can be filtered by request type, responsible city agency, or both. You can return multiple types or agencies, by using a custom where query parameter or by calling each type/agency separately.
Usage
get_area_requests(
area = NULL,
year = 2025,
date_range = NULL,
request_type = NULL,
agency = NULL,
where = NULL,
dist = NULL,
diag_ratio = NULL,
unit = "m",
asp = NULL,
trim = FALSE,
geometry = TRUE,
crs = pkgconfig::get_config("mapbaltimore.crs", 2804),
duplicates = FALSE,
...
)
Arguments
- area
sf, sfc, or bbox object. If multiple areas are provided, they are unioned into a single sf object using
sf::st_union()
.- year
Year for service requests.
- date_range
Date range as character vector in format of c("YYYY-MM-DD", "YYYY-MM-DD"). Minimum and maximum values are used if length is greater than 1.
- request_type
Service request type.
- agency
City agency responsible for request. Options include "Transportation", "BGE", "Solid Waste", "Housing", "Water Wastewater", "Health", "Call Center", "Finance", "Liquor Board", "Recreation & Parks", "Fire Department", "Parking Authority", and "General Services"
- where
string for where condition. This parameter is ignored if a request_type or agency are provided.
- dist
buffer distance in units. Optional.
- diag_ratio
ratio of diagonal distance of area's bounding box used as buffer distance. e.g. if the diagonal distance is 3000 meters and the "diag_ratio = 0.1" a 300 meter will be used. Ignored when
dist
is provided.- unit
Units for buffer. Supported options include "meter", "foot", "kilometer", and "mile", "nautical mile" Common abbreviations (e.g. "km" instead of "kilometer") are also supported. Distance in units is converted to units matching GDAL units for x; defaults to "meter"
- asp
Aspect ratio of width to height as a numeric value (e.g. 0.33) or character (e.g. "1:3"). If numeric,
get_asp()
returns the same value without modification.- trim
If
TRUE
, x is trimmed to y withst_trim()
.- geometry
Default
TRUE.
IfFALSE
, return requests with missing latitude/longitude (for years prior to 2021 only).- crs
Cordinate reference system to return, Default: 4326 for
sf_to_df()
andNULL
fordf_to_sf()
.- duplicates
If
TRUE
, return 311 service requests marked as "Duplicate". IfFALSE
, filter duplicate requests out of results.- ...
Arguments passed on to
esri2sf::esri2sf
outFields
vector of fields you want to include. default is
NULL
for all fields.replaceDomainInfo
If
TRUE
, add domain information to the return data frame. DefaultFALSE
.
Examples
# Get boundary for Edmondson Village
area <- get_baltimore_area("neighborhood", "Edmondson Village")
# Get fallen limb requests for 2022
fallen_limbs <- get_area_requests(
area = area,
date_range = c("2022-11-01", "2022-11-15"),
request_type = "FOR-Fallen Limb"
)
#> Error in get_area_requests(area = area, date_range = c("2022-11-01", "2022-11-15"), request_type = "FOR-Fallen Limb"): 400
#> ℹ Invalid URL
#> Invalid URL
dplyr::glimpse(fallen_limbs)
#> Error: object 'fallen_limbs' not found
# Get dirty alley service requests for multiple years using purrr::map_dfr()
purrr::list_rbind(
purrr::map(
c(2021, 2020),
~ get_area_requests(
area = area,
year = .x,
request_type = "SW-Dirty Alley"
)
)
)
#> Error in purrr::map(c(2021, 2020), ~get_area_requests(area = area, year = .x, request_type = "SW-Dirty Alley")): ℹ In index: 1.
#> Caused by error in `get_area_requests()`:
#> ! 400
#> ℹ Invalid URL
#> Invalid URL