|
|
@@ -44,7 +44,7 @@ gpkg_teisendame_punkte <- function(obj = NULL, gpkg_home = "/tmp") {
|
|
|
layer_names <- layer_names[!layer_names %in% c("bb2", "bb2_epk10t_grid", "bb2_epk02t_grid", "bb2_epk2t_grid")] # c("bb", "bb2", "bb_epk10t_grid", "bb_epk02t_grid", "bb_epk2t_grid", "bb_epk10t", "bb_epk02t")]
|
|
|
for (layer_name in layer_names) {
|
|
|
ruumiline_obj <- sf::read_sf(dsn = dsn, layer = layer_name)
|
|
|
- ## Punktide arv ruudus
|
|
|
+ ## ------------- Punktide arv ruudus ---------------
|
|
|
## Kontlrollime kas geomeetriline objekt on punkt.
|
|
|
(is_point <- any(grepl("point", tolower(attributes(ruumiline_obj$geom)$class), fixed = TRUE)))
|
|
|
if (is_point) {
|
|
|
@@ -59,6 +59,30 @@ gpkg_teisendame_punkte <- function(obj = NULL, gpkg_home = "/tmp") {
|
|
|
str <- sprintf("{ 'CLASSFIELD' : '', 'FIELD' : 'numpoints', 'OUTPUT' : '%s', 'POINTS' : '%s', 'POLYGONS' : '%s', 'WEIGHT' : '' }", output, points, polygons)
|
|
|
cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
|
|
|
system(cmd)
|
|
|
+ ## ------------- TIFF ----------------
|
|
|
+ grid_layer <- sf::read_sf(dsn = dsn, layer = "bb2_epk02t_grid")
|
|
|
+ # sf::st_crs(grid_layer) <- 3301
|
|
|
+ pk_attributes <- attributes(grid_layer$geom)
|
|
|
+ extent <- sprintf("%s,%s,%s,%s [EPSG:3301]", round((pk_attributes$bbox["xmin"] / 100), digits = 0) * 100, ceiling((pk_attributes$bbox["xmax"] / 100)) * 100, round((pk_attributes$bbox["ymin"] / 100), digits = 0) * 100, ceiling((pk_attributes$bbox["ymax"] / 100)) * 100)
|
|
|
+ # ruut::qgis_algorithm_search_by_word("Rasterize")
|
|
|
+ algorithm <- "gdal:rasterize"
|
|
|
+ ruut::qgis_show_help(algorithm = algorithm)
|
|
|
+ conf$gpkg_table <- sprintf("%s_epk02t", layer_name)
|
|
|
+ input <- ruut::construct_to_gpkg_output_file_str(conf = conf, geometry_field = "geom", is_input_str = T)
|
|
|
+ output <- sprintf("%s/tif/%s.tif", conf$gpkg_home, layer_name)
|
|
|
+ str <- sprintf(
|
|
|
+ "{ 'BURN' : 0, 'DATA_TYPE' : 5, 'EXTENT' : '%s', 'EXTRA' : '-a_srs epsg:3301', 'FIELD' : 'numpoints', 'HEIGHT' : 100, 'INIT' : None, 'INPUT' : '%s', 'INVERT' : False, 'NODATA' : -1, 'OPTIONS' : '', 'OUTPUT' : '%s', 'UNITS' : 1, 'WIDTH' : 100 }",
|
|
|
+ extent, input, output
|
|
|
+ )
|
|
|
+ cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
|
|
|
+ system(cmd)
|
|
|
+
|
|
|
+ ## ----------- TIF TO POSTGIS -------------
|
|
|
+ conf$schema <- conf$gpkg_file
|
|
|
+ ruut::db_create_new_schema(conf = conf)
|
|
|
+ (cmd <- sprintf("export PGPASSWORD=%s && raster2pgsql -I %s %s.%s_tif | psql -U %s -d %s -h %s -p %s",
|
|
|
+ conf$password, output, conf$schema, layer_name, conf$user, conf$dbname, conf$host, conf$port))
|
|
|
+ system(cmd)
|
|
|
}
|
|
|
}
|
|
|
## Layers list
|