A week of Geo and Beer

A month or so ago my colleague mentioned that we where considering sending someone over to San Francisco to get to know the Mapbox-stack even better. I think I spent two seconds thinking before I said something like “Going to San Francisco to visit Mapbox? Can I join?” And, as it turned out my schedule and area of knowledge seemed to be a good match, so I booked tickets together with my other colleague that would be coming along. Seriously, a week in SF, with it’s great vibe, superb beers and spending time with one of the most innovative Geo-players? It’s perfect! What could be better?

Well, as events turned out, I found myself in Copenhagen the weekend before my flight to SF, visiting a friend together with my girlfriend. As I left Norway friday afternoon i wrote a Tweet, proclaiming I was exited to be visiting Copenhagen and SF in one go. Then Asger Pedersen from the danish geo-geek company Septima suggested we’d meet up for some beers. I wasn’t really sure I had the time, but along the weekend we agreed to meet up. Well, before that there was beers to be had. On Saturday we headed down to Kødbyen to check out Mikkeller and Three Floyds’ new brewpub: Warpigs. This place opened the day before we visited, and with it being a really sunny and warm day in Copenhagen, the place was packed. Danish alcohol laws are fortunately relatively permissive, so we found ourselves sitting on the pavement outside drinking our beers. Which where great by the way!.

2015-04-11 15.07.50 (Custom)

2015-04-11 16.03.26 (Custom)

The place itself is also really cool, nothing like the “classy” “high-end” feel of the Mikkeller Bars. There was also an outdoors market going on in Kødbyen this Saturday, making the afternoon really pleasant. Great beers, good food and lots of people. We rounded off by a trip to Fermentoren, a couple of blocks away from Warpigs, before we hit our bikes, and went home for a bit of relaxation and then out for dinner, followed by a visit to Mikkeller and Friends, which was packed and not that great of an experience compared to the last time I visited. The day ended in our friends apartment, emptying his refrigerator of the beers I had bought at Kioskh earlier that day.

2015-04-11 17.27.37 (Custom)

This amount of beers meant that Sunday was a bit of a challenge, but I had agreed with Asger to meet him at Taphouse at four PM. A bit tired I still biked down there and after a couple of beers a guy said “I presume you are Atle?” This turned out to be Martin from Septima, and during the next ten minutes Asger and Gregers (also Septima) showed up. Taphouse is a great place, 60 taps going, but I’m “afraid” we spent our 3 hours there talking so much that I didn’t really put all that effort into actually tasting and analyzing the beers. A bit empty place on a Sunday, but we had great fun. Seems like we have a lot in common, and for me this set the standard for what I expected SF to be: meeting people that are deeply passionate about Geo, chatting with them on various topics and really having a great time. I had to leave after some hours, but as Septimas office was just a 5 minute walk from Taphouse, I was invited to take a look. Really a cool office, in what used to be the offices of a record company.

2015-04-12 15.34.42 (Custom)

2015-04-12 19.06.50 (Custom)
Septima Offices

This pretty much completed the Copenhagen-part of my trip, lots of great beers, and good company. I really hope I’m able to visit Septima again, wether it’s on business or just a friendly chat. The next day I took the Metro to Kastrup, met my colleague Keino and got on the plane to SFO, 11 hours really let’s you focus on your book, and I’m really making progress on “Wheel of Time”. When we landed in SFO it was 15.00 local time, 24.00 Norwegian time, and with no sleep on the plane we where a bit tired. We managed to find a taxi to our “Loft” in South of Market (SoMa), rented through AirBnB. Great location, enough space, but we struggled a bit to get the WiFi working, gotta meet the basic needs of living. We found out quickly that the baseball season opened this day, and with the stadium being located 3 blocks away the streets where crowded. We found a place to grab some food and a couple of beers, but nothing much to write home about. On the way back we bought some beers, but after drinking one in the apartment, it was 20.00, and we where dead tired.

2015-04-14 16.01.04 (Custom)

The next day we had an appointment with Paul from Mapbox at 10.30, so we set out for a 30-ish minute walk to their office, stopping for breakfast at a really American diner, BLT and coffee started the day. When we arrived at the Mapbox SF office, located in an old storage house, we where met by Paul and Matt, and after a quick introduction we got down to business; i.e. being given presentations on several aspects of the Mapbox technology stack by various key persons involved in making those. We had a chance to ask a lot of questions and really got a feel for what’s possible to do with their stack! After lunch, a great sandwich bought at a new mall in the Twitter HQ on Market street, we went back to their office, and blended in in their open-floor working area. Sitting in a sofa in SoMa, drinking a Lagunitas IPA while working on vector tiles I really felt at home. It was great having the Mapbox people available for questions, and their open-space office really did work much better than any such I’ve worked in in Norway. At around 19.00, Paul and Matt took us to the AT&T stadium for a baseball-match. We went there in “an Uber”, great taxi-service which I’ll get back to. Anyways, Paul and Matt tried their best to explain the rules of the game to us, bought us beers and really proper American fast food. I’m not really that into sports, and baseball is complicated, but the stadium had a great view, and we spent 3-4 hours talking about this and that, much like the atmosphere I was hoping for when I was in Copenhagen with Septima!

2015-04-14 19.40.54 (Custom)

The game ended, SF Giants lost and Keino and I went for a couple of more beers at a nearby sports bar before heading home, still a bit jet lagged. The Wednesday was spent much in the same manner as the Tuesday, a session of presentations on various parts of the Mapbox stack before lunch (at a great Japanese place, they had lovely Ramen!) At lunch Mapbox CEO Eric Gundersen joined us, and while I guess we’ll cover the usage of Mapbox technology at Norkart in a blog post at our companys blog, what Mapbox is doing is really interesting and we are seeing some great opportunities here! Post-lunch was spent coding some more, we did a climb up to the roof of their office for a beer, and then presented what we had been working on. Great being able to show what we got up and running in relatively short time, and getting the proper channels for feedback and questions.

These two days concluded the bulk of the geo-part of the trip, although we spent half the day on both Thursday and Friday in the “Loft”, coding and updating our colleagues back home. After the “show and tell” session at Mapbox Wednesday evening we headed over to Zeitgeist, a really cool place with an impressive tap list! Still, our clocks wasn’t all that aligned with SF time, and combined with lots of impressions and a number of beers we took a taxi home at a reasonable time.

2015-04-15 23.45.02 (Custom)

Thursday afternoon we decided to be a bit touristy, we walked up to Little Italy, an Anchor Steam, an ok pizza, then Lombard street up to Russian Hill. On our way back we stopped by Rogue Public House, another place I’ve visited before. Not the best beer place in town, but they do have a rather impressive beer lineup. On our way back we stopped by 21st Amendment brewery in SoMa, a new place for me. I really liked this place, great atmosphere and good beers.

After concluding our work on Friday my colleague wanted to do some shopping, and so did I! I went almost straight to City Beer Store, centrally located in SoMa. This is a bottle shop with an impressive range, as well as 10-ish taps. I had 3-4 beers here and bought enough bottles to fill my suitcase, and got a tip about Cellarmaker, a microbrewery just 3 blocks away. Small place, crowded, but I found a place at the bar and had a couple of beers. Impressive stuff! I realized I had to hook up with my colleague again, so i bought a 1 liter growler of one of their beers, which we shared in the “loft”.

2015-04-17 15.28.11 (Custom)
City Beer Store

2015-04-17 15.59.26 (Custom)

We had gotten some restaurant-recommendations from the Mapbox-guys, so we sett off to Lolinda (“If you guys are interested in some great Argentine food and a very cool interior design”). This was a bit far from us, so we decided to test Uber, the taxi app the half the city seemed to be using. Did it work? Absolutely! Within 2 minutes we where hooked up with a driver and on our way. Lolinda was what I guess you would expect, a crowded, noisy place, but great beers and coctails (finished the meal with a Manhattan, that was the only non-beer alcohol I drank throughout the trip I think!).

My colleague had an early flight back home on Saturday, so we took an Uber back, and I went to Safeways and bought 4 beers, 1 bag of chips and and the latest issue of Cosmopolitan. Great combo? However, After a couple of beers I fell asleep as well. Saturday the 18th was my birthday, and I had to relocate to another hotel (Hotel Boheme) in Little Italy. To fight off the hangover I decided to walk, but the topography of SF means that there is no such thing as “Manhattan distance”, so I ended up walking up and down a lot, through crowded streets in Chinatown. An expirience, absolutely!

When I finally got to the hotel I had one goal: find the really great sandwich shop I visited the last time I was in SF: Google knew that place: Freddie’s Sandwiches. As they don’t have any tables, I had my BLT in Washington Square park, in lovely weather.

2015-04-18 11.42.33 (Custom)

I’m guessing that all I really wanted was for the clock to turn “beer o clock”, and around 15.00 I got an Uber to Toronado, a really great bar in Lower Haight. Kinda loud, lots of hoppy beers (including “Pliny”). Beeing Saturday the place was crowded, but there are benefits to drinking alone: I managed to squeeze in at the bar, and after a couple of beers I even talked to people! I was recommended the burrito place and the sausage place next door, but couldn’t decide, so ended up with both. After two large meals and 5-6 beers I felt like I needed to do something else, so I decided to head back to the hotel (around 18.00). The trip back became a long one, as my co-passenger was really indecisive, but the driver was a nice guy. End of story: when I got back I felt like another beer! There was a place 4-5 blocks away that looked promising on ratebeer: La Trappe Cafe. Really the opposite of Toronado, a rather quiet place in a cellar, focusing on Belgian imports, but they had some american sours as well. I spent a good three hours here as well. Not the star beer place in the city, but worth a visit.

2015-04-18 15.27.04 (Custom)

Sunday I woke rather early and felt sorry for myself. Hungover, 31 years old and with a 10 hour flight 10 hours away. What to do? Google “best hamburger SF”, and go to Mo’s Grill. There was actually a line at 10.00, but after I while I realized that there was free seating at the bar, so i set down, got a coffe and ordered a “Burger with Sharp Cheddar Cheese, topped with Smoked Ham, melted Swiss Cheese, and Chipotle Mayonnaise” wow! afterwards I found a small cafe and sat utside for several hours reading, but then it got cold and I didn’t want more coffe, so I went back to Rogue and asked for a “sessionable beer”. What I ended up with: “brutal IPA” at 6% ABV(!). After the beer I walked arund some more, before the transport to the airport. That’s probably not that interesting, but I did get to try the “Mikkeller Sky High Wit” on the plane back!

2015-04-19 10.33.58 (Custom)

So, now I’m sitting at Kastrup, thinking that I’ll go easy on the beer drinking for some days ;) Had a really good time, I’m super happy with having an employer that sends me to San Francisco to do stuff like this!

Geomatikkdagene 2015

Foto: Even Stangebye

Torsdag kveld, jeg er trøtt! Årsaken? Menighetssamling på Lillehammer i tre dager. Nei, ikke sånn menighet, geomatikk-menigheten har vært samlet tre dager til konferanse. Mine inntrykk? Meget bra!

Jeg har ikke noen planer om å i år skrive en like detaljert rapport som jeg har gjort de siste årene, men noen momenter vil jeg gjerne dele.

Sånn starta altså dag 1: en politiker (eller Statssekretær da) snakket om nettopp: politikk. Ja, jeg vet det er viktig hva som gjøres i politikken, jeg vet det setter endel rammer for hva vi kan gjøre, men jeg tror jeg foretrekker å lese om resultatene senere. Mantraet er jo “forenkle, fornye, forbedre”, så i hovedsak er jeg jo enig. Det er masser av tidstyver der ute, og smart teknologi kan fjerne mange av dem!

Geomatikkdagene handler på ingen måte om bare teknologi, men som teknologiopptatt er det jo det som interesserer meg mest. Derfor er det gøy å se et nytt konsept på programmet: Geogründere! Fem kandidater fikk ti minutter hver på å presentere sitt “konsept”. Gøy å se at folk som egentlig ikke er en del av bransjen er med, gøy er det også å treffe igjen bekjentskaper helt ut av det blå. Det var jo så klart mye fokus på teknologi, og jeg skammer meg egentlig litt over at jeg ikke har gjort noe som gjorde at jeg ble nominert.. Uansett: Jon Olav Eiknes og konseptet VizBox var en verdig vinner!

Etter plenumssesjonen befant jeg meg på matrikkelsesjonen, noe de som kjenner meg kanskje vil mene er litt rart. Jeg er ikke noen matrikkelfanatiker, men jeg synes det som skjer nå, matrikkelen er blitt en nasjonal felleskomponent og det snakkes mer om bruk enn føring, er spennende. Dermed ble jeg sittende å se på flere foredrag om matrikkelen, og følte at jeg lærte mye!

Før programmet gled over i utstillers aften fikk meg med meg min nye kollega Alexander snakke om kunnskapsmisjonering: hvordan skal man nå ut utenfor menigheten (eller sandkassa)? Hvordan skal folk forstå hvordan dataene våre kan brukes? Det er spennende å se at GeoForum har satt i gang et arbeid med dette, og jeg er spent på å se resultatene her!

Lyntaler har vært arrangert på Geomatikkdagene i fire år nå, med varierende suksess. Jeg var stressa med PC, kode og organisering for live-kodinga mi, så jeg fikk desverre ikke fulgt med å godt, men det lille jeg fikk med meg var bra, og det var mange som fulgte med og organiseringen var god. Disse to stikkordene er vel antonymer til hva jeg vil beskrive live-kode-stuntet mitt på Norkart-stenden som: Det rant litt vekk i en folkemengde som hadde mye å snakke om og øl i hånda. 4-5 personer fikk meg seg at jeg viste kundespesifikk utvikling basert på WebAtlas-komponenter live.

Dog: selv om folk hadde øl og mye å snakke om var fag i sentrum hele kvelden. Det å labbe rundt i utstillingen, balansere øl, tapas og tanker om geografiske data, tjenester og SOSI-standard er noe av det som er mest givende med Geomatikkdagene spør du meg! Klok av skade fra tidligere år tok jeg relativt tidlig kvelden, dvs: jeg var i seng før midnatt. Imponerende!

2015-03-18 09.29.12
På tross av dette forsov jeg meg en smule til konferansens andre dag, så når jeg dukka opp på sesjon 6 om det offentlige kartgrunnlaget (DOK) var det bare gulvplass igjen. Det gikk for så vidt greit, og etterhvert som den ene foreleseren avløste den andre fikk jeg meg en sitteplass også. DOK er jo noe vi jobber en del med i Norkart, så det var ålreit å få litt oppdateringer her. Dog: det frista mer med innendørskart enn mer DOK, så når muligheten bød seg hoppet jeg over til ” Teknologi og trender”-sesjonen, og så MazeMap sin presentajon. Mye visjoner, endel bruk, men jeg savnet noen problematiseringer. Hvor god er egentlig posisjonering innendørs basert på WiFi? Hvordan navigerer man i et kart med flere etasjer?

Etter en time der jeg labba rundt i utstillingen og så på “beste kart”-utstillingen fikk meg med meg foredrage til hyttenaboen fra NMBU (eller hva det heter nå) om endringsvisualsering. Kanskje ikke det teknologisk sprekeste, jeg hadde håpet på noen automatiske analyser, ikke bare slide-over og blending av flybilder fra forskjellige år. Men, kanskje jeg er kravstor?

Under neste foredrag presenterte Lars Mjølhus fra min tidligere arbeidsgiver, Geomatikk IKT, en løsing for datafangst i felt. Jeg var involvert i en tidligere versjon av dette for 3-4 år siden, så spennende å se. Men, under dette foredraget merket jeg at jeg er inne i en bedrift som absolutt er til stede på Geomatikkdagene: jeg ble kalt inn til et møte. Det skjedde ikke da jeg jobbet i Bouvet! Etter møte og en rask lunsj var det tid for miniseminaret jeg og Alexander skulle holde om open source. Dette seminaret foregikk i et møterom langt unna resten av konferansen, og vi lurte på hvor mange som ville dukke opp. 45 stk tror jeg det ble, det er vel det man kaller en suksess? Jeg har skrevet mer utfyllende om dette på Norkarts blogg.

Etter seminaret var det tid for “hackaton”, eller hacksession som jeg foretrekker å kalle det. Det var meget skralt oppmøte, men jeg fikk noen tips om Thredds-serveren til Meteorologisk institutt, og begynnte å grave meg ned i WCS og netCDF-formatet. Det har jeg enda ikke skjønt helt, men hvis du kan noe om det ligger det noe kode på github-kontoen min. Alle hint og tips taes imot med takk!

Jeg gav til slutt opp NetCDF og tok en halvtime på øyet, før jeg gikk ned i baren og tok et par øl med kolleger, før aperetif og middag. Den tok (som vanlig) lang tid, smakte bra, og underholdningen var i år ålreit, men litt plump. Jeg fikk i det minste bekreftet at jeg ikke ante hvem John Brungodt var.

Etter middag gikk det igrunn slag-i-slag med fagprat, øl, vin, øl og nachspiel og idet sola titta frem fant jeg senga. Etter en lang kveld der jeg tror vi løste alle problemene geomatikkbransjen har stått og kommer til å stå ovenfor noen gang! Sånn sett en meget bra kveld/natt.

Dog: Når jeg nå har passert 30 begynner det å bli vanskelig å være helt både om natta og om dagen, så selv om jeg hadde lyst til å få med meg foredrag både om SAM-X, helsedata i relasjon til GIS og laserdata ble det desverre ikke til at jeg fikk med meg det. Jeg fikk dog med meg plenumssesjonen på slutten. Kartverkssjefen har tydligvis lært om ny teknologi, og jeg synes det ble mye “Internet of things” og “Big data”, uten å egentlig komme inn på _hva_ dette er. Et siste “dataslipp” ble også annonsert: dybdedata! Spennende dette, men: for det første er jo de artige dataene her gradert av forsvaret, og for det andre: “Selve datasettet er gratis, men det må beregnes en kostnad for manuelt uttak.”

Magnar Danielsen fra KMD oppsummerte konferansen godt, men det er vel fristende å si at konferansen ble avrundet som den begynnte: med en politiker. Eller, helt avsluttet var den jo enda ikke: Radarparet Kristoffersen og Midtbø presenterte “beste kart”-konkurransen. Litt kjedelig at Norkart sitt WebAtlas-kart ikke vant, men det var gode tilbakemeldinger som jeg har ganske sikre kilder på at blir tatt til etteretning!

Geomatikkdagene 2015 der altså. En suksess? Ja, jeg tror det. Tre dager er mye på konferanse, og det å hevde at Geomatikkdagene er teknologisk i front er vel å ta vel mye i. Det er uansett den konferansen som samler flest folk innenfor mitt (ene) fagfelt: geomatikkfaget. Bare det i seg selv gjør det verdt å delta: man treffer mye folk man kjenner fra før, og man treffer nye folk. Man diskuterer ideer, deler kunnskap og blir inspirert av noen foredrag. En ting er rimelig sikkert: jeg har nå vært med på 5 geomatikkdager og dette blir ikke mine siste!

Gulating: eller ølbutikk i Trondheim

I dag åpnet Gulating i Trondheim, en spesialbutikk for øl (dvs under 4,7% øl) i Trondheim. Gulating skal inngå i den planlagte mathallen i Trondheim, men de er tidligere ute enn resten av mathallen.

Butikken er en del av Gulating, en “kjede” med bryggeri og ølutsalg her i landet, jeg har enda ikke smakt noe øl fra dem, men fikk kjøpt med i dag. Mer kjent for den ølinteresserte Trondheimer er kanskje mannen som driver utsalget: Tommy Holen Helland, Ølportalen.no, årets ølhund, Bryggerifestivalen og ølsmakinger for å nevne noe. Med på laget har han fått med seg andre fjes ølinteresserte i regionen sannsynligvis drar kjensel på.

Så, hvordan blir dette? Lokasjonen er perfekt, du kan si hva du vil om sentrumshandel og slikt, men for en person som meg som tar buss i en by der ALLE busser går innom sentrum og aldri korresponderer tror jeg jeg kommer til å bruke endel bussventetid på Gulating. I dag var det åpning klokka 14.00, og lokalet var stappfullt i en halvtimes tid. Thomas Sjue fra Austmann kom med noen bevingede ord, og han har helt rett i en ting: dette er ikke stedet du kjøper med deg en sixpack dårlig øl for å drikke deg full en fredagskveld, mer et sted hvor du finner noe spennende og nytt å smake på. Pr i dag har de 200+ sorter øl, et utvalg cider (som jeg ikke sjekka om var av engelsk, skikkelig type, eller av den søte, klissete, svenske sorten) samt noe alkoholfritt; men dette er et ølutsalg. Øl står i fokus.

Butikken føles som i komme inn i en velassortert ølbutikk av det slaget jeg har opplevd i det mindre fanatiske utlandet, med hyller fulle av øl hele verden. Dog: at alt ølet holder maks 4,7% føles veldig rart. Jeg lurer på hvordan dette vil slå ut, jeg mistenker at det er endel norske “mikrobryggerier” som bevisst holder ølet sitt under denne grensen, i mange tilfeller med heller dårlig resultat. På den annen side; det kan være greit å holde seg til litt mer alkoholsvake øl også, så vi får se; dette er uansett ikke butikkens skyld.

Utvalget er stort, men alt er stablet etter øltype, så man finner lett frem (og sikkert lettere når ikke butikken er full av folk på første dag). Mye av ølet er norsk, med fokus på trøndelag og mikrobryggerier, selv om også AASS og Hansa var representert (om nå Ringnes og Dahls var der er jeg faktisk ikke sikker på…). Det meste av ølet er ales i forskjellige varianter, selv om bryggerier som Balder brygg og Atna stiller med lagere. Noe “skvip” var det også å finne, men der var ikke veldig strategisk plassert, så det er langt fra ølhylla på Rema.

Av trønderske bryggerier var de fleste jeg kjenner til representert: Austmann, To Tårn, Klostergården, Inderøya og Namdalsbryggeriet var alle i hyllene, de “store” er representert: Nøgne Ø, Kinn, Lervig, Ægit, Haandbryggeriet (med Soriaci Sess og Hoppy Saison bla.a) og 7 Fjell. Av andre norske bryggerier kan nevnes Ego, Nøisom, Fjellbryggeriet, Kofoedbryggeriet og Balder, samt Gulating sine egne øl som jo fikk god eksponering. Av utenlandske øl var det endel amerikanske session-øl, endel britisk, noe tsjekkiske pilsnere, samt et begrenset utvalg belgiere (etter hva jeg la merke til). Ølstilene er som forventet, en god del øl i skjæringspunktet pale ale, APA, (session) IPA, mye mørkere øl og endel lagere i diverse varianter.

Få av flaskene står i kjøleskap, og jeg ville kanskje før sommeren satset på å få mer av det lyse ølet kaldt slik at man kan være litt spontan. Dette vil jo også være en fordel fremfor dagligvarebutikkene, som skjelden setter annet enn Dahlsbokser på kjøl. En annen ting som skiller Gulating fra f.eks Meny er kunnskapen hos de som jobber der. Med et lite lokale fokusert på en ting, og ansatte som er opptatte av øl vil man nok kunne få mye gode tips. Et problem er kanskje at de færreste av de ansatte har smakt på alt (å dømme etter utvalget i dag), men dette vil nok endre seg på sikt. Jeg fikk ikke akkuratt “testet” de ansatte på ølkunnskap i dag, men jeg kjenner såppass til dem at jeg har trua på at de klarer å komme med gode tips til både nybegynnere øg ølnerder. Kassa er en annen fordel: her blir ikke flasker slengt nedover et rullebånd, men behandlet stående og forsiktig slik at man slipper å la flaska hvile i lang tid for å unngå bunnfall.

Alt i alt håper jeg virkelig at dette er et sted som har livets rett. Lokalet er enkelt, utvalget er stort og de ansatte er ålreite folk. Det store spøesmålet er om markedet er stort nok; men selv om jeg traff mange kjente fjes fra byens ølmiljø på åpningen i dag var det mer folk enn som så til stede, så det kan godt hende dette har livets rett. Selv la jeg igjen godt over 500 kroner i dag, og det blir nok ikke siste gang, selv om jeg i dag kanskje glemte at dette stedet er her i neste uke også.

Jeg snakket litt med Jorg Solheim, som sammen med Monkey Brew-gjengen er i ferd med å starte bryggeripub på Bakklandet, og han hadde et håp om at Trondheim skulle bli Norges svar på Portland, Oregon. Vel, det er et stykke igjen dit, men det begynner absolutt å bli et respektabelt antall ølsteder og bryggerier i byen, så kanskje det ikke er en så dum tanke? Gulating passer godt inn i denne “visjonen”, og som Tommy sa: “det er vel her dere ølnerder kommer til å møtes fremover”; ja og nei. Desverre er det jo ikke tenkelig engang å gjøre som City Beer Store i San Fransisco eller Rosses i Torrades i Barcelona; ha en tappekran eller to og servere øl på stedet. Desverre..

Tower of Prince Henry, Reversed

Ok, for you to enjoy this blog post I’m pretty confident that you have to be a bit of a JavaScript, Python and map geek. At least you will have to watch this presentation from FOSS4G 2014 by Eric Theise.

Ok, you watched it? You got his point? My takeaway was that as you generate map tiles further down in the zoom stack you’ll have to generate a ton of tiles, but in many cases you only want to show a map that puts your town/buisiness/whatever on the map. But, you would like some context, and then you have to set the bbox in TileMill WIDE. And then the tileset gets large, and you don’t bother.

So, I thought that there should be a way to limit a web map library to only request tiles that are within a given bounding box. Turns out that Leaflet has this option, set the “bounds” parameter on an L.TileLayer and you are good to go?

L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors',
bounds: bounds

Well, the user can still pan away from the area, so set “maxBounds” on the map as well:

var map = L.map('map', {maxBounds: bounds}).setView([63.4, 10.3], 0);

This works, the amount of requests sent to the tile server is reduced, but it doesn’t look good, does it:

The main problem is that L.TileLayer only loads tiles that intersects with the bounding box you’ve set (the small, blue square on my map). So, we’ll have to do something about that, and after a bit of digging I found that the “_tileShouldBeLoaded” method of L.TileLayer performs this check (at least in version 0.7.3). Thankfully, Leaflet classes are easy to subclass, and so “L.BoundedTileLayer” was born.

To get more context around I wanted to show some neighboring tiles as well as those that intersects the bounds. So, after we check for intersection we perform one additional check, which I think is best described in code:

//the distance from the tilecenter lng to closest bounds edge
var lngDist = Math.min(
Math.abs(tileCenter.lng - options.bounds.getEast()),
Math.abs(tileCenter.lng - options.bounds.getWest())

//the distance from the tilecenter lat to closest bounds edge
var latDist = Math.min(
Math.abs(tileCenter.lat - options.bounds.getSouth()),
Math.abs(tileCenter.lat - options.bounds.getNorth())

//these are probably equal
var tileWidth = Math.abs(nw.lng - se.lng);
var tileHeight = Math.abs(nw.lat - se.lat);

//check if tile should be loaded
return lngDist < tileWidth && latDist < tileHeight;

In essence, I check if the distance from the distance from the center of a given tile is smaller than the width or height of a tile. This can probably be optimized a bit, and I can almost guarantee that there are corner cases that I've missed, but it seems to work as expected:


Now we get more context, and we still limit the amount of tiles requested. Happy?

No: we still have to generate all those tiles, because we can't know what tiles the client will request. So, ditching JavaScript and Leaflet for a bit I switched to Python and tried to find a way to generate a list of all tiles the client would request using L.BoundedTileLayer for a given bounding box.

Luckily some smart people have already tackled the maths involved in computing tile indexes from bounding boxes, and the open source script I found at http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/ was a good starting point. After that it was just a matter of porting the logic from L.BoundedTileLayer to Python, free myself from the Leaflet context and write some 30 lines of code (3-4 hours of trial and error, I don't know how many times I've mixed up axis ordering!).

In the end I could throw a bounding box and a minimum and maximum zoom level at my script and get back a list in the form of:

{"z": 0, "y": 0, "x": 0},
{"z": 1, "y": 0, "x": 0},
{"z": 1, "y": 1, "x": 0},

But this doesn't help me much, I want to generate these specific tiles using TileMill! So, then I started researching how to do that. Nothing came up, except this page describing how to export tiles from TileMill via the command line. I studied the (lack of?) documentation, before I started digging into the source of TileMill and TileLive (which TileMill uses to use Mapnik to render tiles), but after 3 hours I was going nowhere, and it did not work. The next day I asked on stackexchange, and a couple of hours later it dawned on me (to quote my own answer): "that the option --list=[file] could be what I was after."

After digging a bit through the tilemill and tilelive source code i found that this options is (not suprisingly) used by the filescheme renderer (it says that in the comments), and some further digging in the source code to figure out the format of the file, I was able to tell TileMill to render a specific set of tiles.


Well, a bit on streamlining was called for, so I cleaned up stuff a bit, created a config file for input and looked into calling the TileMill export function from my Python code. This all worked fine, and pretty soon I could type "python tile.py -c config.json" and 3 minutes after have an .mbtiles file of about 14 MB that covers the Trondheim municipality, zoomable from zoom level 0 through 18. Neat!

Then, the moment of truth. Would the tileset I generated line up with what my Leaflet layer requested? I installed TileStache, and 30 seconds later I had a tileserver running at localhost, serving my generated .mbtiles file to my Leaflet map! And it worked!

So, why should you care? Well, I for one, think this is cool by itself, but I also see some useful applications for this. The components I've built now are not far away from the point where I can invoke the generation of a new tileset from a web map. If I do this i can load up a PostGIS database with up-to-data, detailed map data (and refill it through a cron-job or somethin), define the cartography in CartoCSS, and generate a small tilecache for small projects on-the-fly, when needed.

The only drawback is that I have to learn CartoCSS properly to do this, but I guess that's the topic of another blog post.

Do you have any ideas how this can be used, improved or built upon? Feel free to let me know, either in the comments here or via a pull request to the GitHub repo!

Debunking Map Myth #4: The earth is round

Ok, ok, unless you are a member of the “Flat Earth Society” (or a geographer), you might think I’ve gone insane right now?

Well, the earth isn’t round if you by round mean a “sphere“, which Wikipedia defines as:

[...] a perfectly round geometrical and circular object in three-dimensional space that resembles the shape of a completely round ball

So, what is the earth then? Actually, the Earth is a misshapen blob of matter that if matched to a mathematically defined shape would be an “ellipsoid“, i.e. the three-dimensional variant of an ellipse, or a lightly squeezed sphere if you like.

So, dependent of how mathematical you need to be the earth is either an ellipsoid, and these ellipsoids can be defined in several ways, as we discussed when debunking myth #1. These ellipsoids are defined by the parameters semi-major axis, a and semi-minor axis, b, from which you can deduce the flattening, f. The flattening occurs due to the fact that the earth spins.

This ellipsoid is what the GPS-systems use to determine your position, and forms the basis of latitude/longitudes.

But, the more interesting case is perhaps the “misshapen blob of matter”, called the Geoid, that is:

[...]the shape that the surface of the oceans would take under the influence of Earth’s gravitation and rotation alone, in the absence of other influences such as winds and tides.

To determine the actual shape of the geoid, geodesists rely on gravitational measurements from satellites, and by knowing the actual geoid height at a known location you can get a rather accurate idea of your “height above sea level” from a GPS (which really only measures the “ellipsoid height”. These calculations are rather complex, but given decent data they are simple enough that I’ve managed to write a Fortran program which does compute it.

So, there you have it, the earth isn’t round: it’s either ellipsoidal or misshapen, dependent on what you intend to use it for (and for the purpose of myth #5, it’s certainly not ellipsoidal!)

(And by the way, people in the middle ages did not think the earth was flat either!)