Also, see # install.packages('sp') example('spplot', package='sp')
Kingsford Jones On Wed, Mar 11, 2009 at 9:38 AM, Greg Snow <greg.s...@imail.org> wrote: > Another possibility is the my.symbols function in the TeachingDemos package. > You can define a polygon of your arrow (or other symbol), then use my.symbols > to add it to an existing graph, the advantage of my.symbols is that the size > of the arrow is absolute, not in terms of the scale of the original plot. > > -- > Gregory (Greg) L. Snow Ph.D. > Statistical Data Center > Intermountain Healthcare > greg.s...@imail.org > 801.408.8111 > > >> -----Original Message----- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- >> project.org] On Behalf Of Rodrigo Aluizio >> Sent: Wednesday, March 11, 2009 4:22 AM >> To: 'Yihui Xie' >> Cc: R Help >> Subject: [R] RES: North Arrow (.png file) on a Map >> >> Thanks a lot Yihui, It's perfect, in fact exactly identical the I have >> as a >> png file in my computer. >> Thank you so much. >> >> Regards >> Rodrigo >> >> -----Mensagem original----- >> De: Yihui Xie [mailto:xieyi...@gmail.com] >> Enviada em: quarta-feira, 11 de março de 2009 02:48 >> Para: Rodrigo Aluizio >> Cc: R Help >> Assunto: Re: [R] North Arrow (.png file) on a Map >> >> Is this "arrow" satisfactory for you? >> >> north.arrow = function(x, y, h) { >> polygon(c(x, x, x + h/2), c(y - h, y, y - (1 + sqrt(3)/2) * h), >> col = "black", border = NA) >> polygon(c(x, x + h/2, x, x - h/2), c(y - h, y - (1 + sqrt(3)/2) * >> h, y, y - (1 + sqrt(3)/2) * h)) >> text(x, y, "N", adj = c(0.5, 0), cex = 4) >> } >> plot(1, type = "n", ylim = c(0, 1)) >> north.arrow(1, 0.8, 0.3) >> >> Regards, >> Yihui >> -- >> Yihui Xie <xieyi...@gmail.com> >> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086 >> Mobile: +86-15810805877 >> Homepage: http://www.yihui.name >> School of Statistics, Room 1037, Mingde Main Building, >> Renmin University of China, Beijing, 100872, China >> >> >> >> On Tue, Mar 10, 2009 at 7:21 PM, Rodrigo Aluizio <r.alui...@gmail.com> >> wrote: >> > Hi list. >> > >> > I would like to know how do I insert a North arrow, stored as a png >> file >> in >> > my computer, in a map? I found lots of post asking similar things, >> one of >> > them mentioned the pixmap package. The map was done using map() and >> > shapefiles (the code is below). I'm using the pixmap () and addlogo() >> > functions. Well I can import the png with pixmap() function (I guess, >> once >> > there's no error message), but I can't put It on the map, I got an >> error >> > message telling me that: >> > >> > >> > >> > "Error at t(x...@index[nrow(x...@index):1, , drop = FALSE]) : >> > >> > index out of limits" >> > >> > >> > >> > Well I tried changing coordinates but I always got the same result. >> How do >> I >> > do this correctly? Is there a better way? >> > >> > >> > >> > Thanks for the help and attention. >> > >> > >> > >> > Here is the complete map script: >> > >> > >> > >> > library(RODBC) >> > >> > library(maps) >> > >> > library(mapdata) >> > >> > library(maptools) >> > >> > library(pixmap) >> > >> > #Carregar Coordenadas e dados dos Pontos Amostrais >> > >> > Dados<-odbcConnectExcel('Campos.xls',readOnly=T) >> > >> > Coord<-sqlFetch(Dados,'CoordMed',colnames=F,rownames='Ponto') >> > >> > odbcClose(Dados) >> > >> > N<-pixmap('Norte.png',nrow=166,ncol=113) >> > >> > # Carregar pontos e shapes >> > >> > >> Batimetria<- >> readShapeSpatial('C:/Users/Rodrigo/Documents/UFPR/Micropaleontol >> > ogia/Campos/ShapeFiles/Batimetria_BC.shp') >> > >> > >> Estados<- >> readShapeSpatial('C:/Users/Rodrigo/Documents/UFPR/Micropaleontologi >> > a/Campos/ShapeFiles/Estados_Sudeste.shp') >> > >> > >> Faciologia<- >> readShapeSpatial('C:/Users/Rodrigo/Documents/UFPR/Micropaleontol >> > ogia/Campos/ShapeFiles/Faciologia_BC.shp') >> > >> > # Mapa com os Pontos da Bacia >> > >> > >> postscript('MapaCampos.eps',paper='special',onefile=F,horizontal=F,widt >> h=3.5 >> > ,height=4.5,bg='white',pointsize=3) >> > >> > par(mar=c(3,2,2,0)) >> > >> > >> map('worldHires','brazil',ylim=c(23.9,20.3),xlim=c(42.1,39.2),type='n') >> > >> > >> plot(Faciologia,ylab='',xlab='',col=c('lightgreen','lightgreen','lightg >> reen' >> > >> ,'lightgreen','lightgreen','lightgray','lightgray','lightgray','lightgr >> ay',' >> > >> lightgray','lightgray','lightgray','lightgray','lightgray','lightgray', >> 'ligh >> > >> tgray','lightgray','lightgray','lightgray','lightgray','lightgray','lig >> htyel >> > low','lightyellow','lightyellow'),add=T,lwd=0.5,border=0) >> > >> > >> plot(Batimetria,ylab='',xlab='',col='darkgray',lty='solid',lwd=0.2,add= >> T) >> > >> > plot(Estados,ylab='',xlab='',lty='solid',add=T,lwd=0.8) >> > >> > >> text(Coord$Longitude[Coord$Réplicas=='1'],Coord$Latitude[Coord$Réplicas >> =='1' >> > ],rownames(Coord)[Coord$Réplicas=='1'],col='red',cex=0.5,font=2) >> > >> > >> text(Coord$Longitude[Coord$Réplicas=='2'],Coord$Latitude[Coord$Réplicas >> =='2' >> > ],rownames(Coord)[Coord$Réplicas=='2'],col='yellow',cex=0.5,font=2) >> > >> > >> text(Coord$Longitude[Coord$Réplicas=='3'],Coord$Latitude[Coord$Réplicas >> =='3' >> > ],rownames(Coord)[Coord$Réplicas=='3'],col='blue',cex=0.5,font=2) >> > >> > points(Coord$Longitude,Coord$Latitude-0.045,pch=20,cex=0.7) >> > >> > text(c(41.5,41.3),c(21.7,20.6),c('RJ','ES')) >> > >> > axis(1,xaxp=c(42.1,39.2,2),cex.axis=1) >> > >> > axis(2,yaxp=c(23.9,20.3,4),cex.axis=1) >> > >> > title(main='Bacia') >> > >> > >> legend(40.2,23.5,c('Uma','Duas','Três'),pch=21,cex=1,pt.bg=c('red','yel >> low', >> > 'blue'),bty='n',pt.cex=2,pt.lwd=0.6,title='Réplicas') >> > >> > >> legend(39.8,23.5,c('Areia','Calcário','Lama'),pch=21,cex=1,pt.bg=c('lig >> htyel >> > >> low','lightgray','lightgreen'),bty='n',pt.cex=2,pt.lwd=0.6,title='Facio >> logia >> > ') >> > >> > addlogo(N,px=c(40,39.8),py=c(21,20.8)) >> > >> > dev.off() >> > >> > q('no') >> > >> > >> > >> > ------------------------------------------------------------- >> > >> > MSc. Rodrigo Aluizio <mailto:r.alui...@gmail.com> >> > >> > Centro de Estudos do Mar/UFPR >> > Laboratório de Micropaleontologia >> > >> > >> > [[alternative HTML version deleted]] >> > >> > >> > ______________________________________________ >> > R-help@r-project.org mailing list >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, reproducible code. >> > >> > >> >> ______________________________________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting- >> guide.html >> and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.