Weathered Chimo

By chimo on (updated on )

So I haven't been on here for a while, huh?

For the most part, I haven't touched this whole "*.chromic.org" environment since my last post in September. I don't think this post is indicative of a "return to a regular schedule".

So what am I doing here then? I found a draft post I'd started almost a year ago, around the time I was messing with weather data and wrote the Weathered Radio post. I figured I'd get it done and, who knows, maybe I'm wrong and I'll start posting more. So let's cut the crap and get to it, shall we?

This post is very specific to the Environment and Climate Change Canada (ECCC)'s data, so might not be very interesting or relevant to many people, but as always, these posts are mostly about reminding me how my own stuff works.

The recurring theme on this blog is about self-hosting the data that I'm using. Unfortunately, I can't really go out and setup weather stations all over the place, so next best thing is to consume external data in a way that reduces the number of third-parties/tracking/etc.

In short, I have a small PHP script that takes a pair of latitude/longitude coordinates, finds the closest ECCC weather station and returns the current temperature.

This in itself isn't very interesting, but the process of collecting the weather station data was a fun exercise (an exercise that wouldn't have been necessary if they'd just provide an API... but hey, whatever.) It was also the first time (or one of the few times) using PostGIS, so that was also fun.

Most of the work is done via the import_sites.php script. It parses ECCC's "siteList" XML file, then fetches and parses each weather station's XML file to extract its location. It then inserts the weather station's information into the postgres database.

That's pretty much it. Pretty simple, turns out.