<div dir="ltr"><div class="gmail_extra"><div style="font-family:arial,sans-serif;font-size:13px">Senhores, boa tarde!</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
Supondo que o mapa de regiões não estivesse disponível, ainda seria possível 'derivá-lo' do mapa de munícipios fornecido pelo IBGE.</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
A rotina que segue une polígonos com uma característica (atributo) comum. Nesse caso específico utilizei a informação referente às mesoregiões do RJ, disponíveis no shape 1:500.000 com projeção Policônica.</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">### <code r></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace"># install.packages('gpclib', dep=T)</font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace"># library(gpclib) # General Polygon Clipping library </font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">library(maptools) # for geospatial services; also loads foreign and sp</font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">library(rgdal) # for map projection work; also loads sp</font></div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">setwd('c:/Lab/Datasus'); getwd() ### ALTERAR!!!</font></div><div style="font-family:arial,sans-serif;font-size:13px">
<font face="courier new, monospace"><br></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">URL1 <- '<a href="ftp://geoftp.ibge.gov.br/malhas_digitais" target="_blank">ftp://geoftp.ibge.gov.br/malhas_digitais</a>'</font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">URL2 <- 'municipio_2005/escala_500mil/proj_policonica/arcview_shp/uf/rj/33mu500pc.zip'</font></div><div style="font-family:arial,sans-serif;font-size:13px">
<font face="courier new, monospace">fName <- basename(URL2)</font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">dirName <- gsub("\\.zip", "", fName)</font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace"><br></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">if(!file.exists(fName)) download.file(file.path(URL1, URL2), fName, mode='wb')</font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">unzip(fName, exdir=dirName)</font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace"><br>
</font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">RJMun <- readShapePoly(file.path(dirName, gsub("\\.zip", "\\.shp", fName)))</font></div><div style="font-family:arial,sans-serif;font-size:13px">
<font face="courier new, monospace">proj4string(RJMun) <- CRS("+init=epsg:29101") # policônica</font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">proj4string(RJMun)</font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace"># print(CRSargs(CRS("+init=epsg:29101")))</font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">plot(RJMun, col=terrain.colors(8))</font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace"><br></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">names(RJMun@data)</font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">IDNew <- unlist(RJMun@data["MESOREGIAO"]) ### Novos IDs</font></div><div style="font-family:arial,sans-serif;font-size:13px">
<font face="courier new, monospace">RJMeso <- unionSpatialPolygons(RJMun, IDNew)</font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace"><br></font></div><div style="font-family:arial,sans-serif;font-size:13px">
<font face="courier new, monospace">plot(RJMeso, col=heat.colors(6))</font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">names(RJMeso)</font></div><div style="font-family:arial,sans-serif;font-size:13px">
<font face="courier new, monospace">### </code></font></div><div class="gmail_extra" style="font-family:arial,sans-serif;font-size:13px"><br clear="all"><div><div dir="ltr"><font face="arial, helvetica, sans-serif"><br>
<span style="font-size:small">================================================</span><br>Éder Comunello</font><div><span style="font-family:arial,helvetica,sans-serif">Agronomist, MSc in Environ. Sciences (UEM)</span><font face="arial, helvetica, sans-serif"><br>
</font></div><div><font face="arial, helvetica, sans-serif"><br>PhD Student in Agricultural Systems Engineering (USP/ESALQ)<br>Piracicaba, SP, Brazil [22 42.7'S, 47 37.8'W]<br><br></font><font face="arial, helvetica, sans-serif">Researcher at Embrapa Western Region Agriculture</font><div>
<font face="arial, helvetica, sans-serif">Dourados, MS, Brazil [</font>22 16.5'S, 54 49.0'W<span style="font-family:arial,helvetica,sans-serif">]</span></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:small">================================================</span><br>
</font></div></div><div><span style="font-size:small;font-family:arial,helvetica,sans-serif">UTC-04:00 / DST: UTC-03:00</span></div></div></div></div></div></div>