Created
July 11, 2018 11:45
-
-
Save CBSti/cf2e6dc02911489cf07529eadd33b10b to your computer and use it in GitHub Desktop.
Georeferenzierung Parzellenplan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# === | |
# Funktionen für den Geodatenimport in FastWood | |
# === | |
# lib | |
# install.packages("dplyr") | |
# install.packages("tidyr") | |
# install.packages("shapes") | |
# Procrustes Analyse für Georeferenzierung von Parzellenplänen -------------------------------- | |
pzGeoRef <- function(origDat, referMat, transMat, procScale) { | |
require(dplyr) | |
require(tidyr) | |
require(shapes) | |
try(if(!is.matrix(referMat)) stop("Referenz ist keine Matrix")) | |
try(if(!is.matrix(transMat)) stop("Zu transformierendes Objekt ist keine Matrix")) | |
try(if(ncol(origDat) != 2) stop("Bitte nur Datensatz mit X und Y Koordinaten als Spalten übergeben")) | |
procAna <- | |
procOPA( | |
A = referMat, | |
B = transMat, | |
scale = procScale, | |
reflect = FALSE | |
) | |
origDat <- as.matrix(origDat) | |
pzGridT <- ((( | |
origDat * procAna$s - | |
matrix( | |
colMeans(transMat), | |
byrow = TRUE, | |
ncol = 2, | |
nrow = nrow(origDat) | |
) | |
) %*% procAna$R) + | |
matrix( | |
colMeans(referMat), | |
byrow = TRUE, | |
ncol = 2, | |
nrow = nrow(origDat) | |
)) | |
pzGeoRef <- vector("list", length = 2) | |
pzGeoRef[[1]] <- procAna | |
pzGeoRef[[2]] <- pzGridT | |
names(pzGeoRef) <- c("procAna", "pzGridT") | |
return(pzGeoRef) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment