Created
          February 22, 2012 19:12 
        
      - 
      
 - 
        
Save jlehtoma/1886707 to your computer and use it in GitHub Desktop.  
    Dissolve polygons
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | library(rgeos) | |
| library(maptools) | |
| library(gpclib) | |
| if (!rgeosStatus()) gpclibPermit() | |
| gpclibPermit() | |
| # Read in the data | |
| fi.kunnat <- readShapePoly("fi_kunnat.shp") | |
| # Get the polygon coordinates (not sure what these are really) | |
| lps <- coordinates(fi.kunnat) | |
| # Divide the coordinates into 4 bins | |
| ID <- cut(lps[,1], quantile(lps[,1]), include.lowest=TRUE) | |
| # Dissolve the original SpatialPolygonsDataFrame into 4 bins | |
| reg4 <- unionSpatialPolygons(fi.kunnat, ID, avoidGEOS=T) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment