question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add documentation how to load a local topojson file

See original GitHub issue

is this pseudo code supported

import pandas as pd
import altair as alt

counties = alt.topo_feature('https://raw.githubusercontent.com/djouallah/R_leaflet_MAP/master/foundation.json', 'id')

map =alt.Chart(counties).mark_geoshape().encode(
    color='id:Q'
                                                 )
map

all the documentation is using “data.world_110m.url”, how about local topojson or geojson files ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Deepakpratapcommented, Jun 2, 2019

@djouallah your problem literally solved my problem.I wanted to plot for the country India…It is sorted now

` import altair as alt

url = “https://raw.githubusercontent.com/deldersveld/topojson/master/countries/india/india-states.json

source = alt.topo_feature(url, “IND_adm1”)

alt.Chart(source).mark_geoshape().encode( tooltip=‘properties.NAME_1:N’ ) `

2reactions
mattijncommented, Aug 16, 2019

I know some of TopoJSON, as 'm working on a Python package regarding this extension of GeoJSON ( https://github.com/mattijn/topojson)*. Its work in progress. but potentially to be used as an interchange format between geographical packages in the Python ecosystem (eg. geopandas and altair).

Without explaining the format, you are dealing with nested objects. So in the alt.topo_feature(url, feature) you have to define the feature or layer that is present within the objects in your TopoJSON file.

This layer or feature (in your case named foundation) contains often multiple geometries, where each geometry refers to certain top-level stored geometric segments or so-called arcs. Next to the geometry, you have to store some attributes of that geometry, which is stored in another nested object properties.

So in order to access these attribute information you have to add properties to enter this nested object.

{
  "type": "Topology",
  "arcs": [[[641, 1092], [0, 116], [89, 0], [0, -116], [-89, 0]]],
  "objects": {
    "foundation": {
      "type": "GeometryCollection",
      "geometries": [
        {
          "arcs": [[0]],
          "type": "Polygon",
          "properties": {
            "id": 22,
            "width": 0.000558,
            "height": 0.000719,
            "area": 0,
            "perimeter": 0.002555,
            "type": "foundation"
          }
        }
      ]
    }
  }
}

Your issue have been discussed before on the Vega-repo: https://github.com/vega/vega/issues/1319 And more work has also been done in: https://iliatimofeev.github.io/gpdvega/

Read more comments on GitHub >

github_iconTop Results From Across the Web

topojson_read: Read topojson from a local file or a URL - Rdrr.io
In geojsonio: Convert Data from and to 'GeoJSON' or 'TopoJSON' · View source: R/topojson_read.R. topojson_read, R Documentation. Read topojson ...
Read more >
how add a topoJSON file to a Shape Map from an Azure Blob ...
Solved: The only choice seems to be the local file system.
Read more >
TopoJSON in Highcharts Maps
In order to use TopoJSON in Highcharts Maps, we must first decode it to GeoJSON. This is very simple using the TopoJSON Client...
Read more >
Minify TopoJSON in the browser / Lauren Nishizaki - Observable
This is an exploration of different TopoJSON file optimizations. ... The exact property set you leave in the file (or add) are up...
Read more >
geojsonio: Convert Data from and to 'GeoJSON' or 'TopoJSON'
service, and "local" means we use sf. ... The local option uses the function ... option does not document what file size is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found