
Olá Alex Segue alguns exemplos, veja se lhe ajuda library(maptools) library(rgdal) library(maps) library(ggplot2) ##------------------------------------------- ## OBTENDO E DESCOMPACTANDO O SHAPEFILE ##------------------------------------------- ender = 'endereço/ de /trabalho' ## endereço de trabalho setwd(ender) ## set o endereço de trabalho que receberá os arquivos ## site do shapefile url0 = 'http://www.aesa.pb.gov.br/geoprocessamento/geoportal/arquivos/Estados_do_Nor...' ## faz o download do shapefile if (!file.exists(basename(url0))) download.file(url0, dest=basename(url0), mode = "wb") unzip(basename(url0)) ## extrai os arquivos ##------------------------------------------- ## LENDO O SHAPEFILE ##------------------------------------------- nordeste <- readOGR(dsn = ender, layer = 'Nordeste', encoding = "latin1") ##------------------------------------------- ## SEPARANDO ALGUNS ESTADOS ##------------------------------------------- est = data.frame( nord = c('Alagoas', 'Bahia', 'Paraíba'), cor = c('red', 'blue', 'orange'), Temp = c(23, 34, 40)) ## os estados estão na coluna 4 str(nordeste@data) ## separe assim estados1 = nordeste[nordeste@data[, 4] %in% est$nord, ] ## ou assim estados2 = subset(nordeste, Estado %in% c('Alagoas', 'Bahia', 'Paraíba')) ##------------------------------------------- ## GRÁFICOS ##------------------------------------------- ## plot plot(nordeste, axes = TRUE) ## toda região nordeste plot(estados2, axes = TRUE) ## alguns estados ## rode após o plot, acrescenta a escala map.scale(-48, -18, ratio = FALSE, metric = TRUE, cex = 0.8) ## ggplot ggplot(estados2, aes(long, lat, group = group)) + geom_polygon(fill = "white") + geom_path(col = "#7f7f7f", size = 0.25) ## spplot spplot(estados2, zcol = "Estado", col.regions = rainbow(length(levels(nordeste@data$Estado))), colorkey = FALSE)## estados selecionados spplot(nordeste, zcol = "Estado", col.regions = rainbow(length(levels(nordeste@data$Estado))), colorkey = TRUE)## todos os estados -- Salah Saudações! Use R! Use Linux! Use Software free