offset \ˈȯf-ˌset\ noun

a force or influence that makes an opposing force ineffective or less effective

Displaying Location Name from Image Coordinates in Google Earth with Python

A while ago I made a Python script that takes your images and extracts the latitude and longitude coordinates for KML from them. The KML can then be opened with Google Earth where you can enjoy the fancy display of your photos attached to map locations. The script works in the way that it creates placemarks in KML that are correctly placed on the map. When one clicks the placemark, it opens a popup with the image associated with that location.


However, the description is just a timestamp of when an image was taken. That bugged me and there was a better way to get the information about the location, too. The format I opted for was "Photographed at {timestamp} near {location_description}". Quite better than just "{timestamp}".

Since I already had the timestamp to work with, that part was easy, but the other one, where I needed to figure out the location was a bit more tricky. I relied on a public openstreetmap reverse geocoding API to get the information about the specific coordinates. To comply with their terms of service, I needed to avoid bulk querying and query the service only once per second. I also needed to keep a cache of locations so the repeated coordinates didn't need to query the service.

The algorithm in question is simple enough. To get that, first check the cache if it has the location already and return that. If not, pause for two seconds because I don't want to take any chances and then query the service with the requests library, cache the response and get the location description. The requests naively retries for a couple of times just to be sure and drops it if it times out.

The result is a bit more easy to comprehend.


Now, the name that gets into the title also bugs me, but I'll explain the fix I did in the next post.

Displaying Geotagged Photos on Google Earth with Python

I decided to write a Python script that would create a Google Earth KML file with the list of geotagged photos that can be showed in the application. My reasoning for it was that a while ago Google decided to shut down Panoramio, the service they had acquired previously.

The service was of a photo-sharing type; much like Google Photos or Flickr today. The added ability that set the service apart from others was that the Google Earth application had a map layer comprised of photos stored on Panoramio. With Panoramio gone, the layer from Google Earth was removed as well.

I was not a user of it, but I liked looking at photos on Google Earth, thinking of places I wanted to visit. I wanted to share where I was traveling with my friends and family. Of course, provided that they used the same set of tools.

To achieve this the media needs to be enriched with geolocation information. The practice itself is called geotagging. JPEG image format, common with a number of digital cameras, can have metadata added to it (in contrast to PNG for example). The specific metadata is called EXIF and can contain information like the timestamp when the image was taken, camera type, location, etc. All the information necessary to create a KML file that Google Earth can read.

Now, before I get into the details about the Python script, I want to point out that EXIF information has a number of privacy and security issues. A number of TLA agencies are targeting EXIF information and using it for their purposes. For example, thanks to Edward Snowden's whistleblowing, we know that the NSA is targeting EXIF tags.

A number of examples associated with geotagging concerns are presented by Friedland and Sommer. A burglar can track your geotagged information and find out where you live, when you're not at home and steal things from your house.

Social networks make it incredibly easy to collect information on you and distribute it among unwanted people. One should be careful about the use of it, especially with kids nowadays gaining access and doing things they don't understand, enabling predators to exploit the information.

In your travels, you might visit wilderness and snap some photos that you would post online. One of more curious examples of abuse is poachers looking for rare animal photo geotags to figure out where to go. You want to be careful and think twice before you share information in this manner. Your camera or smartphone may be using GPS technology to attach the coordinates to an image.

Having said all that, you might think that EXIF information is not for you or that you want to strip that information before posting it online. It can be done, both stripping the EXIF information and preventing it from being saved in the first place.

I store my photos locally on an external disk and look at them offline. I don't frequent social networks so I don't have much trouble with geotagging information. I wanted to see where and when I was for personal use. That's why I created the Python script mentioned in the beginning of the article. You are free to use it too.

The necessary information I got was mostly from the article showing how to create placemarks for use in Google Earth. I wanted to automate the process and save KML instead. I could do that with Python.

The resulting script works only for Python 2.7.x for now because the PyKML dependency is not Python 3 ready so make sure you have the latest Python 2.7.x installed on your system. I install the dependencies in the virtual environment with virtualenvwrapper and can run it without trouble, but you might want to install them differently. Anyway, they are provided in the requirements.txt file in the repo. You can sift through the README.rst file there for more information. The usage of the script is pretty straightforward and it goes something like this::

$ python --folder=/path/to/folder/with/geotagged/images

Keep in mind that it will parse the folder and the nested folders located in it. I use WSL on Windows to point it there or Linux locally so I can find my way around. It is supposed to work on both. The result of the script processing is the KML file in the specified folder with relative path to the images so you're not supposed to move it from there. You can open the KML with Google Earth and see where the images were taken according to the provided coordinates.


It also takes the timestamp so you can replay your steps and see when you were taking the photos.


I hope you find it useful or that it gives you an idea for a more comprehensive system you might want to work on. The script is on the BitBucket repository and under the GPL license so you can do whatever you want with it provided you share the code and give credit where it's due. Without further ado, you can download the Python script for creating KML from geotagged images in the mentioned repo. I put the download information deliberately at the end because I want people to know what they are doing and read through the article first.

Reddit favorites coloring

This is a GreaseMonkey script that looks up your favorite subs on Reddit and colorizes the posts from them on your home page.

It turns something like this:


To something like this:


The prerequisite is a browser that supports installing the script. I use Firefox and the GreaseMonkey extension, but it should work on others, too. For instance, TamperMonkey on Chrome.

You can get it on Gist under Reddit favorites coloring. Just click "raw" button there and the browser extension should prompt you to install it.

Blood donation and transfusion

Become a blood donor. That's the gist of it. I'll tell you a bit about that. I've been trying to write this post for a very long time now. I've been to the donor clinic about four times already in the past two years. It was always something preventing me from donating. Either me not being originally from this country, having to give samples first, or having to wait because I had been traveling, or having to get some medical documentation they needed to verify first. Right now, after my first proper donation, things are finally falling into place. Vesna and I were persistent, if nothing.

Donating blood is not something that was strongly encouraged in our lives. I know that some high-schools did it. I don't think my class did. It was a chance for students to skip a school-day. If you're employed, depending on the country you are located in and your employer, you might get a paid day off, or there might be other incentives. Not in Ireland, though, but it's not something I was looking for. I'm donating because it's the right thing to do and that should be a proper motivation for others as well.

There are people who oppose it out of an overall hidden fear that doing it might lead to complications, that the procedure can cause an infection in the donor's organism, but that fear is largely unfounded. Every kit used for the donation is brand new and safety procedures are strictly adhered to.

While the best thing is to avoid unnecessary transfusion, we are no strangers to receiving it when the need arises. Blood transfusion is used as a support during surgeries and often for children and people over 65. According to the WHO, up to 76% of blood transfusions is for the people over 65. We might as well develop better life practices now and spread the word while we're young, because, when we get older, chances are we'll need a blood transfusion.


This goes hand in hand with the social sensitivity we should have. We might find ourselves in such a situation where blood donation could save our lives. As minuscule as that risk may be, the blood we receive must come from somewhere. In essence, we're all relying on the good will of some stranger and we can be that stranger to someone.

Carl Sagan said that we're all made of stars:

The nitrogen in our DNA, the calcium in our teeth, the iron in our blood, the carbon in our apple pies were made in the interiors of collapsing stars.

We are inter-compatible in a way. Depending on the variables, we can share some of the body parts between us. Blood would be one of them.

The overall process of donating is easy. Nowadays, there's a questionnaire mostly comprised of questions about your past and current illnesses (if any), a quick check for iron levels in your blood, and soon after, if everything's OK, you donate blood (or a sample for starters). About 470ml is the norm. In Ireland, a donation can occur every 90 days. However, they will delay your donation date if you have exposed yourself to a risk of contracting something (the exposure criteria differs from country to country), or outright prohibit you. If you are green-lit for a donation, they will still test your blood for a number of things.

Aside from donating blood, there are other options as well:

  • donating the platelets which is likely possible even if you're unable to donate blood. They are used for treating bleedings.
  • donating the bone marrow. Mostly for treating leukemia patients and anyone in need of it.

Platelets are usually donated by filtering the blood for it and you have to have both arms connected to the machine. For the bone marrow, there are two ways of obtaining it. Either through direct removal from a hip bone, which requires you to stay in a hospital, or by receiving an injection with a medication that increases the production of stem cells. The stem cells get into your bloodstream and the highest concentration of them occurs a few days later. You are supposed to come in at that time and get your blood taken normally. They usually call you when there is a requirement, so you only get registered once and wait.

The ultimate thing you can do with your body in this respect is the organ donation. While you can give a kidney to someone while you're alive, most organ donations happen posthumously. Some countries implement this as part of an inclusive policy, where one must formally opt-out. That is a good approach in my opinion. If you happen to live in a country where you must opt-in, you can do so if you wish. A transplanted organ can save a life.

I hope I convinced you to make a difference. The procedure for blood donation is not that big of a deal and you get a small free health check-up. You can already start planning today.

Fairphone 2

Like I said in the No subject post, I had to get a new smartphone. My old one broke down completely so I was considering the options. Since I'm not an avid phone user, I wasn't that concerned with hardware performance. Other factors were important to consider, namely the support, openness and manufacturing process. In the end I got the Fairphone 2 and I'm pretty much satisfied with it. So why did I choose that one in particular?


Having access to support would mean that whenever there was a problem, I could turn to the manufacturer for help. But good support is not the only thing that matters; there are also the product's longevity, repairability and modularity.

Fairphone 2 was designed to have as long lifespan as it was possible, meaning that the components it incorporates are as durable as they can be. To further enhance the longevity, the phone was made modular and easily repairable. When it comes to all the fine electronics in it, parts can be detached if they break down and replaced with new pieces. This is achieved through getting a replacement part from their store. The repairability is graded 10 out of 10 on the iFixit web. They market that the screen can be replaced in 20 seconds. Hopefully, I'll never have to verify this, but it's good to have the option.

Openness regards the software side. The phone comes with two versions of Android. The open one and the one with custom closed source modifications. It was announced that the Android would be bumped to the version 6 this month. Better late than never. The default OS is updated with security patches frequently so it is very up to date in terms of closing down security holes. This is something other phones have trouble with. The phone also comes with the rooting option and you can install custom operating systems on it thanks to the support of the community.

Mark Shuttleworth turned the world on its head with the convergence concept, but killed it the other day. The community took up the Ubuntu Touch, but we still don't know if it is going to take root. I have tried Ubuntu Touch on the Fairphone 2 to see how it looked like, but reverted to Android soon enough because not all the features were supported back then. The situation looks better now, but considering the announcement, it might get bleak.

The Sailfish OS can be installed, but I haven't tried it yet. I'm still considering it. It's great not to be locked within a single software ecosystem. I even prolonged the battery life by following the instructions from the official forums and replacing firmware for the phone.

However, it's the manufacturing process where the phone really shines, because all the components are ethically sourced. They track where the materials come from and what the working conditions are at all stages, from raw materials to the finished product. As for the recyclability of the product, the manufacturers have a report on it and are very invested in it.

What the phone could benefit from is a battery with a larger capacity, though, but I am not complaining. My commute is not very lengthy. I still bought a powerbank, because now I had three devices for which it would come in handy: a camera, and both Vesna's and my phone. As a sidenote, considering all the borders we were about to cross travelling, we had to make sure that the powerbank had distinct labeling so it could pass the airport security checks. The powerbank proved to be a life saver because, more often than not, we found ourselves in situations where we had no access to power. Talk about energy usage, eh?

Another thing that I'd like to have regarding the hardware is the addition of the NFC module so I could eliminate the plastics from my wallet and use contactless payment wherever possible.

Both things above could easily be done by adding new modules or upgrading the existing ones. I have my fingers crossed.

I'll finish off with two things. One is to recommend an excellent article from TechCrunch about Fairphone that is a must read, and the other is that this article is being published on Earth day 2017. Take some time to consider the state of things and how you can contribute.