Skip to content

Tile Creation Fails When Concat-ing Geoshape Charts #41

Description

@moss-xyz

I believe this issue will touch on a few problems across altair_tiles, as well as altair and vega-lite with regards to creating geographic maps - I'll link to the issues that I believe are linked together

The Issue

When CONCATenating (such as via the | or & operator) multiple geographic charts with different extents (i.e. showing different areas of the world) together, tile generation fails, as it is seemingly not able to resolve the extents of each plot individually.

Reproducible Example

Some patience here, please - it takes a few steps to arrive at the problem, and I'm not able to share any actual data with you so I've had to recreate it using data from altair.datasets

Set-Up

This code is just to load and prepare the data for our usage
import json
import requests

from altair.datasets import data
import altair as alt 
import altair_tiles as til
import topojson as tpj
import geopandas as gpd
import shapely as shp

# Loading data
response = requests.get(data.us_10m.url)
json_data = response.json()
# Converting to TopoJSON, and then to a GeoDataFrame
gdf = tpj.Topology(json_data, object_name="states").to_gdf().reset_index(drop=False)
gdf.crs = 4326

# Enforcing left-hand rule for geometries for plotting
gdf["geometry"] = shp.orient_polygons(gdf["geometry"], exterior_cw=True)

# A simple function to return an altair chart of the bbox 
def make_bbox(gdf): 
    bbox = shp.orient_polygons(gdf.geometry.buffer(1).union_all().envelope, exterior_cw=True)
    bbox_gdf = gpd.GeoDataFrame(data={"name":["bbox"]}, geometry=[bbox], crs=gdf.crs)

    bbox_chart = (
        alt.Chart(bbox_gdf)
        .mark_geoshape(filled=False, color="red")
    )

    return bbox_chart

Plotting a single geoshape

This works as expected, and is just to show that I know how to do this
# Create a GDF of just Texas (FIPS: 48)
texas_gdf = gdf.query("index == 48")

# Create the map
texas_map = (
    alt.Chart(texas_gdf)
    .mark_geoshape()
    .project('mercator')
    .properties(width=400, height=400)
)

# Create a red bounding box around the state
# Not entirely accurate! But helps understand where the bounds of the geometry are versus the plot
texas_bbox = make_bbox(texas_gdf)

# Layer the two together
texas = (texas_map + texas_bbox)

# Show the output
texas

This results in the following, which is what I expect:

Image

CONCATenating Geoshape Plots Together

Things start to go off the rails here: naively concatenating the charts together causes vega to seemingly try and share their extents together across plots

Expand code:
# Repeating the same process to make a Georgia plot

georgia_gdf = gdf.query("index == 13")

georgia_map = (
    alt.Chart(georgia_gdf)
    .mark_geoshape()
    .project('mercator')
    .properties(width=400, height=400)
)

georgia_bbox = make_bbox(georgia_gdf)

georgia = (georgia_map + georgia_bbox)

# Horizontally concatenating these two together

( texas | georgia )

This creates the following chart:

Image

Clearly this is not what I was intending! But I am not the first person to show up with this problem: it was highlighted in this issue in vega-lite, which mentioned that the workaround was to create a slightly different projection for each chart, and then concatenate them together.

Expand code:
texas_map_fix = (
    alt.Chart(texas_gdf)
    .mark_geoshape()
    .project('mercator', precision=48/1e6)
    .properties(width=400, height=400)
)

texas_fix = (texas_map_fix + texas_bbox)

georgia_map_fix = (
    alt.Chart(georgia_gdf)
    .mark_geoshape()
    .project('mercator', precision=13/1e6)
    .properties(width=400, height=400)
)

georgia_fix = (georgia_map_fix + georgia_bbox)

(texas_fix | georgia_fix)

While I think this workaround is pretty jank, it does work and create the "intended" chart:

Image

However, as far as I can tell this workaround does not work with altair_tiles!

The Tiles Issue

Generating the tiles for a single map is just as easy as the following:

texas_tiles = til.add_tiles(texas_fix)

And this does work!

Image

But it doesn't work when you're concatenating the charts together...

texas_tiles = til.add_tiles(texas_fix)

georgia_tiles = til.add_tiles(georgia_fix)

(texas_tiles | georgia_tiles)

This doesn't produce anything workable as far as I can tell...

Expand to see Vega output
{
  "$schema": "https://vega.github.io/schema/vega-lite/v6.1.0.json",
  "config": {"view": {"continuousHeight": 300, "continuousWidth": 300}},
  "datasets": {
    "data-24368b1215f0ab082bc5f142afd0decd": [
      {
        "geometry": {
          "coordinates": [
            [
              [
                [-97.30784538710489, 26.649693823761847],
                [-97.28630962254722, 26.59973854644592],
                [-97.25400597571071, 26.506810987567903],
                [-97.26477385798955, 26.513793983321744],
                [-97.3329704457555, 26.55998918600099],
                [-97.30784538710489, 26.59973854644592],
                [-97.3329704457555, 26.674940039179575],
                [-97.30784538710489, 26.649693823761847]
              ]
            ],
            [
              [
                [-97.30784538710489, 26.649693823761847],
                [-97.35809550440612, 26.72382100945645],
                [-97.37963126896379, 26.887115679392387],
                [-97.36886338668495, 26.896784442743854],
                [-97.30784538710489, 26.649693823761847]
              ]
            ],
            [
              [
                [-97.36886338668495, 26.896784442743854],
                [-97.39039915124262, 26.90860182017343],
                [-97.3724526807779, 27.24378561635772],
                [-97.36168479849906, 27.27816344160739],
                [-97.36168479849906, 27.364645158251093],
                [-97.24682738752483, 27.581655180139638],
                [-97.22170232887422, 27.576283644944375],
                [-97.34732762212728, 27.27816344160739],
                [-97.3724526807779, 27.158915360272594],
                [-97.36886338668495, 26.896784442743854]
              ]
            ],
            [
              [
                [-97.16786291748004, 27.724000862814055],
                [-97.08889844743526, 27.790070745715767],
                [-97.20016656431655, 27.614958698350257],
                [-97.16786291748004, 27.724000862814055]
              ]
            ],
            [
              [
                [-97.04582691831992, 27.84056317655122],
                [-97.03505903604108, 27.911467441128664],
                [-96.88071939004445, 28.071539189947444],
                [-96.85559433139383, 28.05972181251787],
                [-97.04582691831992, 27.84056317655122]
              ]
            ],
            [
              [
                [-96.5971651567018, 28.284789137199308],
                [-96.44282551070518, 28.33957879619097],
                [-96.84841574320795, 28.06509334771313],
                [-96.84123715502206, 28.089265256091807],
                [-96.83405856683616, 28.10913993631427],
                [-96.79457633181377, 28.185952889606504],
                [-96.7084332735831, 28.195621652957975],
                [-96.5971651567018, 28.284789137199308]
              ]
            ],
            [
              [
                [-95.12196528450147, 29.086222188332254],
                [-94.87430399208827, 29.289803372232647],
                [-94.72355364018459, 29.33223850027521],
                [-95.12196528450147, 29.086222188332254]
              ]
            ],
            [
              [
                [-94.90301834483184, 29.299472135584118],
                [-95.05735799082846, 29.200098734471787],
                [-95.15067963724503, 29.163572295144014],
                [-95.22605481319687, 29.012632156157178],
                [-95.12196528450147, 29.070644736265997],
                [-95.39475163556529, 28.865989245326553],
                [-95.50601975244658, 28.82516557784257],
                [-95.6603593984432, 28.74620401047223],
                [-95.78957398578922, 28.746741163991757],
                [-95.93673504359995, 28.696248733156303],
                [-95.96186010225057, 28.62534446857886],
                [-95.70702022165148, 28.727403637288816],
                [-95.868538455834, 28.63877330656701],
                [-96.0444138663883, 28.584520801094875],
                [-95.97621727862234, 28.65542506567232],
                [-96.16286057145548, 28.60546978835639],
                [-96.23105715922144, 28.63877330656701],
                [-96.1808070419202, 28.713974799300665],
                [-96.32437880563799, 28.64307053472322],
                [-96.39257539340394, 28.67476259237526],
                [-96.4284683343334, 28.70752895706635],
                [-96.43564692251928, 28.599561099641605],
                [-96.55050433349352, 28.64145907416464],
                [-96.57562939214414, 28.701083114832038],
                [-96.57204009805119, 28.705380342988246],
                [-96.57562939214414, 28.701083114832038],
                [-96.65459386218892, 28.72042064153498],
                [-96.65818315628186, 28.71988348801545],
                [-96.66177245037481, 28.72149494857403],
                [-96.65818315628186, 28.701083114832038],
                [-96.61870092125947, 28.57968641941914],
                [-96.5253792748429, 28.553903050481885],
                [-96.40693256977573, 28.45667826344766],
                [-96.64382597991009, 28.325075651163765],
                [-96.78380844953494, 28.447546653615717],
                [-96.85918362548678, 28.41102021428794],
                [-96.79098703772083, 28.31916696244898],
                [-96.79816562590672, 28.275657527367365],
                [-96.79816562590672, 28.270285992172102],
                [-96.79816562590672, 28.22516509653191],
                [-96.80893350818555, 28.220330714856175],
                [-96.84123715502206, 28.187564350165083],
                [-96.93455880143863, 28.12310592782195],
                [-97.01711256557635, 28.202604648711812],
                [-97.24323809343188, 28.062944733635028],
                [-97.16068432929416, 28.048441588607822],
                [-97.18580938794476, 27.974851556432746],
                [-97.18580938794476, 27.97001717475701],
                [-97.03864833013402, 28.118271546146214],
                [-97.0278804478552, 28.033401290061093],
                [-97.13555927064354, 27.90287298481625],
                [-97.13555927064354, 27.9039472918553],
                [-97.13555927064354, 27.90287298481625],
                [-97.14273785882942, 27.89427852850383],
                [-97.18580938794476, 27.824448570965437],
                [-97.34014903394139, 27.883535458113307],
                [-97.49089938584508, 27.840026023031694],
                [-97.37963126896379, 27.837340255434064],
                [-97.32938115166256, 27.71755502057974],
                [-97.25400597571071, 27.696606033318226],
                [-97.32579185756961, 27.56070619287812],
                [-97.40834562170734, 27.324358644286633],
                [-97.5088458563098, 27.274403366970706],
                [-97.47295291538035, 27.39794867646171],
                [-97.60934609091225, 27.285146437361227],
                [-97.72420350188649, 27.395800062383607],
                [-97.66318550230643, 27.286220744400282],
                [-97.76368573690888, 27.27977490216597],
                [-97.77804291328067, 27.28353497680265],
                [-97.76368573690888, 27.27977490216597],
                [-97.54473879723925, 27.229282471330514],
                [-97.42270279807913, 27.263123143060657],
                [-97.45141715082268, 27.115943078710504],
                [-97.48013150356624, 26.998843611453815],
                [-97.55550667951809, 26.974134549555615],
                [-97.56627456179692, 26.84092047671314],
                [-97.46936362128741, 26.75014153191323],
                [-97.4442385626368, 26.59973854644592],
                [-97.42629209217206, 26.514868290360795],
                [-97.42629209217206, 26.44127825818572],
                [-97.45141715082268, 26.410123354053205],
                [-97.39039915124262, 26.410123354053205],
                [-97.28630962254722, 26.097500005689014],
                [-97.21093444659537, 26.063122180439343],
                [-97.25400597571071, 25.968583161002748],
                [-97.15709503520121, 26.008869674967208],
                [-97.14632715292237, 25.95461716949507],
                [-97.27913103436133, 25.95193140189744],
                [-97.37604197487084, 25.905736199218193],
                [-97.3724526807779, 25.839129162796958],
                [-97.58422103226164, 25.9325938751945],
                [-97.64523903184171, 26.027132894631094],
                [-97.76368573690888, 26.025521434072516],
                [-97.8605966774184, 26.069568022673657],
                [-98.0687757348092, 26.04539611429498],
                [-98.25182973354939, 26.072790943790814],
                [-98.29490126266472, 26.120597607028635],
                [-98.58563408419326, 26.257571754507794],
                [-98.66459855423804, 26.235011306687696],
                [-98.8045810238629, 26.36822537953017],
                [-98.89790267027946, 26.352647927463913],
                [-98.9732778462313, 26.400991744221262],
                [-99.08454596311259, 26.396694516065054],
                [-99.17068902134326, 26.571806563430563],
                [-99.26759996185278, 26.843069090791246],
                [-99.44706466650003, 27.020866905754385],
                [-99.42552890194236, 27.172344198260745],
                [-99.45424325468592, 27.265271757138763],
                [-99.50449337198714, 27.33725032875526],
                [-99.47936831333652, 27.48872762126162],
                [-99.59422572431076, 27.639667760248457],
                [-99.72344031165677, 27.66276536158808],
                [-99.90290501630402, 27.863660777890843],
                [-99.93161936904758, 27.98129739866706],
                [-99.98186948634881, 27.988817547940425],
                [-100.08595901504421, 28.1467406826811],
                [-100.21158430829728, 28.196695959997026],
                [-100.294138072435, 28.277806141445467],
                [-100.39822760113042, 28.5850579546144],
                [-100.49872783573286, 28.658647986789475],
                [-100.50590642391876, 28.740295321757444],
                [-100.6530674817295, 28.942802198618786],
                [-100.67101395219422, 29.084610727773676],
                [-100.77510348088963, 29.17216675145643],
                [-100.79304995135435, 29.241996708994826],
                [-101.01558618511693, 29.373062167759194],
                [-101.05865771423227, 29.458469577363843],
                [-101.25606888934423, 29.520242232109347],
                [-101.25247959525129, 29.626598628975515],
                [-101.4534800644562, 29.788281838352873],
                [-101.53962312268688, 29.75927554829846],
                [-101.76215935644946, 29.781298842599032],
                [-102.117499471651, 29.79257906650908],
                [-102.18210676532401, 29.846831571981216],
                [-102.3256785290418, 29.878523629633257],
                [-102.38669652862187, 29.76088700885704],
                [-102.51591111596788, 29.783447456677138],
                [-102.67742935015039, 29.741012328634575],
                [-102.8856084075412, 29.348353105860994],
                [-102.8856084075412, 29.209767497823258],
                [-102.99687652442249, 29.178612593690744],
                [-103.15121617041912, 28.97234564219272],
                [-103.43118110966881, 29.045935674367797],
                [-103.56039569701483, 29.158200759948752],
                [-103.6465387552455, 29.1571264529097],
                [-103.79369981305625, 29.26294569625634],
                [-104.0305932231906, 29.316123894689426],
                [-104.16339710462957, 29.390788233903557],
                [-104.26030804513908, 29.513259236355506],
                [-104.33927251518386, 29.520242232109347],
                [-104.54386227848173, 29.684074055564807],
                [-104.56898733713234, 29.778613075001402],
                [-104.67666615992069, 29.910752840804825],
                [-104.70538051266423, 30.06437874738929],
                [-104.68743404219951, 30.179329600567876],
                [-104.76280921815136, 30.30287491005888],
                [-104.85972015866086, 30.38989378022211],
                [-104.8704880409397, 30.511290475635008],
                [-104.97816686372805, 30.628927096411225],
                [-105.2150602738624, 30.805650604335312],
                [-105.3981142726026, 30.849697192936453],
                [-105.3981142726026, 30.88890939986186],
                [-105.55963250678512, 30.990431415052292],
                [-105.60270403590046, 31.083896127449833],
                [-105.77499015236181, 31.16715492297638],
                [-105.86831179877838, 31.289625925428332],
                [-105.99752638612439, 31.387387865982085],
                [-106.20570544351519, 31.46473797279384],
                [-106.37799155997655, 31.730628964959262],
                [-106.52874191188023, 31.783807163392346],
                [-106.6471886169474, 31.898220863051407],
                [-106.61847426420385, 31.99974287824184],
                [-106.37799155997655, 32.00135433880042],
                [-105.99752638612439, 32.00242864583947],
                [-104.91714886414799, 31.99974287824184],
                [-104.84895227638204, 31.99974287824184],
                [-104.02341463500471, 31.99974287824184],
                [-103.98034310588938, 31.99974287824184],
                [-103.72191393119735, 31.99974287824184],
                [-103.32709158097342, 31.99974287824184],
                [-103.06507311218844, 31.99974287824184],
                [-103.06507311218844, 32.0872989019246],
                [-103.06507311218844, 32.52239325274074],
                [-103.06507311218844, 32.95909906411546],
                [-103.05789452400255, 33.38774757269729],
                [-103.0543052299096, 33.57037976933617],
                [-103.04712664172372, 33.824990537591546],
                [-103.04353734763077, 34.30198286293072],
                [-103.04353734763077, 34.312725933321246],
                [-103.04353734763077, 34.746745977098335],
                [-103.04353734763077, 34.95408723563541],
                [-103.04353734763077, 35.18291463495353],
                [-103.03994805353783, 35.62176906040636],
                [-103.03994805353783, 35.739405681182575],
                [-103.03994805353783, 36.05525195066392],
                [-103.04353734763077, 36.50001506483154],
                [-103.00405511260838, 36.50001506483154],
                [-102.16416029485929, 36.50001506483154],
                [-102.03135641342033, 36.50001506483154],
                [-101.6221768868246, 36.49947791131201],
                [-101.08378277288288, 36.49947791131201],
                [-100.9581574796298, 36.49947791131201],
                [-100.54538865894115, 36.49947791131201],
                [-100.00340525090648, 36.49947791131201],
                [-99.99981595681353, 36.05525195066392],
                [-99.99981595681353, 35.880677056817945],
                [-99.99981595681353, 35.6185461392892],
                [-99.99981595681353, 35.42248510466217],
                [-99.99981595681353, 35.18291463495353],
                [-99.99981595681353, 35.03143734244717],
                [-99.99981595681353, 34.74620882357881],
                [-99.99622666272059, 34.56035370582278],
                [-99.99622666272059, 34.56035370582278],
                [-99.92803007495463, 34.57646831140856],
                [-99.84188701672396, 34.50610120035064],
                [-99.69472595891322, 34.37825866270343],
                [-99.57627925384604, 34.41800802314836],
                [-99.47577901924359, 34.39598472884779],
                [-99.47577901924359, 34.39544757532826],
                [-99.40399313738469, 34.373424281027695],
                [-99.37527878464113, 34.458831690632344],
                [-99.21017125636567, 34.33689784169992],
                [-99.19222478590093, 34.214963992767494],
                [-98.95174208167363, 34.21227822516986],
                [-98.75792020065461, 34.12418504796758],
                [-98.61075914284388, 34.15641425913915],
                [-98.48154455549786, 34.06187523970255],
                [-98.42411585001074, 34.08282422696407],
                [-98.36309785043068, 34.15641425913915],
                [-98.16927596941166, 34.114516284616116],
                [-98.13697232257515, 34.142985421150996],
                [-98.08313291118098, 34.00225119903516],
                [-97.94673973564907, 33.984525132890795],
                [-97.97904338248557, 33.8899861134542],
                [-97.86777526560428, 33.849162445970215],
                [-97.68831056095705, 33.9866737469689],
                [-97.56268526770397, 33.9001920303252],
                [-97.48372079765919, 33.915769482391454],
                [-97.45500644491563, 33.83089922630633],
                [-97.3724526807779, 33.81961900239628],
                [-97.20734515250243, 33.9146951753524],
                [-97.19298797613065, 33.759457808209355],
                [-97.08530915334231, 33.746566123740735],
                [-97.08889844743526, 33.839493682618745],
                [-97.0207018596693, 33.84593952485306],
                [-96.94532668371745, 33.948535847082546],
                [-96.93455880143863, 33.954444535797336],
                [-96.86995150776562, 33.855071134685005],
                [-96.7730405672561, 33.834122147423486],
                [-96.65459386218892, 33.91308371479382],
                [-96.58998656851591, 33.894820495129935],
                [-96.62946880353832, 33.84432806429448],
                [-96.37821821703217, 33.725617136479215],
                [-96.20234280647787, 33.75140050541647],
                [-96.08389610141069, 33.85023675300927],
                [-95.84700269127633, 33.839493682618745],
                [-95.76085963304565, 33.87333435434889],
                [-95.56344845793369, 33.93242124149676],
                [-95.55268057565485, 33.88891180641515],
                [-95.31219787142754, 33.87816873602463],
                [-95.21887622501099, 33.96250183859023],
                [-95.15785822543091, 33.93671846965297],
                [-95.05017940264257, 33.86366559099742],
                [-94.96762563850484, 33.860442669880264],
                [-94.86353610980944, 33.744954663182156],
                [-94.74508940474226, 33.70305668865912],
                [-94.48666023005023, 33.63806111279646],
                [-94.38615999544777, 33.54352209335986],
                [-94.23540964354409, 33.58971729603911],
                [-94.04517705661802, 33.55157939615275],
                [-94.04158776252507, 33.27118525896013],
                [-94.04158776252507, 33.01872310478286],
                [-94.04158776252507, 32.88067465026465],
                [-94.04158776252507, 32.692670918430515],
                [-94.04158776252507, 32.3918649474959],
                [-94.04158776252507, 32.19580391286887],
                [-94.01646270387445, 31.979868198019375],
                [-93.88006952834255, 31.84396835757927],
                [-93.79392647011187, 31.701622674904854],
                [-93.83340870513426, 31.585597514687215],
                [-93.67189047095175, 31.3959823222945],
                [-93.68624764732353, 31.301980456377432],
                [-93.61446176546463, 31.261693942412975],
                [-93.60010458909285, 31.176286532808323],
                [-93.55344376588457, 31.184880989120742],
                [-93.56421164816341, 31.09678781191846],
                [-93.50678294267628, 31.029643621977698],
                [-93.57139023634929, 31.009768941755233],
                [-93.55703305997751, 30.869034719639394],
                [-93.67906905913763, 30.592937810602976],
                [-93.7400870587177, 30.540833919208943],
                [-93.69701552960237, 30.43770044345993],
                [-93.7400870587177, 30.401711157651683],
                [-93.76880141146125, 30.329732586035185],
                [-93.7077834118812, 30.244325176430536],
                [-93.72214058825297, 30.051487062920664],
                [-93.85494446969193, 29.865094791645106],
                [-93.92673035155083, 29.81460236080965],
                [-93.84058729332016, 29.6921313583577],
                [-94.04517705661802, 29.673868138693813],
                [-94.35385634861127, 29.56106589959333],
                [-94.371802819076, 29.554620057359017],
                [-94.77739305157877, 29.37628508887635],
                [-94.68048211106925, 29.47136126183247],
                [-94.46871375958551, 29.557305824956646],
                [-94.54408893553735, 29.571808969983852],
                [-94.7558572870211, 29.524539460265554],
                [-94.69483928744103, 29.745309556790783],
                [-94.80610740432232, 29.76249846941562],
                [-94.87071469799533, 29.676553906291442],
                [-94.92814340348245, 29.681388287967177],
                [-95.1004295199438, 29.785058917235716],
                [-94.98198281487662, 29.677628213330493],
                [-95.01787575580607, 29.548174215124703],
                [-94.91019693301773, 29.496607477250198],
                [-94.90301834483184, 29.299472135584118]
              ]
            ]
          ],
          "type": "MultiPolygon"
        },
        "index": 48,
        "type": "Feature"
      }
    ],
    "data-82511bf0a52f29caa5d20ab7ec476bfe": [
      {
        "geometry": {
          "coordinates": [
            [
              [-107.64701827791579, 24.839494100764476],
              [-107.64701827791579, 37.50001506483154],
              [-92.50688939217761, 37.50001506483154],
              [-92.50688939217761, 24.839494100764476],
              [-107.64701827791579, 24.839494100764476]
            ]
          ],
          "type": "Polygon"
        },
        "name": "bbox",
        "type": "Feature"
      }
    ],
    "data-a832308bd903ce839bde0bdc87d25aa0": [
      {
        "geometry": {
          "coordinates": [
            [
              [
                [-81.47905843721807, 30.797056148022897],
                [-81.51136208405457, 30.884075018186124],
                [-81.40727255535917, 30.977539730583665],
                [-81.40368326126622, 30.907172619525745],
                [-81.47905843721807, 30.797056148022897]
              ]
            ],
            [
              [
                [-81.33189737940732, 31.306814838053167],
                [-81.32471879122144, 31.30788914509222],
                [-81.26370079164137, 31.25793386777629],
                [-81.39650467308033, 31.13277709772671],
                [-81.43239761400979, 31.20153274822605],
                [-81.38214749670855, 31.31379783380701],
                [-81.33189737940732, 31.306814838053167]
              ]
            ],
            [
              [
                [-81.27805796801316, 31.378793409669665],
                [-81.32830808531438, 31.47709250374294],
                [-81.1775577334107, 31.520601938824555],
                [-81.27805796801316, 31.378793409669665]
              ]
            ],
            [
              [
                [-81.18832561568954, 31.647907322952243],
                [-81.18832561568954, 31.64951878351082],
                [-81.13448620429536, 31.68711952987765],
                [-81.17396843931775, 31.55605407111328],
                [-81.18832561568954, 31.647907322952243]
              ]
            ],
            [
              [
                [-81.1380754983883, 31.720960201607795],
                [-81.14166479248125, 31.848802739255007],
                [-81.03757526378585, 31.819796449200595],
                [-81.1380754983883, 31.720960201607795]
              ]
            ],
            [
              [
                [-80.98373585239167, 32.06044122594829],
                [-80.97655726420578, 32.05721830483113],
                [-80.97655726420578, 32.05668115131161],
                [-80.962200087834, 32.0400293922063],
                [-81.0016823228564, 31.955159136121175],
                [-81.04475385197173, 32.03465785701104],
                [-80.98373585239167, 32.06044122594829]
              ]
            ],
            [
              [
                [-81.22421855661898, 31.734389039595946],
                [-81.19909349796836, 31.682285148201913],
                [-81.35343314396499, 31.654353165186556],
                [-81.19909349796836, 31.6038607343511],
                [-81.27446867392021, 31.558202685191382],
                [-81.32830808531438, 31.461515051676685],
                [-81.30318302666377, 31.322392290119424],
                [-81.47187984903218, 31.347101352017624],
                [-81.47546914312512, 31.339044049224732],
                [-81.47546914312512, 31.336358281627103],
                [-81.47187984903218, 31.347101352017624],
                [-81.44316549628861, 31.33528397458805],
                [-81.44675479038156, 31.328838132353738],
                [-81.43598690810273, 31.330449592912316],
                [-81.38932608489445, 31.28318008319402],
                [-81.44675479038156, 31.165006308898278],
                [-81.43239761400979, 31.083896127449833],
                [-81.42880831991684, 31.070467289461682],
                [-81.5544336131699, 31.080136052813153],
                [-81.47546914312512, 31.024809240301963],
                [-81.44316549628861, 30.94638482645115],
                [-81.51495137814752, 30.89159516745949],
                [-81.50059420177574, 30.728300497523552],
                [-81.60468373047114, 30.71916888769161],
                [-81.60827302456408, 30.71755742713303],
                [-81.9061844342785, 30.82821105215541],
                [-82.02463113934569, 30.78792453819095],
                [-82.0497561979963, 30.653636158309425],
                [-82.00668466888096, 30.56339436702904],
                [-82.0497561979963, 30.362498950726277],
                [-82.20409584399293, 30.397951083015],
                [-82.21486372627176, 30.568228748704776],
                [-82.41945348956962, 30.581657586692927],
                [-82.45893572459201, 30.584343354290557],
                [-82.58456101784508, 30.591326350044397],
                [-82.68865054654049, 30.59777219227871],
                [-83.13731230815858, 30.62409271473549],
                [-83.30959842461995, 30.63376147808696],
                [-83.34190207145645, 30.63644724568459],
                [-83.35625924782822, 30.63752155272364],
                [-83.61109912842731, 30.651487544231323],
                [-83.74390300986627, 30.65847053998516],
                [-84.00592147865125, 30.67189937797331],
                [-84.08488594869603, 30.675659452609995],
                [-84.282297123808, 30.68479106244194],
                [-84.37920806431751, 30.689625444117674],
                [-84.86376276686507, 30.711648738418244],
                [-85.00374523648992, 31.000100178403763],
                [-85.02887029514054, 31.075301671137417],
                [-85.10065617699942, 31.162320541300645],
                [-85.08629900062765, 31.308426298611746],
                [-85.04681676560526, 31.516841864187874],
                [-85.05758464788408, 31.622661107534515],
                [-85.12578123565004, 31.762321022611303],
                [-85.14013841202183, 31.78058424227519],
                [-85.13295982383593, 31.892849327856148],
                [-85.06835253016293, 31.991148421929424],
                [-85.05758464788408, 32.06312699354592],
                [-85.06117394197703, 32.13349410460384],
                [-84.92478076644512, 32.23018173811854],
                [-84.88888782551568, 32.264022409848685],
                [-85.00733453058287, 32.32794367867229],
                [-84.97144158965341, 32.37736180246869],
                [-85.00015594239697, 32.51003872179164],
                [-85.07912041244175, 32.60780066234539],
                [-85.13654911792888, 32.74638627038313],
                [-85.18320994113716, 32.86993157987413],
                [-85.23346005843838, 33.107890589024194],
                [-85.23704935253133, 33.12937672980524],
                [-85.29447805801846, 33.428034086661754],
                [-85.30524594029728, 33.48282374565341],
                [-85.3375495871338, 33.65256425782366],
                [-85.38779970443501, 33.90180349088378],
                [-85.39856758671385, 33.964113299148806],
                [-85.42010335127152, 34.08067561288597],
                [-85.46317488038686, 34.28586825734494],
                [-85.51342499768809, 34.52436442001453],
                [-85.52778217405987, 34.588285688838134],
                [-85.53496076224576, 34.623200667607335],
                [-85.58162158545404, 34.86008536971835],
                [-85.60674664410465, 34.9847049862484],
                [-85.47394276266569, 34.983093525689824],
                [-85.36626393987734, 34.98363067920935],
                [-85.26576370527489, 34.98524213976793],
                [-84.9786201778393, 34.98739075384603],
                [-84.81351264956383, 34.98739075384603],
                [-84.77761970863439, 34.98792790736556],
                [-84.61969076854481, 34.98846506088508],
                [-84.3217793588304, 34.98846506088508],
                [-84.13154677190431, 34.98739075384603],
                [-84.00592147865125, 34.98739075384603],
                [-83.93772489088529, 34.98739075384603],
                [-83.55008112884725, 34.992762289041295],
                [-83.4818845410813, 34.992762289041295],
                [-83.10859795541504, 35.00081959183419],
                [-83.11218724950798, 34.93797263004963],
                [-83.241401836854, 34.87888574290176],
                [-83.35266995373529, 34.71559107296582],
                [-83.3383127773635, 34.68712193643094],
                [-83.34190207145645, 34.68443616883331],
                [-83.10500866132209, 34.53671895096363],
                [-83.05116924992791, 34.493209515882015],
                [-82.99015125034785, 34.481929291971966],
                [-82.86452595709478, 34.457220230073766],
                [-82.77479360477116, 34.289091178462094],
                [-82.74248995793465, 34.20851815053318],
                [-82.59532890012392, 34.01406857646473],
                [-82.56661454738035, 33.95713030339496],
                [-82.5630252532874, 33.95551884283638],
                [-82.30100678450243, 33.80243008977145],
                [-82.23281019673648, 33.69338792530765],
                [-82.11436349166931, 33.59670029179295],
                [-82.02822043343863, 33.544596400398916],
                [-82.01386325706684, 33.53170471593029],
                [-81.92772019883617, 33.464560525989526],
                [-81.93848808111501, 33.34370098409615],
                [-81.85234502288434, 33.247013350581454],
                [-81.75543408237482, 33.19813238030458],
                [-81.76261267056071, 33.157308712820594],
                [-81.61545161274996, 33.09499890455557],
                [-81.54007643679813, 33.04558078075917],
                [-81.42162973173095, 32.83447944758541],
                [-81.40368326126622, 32.74477480982455],
                [-81.38932608489445, 32.59490897787676],
                [-81.2816472621061, 32.55677107799041],
                [-81.2816472621061, 32.55623392447089],
                [-81.18832561568954, 32.46062059799524],
                [-81.12730761610948, 32.33653813498471],
                [-81.1452540865742, 32.22642166348186],
                [-81.11653973383063, 32.11737949901806],
                [-81.00527161694934, 32.07172144985834],
                [-81.04475385197173, 32.03465785701104],
                [-81.0016823228564, 31.86867741947747],
                [-81.15602196885303, 31.93689591645729],
                [-81.23139714480487, 31.89123786729757],
                [-81.14166479248125, 31.853099967411215],
                [-81.15961126294597, 31.727943197361633],
                [-81.3211294971285, 31.8095905323296],
                [-81.22421855661898, 31.734389039595946]
              ]
            ]
          ],
          "type": "MultiPolygon"
        },
        "index": 13,
        "type": "Feature"
      }
    ],
    "data-d6f0d131bd916803909d12216f83061f": [
      {
        "geometry": {
          "coordinates": [
            [
              [-86.60674618265506, 29.36288015789856],
              [-86.60674618265506, 36.00058672218704],
              [-79.96284613090833, 36.00058672218704],
              [-79.96284613090833, 29.36288015789856],
              [-86.60674618265506, 29.36288015789856]
            ]
          ],
          "type": "Polygon"
        },
        "name": "bbox",
        "type": "Feature"
      }
    ],
    "empty": [{}]
  },
  "hconcat": [
    {
      "height": 400,
      "layer": [
        {
          "data": {
            "name": "tile_list_dab3806a77ad",
            "sequence": {"as": "a", "start": 0, "stop": 20}
          },
          "encoding": {
            "url": {"field": "url", "type": "nominal"},
            "x": {"field": "x", "scale": null, "type": "quantitative"},
            "y": {"field": "y", "scale": null, "type": "quantitative"}
          },
          "mark": {
            "clip": true,
            "height": {"expr": "tile_size + 1"},
            "type": "image",
            "width": {"expr": "tile_size + 1"}
          },
          "transform": [
            {"as": "b", "calculate": "sequence(0, 20)"},
            {"flatten": ["b"]},
            {
              "as": "url",
              "calculate": "'https://tile.openstreetmap.org/' + zoom_ceil + '/' + ((datum.a + dii_floor + max_one_side_tiles_count) % max_one_side_tiles_count) + '/' + (datum.b + djj_floor) + '.png'"
            },
            {
              "as": "x",
              "calculate": "datum.a * tile_size + dx + (tile_size / 2)"
            },
            {
              "as": "y",
              "calculate": "datum.b * tile_size + dy + (tile_size / 2)"
            },
            {
              "filter": "datum.x < (width + tile_size / 2) && datum.y < (height + tile_size / 2)"
            },
            {
              "filter": "((datum.a + dii_floor + max_one_side_tiles_count) % max_one_side_tiles_count) >= 0 && (datum.b + djj_floor) >= 0 && ((datum.a + dii_floor + max_one_side_tiles_count) % max_one_side_tiles_count) <= (max_one_side_tiles_count - 1) && (datum.b + djj_floor) <= (max_one_side_tiles_count - 1)"
            }
          ]
        },
        {
          "layer": [
            {
              "data": {"name": "data-24368b1215f0ab082bc5f142afd0decd"},
              "mark": {"type": "geoshape"},
              "projection": {"precision": 0.000048, "type": "mercator"}
            },
            {
              "data": {"name": "data-82511bf0a52f29caa5d20ab7ec476bfe"},
              "mark": {"color": "red", "filled": false, "type": "geoshape"}
            }
          ]
        },
        {
          "data": {"name": "empty"},
          "encoding": {"x": {"value": 0}, "y": {"value": {"expr": "height"}}},
          "mark": {
            "align": "left",
            "dx": 3,
            "dy": -8,
            "text": "(C) OpenStreetMap contributors",
            "type": "text"
          }
        }
      ],
      "width": 400
    },
    {
      "height": 400,
      "layer": [
        {
          "data": {
            "name": "tile_list_a1b8ee8dca60",
            "sequence": {"as": "a", "start": 0, "stop": 20}
          },
          "encoding": {
            "url": {"field": "url", "type": "nominal"},
            "x": {"field": "x", "scale": null, "type": "quantitative"},
            "y": {"field": "y", "scale": null, "type": "quantitative"}
          },
          "mark": {
            "clip": true,
            "height": {"expr": "tile_size + 1"},
            "type": "image",
            "width": {"expr": "tile_size + 1"}
          },
          "transform": [
            {"as": "b", "calculate": "sequence(0, 20)"},
            {"flatten": ["b"]},
            {
              "as": "url",
              "calculate": "'https://tile.openstreetmap.org/' + zoom_ceil + '/' + ((datum.a + dii_floor + max_one_side_tiles_count) % max_one_side_tiles_count) + '/' + (datum.b + djj_floor) + '.png'"
            },
            {
              "as": "x",
              "calculate": "datum.a * tile_size + dx + (tile_size / 2)"
            },
            {
              "as": "y",
              "calculate": "datum.b * tile_size + dy + (tile_size / 2)"
            },
            {
              "filter": "datum.x < (width + tile_size / 2) && datum.y < (height + tile_size / 2)"
            },
            {
              "filter": "((datum.a + dii_floor + max_one_side_tiles_count) % max_one_side_tiles_count) >= 0 && (datum.b + djj_floor) >= 0 && ((datum.a + dii_floor + max_one_side_tiles_count) % max_one_side_tiles_count) <= (max_one_side_tiles_count - 1) && (datum.b + djj_floor) <= (max_one_side_tiles_count - 1)"
            }
          ]
        },
        {
          "layer": [
            {
              "data": {"name": "data-a832308bd903ce839bde0bdc87d25aa0"},
              "mark": {"type": "geoshape"},
              "projection": {"precision": 0.000013, "type": "mercator"}
            },
            {
              "data": {"name": "data-d6f0d131bd916803909d12216f83061f"},
              "mark": {"color": "red", "filled": false, "type": "geoshape"}
            }
          ]
        },
        {
          "data": {"name": "empty"},
          "encoding": {"x": {"value": 0}, "y": {"value": {"expr": "height"}}},
          "mark": {
            "align": "left",
            "dx": 3,
            "dy": -8,
            "text": "(C) OpenStreetMap contributors",
            "type": "text"
          }
        }
      ],
      "width": 400
    }
  ],
  "params": [
    {"name": "base_tile_size", "value": 256},
    {"expr": "geoScale('projection')", "name": "pr_scale"},
    {
      "expr": "log((2 * PI * pr_scale) / base_tile_size) / log(2)",
      "name": "zoom_level"
    },
    {"expr": "ceil(zoom_level)", "name": "zoom_ceil"},
    {"expr": "pow(2, zoom_ceil)", "name": "max_one_side_tiles_count"},
    {
      "expr": "base_tile_size * pow(2, zoom_level - zoom_ceil)",
      "name": "tile_size"
    },
    {"expr": "invert('projection', [0, 0])", "name": "base_point"},
    {
      "expr": "(base_point[0] + 180) / 360 * max_one_side_tiles_count",
      "name": "dii"
    },
    {"expr": "floor(dii)", "name": "dii_floor"},
    {"expr": "(dii_floor - dii) * tile_size", "name": "dx"},
    {
      "expr": "(1 - log(tan(base_point[1] * PI / 180) + 1 / cos(base_point[1] * PI / 180)) / PI) / 2 * max_one_side_tiles_count",
      "name": "djj"
    },
    {"expr": "floor(djj)", "name": "djj_floor"},
    {"expr": "round((djj_floor - djj) * tile_size)", "name": "dy"}
  ],
  "usermeta": {"embedOptions": {}}
}

So What To Do About It?

I think the root issue is that vega/vega-lite need to do a better job supporting concatenated maps (which I can't imagine is so rare!), but I'm open to hearing from people who understand this package better than I if this is actually trivial to solve...

I'm happy to help where I can - I understand Python decently well, and JS a little bit, but the API here is intimidating to get started with just jumping in and making edits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions