[R-sig-Geo] shapefiles, images, iimagemaps, and removing internal boundary lines

Roger Bivand Roger.Bivand at nhh.no
Thu Oct 19 09:32:12 CEST 2006

On Wed, 18 Oct 2006 matt.pettis at thomson.com wrote:

> I have sucessfully inputted a shapefile into a SpatialPolygonsDataFrame
> object.  I would like to output this file as a .gif/.png/.bmp/.jpeg
> image and generate an imagemap for the outputted image.  Does anybody
> know the best way to approach this?


gets you to:


This installs on R 2.4.0 from source - which platform are you using and
can you install source packages? The documentation in
imagemap/inst/doc/imagemap-howto.pdf is clear, addRegion(im) <- for each
clickable object. How to go from there depends on what you want to be

Alternatives might be Rpad:


or using ogr2ogr in FWTools (external software) to generate a KML for 
Google Earth (if the bubble that pops up is enough - I don't know how to 
put a link into it, though I guess it could be done), or writing the KML 
from R:


>  secondly (and i may need to start another thread for this), but is
> there an easy function to remove the interior lines of aggregated shapes
> (and generate an imagemap again, etc.)?  For example, If I have a map of
> the U.S.'s with a polygon for each state, could I remove all internal
> state boundaries to leave just the national border?

Using the objects you have now, you need to install the spgpc package:

rSpatial <- "http://r-spatial.sourceforge.net/R"
install.packages("spgpc", repos=rSpatial)

and install gpclib from CRAN. Then


to dissolve internal boundaries. This is for arbitrary polygons, if you 
really just need to dissolve US states, perhaps using the CRAN maps 
package with its built-in database, and its own dissolve mechanism would 
save re-doing topology, but it only works for polygons in the database.


> thanks,
> Matt
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no

More information about the R-sig-Geo mailing list