I am trying to read a topoJSON file generated with geojsonio
package: https://raw.githubusercontent.com/pachamaltese/chilemaps/master/data-raw/r15_arica_y_parinacota.json
Here's a preview of the relevant part on first entry in that file:
{"type":"Topology", ... , "id":295,"properties":{"comuna":"Arica","id":295}} ...
To import I run:
r15 <- "https://raw.githubusercontent.com/pachamaltese/chilemaps/master/data-raw/r15_arica_y_parinacota.json"
r15 <- geojsonio::topojson_read(r15)
And then to convert back to topoJSON I run:
geojsonio::topojson_json(r15)
Which returns:
{"type":"Topology", ... , "id":0,"properties":{"id":"295","comuna":"Arica"}} ...
Being that id=0
wrong unless it's me, as it should be id=295
from the JSON I am reading.
How can I be sure that I am reading and writing to JSON in a correct way?
Thanks @sckott
Your example gave me a simple idea that solves this. Being my original intention to visualize a map, here's the fully reproducible example of what worked. I decided to create a new
id
column in the tibble that I will use with the topoJSON data: