1

I'm plotting a map of hydropower as a function of the distance to the turbine and distance to the uptake. However, when plotting I got an ugly blank space on the sides of my contour plot. I already tried the xlim = c(0,2500) but it did not work. Here you have the code:

# read data
data <- read.csv("ArchivoPotencia.csv", header = TRUE)

# make d into a SpatialPointsDataFrame object
library(sp)
coords <- data[, c("DTurbinas", "DIntake")]
s <- SpatialPointsDataFrame(coords = coords, data = data)

# interpolate with a thin plate spline 
# (or another interpolation method: kriging, inverse distance weighting). 
library(raster)
library(fields)
tps <- Tps(coordinates(s), as.vector(data$Potencia))
p   <- raster(s)
p   <- interpolate(p, tps)

# plot raster, points, and contour lines
plot(p, xlab= "Distance to Turbine", ylab = "Distance to Intake", cex=1.3, cex.lab = 1.3, cex.axis = 1.3,
    legend.width=1, legend.args=list(text='HP (KW)',side=3, line=1, cex=1.0), xlim = c(0,2500))
plot(s, add=T, cex=1.5, cex.lab = 1.3, cex.axis = 1.3)
contour(p, add=T, labcex = 0.8, lwd = 1.5)

Hydropower plot

Could anyone help me to remove the space on the plot?

rawr
  • 20,481
  • 4
  • 44
  • 78
  • 1
    in `?plot.raster` the default aspect ratio is `asp = 1` but that is not true for your device. you need to start a device that is at least roughly square: `pdf(..., height = 5, width = 5)` or something. alternatively, you could try `plot(..., asp = NA, xlim = ...)` which is likely how you expect it to behave, but this won't make sense because one unit on the x axis needs to be the same as one unit on the y – rawr Mar 18 '21 at 22:03
  • Might be relevant https://stackoverflow.com/questions/19680079/r-crop-no-data-of-a-raster – Tung Jun 20 '21 at 17:28

0 Answers0