I'm using shapefiles of history U.S. state boundaries from NHGIS to make maps in R. These shapefiles are much higher resolution than I need when making maps at the scale of the country: over 2 million observations for one file. Is there a way that I can reduce the resolution of these shapefiles in R? If necessary, I can do it in QGIS instead.

  • Can you explain more. Resolution is associated to imagery. Do you mean there are too many nodes in a polygon, providing too much detail? Or is it that there are too many points in a point shapefile? – Ryan Garnett Sep 10 '13 at 14:56
  • 2
    @Ryan Although resolution is indeed associated with imagery, it is a concept that makes sense for vector data, too. For polyline and polygon features it can be estimated in terms of the number of vertices used per unit length of arc. Resolution cannot always be determined accurately by inspecting vector data (consider a set of high-resolution but widely spaced point features, for instance), whence resolution is typically found by consulting appropriate metadata. – whuber Sep 10 '13 at 15:06
  • I mean that there are many more points in the shapefile than is necessary to make a map of a nation. I would want that level of detail for making, say, a map of a city. The reason this matters to me is that it makes generating plots slow and thus time-consuming to iterate. – Lincoln Mullen Sep 10 '13 at 15:10

You can use gSimplify from the rgeos package, and if you add the topologyPreserve=TRUE flag it will preserve the topology.

Note that you can still end up with overlapping lines - we need an implementation of this robust D-P algorithm in R:


[that link possibly behind a paywall]


A standard method for "thinning" linear shapes (including polygon boundaries) is the Douglas-Peucker algorithm. At least two R packages implement this: dp in the shapefiles package and thinnedSpatialPoly in the Guerry package.

Note that thinning adjacent polygons typically creates slight gaps and overlaps in their boundaries: it does not respect the topological relationships among them. I am not aware of any R package that maintains topology while thinning. For small-scale mapping purposes like these that should not be a serious issue.

Incidentally, because nobody knows how to pronounce German anymore :-), Tom Poiker changed the spelling of his name a while ago.

  • You want to be very careful when you are "thinning" geometry. If you have multiple layers that share boundaries, thinning can create gaps, causing visual and accuracy errors. Over thinning can make boundaries jagged and over simplified. You will want to play and test with the tolerances within the simplify. – Ryan Garnett Sep 10 '13 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.