Geo-spatial data in Scratch

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’re normally small or specific questions – asking for help figuring out a bug in a Scratch project or how to get something working.

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 plot points on the map, given coordinates in latitude and longitude.

I agreed to give it a try. (Details for how to access it below.)

It was harder than I expected to get it working.

There were two main challenges.

  1. The code I wanted to write was more complicated than I could express with Scratch blocks.

    So I cheated, wrote it in JavaScript, 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).

    I’m sure it could be done in Scratch, but I didn’t have the time to figure it out – this was just a thousand times quicker for me.

  2. Turning latitude and longitude coordinates from a not-flat Earth into 2D coordinates for a very-flat screen is a pain.

    I know I’m stating the obvious, but map projections are hard. I’m sure my implementation would make any cartographer shudder, but I only needed it to roughly work (the Scratch canvas coordinate system is only 480×360 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’d charitably describe it as a quick-and-dirty hack, but that was all I had time for.

I’ve put the whole thing on GitHub in case it’s useful to anyone else.

If you know how to convert lat/lon coordinates to a map x/y coordinates properly, I’d welcome any fixes!

And if you’d like to give it a try:

Finally, a request. I’m trying to think of something I could use this for myself. Naturally, I’d like to do something using machine learning that would be simple enough for a student project. But I’m stumped for ideas.

Can you think of something?

What dataset would lend itself well to a simple use of machine learning and could be represented on a map?

The only idea I’ve had so far was to find some simplified subset of UK Census data, that would have an obvious geo-spatial correlation you could train a predictive model to recognise, and display on a map.

But I can’t think of anything that would work.

Any suggestions would be very, very welcome.


Leave a Reply