Prechádzať zdrojové kódy

Muudatus 'gpkg_piirkonnale_polygoonide_lisamine'. Maakasutuse kihi 'landuse_a' alamkihtideks filtreerimine.

Ardo Kubjas 5 rokov pred
rodič
commit
05cce10047
1 zmenil súbory, kde vykonal 27 pridanie a 0 odobranie
  1. 27 0
      R/gpkg_piirkonnale_polygoonide_lisamine.R

+ 27 - 0
R/gpkg_piirkonnale_polygoonide_lisamine.R

@@ -42,8 +42,14 @@ gpkg_piirkonnale_polygoonide_lisamine <- function(obj = NULL, gpkg_home = "/tmp"
   ## -------------------- Loop -----------------------
   intersect_layers <- c("piir", "bb")
   andmed <- data.frame("schema" = character(0), "table" = character(0))
+  andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "landuse_a"))
   andmed <- rbind(andmed, data.frame("schema" = "maaamet", "table" = "asustusyksus"))
   andmed <- rbind(andmed, data.frame("schema" = "maaamet", "table" = "shp_katastriyksus"))
+  andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "buildings_a"))
+  andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "water_a"))
+  andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "pofw_a"))
+  andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "pois_a"))
+  andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "natural_a"))
   for (intersect in intersect_layers) {
     for (i in 1:nrow(andmed)) {
       conf$gpkg_table <- sprintf("%s_%s", intersect, andmed$table[i])
@@ -75,6 +81,27 @@ gpkg_piirkonnale_polygoonide_lisamine <- function(obj = NULL, gpkg_home = "/tmp"
         OUTPUT = output
         # .quiet = TRUE
       )
+
+      ## Filtreerime maakasutuse kihi 'landuse-a' eraldi alamkihtideks
+      if (andmed$table[i] == "landuse_a") {
+        landuse_a <- unique(as.data.frame(sf::read_sf(dsn = dsn, layer = sprintf("%s_landuse_a", intersect), as_tibble = T))[, c("code", "fclass")])
+        parent_table <- conf$gpkg_table
+        for (k in 1:nrow(landuse_a)) {
+          table_suffix <- landuse_a$fclass[k]
+          conf$gpkg_table <- sprintf("%s_%s", parent_table, table_suffix)
+          output <- ruut::construct_to_gpkg_output_file_str(conf = conf)
+          result <- qgisprocess::qgis_run_algorithm(
+            algorithm = "native:extractbyattribute",
+            FIELD = "code",
+            OPERATOR = 0, # 0 s.o '='
+            VALUE = landuse_a$code[k],
+            INPUT = sprintf("%s|layername=%s_%s", dsn, intersect, andmed$table[i]),
+            OUTPUT = output,
+            FAIL_OUTPUT = qgisprocess::qgis_tmp_vector()
+            # .quiet = TRUE
+          )
+        }
+      }
     }
   }
   ## Layers list