Altair mark_geo only renders if data is remote

Hello,

I’m trying to use the mark_geo() type chart with altair, for use in a streamlit app.

For my use-case, I actually need to generate my own local polygon data within the app, and use it to generate a map of different shapes on the chart. At the moment, altair seems like the only package that will let me make this kind of chart easily, such that it’s interactive.

The problem arises with streamlit specifically. If I generate the json data correctly and make the chart, streamlit displays an empty chart. Troubleshooting this issue, I found out that it may be related to whether the data is provided locally or defined from a URL.
Below is a minimal example, adapted from this stackoverflow solution:

import altair as alt
import streamlit as st

#simple polygon data, raw from github
url_geojson = 'https://raw.githubusercontent.com/mattijn/datasets/master/two_polygons.geo.json'
data_geojson_remote = alt.Data(url=url_geojson, format=alt.DataFormat(property='features',type='json'))

#chart object for remote data
ch_remote = alt.Chart(data_geojson_remote).mark_geoshape(
).encode(
    color="properties.name:N"
).project(
    type='identity', reflectY=True
)

#Same data, defined in python as a dict
var_geojson = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [[[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]]]
      },
      "properties": {"name": "abc"}
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [[[1, 0], [2, 0], [2, 1], [1, 1], [1, 0]]]
      },
      "properties": {"name": "def"}
    }
  ]
}


# inline geojson data object
data_geojson = alt.InlineData(values=var_geojson, format=alt.DataFormat(property='features',type='json')) 

# chart object using local data
ch_local = alt.Chart(data_geojson).mark_geoshape(
).encode(
    color="properties.name:N"
).project(
    type='identity', reflectY=True
)
st.write(ch_remote)
st.write(ch_local)

This is the result in streamlit

To me, it seems related to this github issue and this comment on a separate altair map chart issue.

One workaround I know is to host the json on github and point the app to the github URL, but that won’t work for me either - our streamlit apps are hosted on instanced VMs that are fully walled-off from the internet (I generated the example image from my local workstation). Plus, I need to generate the shape data within the app itself.

I can’t post to github due to my company firewall, but I wanted to ask here to see if somehow there is any workaround? Is this bug on the devs radar?

Thanks