GPSFileDepot.com
 

News:

Welcome to GPSFileDepot!

Main Menu

Tutorial: Make your own forest shading/landcover

Started by Boyd, April 21, 2013, 01:14:13 PM

Previous topic - Next topic

Boyd

NOTE 6/5/23: Sorry, the illustrations for this post no longer exist and I no longer recommend this approach anyway. I believe you can download landcover from openstreetmap now.

Some of you know this has been a pet topic of mine.  :) After lots of trial and error, I have a procedure that I'm pretty happy with so I would like to share it. You will need Globalmapper and either Photoshop or Photoshop Elements (could also be done with GIMP I'm sure). The procedure is pretty straightforward but involves a number of steps that I will summarize below.

This tutorial assumes you have some basic knowledge of the NLCD and its color coding scheme, although I will show the exact process that I used.

First you need to download the 2006 NLCD imagery, which is one big file covering the entire US. I suggest you crop this down to a very small area for the purpose of experimenting because processing time can be significant with a large file. For example, one USGS 24k quad is about 500x500 pixels and will process pretty quickly.


This is what you should initially see in Globalmapper.


Right-click the image layer in the Control Center and create area features. This function creates polygons from raster images based on the criteria you specify.


I have decided to only extract two things from the image: forest cover and populated areas. I'll leave it up to you to work out similar techniques for extracting other data. Create a layer called forest using the option for selected colors, then choose the colors shown - Palette ID numbers 1, 3, 4, 5 and 8. These are different kinds of vegetation recognized by the NLCD.

After completing this, use the following options to extract the populated areas (which I will call "residential") - palette ID numbers 11, 12 and 13. I am also creating a new layer called residential for these.

This is what you should now see.

Change the Globalmapper background color to black - this will help isolate the colors in Photoshop.


Select all objects on the residential layer, specify a custom style with a null border and solid fill of primary red (RGB value of 255,0,0).

Repeat this for the forest layer using primary green as the fill (RGB 0,255,0). You should now see something like this

We will now export the results as a TIFF raster image using the following options. I am up-sampling the image in order to create a smoother final result (anti-aliasing). I find that 50 feet/pixel is a reasonable setting for a 24k map but feel free to try other values. Processing time and file size will increase with higher settings, lower settings may look too "jaggy". Also be sure to save a TFW and PRJ file or you will have a problem opening it in Globalmapper after modifying in Photoshop.

(continued in next post)

Boyd

NOTE 6/5/23: Sorry, the illustrations for this post no longer exist and I no longer recommend this approach anyway. I believe you can download landcover from openstreetmap now.

Part Two

Now we'll process the image in Photoshop (I am using Photoshop Elements which was included for free with a scanner I bought). Open the TIFF file and convert to RGB color.

Now apply a Gaussian blur. I've found that 2 pixels is a good number, but feel free to experiment with this.

Now switch back to indexed color, and this is where the "magic" happens. :)

Choose Local (Perceptual) for the palette with 3 colors. This will force photoshop to decide on whether each pixel is closest to red, green or black. Since we blurred everything, the result is creating rounded features to replace the stair-stepped image of the original.

Save the Photoshop file over the original TIFF (keeping the same filename) and be sure not to use any form of image compression. Now we return to Globalmapper and open the modified TIFF file. You must repeat the same procedure as before to "vectorize" the new image but it will be much faster this time because we only have 3 colors to deal with.

Again create a forest layer using selected colors and choose the green color from the palette. After the vectorization process completes, repeat the same steps to create a residential layer by choosing the red color from the palette.

The final steps are selecting the forest and residential objects and changing them to a Globalmapper type. If your goal is making a Garmin map, assign an appropriate MP_TYPE attribute to the results. I am using 0x01 for residential and 0x50 for forest. You can also choose USGS style mint green and pink colors to display in Globalmapper. You may want to merge the forest and residential layers into a single one, or maybe add them to an existing layer in a topo map. The rest is really up to you....

That's about all there is to it.  :)  Here are the final results viewed at 1:48000 when combined with other topo features.

And a closer view at 1:24000

Here you can see the landcover elements by themselves at 1:24000. There are some "jaggies" visible and you could smooth these by up-sampling the image more (such as 30 feet/pixel) but that will require more processing time for diminishing results. You may also get into issues where the edges of the residential and forest areas don't register very well when you increase the resolution.

Anyway, this is what I have learned and I felt it was worth sharing. Hope this helps you add a little color to your maps!  :)




Boyd

NOTE 6/5/23: Sorry, the illustrations for this post no longer exist and I no longer recommend this approach anyway. I believe you can download landcover from openstreetmap now.

Here's a little more information that may help you do other things with the NLCD data. First, this is the color code (note this is a .jpg and not color accurate, but it makes a good reference).

And here are the actual palette colors.

Finally, here are the colors in text format. Paste this into a notepad file, save it and change the extension to .pal. This will give you a palette file that Globalmapper should be able to open.

Enjoy!  :)


71,107,161
186,217,235
112,163,186
28,99,48
105,171,99
181,201,143
219,217,61
227,227,194
204,186,125
179,173,163
171,112,41
217,148,130
237,0,0
171,0,0
222,201,201
0,0,0

-Oz-

This is great.  How do you "mix" it with having actual National Parks/forests and the like?  I am thinking of doing this with my update to the AZ topo I'm working on.

Also, should we post this as a full up tutorial (since I can make that happen :)).
Dan Blomberg
Administrator - GPSFileDepot
GPS Units: Garmin Dakota 20, Garmin GPSMap 60csx, Nuvi 255W, Nuvi 250W, ForeRunner 110, Fenix 2, Tactix Bravo, Foretrex 401
See/Download My Maps!

Seldom

Quote from: -Oz- on April 21, 2013, 07:24:01 PM
This is great.  How do you "mix" it with having actual National Parks/forests and the like?  I am thinking of doing this with my update to the AZ topo I'm working on.

I've been doing wooded area using a similar GM script on Desert Southwest.  Wooded areas are a semi-transparent TYP.  Land ownership (Parks, BLM, etc.) are all mutually exclusive solid color polygons.  Adding paved areas or other types of landcover like paved areas would be a problem though, because patterns would get pretty complicated.

Boyd

I have not yet found a technique I like for combining forest shading and parks. I wanted to stick with a style like USGS, and they just use boundary lines, so that's what I currently have. But it leaves a lot to be desired, since you can't easily tell whether you're inside or outside of a park while zoomed in. The transparent pattern is probably the way to go, but I just haven't liked the tests I've done.

Oz, glad you like it - feel free to turn this into a "real" tutorial.  :)

Seldom

Nice idea to use gaussian blur in Photoshop.  :)  Whenever I used Photoshop to saveas TIFF, I needed to re-rectify, when I re-imported, because, although GM exported a geoTIFF, Photoshop stripped it of the reference data.  That was a long time ago.  Does it still do that?

Boyd

Yes, it's a problem but I addressed it in the tutorial. When exporting the TIFF in Globalmapper, choose the option to include a PRJ and TFW file. I guess that Photoshop strips the geo information that Globalmapper embeds in the TIFF, but if you have a separate PRJ and TFW with the same name, Globalmapper will automatically use them.

Quote from: Boyd on April 21, 2013, 01:14:13 PMAlso be sure to save a TFW and PRJ file or you will have a problem opening it in Globalmapper after modifying in Photoshop.


popej

Why don't you use vector functions instead of photoshop? Like for example "smooth" option form Global Mapper.


Boyd

I tried that before, and did not like the results. It created gaps and overlaps of adjacent objects. But that can be somewhat of an issue no matter how you approach the problem (converting stair-steps to a smooth line). I felt the blur combined with a limited palette produced the most visually pleasing results.

Really, the tutorial is just offered as one approach and also a way to get people thinking about different methods. I would encourage everyone to try their own ideas and post examples.

popej

Well, there are land cover data for Europe too, unfortunately already in shp format ;)

Boyd

Here in New Jersey we have high quality LULC data available as shapefiles also (at a scale of 1:12,000). But the whole reason I got interested in this project is the fact that I haven't been able to find any decent vector landcover data for other states (have looked for PA, NY, DE, MD, ME and others). There are some old DLG USGS files but they are only 1:250,000 resolution so not very good for a 24k map.  :)

nm_map_user

Quote from: Seldom on April 22, 2013, 08:14:16 AM
Nice idea to use gaussian blur in Photoshop.  :)  Whenever I used Photoshop to saveas TIFF, I needed to re-rectify, when I re-imported, because, although GM exported a geoTIFF, Photoshop stripped it of the reference data.  That was a long time ago.  Does it still do that?

As Boyd already noted, yes, Photoshop strips off the GeoTiff tags. In fact, almost every image editor will strip them off because they are viewed as non-standard tags so they are neither read nor re-written. Boyd has already explained how to address this in GM. For other tools that don't have this capability, you can use two programs from the GDAL package to save the header information and restore it. listgeo will read the tags and write them in ASCII to a file. geotifcp will read the tag file and insert the tags into a tiff file, making it a geotiff.

nm_map_user

It's possible to remap the colors of the entire NLCD in one shot using gdal_translate. The basic idea is to first convert the geotiff to a .vrt (virtual raster). This step takes essentially no time, as it just creates an XML file describing the key properties of the file. You then edit the .vrt file to change the palette to the one you want on output and add a look-up table to provide the mapping between input colors and output colors. With this done, you run gdal_translate again to generate a new geotiff with the new color palette. (It's actually easier than it looks written like that). gdal tools tend to work on very large rasters, so I suspect it is fully capable of processing the entire NLCD image in one shot. After that, you can skip right to the blurring step (presumably on an extracted tile), though I suppose it's possible that Photoshop might be able to handle the entire map as well.

If anyone is interested, I can provide more details on editing the .vrt file

Seldom

Should anyone be interested in a GM script to vectorize raster maps, GM 14 has a feature, EQUAL_COLORS, to restrict vector processing to just colors you are interested in rather than the entire map.  Using EQUAL_COLORS cut my processing time to 1/6th of what it was without it.

GENERATE_EQUAL_VAL_AREAS FILENAME="%FNAME%" COLOR_DIST=0.0 ATTR_NAME="COLOR" EQUAL_COLORS=RGB(105,171,099);RGB(028,099,048);RGB(181,201,143)

The code fragment is from a do-loop that processes all the TIFFs in a directory.

GENERATE_EQUAL_VAL_AREAS calls the processes that Boyd calls in the "Create area features" dialog above.  EQUAL_COLORS limits the processing to the 3 RGB colors that follow it.  Note that the colors listed are for the NLCD2006_landcover_4-20-11_se5.zip that covers the entire US.   They match the colors in Boyd's example, but they don't match the colors that I downloaded a year or two ago from the National Map Seamless server.    Figuring out why my old scripts weren't working took a while.  :-[