Using Aerial Images as Background for the OpenStreetMap iD Editor

We’ve been experimenting with using OpenStreetMap to map some of the rural Bedouin communities in the Negev desert. These are places where a lot of the construction is made of light materials, not easily discrened in a low resolution image and often changing – on top of which, the default satellite images are patchy and not the most amazing quality:

The default background satellite image

We managed to get more recent aerial photos with better resolution, in TIF+TFW files (the method below works for other world files as well, JPW etc). The trick was to convert it to a background tile map. That was simple enough with gdal2tiles:

gdal2tiles.py -s EPSG:3857 -v source/chura1.tif tiles/

Now we’ve got a whole lot of tiles, but we need to serve them from somewhere. Tiles are just a bunch of small static files — I’ve already discovered GitHub Pages is a zero cost and extremely scalable solution for serving them. I created a repo hura_tiles (Hura is the name of the town we’re mapping) and added the new /tiles directory:

git checkout -b gh-pages
git add tiles
git commit -am "add tiles"
git push origin gh-pages

We’re good! All that’s needed now is to is to tell iD to use a custom background layer, and set the URL:

https://niryariv.github.io/hura_tiles/tiles/{z}/{x}/{-y}.png

And here we are. Below are images of of the default and new backgrounds, can you spot the difference?


Since doing this, I’ve learned that this is a pretty common issue when speaking with local municipalities. Seems like pretty much all of them (at least here in Israel) have very good aerial images that are much higher resolution than the satellite images, so being able to use them is a critical need, rather than just a bonus as we initially assumed.

A Sense of Wonder

I recently gave a short talk about Tipa.li at a local dev convention in Tel Aviv, which in turn sparked some brief discussion of its user experience on Twitter. Some criticized it for being too sparse, having no exposition, so to speak – no introduction to explain what it’s about, guide you on how to use it etc.

It’s true. When a user opens http://tipa.li on their (generally mobile) browser, they’re just prompted to allow it to access their location:

Image

And then are shown a neighborhood-level map centered at their location with some markers. Clicking a marker shows the details for a baby wellness clinic – opening times, address, phone number.

Image

The Twitter conversation made me realize this is what I’ve been trying to do all along, with all UIs I had the chance to build or influence. Part of this minimalism is due to pure laziness, but it’s also about particular moment I think good UIs can recreate.

Omri, my son, is now four months old and starting to learn how to use his hands to grab things and move them around (most of time eventually trying to eat them). A great UI can replicate that feeling of getting acquainted with a new object for the first time, tinkering with it a bit, figuring out how to operate it and what it does.

Image

Of course there’s the threat that the interface will be too cryptic for most users to bother with. Fortunately Tipa.li is too tiny to really risk this, but thinking about it instills some respect for the achievement of truly great products, like the first iPhone, which manage to be instantly usable while keeping a sense of wonder about the experience.

Tipa.li — a Tool for Easily Finding Polio Vaccination Clinics

No one is sure what caused the Polio virus, eradicated from Israel since the 1990s, to reappear. The virus was detected in sewage samples in the south of the country in early summer and began spreading northwards, prompting Ministry of Health to start a massive vaccination drive.

Parents of children under the age of 9 were asked to bring them to the nearest Tipat Halav clinic for vaccination. Country-run Tipat Halav (in Hebrew, “drop of milk”) childcare clinics are a household name in Israel. Spread throughout the country, they helped it reach some of the world’s lowest infant mortality rates.

The Ministry of Health decided to create a mobile application to help parents find the nearest clinic. It commissioned one of the country’s largest development shops to create it. They decided to create a native app. This is the Android version:


It’s in Hebrew, but you get the idea.

The iOS version, presumably, is still undergoing the App Store approval process (Note: this was published 3 years ago. The iOS version was never released.)

We discussed the app during lunch at work. We’re no doctors, but we thought we could do something about the software. Going with a native app didn’t seem ideal for a single-use application which needs to be deployed on as many platforms ASAP. As for the UI, I’ll leave the image above as an exercise to the reader.

Lunch concluded with a particularly good Malabi. It’s one of the few deserts I ever bother with, so I’m pretty sure the extra sugar is the reason I shot off a message to the Public Knowledge Workshop mailing list as I got back to my laptop, asking who’s with me — help me scrape the clinic data and I’ll take care of the front end.

Malabi, by naamanus. This is good.

Within a few hours, a person I’ve never met sent me a link to a JSON file with all the clinics. I still have no idea who this is and how s/he had this file. I geo-encoded a few, put the data on map using GitHub’s geoJSON support, and sent a link back to the mailing list. At 1am that night, Alon Nisser (whom I’ve also never met before) sent some patches that fixed the major missing parts in my code.

By morning we had a working prototype. Meanwhile, Udi Oron and Erez Segall — yet another two people I’ve never met — announced they were working on a more robust scraping code to get all the data from the MoH’s website and encode it reliably.

With the data in Alon, Udi and Erez’s capable hands, I focused on the front end with the goal of keeping it server-free — only HTML/JS code — thus allowing us to develop a quick, simple solution that’s easy to deploy and scale.

The final app is extremely simple. When opening tipa.li (Hebrew wordplay meaning “My drop” or “Tiny drop”) the user is presented with a map, zoomed to the city level and centered on her current location, showing nearby stations. Touching a marker (design donated by Ilan Dray, who I’ve also yet to meet) reveals its street address, opening hours and a phone number.


Tipa.li UI. This is all of it.

That’s all. No search or distance filtering features to clutter the UI. The user knows better — a more distant station might have better parking, for example. All the stations in the country are the one geoJSON file, so users can find clinics in other locations by just zooming and panning around.

The code is as simple as the UI. The app is one geoJSON file rendered on a MapBox map with the excellent Leaflet.js API. No searching, no AJAX calls to a backend server. Everything is client-side, served from the ultra scalable (and only occasionally down) GitHub Pages.

I’m pretty happy with tipa.li. It’s one of these rare cases where things just work right, from the start — the code, the UI, the development process. The media in Israel liked it too, giving it some nice coverage on Haaretz, Calcalist and some national radio/TV shows, helping us further the cause of opening government data. As for users — within 12 hours of posting the site on Facebook, we’ve passed MapBox’s free quota of 3000 requests. It was a good week.


Originally published at niryariv.wordpress.com on September 3, 2013.

Tipa.li – a Tool for Easily Finding Polio Vaccination Clinics

No one is sure what caused the Polio virus, eradicated from Israel since the1990s, to reappear. The virus was detected in sewage samples in the south of the country in early summer and began spreading northwards, prompting Ministry of Health to start a massive vaccination drive.

Parents of children under the age of 9 were asked to bring them to the nearest Tipat Halav clinic for vaccination. Country-run Tipat Halav (in Hebrew, “drop of milk”) childcare clinics are a household name in Israel. Spread throughout the country, they helped it reach some of the world’s lowest infant mortality rates.

The Ministry of Health decided to create a mobile application to help parents find the nearest clinic. It commissioned one of the country’s largest development shops to create it. They decided to create a native app. This is the Android version:

It’s in Hebrew, but you get the idea

I assume the iOS version is still undergoing the App Store approval process.

We discussed the app during lunch at Gizra. We’re no doctors, but we thought we could do something about the software. Going with a native app didn’t seem ideal for a single-use application which needs to be deployed on as many platforms ASAP. As for the UI, I’ll leave the image above as an exercise to the reader.

Lunch concluded with a particularly good Malabi. It’s one of the few deserts I ever bother with, so I’m pretty sure the extra sugar is the reason I shot off a message to the Public Knowledge Workshop mailing list as I got back to my laptop, asking who’s with me – help me scrape the clinic data and I’ll take care of the front end.

Malabi, by naamanus. Best desert ever.

Malabi, by naamanus. This is good.

Within a few hours, a person I’ve never met sent me a link to a JSON file with all the clinics. I still have no idea who this is and how s/he had this file. I geo-encoded a few, put the data on map using GitHub’s geoJSON support, and sent a link back to the mailing list. At 1am that night, Alon Nisser (whom I’ve also never met before) sent some patches that fixed the major missing parts in my code.

By morning we had a working prototype. Meanwhile, Udi Oron and Erez Segall – yet another two people I’ve never met – announced they were working on a more robust scraping code to get all the data from the MoH’s website and encode it reliably.

With the data in Alon, Udi and Erez’s capable hands, I focused on the front end with the goal of keeping it server-free – only HTML/JS code – thus allowing us to develop a quick, simple solution that’s easy to deploy and scale.

The final app is extremely simple. When opening tipa.li (Hebrew wordplay meaning “My drop” or “Tiny drop”) the user is presented with a map, zoomed to the city level and centered on her current location, showing nearby stations. Touching a marker (design donated by Ilan Dray, who I’ve also yet to meet) reveals its street address, opening hours and a phone number.

Tipa.li UI. This is all of it.

Tipa.li UI. This is all of it.

That’s all. No search or distance filtering features to clutter the UI. The user knows better – a more distant station might have better parking, for example. All the stations in the country are the one geoJSON file, so users can find clinics in other locations by just zooming and panning around.

The code is as simple as the UI. The app is one geoJSON file rendered on a MapBox map with the excellent Leaflet.js API. No searching, no AJAX calls to a backend server. Everything is client-side, served from the ultra scalable (and only occasionally down) GitHub Pages.

I’m pretty happy with tipa.li. It’s one of these rare cases where things just work right, from the start – the code, the UI, the development process. The media in Israel liked it too, giving it some nice coverage on Haaretz, Calcalist and some national radio/TV shows, helping us further the cause of opening government data. As for users – within 12 hours of posting the site on Facebook, we’ve passed MapBox’s free quota of 3000 requests. It was a good week.

Around Here & the New GeoCities

I know I’m not the only one who needs a map in Jerusalem:


Problem is, a simple map is not enough here. Some places just really accentuate a dimension. Australia taught us to respect distance, driving our camper all day to cover a mere wrinkle on the map. Manhattan forces you to acknowledge it is 3 dimensional. Jerusalem is impossible to understand if you ignore the dimension of time.

So I made a little app I call “Around Here” which shows wiki articles around my current location:


It’s not a lot of code, but actually pretty useful. I mostly use it on my phone, but it works on laptop, tablet and would work right here too if WordPress would allow embedding JS.

Building it made me think of how much the web has changed in the last couple of years. Have you noticed how much you can do with JavaScript now? All the awesome libraries coming out? Not even node.js, just old fashioned client-side JS.

Programming languages are like musical genres. New ones are created, existing ones change and move in and out of fashion, but every once in a while a specific genre will experiences a sudden explosion of creativity. If JavaScript is Punk rock I guess this is the mid-1970s now. (Note: I’m importing this to Medium now, and realize in the four years since blogging this JS has shifted to the tedious, self absorbed and skill-obsessed prog rock of the late ‘70s)

HTML5 and modern browsers’ capabilities are a major factor, but also some slower moving, deep server side changes:

  1. Continued APIzation of everything allowed me to write the app using the WikiLocation API instead of my own DB backend. An embeddable service like Disqus enables pure HTML Jekyll blogs to have active comments. If your data is not sensitive you could even use a Google Spreadsheet as your DB.
  2. Decreasing costs of serving HTML/JS/CSS only pages now allow GitHub to let you serve your pages for free, with no restriction on content and almost no scaling limit. Basically you could do that in 1995 with GeoCities — look how much more you can do with just the above client side technologies now.

So, what we used to call “static pages” are now becoming increasingly powerful, and free. There’s an odd back to basics feel as we’re crossing a gap between very low cost to zero cost for serving a useful, highly scalable app. It might turn out a big deal. More importantly, coding is fun again.


Originally published at niryariv.wordpress.com on December 25, 2012.

Around Here, the New GeoCities

I know I’m not the only one who needs a map in Jerusalem:

Old City Map

Problem is, a simple map is not enough here. Some places just really accentuate a dimension. Australia taught us to respect distance, driving our camper all day to cover a mere wrinkle on the map. Manhattan forces you to acknowledge it is 3 dimensional. Jerusalem is impossible to understand if you ignore the dimension of time.

So I made a little app I call “Around Here” which shows wiki articles around my current location:

around-here

It’s not a lot of code, but actually pretty useful. I mostly use it on my phone, but it works on laptop, tablet and would work right here too if WordPress would allow embedding JS.

Building it made me think of how much the web has changed in the last couple of years. Have you noticed how much you can do with JavaScript now? All the awesome libraries coming out? Not even node.js, just old fashioned client-side JS.

Programming languages are like musical genres. New ones are created, existing ones change and move in and out of fashion, but every once in a while a specific genre will experiences a sudden explosion of creativity. If JavaScript is Punk rock I guess this is the mid-1970s now.

punk

HTML5 and modern browsers’ capabilities are a major factor, but also some slower moving, deep server side changes:

  1. Continued APIzation of everything  allowed me to write the app using the WikiLocation API instead of my own DB backend. An embeddable service like Disqus enables pure HTML Jekyll blogs to have active comments. If your data is not sensitive you could even use a Google Spreadsheet as your DB.
  2. Decreasing costs of serving HTML/JS/CSS only pages now allow GitHub to let you serve your pages for free, with no restriction on content and almost no scaling limit. Basically you could do that in 1995 with GeoCities – look how much more you can do with just the above client side technologies now.

So, what we used to call “static pages” are now becoming increasingly powerful, and free. There’s an odd back to basics feel as we’re crossing a gap between very low cost to zero cost for serving a useful, highly scalable app. It might turn out a big deal. More importantly, coding is fun again.

Retweet Reach, Randomness and the New News

Disclaimers

This one is R-Rated. It’s really about technology and how it affects the world, but also touches a subject that’s impossible to write about without offending half your readers. So, gentle souls probably want to go elsewhere.

0. I want to believe I’m writing this objectively. However, I live in Jerusalem now so my experience of the events mentioned is relatively personal.

1. Obviously all figures below are approximate. There are no hard numbers on the Internet: Twitter follower counts change all the time, messages added and deleted, site traffic estimates are ballpark at best, etc.

2. Also obviously, I hope, I’m not trying to judge the people mentioned in any way. I don’t know that much about neither, from what I’ve learned they both seem well-meaning and obviously highly capable individuals.

The New Media Moguls

During the recent Israel-Gaza clashes, David Zirin posted an column in The Nation’s website on the bombing of a soccer stadium in Gaza.

The incident was not heavily covered: In the grand scheme of war’s horrors, an attack on an empty soccer field merits perhaps a line inside a bigger story. No civilian casualties were reported and, moreover, the IDF owned up to the strike, providing aerial photos of Hamas rocket launch sites in stadium.

But news travel differently now. One of Zirin’s readers was Paul Graham, prominent VC and entrepreneur who tweeted the article to his 85,000 followers:

This tweet was retweeted 85 times. That’s only %0.1, but it amplified the story’s reach considerably. To figure out by how much, you have to use Twitter’s API (Twitter’s UI only displays the first 20 retweeters). Time to break out Twython:

rts = t.getRetweets(id = 270592944891912192, count=100)
total = 0

for i in rts:
	followers = i['user']['followers_count']
	print "@%s\t%s" % (i['user']['screen_name'], followers)
	total += followers

print "TOTAL REACH:", total

The total comes down to 1,428,698. Adding @paulg’s own followers the audience for this tweet was over 1.5 million people.

I ran the same code on Zirin’s own tweet of his article. The result is 11,472, adding Zirin’s almost 15,000 followers the total audience for author’s tweet of his own article is only 26,500.

According to compete.com, TheNation.com gets about 400K visitors/month (relatively little, compared for example to Salon.com’s 2 million). In a day, that would be 13,000 people, obviously not all of whom read Zirin’s column. Generously the total viewers of Zirin’s tweet + the article might come to 30,000.

Graham’s tweet multiplied the article’s audience 50 times.

Breaking Down Retweeters

It’s interesting to see how this audience of 1.5 million is divided among the rewteets. Feeding the output from the code above into google docs produces this:

Obviously, not all retweets are remotely equal. The big blue slice represents Chris Sacca, a fellow VC who has over 1.3m followers. Without Sacca, Graham’s original tweet would reach 200,000 people instead of 1.5 million. Sacca’s single retweet increased the audience 7.5 times.

Randomness

Perhaps the real measure of a Twitter user’s influence isn’t number of followers but potential retweet reach. Maybe Sacca’s college roommate is on Twitter and has 10 followers. But one of them is Sacca who has 1.3 million followers. That gives him a potential audience larger than that of users with 100,000 followers who are less well connected.

This is where linearity breaks: There’s reasonable correlation between a person’s prominence and their number of followers, but things get a lot more chaotic when you account for the followers’ followers.

This accounts for what I think is the most significant trait in this new distribution model: its randomness.

Randomness isn’t only in the network, but encouraged by the process: A retweet involves a click on “Retweet” and then a click on “OK”. It takes less than a second. If not immediately, it probably won’t be done at all, on an active account you usually don’t see the same tweets twice.

If Sacca was traveling that day, or busy in meetings, or had poor reception, Zirin’s audience would be a fraction of what it ended up as.

I believe we’re seeing this random amplification typical of a highly networked world not just in news. They are changing lives and moving billions of dollars around, and affect every member of our society.

In the Olden Days

A single journalist or publisher could always have had a big effect on a story. But it would normally take considerable effort, often involving professional risk. It would require some amount of time, and at the very least a conscious decision.

In the new model, it’s done casually, almost subconsciously. There’s no real risk. Sacca and Graham are not journalists, their reputation is not at stake.

With old media imploding, I’m mostly sad to lose the archetypal street wise reporter who spent a career learning to tell truth from bullshit – whether the latter comes from a street corner drug dealer or the US President or a fellow journalist. We will not be getting this in the new model, where distribution is shaped almost randomly by people whose sensibilities were honed in streets very different from Gaza’s or Jerusalem’s.

KalSMS Growing

It’s been a good first year for KalSMS, which I’m particularly happy about since I didn’t really have much time to work on it myself (nor, evidently, on this blog). It truly took on a life of its own.

In India, Sheldon D’Souza was using it to power a food ordering startup and contributed some polling code to the codebase (it’s still in a separate branch, I really didn’t have much time for non-work stuff).

In Liberia, local activists were using John Etherton’s Ushahidi KalSMS plugin to track conflict indicators and humanitarian needs.

I had the opportunity to give a talk on KalSMS at the inaugural Dar es Salaam GTUG meeting. Allen Machary, one of the engineers I met in Tanzania (an impressively sharp and passionate group, btw), later joined Bienmoyo and ended up using KalSMS for part of a mobile pregnancy care program he was working on. Here’s a photo I got from Lushen Wu, Allen’s colleague, of a training session in Tanzania.

KalSMS is not pictured, but is somewhere around here

I’ve been hearing from people interested in putting it to various other uses: cross-network SMS service in Poland, salsa club promotion in LA, activists communications in Northern Africa, marketing for a fashion boutique in Finland and so on. Who knows how many of these got built, and how many others I never heard of.

All that has been a pleasant surprise, since about a month after I released KalSMS Ushahidi project launched SMSsync, which has similar goals and obviously much more resources behind it. With my rapidly shrinking spare time and negligible Java skills, I assumed KalSMS was done for. But people still seemed to find a use for it, and improve it.

I was particularly happy to get an email recently from Jesse Young of Envaya, who have taken the codebase and added a LOT of functionality. Envaya’s version is now out as EnvayaSMS, the history page lists the major features they added.

If you’re looking for new features, EnvayaSMS is your best bet. I’m still going to keep KalSMS up, with minimal maintenance, in the same place, and it’s also out on the Amazon Appstore now for easier download. There may be a place for having a minimal feature and the super-simple UI it enables.

When I get some free time, I might integrate some of EnvayaSMS new features down to KalSMS, keeping the UI minimal. If Python/Ruby/etc on Android ever become viable I’d be happy to rewrite the whole thing in a language that doesn’t feel like it was designed by a committee of lawyers.

It’s been a fun ride so far. It’s a great feeling to see my code gets picked up and used all around the world, and have much better programmers than myself take it places I never thought it’ll get. Thanks everyone. Keep KalSMSing.

KalSMS

KalSMS is a small Android based SMS gateway I’ve released as open source. “Kal” is a Hebrew word meaning “lightweight” and “easy”, so it fits KalSMS’ primary goal of being very easy to install, maintain and work with.

KalSMS is a very thin layer between SMS to HTTP and back to SMS. For example, a simple SMS weather service works like this:

  1. A user sends an SMS “weather 10026” to a phone running KalSMS
  2. KalSMS intercepts the SMS message, and sends it to pre defined URL. In this case http://qkhack.appspot.com/weather?msg=weather+10026
  3. In this URL, a script uses Yahoo!Weather API to get the weather forecast for zip code 10025, and formats an XML response like:
    <reply>
      <sms-to-sender>
        Fair 37F today, Mostly Clear 34F tomorrow, Partly Cloudy 37F Friday
      </sms-to-sender>
    </reply>
    
  4. KalSMS parses the response, and sends an SMS back to the user with the weather forecast.

In effect the phone running KalSMS has now become an SMS server, running a weather application.

I’ve been working recently on applications that are meant to be used in places like India and Africa. This taught me that (a) SMS is accessible by a LOT more people worldwide than the web, and (b) it is MUCH harder to build an SMS app than a web app.

KalSMS tries to help this by leaving the heavy lifting to a web app, and just providing a simple, as thin as possible layer between SMS to the Web and back again. This means developers can work with the tools they already know, use state of art technologies like Heroku or App Engine that make launching a web app extremely simple and cheap, and just use an Android phone to enable the SMS part.

Current solutions require either collaboration from a local cellular provider, often a challenge for low budget projects, or setting up your own server – that is, an actual computer running the SMS gateway software connected to a cellular modem. This is non-trivial to install and maintain, and since the solutions out there are tightly coupled you have to write your actual application in a specific language or framework dictated by the SMS solution.

By being Android-based, KalSMS installation is a matter of scanning a barcode, maintenance means keeping the phone working – something almost all people in the world now know how to do. Basically an Android phone with KalSMS replaces a computer, network connection, cell modem, a UPS system and whole bunch of software.

I’ve got plenty of opinions on aid efforts and their effects over the years, but in keeping with the unwritten “produce or shut up” motto of this blog I’ll just say I think things will start to improve when more people pay attention to Bill Easterly than Bono. In my corner, I hope hackers will use KalSMS for various projects simply for its simplicity and reliability – and perhaps in time will seep into the developing world projects I had in mind when building it.