|
@@ -0,0 +1,54 @@
|
|
|
|
|
+#' Maa-ameti kogu Eesti andmestiku teisendamised
|
|
|
|
|
+#'
|
|
|
|
|
+#' Source: \url{https://geoportaal.maaamet.ee/est/Ruumiandmed/Topokaardid-ja-aluskaardid/Eesti-pohikaart-1-10000/Laadi-pohikaart-alla-p612.html} . Andmed salvestatakse postgisi andmebaasi. Schema = 'eesti'. Koniguratsiooni muutmiseks muuda konfiguratsiooni. Muutujate vaikeväärtused on sellised, et ei ole vaja midagi muuta.
|
|
|
|
|
+#' @param conf A list() of configuration variables. Default values \code{\link[ruut]{get_config}}.
|
|
|
|
|
+#' @return No output.
|
|
|
|
|
+#' @seealso [ruut::get_config()], [ruut::copy_shp_to_db()]
|
|
|
|
|
+#' @keywords postgis, maps, ESRI Shpfile, OSM
|
|
|
|
|
+#' @export
|
|
|
|
|
+#' @examples
|
|
|
|
|
+#' \dontrun{
|
|
|
|
|
+#'
|
|
|
|
|
+#' conf <- ruut::get_config()
|
|
|
|
|
+#' maaamet_eesti_muutmine(conf = conf)
|
|
|
|
|
+#' }
|
|
|
|
|
+maaamet_eesti_muutmine <- function(conf = NULL) {
|
|
|
|
|
+ ans <- utils::askYesNo("Do you want to import maps into database?", default = F)
|
|
|
|
|
+ if (!ans | is.na(ans)) {
|
|
|
|
|
+ cat("\n------------------------\n")
|
|
|
|
|
+ cat("Kaardikihte ei lisatud.")
|
|
|
|
|
+ cat("\n------------------------\n")
|
|
|
|
|
+ return()
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ans) {
|
|
|
|
|
+ # Export to postgis
|
|
|
|
|
+ if (is.null(conf)) {
|
|
|
|
|
+ conf <- ruut::get_config()
|
|
|
|
|
+ conf$schema <- "eesti"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ## ==================================================================================================
|
|
|
|
|
+ ## !!!!!!!!!!!!!!! Muud teisendused !!!!!!!!!!!!!!!!!!
|
|
|
|
|
+ ## Võtab palju aega, kuni 10 tundi.
|
|
|
|
|
+ ## 1. Üheks tervikobjektiks ühendamine mingi tunnuse järele.
|
|
|
|
|
+ andmed <- data.frame("tabeli_nimi" = character(0), "tunnus" = character(0))
|
|
|
|
|
+ andmed <- rbind(andmed, data.frame("tabeli_nimi" = "e_201_meri_a", "tunnus" = "kood"))
|
|
|
|
|
+ andmed <- rbind(andmed, data.frame("tabeli_nimi" = "e_202_seisuveekogu_a", "tunnus" = "kkr_kood"))
|
|
|
|
|
+ andmed <- rbind(andmed, data.frame("tabeli_nimi" = "e_203_vooluveekogu_a", "tunnus" = "kkr_kood"))
|
|
|
|
|
+ andmed <- rbind(andmed, data.frame("tabeli_nimi" = "e_306_margala_a", "tunnus" = "tyyp"))
|
|
|
|
|
+ andmed <- rbind(andmed, data.frame("tabeli_nimi" = "e_307_turbavali_a", "tunnus" = "tyyp"))
|
|
|
|
|
+ andmed <- rbind(andmed, data.frame("tabeli_nimi" = "e_305_puittaimestik_a", "tunnus" = "tyyp"))
|
|
|
|
|
+
|
|
|
|
|
+ # ruut::qgis_algorithm_search_by_word('Dissolve')
|
|
|
|
|
+ for (i in 1:nrow(andmed)) {
|
|
|
|
|
+ conf$table <- andmed$tabeli_nimi[i]
|
|
|
|
|
+ input <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_field = "geom", geometry_type = "Polygon", srid = 3301, checkPrimaryKeyUnicity = 1, key = "id")
|
|
|
|
|
+ conf$table <- sprintf("%s_%s", conf$table, "dissolved")
|
|
|
|
|
+ output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_field = "geom", geometry_type = NULL, srid = NULL, checkPrimaryKeyUnicity = FALSE, key = NULL)
|
|
|
|
|
+ str <- sprintf("{ 'FIELD' : ['%s'], 'INPUT' : '%s', 'OUTPUT' : '%s' }", andmed$tunnus[i], input, output)
|
|
|
|
|
+ cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = "native:dissolve")
|
|
|
|
|
+ system(cmd)
|
|
|
|
|
+ cat(sprintf("\n\n%s/%s ---------------\nAndmed %s on muudetud.\n", i, nrow(andmed), andmed$tabeli_nimi[i]))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|