# How to make vegalite read my topojson file?

**URL:** <https://discourse.julialang.org/t/how-to-make-vegalite-read-my-topojson-file/34546>\
**Category:** General Usage\
**Tags:** first-steps, vegalite\
**Created:** [February 12, 2020, 10:06pm UTC](https://discourse.julialang.org/t/how-to-make-vegalite-read-my-topojson-file/34546 "2020-02-12T22:06:07Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [February 13, 2020, 1:16am UTC](https://discourse.julialang.org/t/how-to-make-vegalite-read-my-topojson-file/34546/6 "2020-02-13T01:16:55Z")

</div>

There are two different ways in which you can load data: 1) you can create a `Path` object from the [FilePaths.jl](https://github.com/rofinn/FilePaths.jl) package that points to your file and put that into your spec, or 2) you can pass the values themselves.

In the case of 1) you are not loading the values yourself, but you let vega/vega-lite load the data from disc, i.e. you just put a pointer to the file into the figure. In theory this is great, but in practice we have a problem that this doesn’t work for various display front-ends (it doesn’t work in VS Code, ElectronDisplay and the default browser viewer, not sure about Jupyter). It _does_ work if you save such a figure to disc with `save`.

In the case of 2) you need to load the data yourself into memory in Julia, and then pass the data itself to vega/vega-lite. This should always work.

In the case of 1) we don’t have to worry about different file formats, vega is going to figure it out.

In the case of 2) we need to differentiate a bit between tabular and other data. For tabular data anything that complies with the [TableTraits.jl](https://github.com/queryverse/TableTraits.jl) interface can be passed, which is pretty much everything, so that is easy. For non-tabular data, for example a topjson, you should ideally use [JSON.jl](https://github.com/JuliaIO/JSON.jl) to read the file content and pass it to [VegaLite.jl](https://github.com/queryverse/VegaLite.jl). The code might look like this:

```julia
data={
    values=JSON.parsefile(filename),
    format={
        typ=:topojson,
        feature=:disa_ONT_region
    }
}

```

Let me know if this works!

---

_[View the full topic](https://discourse.julialang.org/t/how-to-make-vegalite-read-my-topojson-file/34546)._
