Skip to content

Generalize your data

Marjorie Roswell edited this page Jan 3, 2014 · 19 revisions

##Overview

Mike Bostock has a great demo showing this visually: http://bost.ocks.org/mike/simplify/

ScaleMaster Diagram

#Generalization Tools

  • MapShaper.org allows you to upload Shapefiles up to 16MB and generalize them interactively. Besides Douglas-Peucker, it offers Visvalingam-Whyatt, and a custom Visvalingam-Whyatt algorithm for extra smoothing. You then download your generalized Shapefile. The site is buggy and seems to work best with a Windows PC and Firefox browser.

  • Bloch - Python tool for simplifying linework in polygonal geographic datasources. Inspired by MapShaper.org, Bloch can load OGR-compatible data sources and simplify the linework while preserving topology. The simplify() method accepts tolerances in map units, so simplification can be performed by known amounts with predictable outcomes.

  • TopoJSON - TopoJSON is an extension of GeoJSON that encodes topology. Rather than representing geometries discretely, geometries in TopoJSON files are stitched together from shared line segments called arcs. This technique is similar to Matt Bloch’s MapShaper and the Arc/Info Export format, .e00. TopoJSON is substantially more compact than GeoJSON. A shapefile of U.S. counties is 2.2M as a GeoJSON file, but only 436K as a boundary mesh, a reduction of 80.4% even without simplification. TopoJSON can also be more efficient to render since shared control points need only be projected once.

##Inkscape

Inkscape is an OS app for vector graphics, particularly nice for SVG. Apparently it can generalize SHP files?

##Generalization in Adobe Illustrator

No standard method exists for generalizing vectors to give them the right amount of detail and look needed. Depending on the type of data and the quality, you will need to experiment with the techniques below to achieve the desired result. In some cases you may have to resort to manual digitizing—we had to manually digitize the fjord coasts of Alaska, Chile, and Norway for the 1:50m Natural Earth coastline. Creating the highest quality map data as efficiently as possible by whatever means trumps all other considerations. The generalization tools available in Adobe Illustrator have both strengths and weaknesses:

  • Adobe Illustrator/Simplify Path (curved option) – Drastically reduces points and drastically distorts geographic shapes. It places corner points where they are not wanted, creates inaccurate convex and concave shapes, and generalized lines cross where they shouldn’t. Use only at the lightest possible settings, 99 or 100 percent curve precision. Produces Béziers that must be converted to straight paths.

  • Adobe Illustrator/Simplify Path (straight path option) – Deletes points based on angle threshold, removing detail from smooth portions of lines and leaving busy portions unaltered—the opposite goal of map generalization. Best used at the 0 degree setting for simply converting Bézier paths to straight lines without reducing the overall point count.

  • MAPublisher/Simplify Lines – Applies the well-known Douglas-Peucker generalization algorithm. Produces good generalization results when applied lightly to regular shapes, such as the coast of Africa. It produces lines with an angular, very busy appearance when applied heavily to complex shapes, such as the coast of British Columbia. Small areas become two-point lines requiring manual deletion.

  • Round Any Corner (freeware script) – Applies smoothing to angular shapes such as those created by MAPublisher/Simplify Lines. Shapes consisting of lines intersecting at acute angles become slightly truncated in length. It produces Béziers and sometimes more data points than desired. A second very light application of MAPublisher/Simplify Lines will remove the Béziers and reduce the point count.

  • Remove Redundant Points - download (freeware script) – Useful for simplifying certain types of busy geographic lines. Creates Béziers in need of straightening.

##Production Tips

  1. Use existing Natural Earth vectors as a reference for generalizing and smoothing your data at 10, 50, and 110 million-scales.
  2. Vary generalization (with restraint) depending on geographic size and complexity. For example, Hawaii requires less generalization than Greenland.
  3. The Round Any Corner script smoothes everything selected. Snip lines with the scissors tool to avoid rounding straight lines with corners that are attached to curved lines, such as the Texas panhandle.
  4. Creating generalized lines with the minimum necessary data points is a desirable goal. So too is creating curved lines with enough points to appear smooth. You will need to find a balance between these two goals.
  5. Use Object/Path/Add Anchor Points (or the pen tool) to add intermediate points on straight lines.
  6. Use Live Trace to convert raster area data to vector shapes. Start with the technical drawing preset and then experiment with the various options. The urban areas found in Natural Earth were converted from raster land cover data in this manner. Live Trace is the only generalization tool in Adobe Illustrator that aggregates small polygons as coalesced, larger polygons.
  7. The Pathfinder Add to Shape Area and Divide tools are helpful for creating polygons from their constituent bounding lines. The Outline tool is useful for going in the opposite direction to break polygons apart. The Live Paint Bucket in the tool bar offers a quick way to create polygons from lines.

#Densify your linework

When your map is in Robinson or some other NOT in a cylindrical (Geographic and web Mercator are both cylindrical) projection, you may want to add intermediate points so your long straight-aways curve.

Note: Uses the units of your data store, here 0.5 degrees assuming Geographic.

ogr2ogr -segmentize 0.5 <out_file> <in_file>

Clone this wiki locally