gSimplify not simplifying shapefile in R

I'm unable to simplify a shapefile in R

Shapefile from here: https://geoportal.statistics.gov.uk/Docs/Boundaries/Local_authority_district_(GB)_2014_Boundaries_(Generalised_Clipped).zip

library(tmap) library(maptools) library(ggmap) England <- readOGR(dsn = "...") #works fine print(qtm(England, "LAD14CD", borders = NA, fill.title = "A-Level" )) # simplify the polygons England<-gSimplify(England,tol=0.01, topologyPreserve=TRUE) print(qtm(England, "LAD14CD", borders = NA, fill.title = "A-Level" ))

Gives an error of:

Error in process_fill(data, g$tm_fill, gborders, gt, gf, z = z + which(plot.order == : Fill argument neither colors nor valid variable name(s)

If you look at the UK dataobject you can see that it has changed from a Large Spatial polygonDataFrame to Large Spatial Polygons and dropped the @data

Instead, if you try to only simplify the polygons in the Shapefile:

England@polygons<-gSimplify(England@polygons,tol=0.01, topologyPreserve=TRUE)

It says that:

Error in gSimplify(England@polygons, tol = 0.01, topologyPreserve = TRUE) : cannot get a slot ("proj4string") from an object of type "list"

How can I simplify the polygons from a shapefile?


The return from gSimplify is just the geometry, not the attributes, so you have to construct a new SpatialPolygonsDataFrame with the simplified geometry and the attribute data from the original:

> England2 <-gSimplify(England,tol=0.01, topologyPreserve=TRUE) > England3 = SpatialPolygonsDataFrame(England2, data=England@data)

I think the polygons are guaranteed to be in the same order, unless anything has been simplified away. Check length(England2) has the same number of rows as England, or match up the rows on an ID.


  • Leaflet/shiny: cannot draw reactive polygons
  • Change the language of Yes/No buttons in vba dialog
  • Delphi XE3, ugly StringGrid's borders
  • Editing border of one side in a cell without CSS, only with HTML/XHTML?
  • Zend\\ServiceManager\\ServiceManager::get was unable to fetch or create an instance for getAlbum
  • Error in opening an Access database in python
  • Gnuplot multiplot: Convenient method for creating more complex layouts
  • CSS transition glitch
  • pandas computation in each group
  • How to estimate the Kalman Filter with 'KFAS' R package, with an AR(1) transition equation
  • Plotting line graph with factors in R
  • Invalid object name 'dbo.Item'
  • nonblocking BIO_do_connect blocked when there is no internet connected
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • Query to find the duplicates between the name and number in table
  • Excel's Macro-Recorder usage
  • What and where is mdimport
  • zope_i18n_compile_mo_files doesn't work on a Zeo configuration
  • How do I get HTML corresponding to current DOM tree?
  • PHP buffered output depending on server setting?
  • Why does access(2) check for real and not effective UID?
  • Is it possible to access block's scope in method?
  • Meteor helpers not available in Angular template
  • MongoDB in PHP using aggregate to group by _id is null not working
  • Retrieving value from sql ExecuteScalar()
  • Display issues when we change from one jquery mobile page to another in firefox
  • Can Jackson SerializationFeature be overridden per field or class?
  • How to recover from a Spring Social ExpiredAuthorizationException
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • ILMerge & Keep Assembly Name
  • Redux, normalised entities and lodash merge
  • Large data - storage and query
  • To display the title for the current loaction in map in iphone
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • WOWZA + RTMP + HTML5 Playback?
  • Matrix multiplication with MKL
  • Android Studio and gradle
  • trying to dynamically update Highchart column chart but series undefined
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • Unable to use reactive element in my shiny app