You are currently browsing the tag archive for the ‘Quantum GIS’ tag.
I’ve been playing video games since – well, since there have been video games.
Sort of. Technically, the first video game patent was granted in December of 1948 (well before I was born), but I – like most of the world – consider Pong to be the first real video game. And Pong hit the shelves in 1972.
So I have seen video games come and go, and I’ve played a fair number of them. I don’t have a favorite (or even a favorite genre), but there have certainly been games I have loved. The Legend of Zelda. Sonic the Hedgehog. Civilization III. Final Fantasy VII. Half-Life 2. A few video games have even gone so far as to have had a genuine emotional impact on me (if you know who Aeris or Eli Vance are you know what I’m talking about). Others have forced me to think to a degree I never expected from a video game (it took me days to fully unravel and digest the final events of BioShock Infinite). In fact, I would posit that video games are currently on the brink of (if not in the midst of) a process similar to that undergone by cinema about a century ago, more recently by comic books: transforming from a diversion into a viable (even respectable) medium for storytelling.
Of course, not all video games tell a story, which should not be considered a shortcoming. Some – by design – leave you to your own devices (to varying degrees). This is called ‘nonlinear gameplay’, and it comes in a variety of forms. My personal favorite is what they call ‘sandbox’ games. Basically, sandbox games give you a world (or a situation) and a set of rules and then leave you to master your own fate. Kind of like this series of random and happy events we call “life”. Minecraft is probably the best known sandbox game on the market today. It is certainly my favorite.
To be honest, though, I probably never would have played Minecraft if it wasn’t for my son. He started playing, and since I’m one of those annoying parents that actually likes to engage in activities with my child, I joined in. I’m glad I did. And I highly recommend it.
Minecraft has a multiplayer mode, which is easy to access and enjoy with a friend or loved one if you happen to have the console version of the game. If you have the PC version of the game, multiplayer games can be realized over your LAN or by accessing a server. As you may or may not know, accessing most online servers for gaming is much like entering Mos Eisley. They tend to be cesspits. However, on this front Minecraft really comes through for us. Running your own server is as easy as opening a port in your router and running a simple .exe on a computer. I have a Minecraft server running on an old computer in my home office, which is further whitelisted so that only my son and his buddies can play on it. You can also run a Minecraft server on an Amazon EC2 or on Openshift, if you’re so inclined. When it comes to controlled multiplayer experiences, Minecraft really is the Video Game Promised Land. And since multiplayer games are collaborative and creative, awesome things can result.
Being a Map Dork, it was only a matter of time before I decided to recreate our town as a playable world for Minecraft. I had heard rumors about GIS data being translated into Minecraft, so I figured I’d try my hand at it. What follows is a discussion of the process I eventually went through and a few of the things I learned along the way. This is not a tutorial of any kind, or even instructions. The first thing I learned is that the process is intensely enslaved to the particular location chosen. As usual, the landscape dictates the rules by which we must engage it.
At first, I went at this task in full Map Dork mode. I had heard of some instances of this being done – entire countries, in fact. Great Britain has been done, as has Denmark. I was also aware that Minecraftery was possible using FME, and a minimal amount of searching led me to detailed instructions for doing so. So I amassed a bunch of data, fired up FME and had at it.
The results were less than satisfactory. I cannot say whether this was due to a shortcoming on my own part, a drawback of the software, or simply crossed purposes. I initially suspected the first case, but I am now leaning toward the last. Looking at the models of Denmark and Great Britain, as well as the FME directions, it would appear that the GIS approach to Minecraft is to use it for building scale models, ostensibly for use for municipal planning and similar nefarious purposes. I, however, wanted more to build a virtual playground for my son and his friends, modeled on our town. The idea was to produce something they could virtually walk around in and explore, not just look at and admire. Which led me to conclude that the GIS approach would not get me where I wanted to go. Another pitfall of the GIS approach is the assumption that most (if not all) of the cartographic heavy lifting can be done procedurally. Some jobs are best done by hand (it is worth noting that in the end this project required a rather large commitment of time and energy on my part. Of course, in my experience dedicating enormous amounts of time and energy to pastimes that only marginally interest you pretty much defines ‘parenthood’). So I decided to abandon my usual modus operandi and looked instead for a Minecraftian approach.
There are a variety of Minecraft world building/editing programs out there (you can find a good list here). The one I eventually decided to use is called WorldPainter. I decided upon WorldPainter mainly for two reasons: It allows for importing heightmaps and it also allows for using semitransparent overlays on top of said heightmaps. In total I used three programs (four if you count Minecraft itself) for Minecrafting Greenfield. Quantum GIS, Photoshop (simply a matter of personal preference. Any image editor/manipulator would probably suffice), and WorldPainter. First, I loaded GIS data into Quantum GIS, tweaked it to my purposes and then exported it as various rasters. Next I used Photoshop to alter and/or combine the various rasters for use in Worldpainter. Lastly I either imported the rasters directly into WorldPainter, or used them as overlays for guiding further landscape manipulation. WorldPainter exports Minecraft worlds directly into the folder Minecraft looks to for saved worlds.
Maps are often built in layers, and the order of the layers is both logical and important. Usually when I make a map I start from the bottom and work my way up. As an (oversimplified) example, a typical map would start with topography (the bare shape of the land), overlain by hydrography (lakes and streams), then roads and buildings. Lastly, I might put on some borders (if appropriate) and labels. In this way features are layered as they are in the real world (we tend to put our roads on bridges over streams) or in the fashion that makes most sense for the map (borders and labels overlying the features they inform or delineate).
Minecraft, however, has its own set of rules. It has physics (of a sort), but physics that are only vaguely similar to the physics that operate in reality. For example, water flows downhill, it follows the path of least resistance, and it seeks it own level. Minecraft only really understands the last of these. If you tell Minecraft that there is a stream halfway up a mountain, it will want to fill the entire landscape up to that level. It views your ‘world’ as a flat plain with bumps on it, not as a small portion of a quasi-spherical planet.
An important point to remember is that I was not trying to replicate our town. We’re dealing with Minecraft here, which can be fairly well described as the LEGO of video games. My goal was to create a recognizable representation of the town – a Close Facsimile Thereof. So don’t get upset when I play fast and loose with data.
All the data I used for this project came from MassGIS and OpenStreetMap. My two go-to sources for geospatial data. I started with a basic heightmap, generated myself using 1:5000 contours from MassGIS. I used this heightmap mainly because I already had it, but in fact it was far more detailed than I needed for this project. A NED DEM at virtually any resolution would probably suffice (but you might as well get the best resolution you can get your hands on because why not?). To complete my initial basemap I also used a hydrography polygon shapefile (from MassGIS) and a 2D shapefile of building outlines (this one from OpenStreetMap. MassGIS has a fine one, but OSM tends to have more current data, and there are a couple of new buildings in town I wanted to be sure to include).
I know. It sounds strange that I’m including buildings at this point. Bear with me. WorldPainter works best if we give it as much three-dimensional information as we can from the outset.
A Minecraft landscape has a maximum height of 256 blocks, and a Minecraft block represents roughly one cubic meter. Luckily, my neck of the woods is hilly but not very high. The change in altitude in my area of interest is just over 300 meters, which is close enough to Minecraft’s 256 that I can call it even with a straight face (remember – we’re just building an approximation here). After loading my chosen DEM into QGIS, I went with this ‘scale’ by zooming in to an area roughly 10 kilometers square. I then created a new Print Composer, set the size to 210 mm x 210 mm and set the resolution to 1200 dpi (this makes for rather large exported images, but when it’s all said and done they scale to roughly 1 pixel = 1 meter).
I decided to deal with the aforementioned hydrography problem by simply cutting water features more deeply into the landscape (I was afraid that this would result in ridiculous chasms in the higher elevations of the project area, but the effect turned out to be less severe than I had expected. Besides – we are talking about a video game here). I opened my hydrography polygon layer in QGIS and created a smaller version of it by negatively buffering it. I then exported images of each hydro layer in turn. Opening the DEM in Photoshop, I brightened the whole thing slightly so that the hydro layers could dominate the lower end of the spectrum. I set the image of the original hydro layer to an RGB slightly darker than the lowest end of the DEM, the buffered hydro layer slightly darker than the original hydro layer. I then merged the three layers into a single landscape. For a final touch I put a bit of a Gaussian blur over the whole thing, to keep WorldPainter from building cliffs at every elevation change.
Lastly, I put every building in town on the DEM. I didn’t want them all to just be flat, one-story affairs, so I first separated them out by number of floors. Luckily, there are no buildings in our town taller than 4 floors, and the only 4-story buildings are on Main Street. So I used QGIS to separate the buildings into separate layers of 1, 2, and 3 floors. I further subdivided these into flat-roofed or sloped-roofed layers (Main Street I did entirely by hand, since I wanted it to be more easily recognizable to the kids. Besides, it’s only one road barely over a kilometer long). Since the buildings rest upon various elevations (rather than a fixed one), I used QGIS to export a simple black and white image of each layer in turn. These I placed over the base DEM in Photoshop, using the building images to select the buildings. I then used that selection to copy the appropriate portion of the original DEM, which I then pasted onto a new, blank layer. I then adjusted the brightness of the new layer according to the size of the buildings (at the scale I was working at, I found a Brightness of +8 worked for single floor buildings, +15 for two-story buildings, +21 and +28 for 3- and 4-floor buildings, respectively). I further used Photoshop’s blending options to apply a radial gradient to the sloped buildings, giving them an appearance of peaked rooftops (I use ‘appearance of’ only in the grossest sense. When you only have blocks to work with, you can only get so close to an actual ‘slope’).
Once I had all of these layers situated, I stacked them all up in Photoshop and merged them into a single basemap (I also resized all the rasters to 9984 x 9984 px in Photoshop. WorldPainter behaves much better if you give it rasters of a size divisible by 128. I could have achieved the same thing by adjusting options in the Print Composer of QGIS, but I didn’t realize the need until I had everything in Photoshop).
I then imported this combined raster as a heightmap into WorldPainter. I set the water level to 0 (it defaults to 62, but I wanted a dry map, planning to add the water manually in the following step). I also removed the noise and beaches, and I deleted all the materials but Grass, which I switched to Bare Grass (overwhelmingly, the area I chose to build is forested, but the forests would come later. As a secondary choice, I figured universal lawn as a starting point made sense for this project).
Yes – I now had a town consisting of buildings made out of grass-covered dirt.
But that’s okay. I had plans. Just after I finished the water, which is up next.
Believe it or not, the basemap was the easy part. From then on I had to do most of the heavy lifting myself. But we’ll get to that next time.