How to Edit a Raster in a Photo Editing Program and Open it in QGIS

Ever work on a project where you can’t tell if you’re stupid or if what you want to do is legit hard? After plenty of consultation with peers it appears that the project I’m working on is a little of column A, a little of column B.

Everyone who plays around with QGIS is at some point going to manipulate rasters but I wanted to run a georeferenced image raster (like a map scan) through a photo-editing program and then reintroduce it to QGIS so that it is recognized, projected and drawn correctly in place.

Step 1. Clip the Nautical Charts

NOAA has this amazing collection of nautical charts that are archived both as PDF and georeferenced .KAP files with a BSB file of metadata. The KAP and BSB combined form a georeferenced file that we want- the PDF is just a pretty picture. The KAP shown is 18686. Each file is mixed with about 12 channels of color so I can turn them on and off with transparency individually which is pretty neat. I set the blue water and grey contour lines to transparent but the sounding numbers were a problem because I wanted to retain the nice, thick black outlines around the land but I wanted to get rid of the sounding numbers which are in fathoms and a little too archaic for my taste. I needed to edit the raster to delete the sounding numbers and extra text. I saved the KAP as a PDF in QGIS and opened the PDF in GIMP to clean it up a bit by cutting out all the parts I didn’t want to show up on my map (select by color: blue/gray/green>delete) and lassoed out the soundings and some of the annotation. It was time consuming and tedious but now it looked great and I saved the project. This is where it got confusing.

All dressed up with nowhere to go.

Step 2. Export Edited Image

I had a hard time exporting the edited raster as a TIFF that QGIS could read and draw correctly. Even though I had copied the projection from the NOAA PDFs, my edited rasters kept drawing off the coast of Baja. It was very frustrating.

The trick is this:

Open the original georeferenced KAP in QGIS and take note of the projection system. Then save it as a GTIFF.

Use the Raster>Conversion>Export Projection function to export PRJ and WLD file from the GTIFF. For some reason I found that I had to export the WLD twice. Huh. It only worked this way.

Copy the WLD file into a new folder. Export the TIFF raster that you edited in Gimp and put it here too. Now change the file names so that they’re both the same name just with different file extensions. Import the edited raster into QGIS and when the dialogue box pops up to ask you what projection the file should be displayed in, select the projection that was used by the georeferenced PDF. Your edited raster should draw correctly now. Save it as a GTIFF to capture all of the data together in one easy file.

Ta da!

To finish I wanted to add some terrain beneath my edited chart.

I combined a hill shaded bathymetric map with a singleband psuedocolor and added a 30% transparency to both. I grouped the layers and put them beneath the chart.

Not bad. I’m still working on this project and playing around with different bathymetric data sets and terrain textures so stay tuned to see what I put together. Happy mapping!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.