View source: R/extendr-wrappers.R
process_pbf | R Documentation |
Process a pbf from a raw vector or a list of raw vectors.
process_pbf(proto)
proto |
either a raw vector or a list of raw vectors containing a FeatureCollection pbf |
There are three types of PBF FeatureCollection responses that may be returned.
In the case the PBF is a FeatureResult
and use_sf = FALSE
, a data.frame
is returned with the spatial reference stored in the crs
attribute.
Otherwise an sf
object is returned.
The PBF can also return a count result, for example if the query parameter
returnCountOnly
is set to true
. In this case, a scalar integer vector
is returned.
In the case that the query parameter returnIdsOnly
is true
, a
data.frame
is returned containing the object IDs and the column name
set to the object ID field name in the feature service.
For count results, a scalar integer.
For object ID results a data.frame
with one column.
For pbfs that contain geometries, a list of 3 elements:
attributes
is a data.frame
of the fields of the FeatureCollection
geometry
is an sfc object without a computed bounding box or coordinate reference system set
sr
is a named list of the spatial reference of the feature collection
Important: Use post_process_pbf()
to convert to an sf
object with a computed bounding box and CRS.
count_fp <- system.file("count.pbf", package = "arcpbf")
oid_fp <- system.file("ids.pbf", package = "arcpbf")
tbl_fp <- system.file("small-table.pbf", package = "arcpbf")
fc_fp <- system.file("small-points.pbf", package = "arcpbf")
# count response
count_raw <- open_pbf(count_fp)
process_pbf(count_raw)
# object id response
oid_raw <- open_pbf(oid_fp)
head(process_pbf(oid_raw))
# table feature collection
tbl_raw <- open_pbf(tbl_fp)
process_pbf(tbl_raw)
# feature collection with geometry
fc_raw <- open_pbf(fc_fp)
process_pbf(fc_raw)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.