Description Usage Arguments Examples
Title
1 | tj_transform(x, sc = 1, tr = 0)
|
x |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | tx <- "{\"type\":\"Topology\",\"objects\":{\"collection\":{\"type\":\"GeometryCollection\",\"geometries\":[{\"type\":\"Polygon\",\"properties\":{\"a\":1},\"arcs\":[[0,1],[2]]},{\"type\":\"Polygon\",\"properties\":{\"a\":2},\"arcs\":[[-1,3]]}]}},\"arcs\":[[[6503,5999],[-894,-5999]],[[5609,0],[-5609,0],[0,9999],[6097,0],[2032,-2000],[-4064,-1000],[2438,-1000]],[[1626,2000],[2439,0],[0,2000],[-1626,1999],[-813,-1999],[0,-2000]],[[6503,5999],[2439,300],[1057,-3299],[-4390,-3000]]],\"transform\":{\"scale\":[0.00012301230123012302,0.00010001000100010001],\"translate\":[0,0]},\"bbox\":[0,0,1.23,1]}"
jsonlite::prettify(tx)
library(tibble)
library(dplyr)
## it is easiest to parse twice, once for the coords
## once for the objects, but better parsing will fix
#tj_coords <- jsonlite::fromJSON(tx, simplifyVector = TRUE, simplifyDataFrame = FALSE, simplifyMatrix = TRUE)
#tj_objects <- jsonlite::fromJSON(tx, simplifyVector = TRUE, simplifyDataFrame = FALSE, simplifyMatrix = FALSE)
obj <- rjson::fromJSON(tx)
v <- tj_coord(obj)
ns_obj <- tj_object(tx)
## convert to simple features
rapply(ns_obj, classes = "data.frame", f = function(x) inner_join(x, v))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.