Ich habe einen Datenrahmen, der zum Zeichnen von Rechtecken verwendet wird. Ich würde gerne wissen, wie viele Rechtecke eine vertikale Linie bei jeder x-Koordinate kreuzt.R: Wie viele Rechtecke eine Linie kreuzt
DataFrame = structure(list(topleftx = c(567L, 762L, 579L), toplefty = c(1000L,
1001L, 1304L), bottomrightx = c(761L, 956L, 949L), bottomrighty = c(1292L,
1309L, 1774L), PageDetailID = c("0014214H565", "0014215H565",
"0014216H565"), Page = c(3L, 3L, 3L)), .Names = c("topleftx",
"toplefty", "bottomrightx", "bottomrighty", "PageDetailID", "Page"
), row.names = 5:7, class = "data.frame")
xmin = round_any(min(DataFrame$topleftx),100)
xmax = round_any(max(DataFrame$bottomrightx),100)
ymin = round_any(min(DataFrame$toplefty),100)
ymax = round_any(max(DataFrame$bottomrighty),100)
print(paste(xmin,xmax,ymin,ymax))
prec_x = round_any(0.1*(xmax-xmin),10)
prec_y = round_any(0.1*(ymax-ymin),10)
topleftx = round_any(DataFrame$topleftx,prec_x)
toplefty = round_any(DataFrame$toplefty,prec_y)
bottomrightx = round_any(DataFrame$bottomrightx,prec_x)
bottomrighty = round_any(DataFrame$bottomrighty,prec_y)
# View(DataFrame)
require(grDevices)
## set up the plot region:
op <- par(bg = "white")
plot(c(xmin, xmax), c(ymin, ymax), type = "n", xlab = "", ylab = "", main = "Y-axis should be inverted")
#569 935 723 1076
rect(topleftx, toplefty, bottomrightx, bottomrighty , col = c(NA,0))#, col = rainbow(11, start = 0.7, end = 0.1))
Hier ist das Grundstück:
also bei allen x
in diesem Beispiel die Antwort 2. Hinweis sein sollte: Grenzen bei gleichen y
nicht immer sind - es gibt eine Lücke zwischen könnte Rechtecke.
Irgendwelche Ideen? Vielen Dank!
Vielen Dank! Einfacher als ich dachte –