{"id":222,"date":"2015-01-05T14:17:44","date_gmt":"2015-01-05T12:17:44","guid":{"rendered":"http:\/\/tuijasonkkila.fi\/?p=222"},"modified":"2024-09-20T13:22:58","modified_gmt":"2024-09-20T10:22:58","slug":"snow-in-lapland","status":"publish","type":"post","link":"https:\/\/tuijasonkkila.fi\/?p=222","title":{"rendered":"Snow in Lapland"},"content":{"rendered":"<p>Finnish Meteorological Institute (FMI) <a href=\"https:\/\/en.ilmatieteenlaitos.fi\/open-data\">Open Data API<\/a> has been with us for over a year already. Like any other specialist data source, it takes some time before a lay person like me is able to get a grasp on it. Now, thanks to the <a href=\"http:\/\/ropengov.github.io\/general\/2014\/09\/30\/fmi\/\">fmi R package<\/a> by the collaborative effort of <a href=\"https:\/\/tuhat.halvi.helsinki.fi\/portal\/en\/persons\/jussi-jousimo(ba68d2b7-d32f-4a71-b52e-b79386e79007).html\">Jussi Jousimo<\/a> and <a href=\"https:\/\/github.com\/rOpenGov\/fmi\/graphs\/contributors\">other active contributors<\/a>, the road ahead is much easier. A significant leap forward came just before New Year, when Joona Lehtom\u00e4ki submitted a posting on <a href=\"http:\/\/ropengov.github.io\/general\/2014\/12\/30\/fmi-stations\/\">fmi and FMI observation stations<\/a> to the <a href=\"http:\/\/ropengov.github.io\/\">rOpengov<\/a> blog. <\/p>\n<p>Unlike many other Finns, I am relatively novice when it comes to Finnish Lapland. I&#8217;ve never been there during summertime, for example, and never farther North than the village of <a href=\"http:\/\/en.wikipedia.org\/wiki\/Inari,_Finland\">Inari<\/a>. Yet, I count cross-country skiing in Lapland among the best memories of my adulthood years so far; pure fun in the scorchio April sun, but maybe even more memorable under the slowly shifting colors of the polar night. <\/p>\n<p>Snow is of course a central element in skiing. Although <a href=\"http:\/\/qz.com\/316724\/finland-is-heating-up-twice-as-fast-as-any-other-country-in-the-world\/\">warmer temperatures seem to be catching us up here<\/a>, there has still been plenty of snow in Lapland during the core winter months. But how much, exactly, and when did it rain, when melt?<\/p>\n<p>I followed Joona&#8217;s steps, and queried the FMI API of snow depth observations at three weather stations in Lapland, from the beginning of 2012 to the end of 2014: Kilpisj\u00e4rvi, Saariselk\u00e4 and Salla. Note that you have to repeat the query year-wise because the API doesn&#8217;t want to return all the years in one go.<\/p>\n<p>Being lazy, I used the <code>get_weather_data<\/code> utility function by Joona as is, meaning I got more data than I needed. Here I filter it down to time and snow measurements, and also change the column name from &#8216;measurement&#8217; to &#8216;snow&#8217;<\/p>\n<pre>\r\nsnow.Salla.2014 <- salla.2014 %>%\r\n  filter(variable == \"snow\") %>%\r\n  mutate(snow = measurement) %>%\r\n  select(time, snow)\r\n<\/pre>\n<p>and then combine all data rows of one station:<\/p>\n<pre>snow.Salla <- rbind(snow.Salla.2012, snow.Salla.2013, snow.Salla.2014)<\/pre>\n<p>One of the many interesting new R package suites out there is <a href=\"https:\/\/github.com\/ramnathv\/htmlwidgets\">htmlwidgets<\/a>. For my experiment of representing time-series and weather stations on a map, <a href=\"http:\/\/rstudio.github.io\/dygraphs\/\">dygraphs<\/a> and <a href=\"https:\/\/github.com\/rstudio\/leaflet\">leaflet<\/a> looked particularly useful. <\/p>\n<p>Last time I was in Lapland was in mid-December 2014, in Inari, Saariselk\u00e4. BTW, over 40 cm of snow! During some trips I left <a href=\"https:\/\/www.endomondo.com\/home\">Endomondo<\/a> on to gather data about tracks, speed etc. I have to point out that I'm not into fitness gadgets as such, but it's nice to experiment with them. Endomondo is a popular app in its genre. Among other things it lets you export data in a standard GPX format, which is a friendly gesture. <\/p>\n<p>For the sake of testing how to add GeoJSON to a <code>leaflet<\/code> map, I needed to convert the GPX files to GeoJSON. This turned out to be easy with the <code>ogr2ogr<\/code> command line tool that comes with the <a href=\"http:\/\/www.gdal.org\/\">GDAL<\/a> library, used by the fmi R package too. Here I convert the skiing (\"hiihto\") route of Dec 14th:<\/p>\n<pre>ogr2ogr -f \"GeoJSON\" hiihto1214.geojson hiihto1214.gpx tracks<\/pre>\n<p>One of the many aspects I like about <code>dygraphs<\/code> is how it lets you zoom into the graph. You can try it yourself in my <code>shiny<\/code> web application titled (a bit too grandiously I'm afraid) <a href=\"https:\/\/ttso.shinyapps.io\/snow\/\">Snow Depth 2012-2014<\/a>. Double-clicking resets. To demonstrate what one can do with the various options that the R <code>shiny<\/code> package provides, and how you can bind a value to a <code>dygraphs<\/code> event - pick a day from the calendar, and notice how it is drawn as a vertical line onto the graph.<\/p>\n<p>The tiny, blue spot on the map denotes my skiing routes in Saariselk\u00e4. You have to zoom all the way in to see them properly.<\/p>\n<p>The shiny application R code is <a href=\"https:\/\/gist.github.com\/tts\/756c0d4f4a77d9d93654\">here<\/a>.<\/p>\n<p>Edit 11.1: Winter and snow do not follow calendar years, so added data from the first leg of the 2012 winter period.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Finnish Meteorological Institute (FMI) Open Data API has been with us for over a year already. Like any other specialist data source, it takes some time before a lay person like me is able to get a grasp on it. Now, thanks to the fmi R package by the collaborative effort of Jussi Jousimo and &hellip; <a href=\"https:\/\/tuijasonkkila.fi\/?p=222\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Snow in Lapland<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[149,146],"tags":[86,83,84,88,85,13,90,7,87,89],"class_list":["post-222","post","type-post","status-publish","format-standard","hentry","category-diverse-coding","category-travel","tag-dygraphs","tag-finnish-meteorological-institute","tag-fmi","tag-lapland","tag-leaflet","tag-r","tag-ropengov","tag-shiny","tag-skiing","tag-snow"],"_links":{"self":[{"href":"https:\/\/tuijasonkkila.fi\/index.php?rest_route=\/wp\/v2\/posts\/222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tuijasonkkila.fi\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tuijasonkkila.fi\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tuijasonkkila.fi\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tuijasonkkila.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=222"}],"version-history":[{"count":11,"href":"https:\/\/tuijasonkkila.fi\/index.php?rest_route=\/wp\/v2\/posts\/222\/revisions"}],"predecessor-version":[{"id":234,"href":"https:\/\/tuijasonkkila.fi\/index.php?rest_route=\/wp\/v2\/posts\/222\/revisions\/234"}],"wp:attachment":[{"href":"https:\/\/tuijasonkkila.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tuijasonkkila.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tuijasonkkila.fi\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}