minu_teed_loomine.R 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. #' Teeregistri WFS ja maaameti andmete põhjal oma teeandmete 'minu_teed' loomine
  2. #'
  3. #' 1. Põhi-, kõrval ja tugimaanteedest ning rambid moodustatakse uus andmebaas 'riigiteedevork'.
  4. #' 2. Ilma teenumbrita kohalike teede andmebaasi 'numbrita_kohalik_tee' loomine.
  5. #' 3. Eesti kaart ainult suurte saartega (üle 10km2).
  6. #' 4. Polügoniseerime riigiteedevõrgu.
  7. #' Eesti avaandmete \url{https://avaandmed.eesti.ee/datasets?emsId=35} teabevärava kaudu teederegistri WFS (Web Feature Service) andmete eksportimine postgisandmebaasi. WFS andmestiku kirjeldus: \url{https://teeregister-api.mnt.ee/teenus/wfs?request=GetCapabilities&service=WFS}
  8. #'
  9. #' @param conf A list() of configuration variables. Default values \code{\link[ruut]{get_config}}.
  10. #' @return No output.
  11. #' @seealso [ruut::get_config()], [ruut::copy_shp_to_db()], [estmap::teeregister_wfs()]
  12. #' @keywords postgis, maps, WFS, OSM
  13. #' @export
  14. #' @examples
  15. #' \dontrun{
  16. #'
  17. #' conf <- ruut::get_config()
  18. #' minu_teed_loomine(conf = conf)
  19. #' }
  20. minu_teed_loomine <- function(conf = NULL) {
  21. ## ------------- muutujad ja teisendused ---------------
  22. if (is.null(conf)) {
  23. conf <- ruut::get_config()
  24. }
  25. ## Defineerime ajutised failid ja muutujad.
  26. tmp_dir <- tempdir() # ajutine kataloog
  27. obj <- "demo"
  28. tmp_gpkg_file <- sprintf("%s/%s.gpkg", tmp_dir, obj) # ajutine gpkg fail
  29. conf$gpkg_home <- tmp_dir
  30. conf$gpkg_file <- obj
  31. conf$primary_key <- "id"
  32. ## Loome lingid gpkg ajutistest tabelitest lugemiseks ja kirjutamiseks
  33. conf$gpkg_table <- layer_3 <- "test_layer_3"
  34. tmp_gpkg_file_output_3 <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = F)
  35. tmp_gpkg_file_input_3 <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = T)
  36. conf$gpkg_table <- layer_2 <- "test_layer_2"
  37. tmp_gpkg_file_output_2 <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = F)
  38. tmp_gpkg_file_input_2 <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = T)
  39. conf$gpkg_table <- layer_1 <- "test_layer_1"
  40. tmp_gpkg_file_output_1 <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = F)
  41. tmp_gpkg_file_input_1 <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = T)
  42. # ## =================== 1. 'riigiteedevõrk' =======================
  43. # ## Teeregistri WFS avaandmete abil riigiteedevõrgu loomine
  44. # # Loe instaleeritud tabelid andmebaasis
  45. # installed_tables <- ruut::db_schema_tablenames(conf = conf)
  46. # ## Kontrollime ühendatavate andmebaaside olemasolu.
  47. # if (all(c("pohimaantee", "ramp", "tugimaantee", "korvalmaantee") %in% installed_tables)) {
  48. # ## 1. Ühendame riigiteed üheks võrgustikuks
  49. # # ruut::qgis_algorithm_search_by_word("merge")
  50. # algorithm <- "native:mergevectorlayers"
  51. # # ruut::qgis_show_help(algorithm = algorithm)
  52. # conf$schema <- "teeregister_wfs"
  53. # conf$table <- "pohimaantee"
  54. # layer_1 <- ruut::construct_to_gpkg_output_postgres_str(
  55. # conf = conf, geometry_type = "MultiLineString", srid = 3301,
  56. # checkPrimaryKeyUnicity = TRUE, key = "id", geometry_field = "geometry"
  57. # )
  58. # conf$table <- "tugimaantee"
  59. # layer_2 <- ruut::construct_to_gpkg_output_postgres_str(
  60. # conf = conf, geometry_type = "MultiLineString", srid = 3301,
  61. # checkPrimaryKeyUnicity = TRUE, key = "id", geometry_field = "geometry"
  62. # )
  63. # conf$table <- "korvalmaantee"
  64. # layer_3 <- ruut::construct_to_gpkg_output_postgres_str(
  65. # conf = conf, geometry_type = "MultiLineString", srid = 3301,
  66. # checkPrimaryKeyUnicity = TRUE, key = "id", geometry_field = "geometry"
  67. # )
  68. # # conf$table <- "ramp"
  69. # # layer_4 <- ruut::construct_to_gpkg_output_postgres_str(
  70. # # conf = conf, geometry_type = "MultiLineString", srid = 3301,
  71. # # checkPrimaryKeyUnicity = TRUE, key = "id", geometry_field = "geometry"
  72. # # )
  73. # conf$schema <- "minu_teed"
  74. # # New schema
  75. # ruut::db_create_new_schema(conf = conf)
  76. # conf$table <- "riigiteedevork"
  77. # output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_field = "geom", geometry_type = "MultiLineString", srid = 3301, checkPrimaryKeyUnicity = FALSE)
  78. # cmd <- sprintf(
  79. # "qgis_process run native:mergevectorlayers --CRS='epsg:3301' --LAYERS='%s' --LAYERS='%s' --LAYERS='%s' --OUTPUT='%s' ",
  80. # layer_1, layer_2, layer_3, output
  81. # )
  82. # system(cmd)
  83. # cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", conf$table))
  84. # }
  85. ## ================= Schema 'minu_teed' ====================
  86. conf$schema <- "minu_teed"
  87. ruut::db_create_new_schema(conf = conf)
  88. ## =================== 2. teedevõrkude loomine =======================
  89. ## 2.1 Riigiteedevõrk (ilma rampideta) <= 30, koos rampide ja muude riigiteedega <= 45.
  90. # ruut::qgis_algorithm_search_by_word("extract")
  91. algorithm <- "native:extractbyattribute"
  92. # ruut::qgis_show_help(algorithm = algorithm)
  93. conf$schema <- "eesti"
  94. conf$table <- "e_501_tee_j"
  95. input <- ruut::construct_to_gpkg_output_postgres_str(
  96. conf = conf, geometry_type = "MultiLineString", srid = 3301,
  97. checkPrimaryKeyUnicity = TRUE, key = "id", geometry_field = "geom"
  98. )
  99. output <- tmp_gpkg_file_output_1
  100. str <- sprintf("{ 'FIELD' : 'tyyp', 'INPUT' : '%s', 'OPERATOR' : 5, 'OUTPUT' : '%s', 'VALUE' : '45' }", input, output)
  101. cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
  102. system(cmd)
  103. cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", output))
  104. ## 2.1.1 Copy temp gpkg file to postgis.
  105. conf$schema <- "minu_teed"
  106. conf$table <- "teedevork_riigiteed"
  107. PG <- ruut::construct_ogr2ogr_PG_connect_str(conf = conf)
  108. cmd <- sprintf('ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL %s -lco DIM=2 %s %s -overwrite -nlt %s -lco GEOMETRY_NAME=geom -lco FID=id -nln %s.%s -nlt PROMOTE_TO_MULTI', PG, tmp_gpkg_file, layer_1, "LINESTRING", conf$schema, conf$table)
  109. system(cmd)
  110. cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", conf$table))
  111. ## 2.2 Muud teed s.o tyyp IN (50,60,).
  112. ## 2.2.1 Esmalt sorteerime >= 50
  113. # ruut::qgis_algorithm_search_by_word("extract")
  114. algorithm <- "native:extractbyattribute"
  115. # ruut::qgis_show_help(algorithm = algorithm)
  116. conf$schema <- "eesti"
  117. conf$table <- "e_501_tee_j"
  118. input <- ruut::construct_to_gpkg_output_postgres_str(
  119. conf = conf, geometry_type = "MultiLineString", srid = 3301,
  120. checkPrimaryKeyUnicity = TRUE, key = "id", geometry_field = "geom"
  121. )
  122. output <- tmp_gpkg_file_output_1
  123. str <- sprintf("{ 'FIELD' : 'tyyp', 'INPUT' : '%s', 'OPERATOR' : 3, 'OUTPUT' : '%s', 'VALUE' : '50' }", input, output)
  124. cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
  125. system(cmd)
  126. cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", output))
  127. ## 2.2.2 Seejärel sorteerime <= 60
  128. input <- tmp_gpkg_file_input_1
  129. output <- tmp_gpkg_file_output_2
  130. str <- sprintf("{ 'FIELD' : 'tyyp', 'INPUT' : '%s', 'OPERATOR' : 5, 'OUTPUT' : '%s', 'VALUE' : '60' }", input, output)
  131. cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
  132. system(cmd)
  133. cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", output))
  134. ## 2.2.3 Copy temp gpkg file to postgis.
  135. conf$schema <- "minu_teed"
  136. conf$table <- "teedevork_muud_teed"
  137. PG <- ruut::construct_ogr2ogr_PG_connect_str(conf = conf)
  138. cmd <- sprintf('ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL %s -lco DIM=2 %s %s -overwrite -nlt %s -lco GEOMETRY_NAME=geom -lco FID=id -nln %s.%s -nlt PROMOTE_TO_MULTI', PG, tmp_gpkg_file, layer_2, "LINESTRING", conf$schema, conf$table)
  139. system(cmd)
  140. cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", conf$table))
  141. ## 2.2.4 Leiame need muud teed kus 'tee'=NULL (ilma teenumbrita ehk kvartalissisesed).
  142. input <- tmp_gpkg_file_input_2
  143. output <- tmp_gpkg_file_output_3
  144. str <- sprintf("{ 'FIELD' : 'tee', 'INPUT' : '%s', 'OPERATOR' : 8, 'OUTPUT' : '%s' }", input, output)
  145. cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
  146. system(cmd)
  147. cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", output))
  148. ## 2.2.5 Copy temp gpkg file to postgis.
  149. conf$schema <- "minu_teed"
  150. conf$table <- "numbrita_kohalik_tee"
  151. PG <- ruut::construct_ogr2ogr_PG_connect_str(conf = conf)
  152. cmd <- sprintf('ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL %s -lco DIM=2 %s %s -overwrite -nlt %s -lco GEOMETRY_NAME=geom -lco FID=id -nln %s.%s -nlt PROMOTE_TO_MULTI', PG, tmp_gpkg_file, layer_3, "LINESTRING", conf$schema, conf$table)
  153. system(cmd)
  154. cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", conf$table))
  155. ## =================== 3. 'eesti' =======================
  156. ## 3.1 Maakondadest Eesti maismaapiir
  157. # ruut::qgis_algorithm_search_by_word("dissolve")
  158. algorithm <- "native:dissolve"
  159. # ruut::qgis_show_help(algorithm = algorithm)
  160. conf$schema <- "maaamet"
  161. conf$table <- "maakond"
  162. input <- ruut::construct_to_gpkg_output_postgres_str(
  163. conf = conf, geometry_type = "MultiPolygon", srid = 3301,
  164. checkPrimaryKeyUnicity = TRUE, key = "id", geometry_field = "geom"
  165. )
  166. output <- tmp_gpkg_file_output_1
  167. str <- sprintf("{ 'FIELD' : [], 'INPUT' : '%s', 'OUTPUT' : '%s' }", input, output)
  168. cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
  169. system(cmd)
  170. ## 3.2 Kustutame ebaolulised väljad
  171. # ruut::qgis_algorithm_search_by_word("delete")
  172. algorithm <- "native:deletecolumn"
  173. # ruut::qgis_show_help(algorithm = algorithm)
  174. input <- tmp_gpkg_file_input_1
  175. output <- tmp_gpkg_file_output_2
  176. cmd <- sprintf("qgis_process run %s --COLUMN='mnimi' --COLUMN='mkood' --COLUMN='fid' --INPUT='%s' --OUTPUT='%s' ", algorithm, input, output)
  177. system(cmd)
  178. ## 3.3 Jaotame multipart polügooni singlepart polügoonideks.
  179. # ruut::qgis_algorithm_search_by_word("multipart")
  180. algorithm <- "native:multiparttosingleparts"
  181. # ruut::qgis_show_help(algorithm = algorithm)
  182. input <- tmp_gpkg_file_input_2
  183. output <- tmp_gpkg_file_output_3
  184. str <- sprintf("{ 'INPUT' : '%s', 'OUTPUT' : '%s' }", input, output)
  185. cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
  186. system(cmd)
  187. ## 3.4 Lisame pindade pindalad ja perimeetri
  188. # ruut::qgis_algorithm_search_by_word("columns")
  189. algorithm <- "qgis:exportaddgeometrycolumns"
  190. # ruut::qgis_show_help(algorithm = algorithm)
  191. input <- tmp_gpkg_file_input_3
  192. output <- tmp_gpkg_file_output_1
  193. str <- sprintf("{ 'CALC_METHOD' : 0, 'INPUT' : '%s', 'OUTPUT' : '%s' }", input, output)
  194. cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
  195. system(cmd)
  196. ## 3.5 Eemaldame objektid mille pindala on väiksem kui 10km2 (väikesaared)
  197. # ruut::qgis_algorithm_search_by_word("extract")
  198. algorithm <- "native:extractbyattribute"
  199. # ruut::qgis_show_help(algorithm = algorithm)
  200. input <- tmp_gpkg_file_input_1
  201. output <- tmp_gpkg_file_output_2
  202. # conf$schema <- "minu_teed"
  203. # conf$table <- "eesti"
  204. # output <- ruut::construct_to_gpkg_output_postgres_str(
  205. # conf = conf, key = "fid", geometry_field = "geom"
  206. # )
  207. str <- sprintf("{ 'FIELD' : 'area', 'OPERATOR' : 2, 'VALUE' : '10000000', 'INPUT' : '%s', 'OUTPUT' : '%s' }", input, output)
  208. cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
  209. system(cmd)
  210. ## 3.6 Eemaldame augud, mis on suuremad kui 1ha.
  211. # ruut::qgis_algorithm_search_by_word("holes")
  212. algorithm <- "native:deleteholes"
  213. # ruut::qgis_show_help(algorithm = algorithm)
  214. input <- tmp_gpkg_file_input_2
  215. conf$schema <- "minu_teed"
  216. conf$table <- "eesti"
  217. output <- ruut::construct_to_gpkg_output_postgres_str(
  218. conf = conf, geometry_field = "geom"
  219. )
  220. str <- sprintf("{ 'MIN_AREA' : '10000', 'INPUT' : '%s', 'OUTPUT' : '%s' }", input, output)
  221. cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
  222. system(cmd)
  223. # Processing algorithm…
  224. # Algorithm 'Polygons to lines' starting…
  225. # Input parameters:
  226. # { 'INPUT' : 'postgres://dbname=\'data\' host=localhost port=6432 user=\'osm\' sslmode=disable authcfg=0i30k14 key=\'fid\' srid=3301 type=Polygon checkPrimaryKeyUnicity=\'1\' table=\"minu_teed\".\"eesti\" (geom)', 'OUTPUT' : 'TEMPORARY_OUTPUT' }
  227. ## 3.7 Salvestame eraldi eesti kontuurjooned.
  228. # ruut::qgis_algorithm_search_by_word("lines")
  229. algorithm <- "native:polygonstolines"
  230. # ruut::qgis_show_help(algorithm = algorithm)
  231. conf$schema <- "minu_teed"
  232. conf$table <- "eesti"
  233. input <- ruut::construct_to_gpkg_output_postgres_str(
  234. conf = conf, geometry_type = "Polygon", srid = 3301,
  235. checkPrimaryKeyUnicity = TRUE, key = "fid", geometry_field = "geom"
  236. )
  237. conf$schema <- "minu_teed"
  238. conf$table <- "eesti_l"
  239. output <- ruut::construct_to_gpkg_output_postgres_str(
  240. conf = conf, geometry_field = "geom"
  241. )
  242. str <- sprintf("{ 'INPUT' : '%s', 'OUTPUT' : '%s' }", input, output)
  243. cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
  244. system(cmd)
  245. ## =================== 4. 'riigiteedevork_a' =======================
  246. ## 4.0 Enne polügoniseerimist ühendame eesti kontuuri ja teedevõrgu üheks.
  247. # ruut::qgis_algorithm_search_by_word("merge")
  248. algorithm <- "native:mergevectorlayers"
  249. # ruut::qgis_show_help(algorithm = algorithm)
  250. conf$schema <- "minu_teed"
  251. conf$table <- "eesti_l"
  252. layer_1 <- ruut::construct_to_gpkg_output_postgres_str(
  253. conf = conf, geometry_type = "MultiLineString", srid = 3301,
  254. checkPrimaryKeyUnicity = TRUE, key = "id_1", geometry_field = "geom"
  255. )
  256. conf$schema <- "minu_teed"
  257. conf$table <- "riigiteedevork"
  258. layer_2 <- ruut::construct_to_gpkg_output_postgres_str(
  259. conf = conf, geometry_type = "MultiLineString", srid = 3301,
  260. checkPrimaryKeyUnicity = TRUE, key = "id_0", geometry_field = "geom"
  261. )
  262. output <- tmp_gpkg_file_output_3
  263. # conf$schema <- "minu_teed"
  264. # conf$table <- "riigiteedevork_piiriga"
  265. # output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_field = "geom")
  266. cmd <- sprintf(
  267. "qgis_process run native:mergevectorlayers --CRS='epsg:3301' --LAYERS='%s' --LAYERS='%s' --OUTPUT='%s' ",
  268. layer_1, layer_2, output
  269. )
  270. system(cmd)
  271. cat(sprintf("\n-------------\nLoodi teedev\U00F5rgu andmebaas '%s'.\n",conf$table))
  272. ## 4.1 Polügoniseerime riigiteedevõrgu. Tekib teedega piiratud polügoonid.
  273. # ruut::qgis_algorithm_search_by_word("Polygonize")
  274. algorithm <- "native:polygonize"
  275. # ruut::qgis_show_help(algorithm = algorithm)
  276. input <- tmp_gpkg_file_input_3
  277. # conf$schema <- "minu_teed"
  278. # conf$table <- "riigiteedevork_piiriga"
  279. # input <- ruut::construct_to_gpkg_output_postgres_str(
  280. # conf = conf, geometry_type = "MultiLineString", srid = 3301,
  281. # checkPrimaryKeyUnicity = TRUE, key = "id_0", geometry_field = "geom"
  282. # )
  283. conf$schema <- "minu_teed"
  284. conf$table <- "riigiteedevork_a"
  285. output <- ruut::construct_to_gpkg_output_postgres_str(
  286. conf = conf, geometry_field = "geom"
  287. )
  288. str <- sprintf("{ 'INPUT' : '%s', 'KEEP_FIELDS' : False, 'OUTPUT' : '%s' }", input, output)
  289. cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
  290. system(cmd)
  291. ## 4.2 Lõikame Eesti kaardist polügoniseerime riigiteedevõrgu välja.
  292. ## Tekib ümber Eesti raam, mis tuleb jagada kuidagi transporditsoonideks.
  293. # ruut::qgis_algorithm_search_by_word("Difference")
  294. algorithm <- "native:difference"
  295. # ruut::qgis_show_help(algorithm = algorithm)
  296. conf$schema <- "minu_teed"
  297. conf$table <- "eesti"
  298. input <- ruut::construct_to_gpkg_output_postgres_str(
  299. conf = conf, geometry_type = "Polygon", srid = 3301,
  300. checkPrimaryKeyUnicity = TRUE, key = "fid", geometry_field = "geom"
  301. )
  302. conf$schema <- "minu_teed"
  303. conf$table <- "riigiteedevork_a"
  304. overlay <- ruut::construct_to_gpkg_output_postgres_str(
  305. conf = conf, geometry_type = "Polygon", srid = 3301,
  306. checkPrimaryKeyUnicity = TRUE, key = "fid", geometry_field = "geom"
  307. )
  308. conf$schema <- "minu_teed"
  309. conf$table <- "riigiteedevork_xxx"
  310. output <- ruut::construct_to_gpkg_output_postgres_str(
  311. conf = conf, geometry_field = "geom", key = "fid"
  312. )
  313. str <- sprintf("{ 'INPUT' : '%s', 'OUTPUT' : '%s', 'OVERLAY' : '%s' }", input, output, overlay)
  314. cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
  315. system(cmd)
  316. "Processing algorithm…
  317. Algorithm 'Intersection' starting…
  318. Input parameters:
  319. { 'INPUT' : 'postgres://dbname=\'data\' host=localhost port=6432 user=\'osm\' sslmode=disable authcfg=0i30k14 key=\'fid\' srid=3301 type=MultiLineString checkPrimaryKeyUnicity=\'1\' table=\"minu_teed\".\"riigiteedevork\" (geom)', 'INPUT_FIELDS' : [], 'OUTPUT' : 'TEMPORARY_OUTPUT', 'OVERLAY' : 'postgres://dbname=\'data\' host=localhost port=6432 user=\'osm\' sslmode=disable authcfg=0i30k14 key=\'id_0\' srid=3301 type=MultiPolygon checkPrimaryKeyUnicity=\'1\' table=\"minu_teed\".\"riigiteedevork_xxx\" (geom)', 'OVERLAY_FIELDS' : [], 'OVERLAY_FIELDS_PREFIX' : '' }"
  320. ## 4.3 Kuna polügoniseeritud pinnad ei olnud täiuslikud, siis teostame
  321. ## polügoniseeriist veelkorra. Selleks lõikame esmalt teedevõrgust
  322. ## tekkinud raamiga need teed mis jäävad raamis sisse.
  323. # ruut::qgis_algorithm_search_by_word("Intersection")
  324. algorithm <- "native:intersection"
  325. # ruut::qgis_show_help(algorithm = algorithm)
  326. conf$schema <- "minu_teed"
  327. conf$table <- "riigiteedevork"
  328. input <- ruut::construct_to_gpkg_output_postgres_str(
  329. conf = conf, geometry_type = "MultiLineString", srid = 3301,
  330. checkPrimaryKeyUnicity = TRUE, key = "fid", geometry_field = "geom"
  331. )
  332. conf$schema <- "minu_teed"
  333. conf$table <- "riigiteedevork_xxx"
  334. overlay <- ruut::construct_to_gpkg_output_postgres_str(
  335. conf = conf, geometry_type = "MultiPolygon", srid = 3301,
  336. checkPrimaryKeyUnicity = TRUE, key = "fid", geometry_field = "geom"
  337. )
  338. conf$schema <- "minu_teed"
  339. conf$table <- "riigiteedevork_xxx1"
  340. output <- ruut::construct_to_gpkg_output_postgres_str(
  341. conf = conf, geometry_field = "geom"
  342. )
  343. str <- sprintf("{ 'INPUT' : '%s', 'INPUT_FIELDS' : [], 'OUTPUT' : '%s', 'OVERLAY' : '%s', 'OVERLAY_FIELDS' : [], 'OVERLAY_FIELDS_PREFIX' : '' }", input, output, overlay)
  344. cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
  345. system(cmd)
  346. }