coastline_gen simple coastline generalization
This text describes the use of the
coastline_gen tool that implements a
simple raster based algorithm for generalizing coastlines or other polygon
features for map rendering.
Compiling the program
coastline_gen requires the CImg image
processing library to be built and should be compilable on all platforms
supported by the library. You need to download this library separately.
Copying CImg.h to the source directory is sufficient.
The package includes a makefile to simplify the built process.
the program offers the following command line options:
-iInput land water mask image file (required)
-oOutput image file name for the generalized land water mask (required)
-fInput image file containing a mask to restrict generalization. Has to be the same size as main input (optional)
-cInput image file containing a mask to collapse small features. Has to be the same size as main input (optional)
-sfspecifies how to interpret the fixed mask: 1: mask repels generalized features; -1: mask attracts generalized features.
-rfinfluence radius of the fixed mask in pixels
-lallows to set a bias in the coastline position. Larger values move the coastline to the land. Default:
-lsseparate bias level for small features. Default:
-ilisland threshold level. Default:
-rRadius values for various generalization steps in pixels. Fractional values are allowed here. a total of five values separated by colons, their meaning is
-isSize thresholds for special treatment of islands in pixels. First value: remove island smaller than this. Second: try to connect these islands to main land if smaller than this. Third: enlarge islands up to this size, Fourth: upper limit of island treatment (used for
-ngcDo not generalized connection pixels in the input data. Default: off
-fcrRadius for fixing gaps between connection pixels and fixed mask. Default:
-xcExtend connections. Default: off
-debugGenerate a large number of image files from intermediate steps in the current directory for debugging. Default: off
-hshow available options
All image files are expected to be byte valued grayscale images with land pixel values > 0 and water pixel value 0. Version 0.5 interprets values of 255 as connection pixels meaning they represent areas connected to the fixed mask (see below) You can use any file format supported by CImg. When using GeoTiff files you will get some warnings that can be safely ignored. Note though that coordinate system information in any file is not transferred to the output. If necessary you have to do that yourself.
The fixed mask image (option
-f) is interpreted inversely, i.e. pixel values of 0 are 'active' while values of 255 are 'inactive'. This way the
coastline mask can be used as is as a fixed mask for generalization of other land features.
In the collapse mask image (option
-c) values of 255 represent areas where small features ('islands') are to be collapsed depending
on the radius settings.
The program operates purely on the raster image and is unaware of the geographic coordinate system the data is supplied in. All parameters are specified in pixels as basic units.
Using the program
coastline_gen operates on raster images normal use of the program includes the following steps:
- Rasterizing the land polygons, for example using gdal_rasterize.
- Vectorizing the resulting image, for example using potrace.
This program is licensed under the GNU GPL version 3.
Copyright 2012-2013 Christoph Hormann