Manual Raster Manipulation or, How Making Sh*t Up is Good Actually

Andrew Middleton
11 min readDec 2, 2021

I’ve been working on a project for a few years now and it feels like every few months I come up with a new way to make my maps a little better, a little more complicated and a lot more labor intensive. At no point are the maps ever more than a couple of days work to crank out but the iteration, learning curve and exhaustive trial and error have made this THE PROJECT THAT WILL NOT DIE. (Except it’s ready now and you can see them all here!) So here I am to chronicle a couple of the nifty little techniques that I’ve worked out to get some interesting results using open source software and a creative eye that gets a little dirtier than using command line raster modification. Like an irritating recipe website, you can scroll down to the bottom to cut right to the procedure but in the meantime, enjoy some narrative!

The Problem:

I make maps of the seafloor for scuba divers. I want people to be able to visualize both features on the shore and terrain underwater to help divers find cool places to visit in an environment where navigation is very difficult and often relies on lining up objects on shore to eyeball a location on the water rather using a waterproof GPS unit. For this explainer I’m working on Point Lobos State Park on the north end of Big Sur, California.

This is Whalers Cove at Point Lobos courtesy of Bing Virtual Earth

Where it starts

The first thing I need is sonar data of the sea floor. Everyone has imagery of the land but the underwater stuff is harder to come by. It is out there though. Sonar data is tricky. The better the equipment, the heavier it is. The heavier it is, the bigger the boat it takes to cart it around. The bigger the boat, the deeper the water it needs to stay afloat. While mapping the open ocean is a big job that has been a subject of international scientific cooperation for centuries, in recent years it has been far easier to map the deepest depths than the rocky and shallow coastline of California where thousands of shipwrecks lie testament to the shallow reefs, wave-crashed rocks and thick fog of nearshore navigation. Since I’m making maps for scuba divers, I really only care about the water shallower than 200 feet deep and that’s the toughest water to survey.

Fortunately for me, the CSUMB Seafloor Mapping Lab did most of the legwork for me. They mounted a sonar unit on a shallow draft boat called Kelpfly and were able to get very high (~1m) resolution imagery for most of the extents that I was interested in, including very, very close to shore.

Kelpfly in action. I really wish I got to be involved in this process.

As a quick aside, the Bay Area Underwater Explorers group even took that sonar data and made a CNC mold which they used to cast a concrete bathymetric map of Whalers Cove. It’s been mounted at Point Lobos ever since to the delight of divers and landlubbers alike.

From Sport Diver

The data are incomplete though. Those weird smooth patches in the concrete map aren’t all smooth sand- some of those patches are gaps where no data were collected. All of the mountains are sheared off at the high tide mark and the land is shown as a perfectly flat footprint because they didn’t align sonar data model with a terrestrial one so you can’t see the smooth continuity of landscape above and below the surface. This map is super cool to see in person and there’s nothing that beats a good tactile map, but it does a poor job of showing the regions we couldn’t directly measure.

Hillshade of raw CSUMB Seafloor Lab data

The data they used looks like this. I wanted to flesh out the scene a bit more.

Seafloor composite made of terrestrial LiDAR data from USGS and bathymetry data from GEBCO and CSUMB

I found LiDAR data and converted them into a DEM so that I had some fine land topography and then used a low resolution terrain model to fill in the gaps like a stitched together Frankenstein or using frog DNA to fill in incomplete dinosaur gene sequences. You can see in this model I made that there’s AMAZING land detail, great seafloor detail in some places and GARBAGE data in others places and basically any time the data set edges were touching there were artifacts. The seams where the different rasters meet have these little ridges that are pretty irritating and have to go.

Where it gets hard

I started brushing on the right and you can see the artifact ridge as a lighter line with a sharp contrast there on the left side of the image.

So how do I get rid of those ridges that the computer invented and don’t actually exist? Well, a Digital Elevation Model is a raster image and using software for editing photographs works just as well. First I extracted a .WLD file from my big Frankenstein raster so I could locate my raster later. Then, I opened the raster as a TIFF in GIMP and stretched the range of values to the maximum with the contrast adjustment so I could see very small differences in value between adjacent pixels. I used a wide, blurry-edged brush to buff out my artifacts. This was a long, manual process.

Composite with mask cut from Bing Imagery

Next, I made a georeferenced cutout of the land in GIMP so I could make a mask of satellite imagery. I added a Bing satellite layer to a QGIS layout and exported the image with a .WLD file. I opened this file in GIMP and manually lassoed out all of the water before saving the new file as a TIFF that I could pair with the .WLD and read to QGIS.
But when I added the land mask, I noticed that there are some rocks and islands that show up on the satellite but not in the sonar. They look like they’re hovering over a flat sea floor. The boat carrying the sonar unit had to navigate around all of the obstructions and missed out on those spots.

And this is the part where I have to make stuff up.

Brief Thematic Aside

A map is supposed to tell a story or help the reader understand something. In my case, I wanted to evoke what the bottom of the ocean looks like and how a diver might encounter it without necessarily getting wet or being there. What I’ve produced is simplified and scaled and colored and modified but the hope is that when it’s done, the parts that I more or less invented will improve the readability of the map even if it doesn’t necessarily improve the accuracy of the map.

Tharp with several maps she helped to create

Marie Tharp knew this intimately and today she is recognized as having produced some of the most famous maps ever made. Hers were not the first maps of the seafloor nor were they the most accurate. In fact, they’re not particularly accurate at all. What Tharp should be remembered for is what she made up.

Humans have been laying cables across the Atlantic Ocean since the 19th century. In 20,000 Leagues Under the Sea, the submarine Nautilus visits and investigates a transatlantic telegraph cable on the seafloor in the year 1868. But these cables were prone to breaking down and by the mid twentieth century there was great interest in laying more durable and reliable cables that could carry more kinds of electronic information. While ships were dispatched to unreel thousands of miles of cable onto the sea floor in the 1950s, Tharp was a geologist who painstakingly analyzed the data about sea floor depth that came back as the ships sailed from continent to continent sounding the depths with sonar. From these tiny, narrow ribbons of data mostly travelling East and West between the North America and Western Europe, Tharp noticed a pattern: somewhere in the middle of the ocean these transects would, at some point, meet what appeared to be a long, narrow mountain chain that seemed to unzip the bottom of the ocean in a configuration that could be very neatly explained by tectonic plate theory, then an idea that was largely sneered at by American geologists. She had discovered the hypothesized Mid Atlantic Rift.

Resampled composite with manually adjusted elevation. I wonder how long it would take to discover the Mid Ocean Rift the principle communication across the ocean were north and south instead of east and west.

For the next several decades, Tharp extrapolated immense detail of the seafloor from these limited transect surveys, assisted by her husband and collaborator Bruce Heezen and the Swiss cartographer Heinrich Berann she hired to bring life to her research. All of those mountains and fine details between the measured data points are the product of Marie Tharp’s exhaustive geological knowledge and her own imagination. You will never visit any mountain on her maps of the ocean but you can visit thousands that are very similar. She was right in the ways that count: her iconic maps are largely credited with the subsequent swift adoption of tectonic plate theory in the United States because it illustrated a broader idea, not a specific reality. In many respects, measuring a mountain to make a map of it is quite a straightforward task compared to making a detailed schematic of a huge, pitch-black room using only a lit candle. That Tharp did this with the world’s oceans, and was largely right about it, is a testament to her knowledge of geology and her imagination.

Marie Tharp and Bruce Heezen made maps like this that were illustrated by Heinrich Berann

As a final note: It is tempting to create a character of solitary feminine heroism from Marie Tharp’s story. She fought a misogynistic boys club that literally would not let her on the ships that collected her data yet she became an essential part of one of the most important topplings of scientific paradigm in the twentieth century. Her recognition is long overdue but the truth is that Tharp was no lone genius. She was determined, smart, stubborn and in the right place at the right time like all visionaries are. We mustn’t replace the myth that women haven’t been doing science this whole time with the even more pernicious myth that science is propelled forward by singular genius. Tharp’s story is one of hard work, interdisciplinary collaboration between art and science as well as uncommon intellect. But I digress.

Making Sh*t Up for Art and Science

I exported my clipped Frankenstein raster to a TIFF and opened it in GIMP where I used a large spray paint brush with a gradient to manually add slope to the DEM under the islands I could see on the satellites to create slopes I presumed were there and at least make those islands look like they’re attached to the seafloor. I did the same to the beach where the raster makes it look like there was a dramatic dropoff into the sea instead of a smooth, beachy gradient. Then I resampled the image to a lower resolution and smoothed the surface so it didn’t look so blocky and pixelated and to cover up my heavy brushstrokes. To bring the raster back to QGIS and use it as a DEM, I reunited the touched up TIFF with its .WLD file and reregistered the pixel values into elevation values using the Raster Calculator tool. I knew that my DEM represented a 180 foot range in elevation and I knew what the range of gray values in my image was so I was able to make every change in color the correctly scaled change in elevation and then just shift the raster values down so that values below sea level are negative. This is important to do so that my contour lines come out as pretty as the raster did.

There! Now those islands actually have some slope attached to them. The pinnacles go straight to the bottom like papier-mâché volcanoes and the beaches have dramatic rounded slopes but it’s less wrong. When I run a contour line analysis, the contour lines don’t pass through what is obviously land. It works.

The completed image, available for purchase here.

I’ve smoothed and generalized and even added terrain that I can only guess at but I don’t feel too badly about it. I did, after all, present a talk a few years ago called “How Maps Lie” to a group of museum educators in 2017. The colors, the orientations, the perspectives and the illustrations of all the other maps I’ve made are fabrications, some of them are just useful. I wonder what Marie Tharp would have thought…

More Detailed How-to: Satellite imagery mask

I figured that a good thing to do would be to create a smooth transition where the satellite imagery of the land fades into the bathymetry underneath. This would all the color and texture of the beach to fade into the topography and mask somewhat the fact that the this transition zone is usually pretty weak on detail.

  1. Open up a basemap imagery layer (in my case I used Bing) and zoom in to the region of interest. Export the image as a geotiff using the Export Image function under the file menu. This is basically a georeferenced screengrab.
  2. Then, open up your newly saved file as a raster and add it to your canvas. You can turn off your basemap and see your georeferenced image locked into the right area of the planet due to the location data saved into the geotiff file.
  3. Because we are going to modify the image, we need to separate the geotiff file into a .WLD and a .TIFF so use Extract Projection in the Raster menu and save it with the .WLD.
  4. Now we can open the .TIFF in our favorite image manipulation software. I tried a couple of different approaches. First I used a lasso tool in GIMP to create a simple cutout like clipart from a magazine. Because the very shallow water at the beach is transparent, it was kind of hard to decide sometimes where to draw the line between land and water so I tried another one with Inkscape. There I used a bezier curve to create a mask polygon with solid fill and no outline and an edge blur of about 20%
  5. No matter how you modify the image, you can export it as a TIFF to a new folder. Then just drop in the .WLD from the initial export and modify the file names so they all match.
  6. Now you can add your mask to the QGIS canvas.