[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?

RSiteSearch("imagemap")

gets you to:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/28035.html

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
clickable. 

Alternatives might be Rpad:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77952.html

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:

http://bbs.keyhole.com/ubb/showflat.php/Cat/0/Number/221682/Main/219131

>  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

?unionSpatialPolygons

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.

Roger

>  
> 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