How can I read an SBDF file from Spotfire that contains a well-known binary (WKB) object into TERR
book
Article ID: KB0080165
calendar_today
Updated On:
Products
Versions
Spotfire Enterprise Runtime for R
-
Description
Customer has an SBDF file from Spotfire that contains a well-known binary (WKB) object to create a map chart, wants to import it into TERR.
Environment
Product: TIBCO Enterprise Runtime for R
Version: All supported versions
OS: All supported Operating Systems
Resolution
There is a new package available on CRAN which contains this functionality. The wkb package contains a function named readWKB() which will convert well-known binary (WKB) geometry representations to Spatial objects (for example, a SpatialPolygon object).
To install the package in TERR, run:
install.packages("wkb")
at the command prompt.
You will then need to do the following in TERR to read this sbdf file and convert it to a SpatialPolygon:
# Load the package needed to read in the SBDF file library(SpotfireData)
# Load the wkb and sp packages needed to convert the imported object into a SpatialPolygon library(wkb) library(sp)
# Run the import code test.in <- importDataFromSBDF("<path_to_file>/usa_st.sbdf")
# Run the conversion function from wkb # You will only want to pass the binary portion of the data (i.e. Geometry) test.sp <- readWKB(test.in$Geometry)
# View the class of the object class(test.sp)
For example:
> class(test.sp)
[1] "SpatialPolygons"
The wkb package also contains functions which will allow you to write well-known binary objects.
Issue/Introduction
How can I read an SBDF file from Spotfire that contains a well-known binary (WKB) object into TERR.