Retrieve a dataset by ID or search result with
tbod_get_dataset(). For a public ArcGIS layer URL, use
tbod_get_arcgis_layer(). These examples need internet
access and do not run during site builds.
Retrieve and filter records
library(tampaBayOpenData)
permits <- tbod_get_dataset(
"tampa-construction-permits",
where = "PROJECTSTATUS IS NOT NULL",
fields = c("RECORD_ID", "PROJECTSTATUS", "LASTUPDATE"),
limit = 100
)
head(permits)
tbod_provenance(permits)[c("matched_rows", "returned_rows", "complete", "integrity")]This returns up to 100 active permit-viewer rows.
LASTUPDATE is an update time, not an issue date.
Provenance gives matching and returned counts. complete
is TRUE only when all matches were returned.
where uses ArcGIS SQL; fields needs exact
source names. Inspect them with
tbod_dataset_info("tampa-construction-permits", refresh = TRUE)$fields.
See ?tbod_get_dataset for advanced query
filters.
Omit limit to retrieve all matches. Use
order_by for a repeatable order when supported. Shortcuts
include tbod_get_permits(),
tbod_get_development_cases(), and
tbod_get_capital_projects().
Retrieve a discovery row:
found <- tbod_search_datasets("housing", source = "live", portals = "city")
if (nrow(found)) {
housing <- tbod_get_dataset(found[1, ], limit = 100)
tbod_provenance(housing)[c("publisher", "item_id", "validation_status")]
}Or use a layer URL ending in /FeatureServer/<id>
or /MapServer/<id>:
yard_waste <- tbod_get_arcgis_layer(
"https://arcgis.tampagov.net/arcgis/rest/services/OpenData/SolidWaste/MapServer/4",
limit = 10
)
tbod_provenance(yard_waste)$validation_status # "not_checked"Direct URLs have not_checked status. Review their source
and reuse terms.
Check the live schema
tbod_schema() reads the saved schema;
refresh = TRUE reads the service. Compare them with
tbod_check_schema():
expected <- tbod_schema("tampa-construction-permits")
report <- tbod_check_schema("tampa-construction-permits")
report$status
report$issues[, c("category", "severity", "field", "expected", "actual")]The report lists affected fields, expected and actual definitions, and severity.
Compatible additions warn. Missing fields, type changes, and incompatible geometry, CRS, object-ID, or endpoint changes stop retrieval.
For a direct or newly discovered layer, save a baseline yourself:
# Replace this example address with a public ArcGIS layer URL.
url <- "https://example.org/arcgis/rest/services/Example/FeatureServer/0"
baseline <- tbod_schema(url, refresh = TRUE)
later <- tbod_check_schema(url, expected = baseline)Retrieval checks and timeouts
Retrieval checks counts and object IDs. Missing, repeated, or
unexpected records stop the request. Large bounded previews may check a
subset manifest; full manifests are limited to one million matches. Use
a narrower where filter for larger sources. See
?tbod_get_dataset for integrity options.
These checks cannot freeze attributes while a live service is being updated.
timeout limits each HTTP attempt.
total_timeout defaults to 120 seconds for retrieval, 90 for
discovery, and 60 for metadata. Use Inf to remove the
overall deadline. Parsing may finish after the deadline before an error
is reported.
Attempts default to 30 seconds, with a 10-second connection limit. Adjust connection timing or add a delay between requests:
options(tampaBayOpenData.connect_timeout = 15,
tampaBayOpenData.request_delay = 0.2)
# Restore defaults:
options(tampaBayOpenData.connect_timeout = NULL,
tampaBayOpenData.request_delay = NULL)Delays apply to every attempt, including retries, and count toward the overall timeout. Separate R processes are not coordinated.
Temporary failures and rate limits are retried; permanent errors stop immediately. Set the retry limit for this session:
options(tampaBayOpenData.max_retries = 2L)
# Restore the default later with:
options(tampaBayOpenData.max_retries = NULL)Retries use increasing delays. Retry-After takes
precedence up to 30 seconds; a longer server-requested wait stops the
operation.
To identify your application, set
options(tampaBayOpenData.user_agent = "my-project/1.0 (contact: me@example.org)").
Set it to NULL to restore the default.
Types and spatial results
Source column names and text are preserved. ArcGIS date-times usually
become UTC POSIXct; unknown-zone values remain milliseconds
with a warning. Date-only fields become Date. Other
date/time types retain source strings.
Install sf and request spatial = TRUE for
geometry. Use out_sr = 4326 for WGS 84, or omit it to keep
the native CRS.
projects <- tbod_get_dataset(
"tampa-development-cases", spatial = TRUE, out_sr = 4326
)
boundary <- tbod_get_dataset(
"tampa-city-boundary", fields = "OBJECTID", spatial = TRUE, out_sr = 4326
)
sf::st_crs(projects)$epsgBoth results are sf tables. The CRS check should print
4326.
Exclude empty case geometries before plotting:
mapped_projects <- projects[!sf::st_is_empty(projects), ]
plot(
sf::st_geometry(boundary),
col = "#EDF4F6", border = "#7898A5", lwd = 1.2,
axes = TRUE, graticule = TRUE, col_graticule = "#DCE7EB",
xlab = "Longitude", ylab = "Latitude",
main = "Active development cases in Tampa"
)
if (nrow(mapped_projects) > 0L) {
case_fill <- grDevices::adjustcolor("#E76F51", alpha.f = 0.7)
plot(sf::st_geometry(mapped_projects), add = TRUE, pch = 21,
bg = case_fill, col = "#9B4934", cex = 0.85)
graphics::legend(
"bottomleft", legend = "Development case location", pch = 21,
pt.bg = case_fill, col = "#9B4934", bg = "white",
box.col = "#DCE7EB", cex = 0.85
)
}Dots are active case features. They may overlap, and rows without geometry remain in the data but are absent from the map.
The shoreline-adjusted city outline is map context, not a legal survey. See coverage for source limits.
Resume a large download
tbod_download_dataset() saves RDS chunks without
collecting all pages in memory. Its ID manifest still has the
one-million-match limit. Use tbod_download_arcgis_layer()
for direct URLs.
saved <- tbod_download_dataset(
"tampa-construction-permits",
path = "~/tampaBayOpenData-downloads/permits",
fields = c("OBJECTID", "RECORD_ID", "LASTUPDATE"),
page_size = 500,
total_timeout = 600
)
saved$complete
first_chunk <- readRDS(saved$files[[1]])
tbod_provenance(first_chunk)saved$files lists chunk paths. Check that files exist
before reading one when your filter may match no records.
Repeat the same call to resume. Saved chunks, settings, schema, and
IDs are rechecked. Changed settings or membership require a new empty
directory. saved$complete describes the whole download;
individual chunks do not. Live records may change between sessions.
Downloads default to no overall deadline. Interrupted chunks can be
resumed. If R was terminated, confirm it has stopped before removing a
leftover empty .lock directory.
Troubleshooting common errors
- Unknown ID: Search the catalog and use an ID from the results.
- Timeout or rate limit: Try later, or increase the time budget.
-
Schema change: Inspect current fields and run
tbod_check_schema(). -
Missing or repeated records: Retry or narrow
where. - Cannot resume: Keep existing files and use a new empty directory.
See coverage for attribution and discovery for search limits.