[R-sig-Geo] adding new maps to map, mapdata, mapproj; archive of R-sig-geo

Galkowski, Jan jgalkows at akamai.com
Tue Dec 18 21:14:22 CET 2007


Thanks for your suggestions, Roger and Tom.  

I found something that'll work for now, a cheat in a way.

If you create a sphere with rgl, you can map a texture to it.  So, if I
create a high resolution texture image, I can drape that over the sphere
and automatically get the transformation I want, assuming I start by
creating the image on the rectangle with a Mercator projection.

Now I need to implement a Stripack Voronoi tessellator in R so it knows
how to generate a dataset from which I can recover the latitudes and
longitudes into the image.

 - j 

-----Original Message-----
From: Mulholland, Tom [mailto:Tom.Mulholland at dpi.wa.gov.au] 
Sent: Monday, December 17, 2007 8:04 PM
To: Galkowski, Jan
Subject: RE: [R-sig-Geo] adding new maps to map, mapdata,
mapproj;archive of R-sig-geo

I have been playing with the iplots package and it uses the map class.
So I wrote something to test the imap function that may be of help. I
make no claim to efficient coding, it's a take it as you get it type of
email. So "small" is an sp object created by using readShapePoly in
maptools. I have not tested it on anything other than a
SpatialPolygonDataFrame.

However your email seems to suggest to me that you really need to be
working with sp objects where overlay methods are available. In which
case what you need to do is convert your data from map into sp objects
using map2SpatialPolygons in maptools. On rereading your message it is
not clear if you are talking about overlay in the same way I use the
word. If you are just talking about adding a new layer then you can just
make sure the new plot statement does not overwrite the existing plot.

Anyway I hope this is another step in you way forward.

addNA <- function(x){
	 rbind(x,c(NA,NA))
	 }

makemap <- function(small){
n <- length(getSpPpolygonsSlot(small))
coordsList <- vector('list', n)
for (j in  1:n){
	coordsList[[j]] <-
getPolygonsPolygonsSlot(getSpPpolygonsSlot(small)[[j]])[[1]]@coords
	}
xyout <- lapply(coordsList,addNA)
xyout <- do.call("rbind",xyout)
n <- length(xyout[,1])
xyout <- xyout[1:(n-1),]
thismap  <- list(x = xyout[,1], y = xyout[,2],
    range = c(min(xyout[,1], na.rm = TRUE),max(xyout[,1], na.rm = TRUE),
		          min(xyout[,2], na.rm = TRUE),max(xyout[,2],
na.rm = TRUE)),
		          names = small at data[,1])
class(thismap) <- "map"
return(thismap)
} 

Tom

-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Galkowski, Jan
Sent: Tuesday, 18 December 2007 7:28 AM
To: r-sig-geo at stat.math.ethz.ch
Subject: [R-sig-Geo] adding new maps to map, mapdata, mapproj;archive of
R-sig-geo

Hi,

Sorry if this has been covered somewhere.  

Is there a writeup describing how new maps get added to map, mapdata,
mapproj?  What I'm trying to do is overlay polygons in latitude and
longitude onto these maps, then project them.  The associated things
you'd like to do with such overlays apply, e.g,. color them, use
different boundaries, etc.  Or perhaps there is also an overlay
mechanism?

Second, is there an online archive of r-sig-geo (or for that matter
r-help, etc) that can be searched for such questions?

Thanks,

 - Jan



	[[alternative HTML version deleted]]

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




More information about the R-sig-Geo mailing list