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.
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:0.5-lsseparate bias level for small features. Default:0.5-ilisland threshold level. Default:0.06-rRadius values for various generalization steps in pixels. Fractional values are allowed here. a total of five values separated by colons, their meaning isnormal:feature:min_water:min_land:island:collapse:collapse_mask:collapse_mask2. Default:4.0:2.5:1.0:0.5:1.0:0.0:0.0.-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-ls). Default:8:16:36:120-ngcDo not generalized connection pixels in the input data. Default: off-fcrRadius for fixing gaps between connection pixels and fixed mask. Default:0-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.
Since coastline_gen operates on raster images normal use of the program includes the following steps:
- Rasterizing the land polygons, for example using gdal_rasterize.
- Running
coastline_gen. - Vectorizing the resulting image, for example using potrace.
The makefile included in the source package contains a test target demonstrating this using sample data from OpenStreetMap. Running this test requires wget, GDAL and potrace.
This program is licensed under the GNU GPL version 3.
Copyright 2012-2013 Christoph Hormann