r - Background color of a .shp using `readShapeSpatial` function -
i looking use background color on .shp using readshapespatial
function. can me this?. there function similar (except: readshapepoly
) can used add background color .shp files?
this part of code...
library(raster) library(maptools) library(mapdata) library(maps) library(scales) pcontorta <- readshapespatial("per_water_areas_dcw.shp") pcontorta2 <- readshapespatial("bol_water_areas_dcw.shp") pcontorta3 <- readshapespatial("ecu_water_areas_dcw.shp") pcontorta4 <- readshapespatial("pry_water_areas_dcw.shp") pcontorta5 <- readshapespatial("per_adm2.shp") pcontorta6 <- readshapespatial("bol_adm2.shp") pcontorta7 <- readshapespatial("ecu_adm2.shp") pcontorta8 <- readshapespatial("pry_adm2.shp") read.csv("coord.csv") -> data data <- data.frame(data[,1:4]) data[data$species=="b._nn",] -> primera data[data$species=="b._ghn",] -> segunda data[data$species=="b._bolivianus",] -> tercera data[data$species=="b._brevirostris",] -> cuarta data[data$species=="b._diasphanus",] -> quinta data[data$species=="b._osgoodi",] -> sexta data[data$species=="b._pachacuti",] -> septima data[data$species=="b._phoenicoteru",] -> octava data[data$species=="b._pectinatus",] -> novena data[data$species=="b._peruanus",] -> decima data[data$species=="b._thomasi",] -> once rownames(data) <- data[,1] attach(data) na.omit(data) -> data alt <- raster("alt.bil") extent_all <-extent (-85, -50, -30, 5) crop(alt, extent_all)->alt tiff(filename = "mapa.tiff",res = 800, pointsize = 6, width = 3200, height = 3200, units = "px") #... #continues little bit...plotting... box() dev.off()
thanks , have nice day!
in general shp file not have background, how plots created background colour be.
using example ?readshapespatial
xx <- readshapespatial(system.file("shapes/sids.shp", package="maptools")[1], idvar="fipsno", proj4string=crs("+proj=longlat +ellps=clrk66"))
(1) set while plotting using bg
i.e.
plot(xx, col = 'red', bg = 'blue')
(2) set plot background "transparent"
, define in output device
tiff(filename = "mapa.png",bg = 'green') plot(xx, bg = 'transparent', col = 'white') dev.off() # gives (converting `png` allow uploaded so)
Comments
Post a Comment