Hi, I'm very new to R and I'm trying to achieve something which may be easy but I couldn't find any solutions for a week.
I read a GeoTiff file with Raster library and then crop with mask it with shape file. Then I want to save it as a PNG file to show it on Google Maps JS API, but it doesn't work due to inner margins when using plot(). This the code I'm working on : ---------Code---------------------------- xidw <- raster("output_6.tiff") crs(xidw) <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" xidw.sub <- crop(xidw, extent(state)) xidw.sub <- mask(xidw.sub, state) yidw <- projectRaster(xidw.sub, crs='+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs') png(filename="output.png", width=800, height=500, bg="transparent") plot(yidw, axes = F, box = F, legend = F) dev.off(); ---------Code---------------------------- Is there anything that I can get the PNG file with full extent of of my cropped and masked raster? Thanks. Best wishes. A [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo