[R-br] Problemas com fixed breaks

Julianna Trindade julianna em jubalitpb.com
Segunda Abril 2 08:02:47 BRT 2012


eu tentei mas como anexo pelo grupo não é permitido.

Em 1 de abril de 2012 21:05, Mauro Sznelwar <sznelwar em uol.com.br> escreveu:

> **
> Estava tentando rodar este código, e vi que falta este
> arquivoc:/users/Julianna/Documents/SecSaude/saudemapa.shp
> Daria para enviar?.
>
>
> Mensagem abaixo em nome da Julianna... (dados disponiveis via
> datafilehost)
>
> ====
>
>  E quando fui conferir os breaks, os intervalos estavam certos,mas o mapa
> resultante estava errado.
> Porque quando eu não importo o csv e uso o dataframe resultante da função,
> os breaks ficam ok(da maneira que eu especifico em FixedBreaks) e, do
> contrario, não???
>
> segue o código:
>
> #######################################################
> # CONSTRUINDO MAPAS
> #######################################################
> ##Code (Comments are preceded by ##)
> ## Load required packages
>
> # Limpando memoria.
> rm(list=ls(all=TRUE))
>
> library(maps)
> library(sp)
> library(maptools)
> library(spdep)
> library(classInt)
> library(RColorBrewer)
> library(shape)
> library(SDMTools)
> library(latticeExtra)
> library(ReadImages)
> library(png)
>
> rosa_dos_ventos = function(loc=c(-34.5, -8), size = 0.15, bearing=0,
> cols=1, cex=0.6,...)
> {
>   cols <- rep(c("white","black"),8)
>   radii <- rep(size/c(1,4,2,4),4)
>   x <- radii[(0:15)+1]*cos((0:15)*pi/8+bearing)+loc[1]
>   y <- radii[(0:15)+1]*sin((0:15)*pi/8+bearing)+loc[2]
>   for (i in 1:15)
>   {
>     x1 <- c(x[i],x[i+1],loc[1])
>     y1 <- c(y[i],y[i+1],loc[2])
>     polygon(x1,y1,col=cols[i])
>   }
>   polygon(c(x[16],x[1],loc[1]),c(y[16],y[1],loc[2]),col=cols[16])
>   b <- c("O","S","L","N")
>   for (i in 0:3) text((size+par("cxy")[1]-0.40)*cos(bearing+i*pi/2)+loc[1],
>
> (size+par("cxy")[2]-0.42)*sin(bearing+i*pi/2)+loc[2],b[i+1],cex=cex)
> }
>
> ## Lendo dados
> ## http://www.datafilehost.com/download-e5cb7e86.html
> dados = read.table("dadosJulianna.csv", sep = ",", header = TRUE)
>
> # Lendo mapa.
> mapa = readShapePoly("c:/users/Julianna/Documents/SecSaude/saudemapa.shp")
> proj4string(mapa) <- CRS("+init=epsg:4291")
> scaleXY(mapa, 1836656)
>
>
> # arquivo png
> #img <- readPNG("c:/users/Julianna/Documents/SecSaude/logo_pb.png") # seu
> arquivo png aqui
> #set.seed(123)
> #par(xpd = TRUE)
>
>
> colors <- brewer.pal(7, "Reds")
> brks <- classIntervals(dados$ano_2006, n = 7,style="fixed",
> intervalClosure="right",
>                        fixedBreaks=c(-2, -0.5, 0, 20, 40, 60, 80, 10000),
> main="Fixed")
> brks<- brks$brks
>
> ID =
> match(substr(mapa$CODIGO,1,6),dados$t_indicadores_municipio.f_municipio)
> dados = dados[ID,]
>
> png(filename="c:/mif2006.png", height=750, width=1500)
>
>
> plot(mapa, col = colors[findInterval(dados$ano_2006,
> brks,all.inside=TRUE)], axes = TRUE, cex = 1.5, mar=5)
> ##, xlim=c(-39.7, -34.7), ylim=c(-8.5, -6)
>
> ##invisible(text(getSpPPolygonsLabptSlots(mapa),
> labels=as.character(mapa$NOMEMUN_1), cex=0.65))
>
> title(main = "PORCENTAGEM DE Ã BITOS INVESTIGADOS\ntipo: mulheres em idade
> fértil",
>       font.main = 2, cex.main = 1.8)
>
> text(-35.7, -6.2, "ANO: 2006", cex = 1.8)
>
> legend(-39.6,-7.6, c("Sem informação", "0", "]0,20]", "]20,40]",
> "]40,60]", "]60,80]","Acima de 80"),
>        fill = colors, bty="n", x.intersp = 1.1, y.intersp = 1.1, cex = 1.6)
>
> rosa_dos_ventos(loc=c(-34.5,-8),size=0.17,cex=1.20, bearing=0, cols=1)
>
> SpatialPolygonsRescale(layout.scale.bar(), offset = c(-35,-8.30),
>                        scale = 1, fill = c("transparent", "black"),
>                        plot.grid= FALSE)
>
> text(-34.5, -8.35, "110.3 KM", cex= 1.3)
>
> #rasterImage(img, xleft = -39.5, ybottom = -6.25, xright = -38.9 , ytop =
> -6)
>
> dev.off()
>
>
> _______________________________________________
> R-br mailing list
> R-br em listas.c3sl.ufpr.br
> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça
> código mínimo reproduzível.
>



-- 
Julianna Trindade

"Exalta-te, Senhor, na Tua força! Nós cantaremos e louvaremos o Teu poder."

Salmos 21; 13
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.inf.ufpr.br/pipermail/r-br/attachments/20120402/e11c56e3/attachment.html>


Mais detalhes sobre a lista de discussão R-br