| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #' Kõikide kaardiruudukeste genereerimine
- #'
- #' Eesti projektsioonile vastava ning kogu Eestit katva ruutvõrgustiku genereerimine ja salvestamine andmebaasi. Valikud on 'postgis' ja 'gpkg'. Ruutvõrgustike ruutude suuruse on 100x100 km, 5x5 km, 1x1 km ja 100x100 mmeetrid, lisaks ruudukastide piirjoon.. Võrgustik salvestatakse vaikimisi andmebaasi nime postgisi andmebaasi 'data' schema 'maaamet' alla või gpkg andmebaasid kataloogi '/data/gpkg'. Loe: \url{https://geoportaal.maaamet.ee/est/Ruumiandmed/Kaardilehtede-susteemid-p224.html}. Koniguratsiooni muutmiseks muuda konfiguratsiooni faili.
- #' @param conf A list() of configuration variables. Default values \code{\link[ruut]{get_config}}.
- #' @param output_format format_name: output file format name, possible values are:
- #' - "GPKG"
- #' - "PostgreSQL" (Default)
- #' @return String.
- #' @seealso [ruut::get_config()], [ruut::construct_to_gpkg_output_file_str()], [ruut::construct_to_gpkg_output_postgres_str()]
- #' @keywords postgis, gpkg
- #' @export
- #' @examples
- #' \dontrun{
- #'
- #' # Postgresql output
- #' conf <- ruut::get_config()
- #' conf$schema <- "maaamet"
- #' conf$table <- "epk200t_bb"
- #' output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, key = "id")
- #' epk_grids(conf = conf, output_format = "PostgreSQL")
- #'
- #' # GPKG output
- #' conf <- ruut::get_config()
- #' conf$gpkg_home <- "/data/gpkg/artiklid/artikkel_210127_valga_matsalu_lahemaa"
- #' conf$gpkg_file <- "ruudud"
- #' conf$gpkg_table <- "epk200t_bb"
- #' output <- ruut::construct_to_gpkg_output_file_str(conf = conf)
- #' epk_grids(conf = conf, output_format = "GPKG")
- #' }
- epk_grids <- function(conf = NULL, output_format = "PostgreSQL") {
- # Export to postgis
- if (is.null(conf)) {
- conf <- ruut::get_config()
- conf$schema <- "maaamet"
- conf$gpkg_home <- "/data/gpkg"
- conf$gpkg_file <- "ruudud"
- conf$primary_key <- "id"
- }
- conf$table <- conf$gpkg_table <- "epk200t_bb"
- if (tolower(output_format) == "postgresql") output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, key = "id")
- if (tolower(output_format) == "gpkg") output <- ruut::construct_to_gpkg_output_file_str(conf = conf)
- # ruut::qgis_algorithm_search_by_word(str = "grid")
- algorithm <- "native:creategrid"
- # ruut::qgis_show_help(algorithm = algorithm)
- str <- sprintf("{ 'CRS' : 'epsg:3301', 'EXTENT' : '300000.000000000,800000.000000000,6300000.000000000,6700000.000000000 [EPSG:3301]', 'HOVERLAY' : 0, 'HSPACING' : 500000, 'OUTPUT' : '%s', 'TYPE' : 2, 'VOVERLAY' : 0, 'VSPACING' : 400000 }", output)
- cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
- system(cmd)
- conf$table <- conf$gpkg_table <- "epk200t_grid"
- if (tolower(output_format) == "postgresql") output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, key = "id")
- if (tolower(output_format) == "gpkg") output <- ruut::construct_to_gpkg_output_file_str(conf = conf)
- str <- sprintf("{ 'CRS' : 'epsg:3301', 'EXTENT' : '300000.000000000,800000.000000000,6300000.000000000,6700000.000000000 [EPSG:3301]', 'HOVERLAY' : 0, 'HSPACING' : 100000, 'OUTPUT' : '%s', 'TYPE' : 2, 'VOVERLAY' : 0, 'VSPACING' : 100000 }", output)
- cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
- system(cmd)
- conf$table <- conf$gpkg_table <- "epk2t_grid"
- if (tolower(output_format) == "postgresql") output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, key = "id")
- if (tolower(output_format) == "gpkg") output <- ruut::construct_to_gpkg_output_file_str(conf = conf)
- str <- sprintf("{ 'CRS' : 'epsg:3301', 'EXTENT' : '300000.000000000,800000.000000000,6300000.000000000,6700000.000000000 [EPSG:3301]', 'HOVERLAY' : 0, 'HSPACING' : 1000, 'OUTPUT' : '%s', 'TYPE' : 2, 'VOVERLAY' : 0, 'VSPACING' : 1000 }", output)
- cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
- system(cmd)
- conf$table <- conf$gpkg_table <- "epk10t_grid"
- if (tolower(output_format) == "postgresql") output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, key = "id")
- if (tolower(output_format) == "gpkg") output <- ruut::construct_to_gpkg_output_file_str(conf = conf)
- str <- sprintf("{ 'CRS' : 'epsg:3301', 'EXTENT' : '300000.000000000,800000.000000000,6300000.000000000,6700000.000000000 [EPSG:3301]', 'HOVERLAY' : 0, 'HSPACING' : 5000, 'OUTPUT' : '%s', 'TYPE' : 2, 'VOVERLAY' : 0, 'VSPACING' : 5000 }", output)
- cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
- system(cmd)
- conf$table <- conf$gpkg_table <- "epk02t_grid"
- if (tolower(output_format) == "postgresql") output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, key = "id")
- if (tolower(output_format) == "gpkg") output <- ruut::construct_to_gpkg_output_file_str(conf = conf)
- str <- sprintf("{ 'CRS' : 'epsg:3301', 'EXTENT' : '300000.000000000,800000.000000000,6300000.000000000,6700000.000000000 [EPSG:3301]', 'HOVERLAY' : 0, 'HSPACING' : 100, 'OUTPUT' : '%s', 'TYPE' : 2, 'VOVERLAY' : 0, 'VSPACING' : 100 }", output)
- cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
- system(cmd)
- cat(sprintf("\nAndmed salvestati asukohta: %s.\n\n", output))
- }
|