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,width=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','lightgreen'
,'lightgreen','lightgreen','lightgray','lightgray','lightgray','lightgray','
lightgray','lightgray','lightgray','lightgray','lightgray','lightgray','ligh
tgray','lightgray','lightgray','lightgray','lightgray','lightgray','lightyel
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','yellow',
'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('lightyel
low','lightgray','lightgreen'),bty='n',pt.cex=2,pt.lwd=0.6,title='Faciologia
')

addlogo(N,px=c(40,39.8),py=c(21,20.8))

dev.off()

q('no')

 

-------------------------------------------------------------

MSc. Rodrigo Aluizio <mailto:r.aluizio@gmail.com> 

Centro de Estudos do Mar/UFPR
Laboratório de Micropaleontologia


	[[alternative HTML version deleted]]


