{"id":3973,"date":"2019-11-13T00:16:12","date_gmt":"2019-11-13T00:16:12","guid":{"rendered":"https:\/\/dalelane.co.uk\/blog\/?p=3973"},"modified":"2019-11-13T00:26:27","modified_gmt":"2019-11-13T00:26:27","slug":"geo-spatial-data-in-scratch","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=3973","title":{"rendered":"Geo-spatial data in Scratch"},"content":{"rendered":"<p><strong>In this post, I want to share a random thing I made in Scratch this week, and ask for suggestions of what I could do with it.<\/strong><\/p>\n<p><a href=\"https:\/\/raw.githubusercontent.com\/dalelane\/scratch3-uk-map-extension\/master\/example.png\"><img decoding=\"async\" style=\"border: thin black solid\" src=\"https:\/\/dalelane.co.uk\/blog\/wp-content\/uploads\/2019\/11\/example-small.png\"\/><\/a><br \/>\n<a href=\"https:\/\/raw.githubusercontent.com\/dalelane\/scratch3-uk-map-extension\/master\/example.png\"><small><em>Click for larger version<\/em><\/small><\/a><\/p>\n<p>I get a lot of emails from teachers and coding groups asking for help with <a href=\"https:\/\/scratch.mit.edu\/\">Scratch<\/a> projects. They&#8217;re normally small or specific questions &#8211; asking for help figuring out a bug in a Scratch project or how to get something working.<\/p>\n<p>But this week I got a more challenging email. It asked for a way to show a map in Scratch, and use a Scratch script to <strong>plot points on the map, given coordinates in latitude and longitude<\/strong>.<\/p>\n<p>I agreed to give it a try. (Details for how to access it below.)<\/p>\n<p><!--more-->It was harder than I expected to get it working.<\/p>\n<p>There were two main challenges.<\/p>\n<ol>\n<li>\n<strong>The code I wanted to write was more complicated than I could express with Scratch blocks.<\/strong><\/p>\n<p>So I cheated, <a href=\"https:\/\/github.com\/dalelane\/scratch3-uk-map-extension\/blob\/master\/extension.js\">wrote it in JavaScript<\/a>, and put it in an extension. (That meant the code I wrote in JavaScript was represented as a couple of new blocks in the Scratch palette, that I could just use as-is).<\/p>\n<p><em>I&#8217;m sure it could be done in Scratch, but I didn&#8217;t have the time to figure it out &#8211; this was just a thousand times quicker for me.<\/em><\/li>\n<li>\n<strong>Turning latitude and longitude coordinates from a not-flat Earth into 2D coordinates for a very-flat screen is a pain.<\/strong><\/p>\n<p>I know I&#8217;m stating the obvious, but map projections are hard. I&#8217;m sure <a href=\"https:\/\/github.com\/dalelane\/scratch3-uk-map-extension\/blob\/master\/extension.js\">my implementation<\/a> would make any cartographer shudder, but I only needed it to roughly work (the <a href=\"https:\/\/dalelane.co.uk\/blog\/?p=3795\">Scratch canvas coordinate system is only 480&#215;360<\/a> so precision was never going to be an option) and only for a relatively small area (they wanted it to work for a UK map, not a world map). I&#8217;d charitably describe it as a quick-and-dirty hack, but that was all I had time for.<\/li>\n<\/ol>\n<p>I&#8217;ve <a href=\"https:\/\/github.com\/dalelane\/scratch3-uk-map-extension\">put the whole thing on GitHub<\/a> in case it&#8217;s useful to anyone else.<\/p>\n<p><em>If you know how to convert lat\/lon coordinates to a map x\/y coordinates properly, I&#8217;d welcome any fixes!<\/em><\/p>\n<p><strong>And if you&#8217;d like to give it a try:<\/strong><\/p>\n<ul>\n<li>Download this <a href=\"https:\/\/github.com\/dalelane\/scratch3-uk-map-extension\/raw\/master\/uk-map-demo.sb3\">sample project file<\/a><\/li>\n<li>Open it in <a href=\"https:\/\/machinelearningforkids.co.uk\/scratch3\/\">a version of Scratch with my extension loaded<\/a><\/li>\n<\/ul>\n<p>Finally, a request. I&#8217;m trying to think of something I could use this for myself. Naturally, I&#8217;d like to do something using <a href=\"https:\/\/machinelearningforkids.co.uk\/\">machine learning<\/a> that would be simple enough for a student project. But I&#8217;m stumped for ideas.<\/p>\n<p><strong>Can you think of something?<\/strong><\/p>\n<p>What dataset would lend itself well to a simple use of machine learning and could be represented on a map?<\/p>\n<p>The only idea I&#8217;ve had so far was to find some simplified subset of <a href=\"https:\/\/census.ukdataservice.ac.uk\/\">UK Census data<\/a>, that would have an obvious geo-spatial correlation you could train a predictive model to recognise, and display on a map.<\/p>\n<p>But I can&#8217;t think of anything that would work.<\/p>\n<p>Any suggestions would be very, very welcome.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, I want to share a random thing I made in Scratch this week, and ask for suggestions of what I could do with it. Click for larger version I get a lot of emails from teachers and coding groups asking for help with Scratch projects. They&#8217;re normally small or specific questions &#8211; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3974,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[536],"class_list":["post-3973","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code","tag-scratch"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3973","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3973"}],"version-history":[{"count":0,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3973\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/media\/3974"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3973"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3973"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3973"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}