.Rhistory 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. db_is_shema_exist(schema = "x_matsalu")
  2. db_create_new_schema <- function(conf) {
  3. conn <- db_connect()
  4. all_schemas <- DBI::dbGetQuery(conn,sprintf(
  5. "-- DROP SCHEMA x_matsalu;
  6. CREATE SCHEMA %s AUTHORIZATION %s;", conf$schema, conf$user))
  7. }
  8. db_create_new_schema(conf)
  9. styler:::style_active_file()
  10. db_create_new_schema <- function(conf) {
  11. conn <- db_connect()
  12. DBI::dbExecute(conn, sprintf(
  13. "-- DROP SCHEMA x_matsalu;
  14. CREATE SCHEMA %s AUTHORIZATION %s;", conf$schema, conf$user
  15. ))
  16. }
  17. conf <- ruut::get_config()
  18. conf
  19. db_create_new_schema <- function(conf) {
  20. conn <- db_connect()
  21. DBI::dbExecute(conn, sprintf(
  22. "-- DROP SCHEMA x_matsalu;
  23. CREATE SCHEMA %s AUTHORIZATION %s;", conf$schema, conf$user
  24. ))
  25. }
  26. db_create_new_schema(conf)
  27. conf$schema <- "x_valga"
  28. db_create_new_schema(conf)
  29. source(paste0(getwd(), "/R/db_all_schemas"))
  30. source(paste0(getwd(), "/R/db_all_schemas.R"))
  31. paste0(getwd(), "/R/db_all_schemas.R")
  32. source(paste0(getwd(), "/R/db_all_schemas.R"))
  33. db_is_shema_exist(schema = "x_matsalu")
  34. db_is_shema_exist(schema = "x_matsalu")
  35. db_is_shema_exist(schema = "zx_matsalu")
  36. styler:::style_active_file()
  37. styler:::style_active_file()
  38. db_create_new_schema <- function(conf) {
  39. source(paste0(getwd(), "/R/db_is_shema_exist.R"))
  40. if(db_is_shema_exist(schema)) {
  41. conn <- db_connect()
  42. DBI::dbExecute(conn, sprintf(
  43. "-- DROP SCHEMA x_matsalu;
  44. CREATE SCHEMA %s AUTHORIZATION %s;", conf$schema, conf$user
  45. ))
  46. }
  47. }
  48. conf <- ruut::get_config()
  49. conf$schema <- "x_valga"
  50. db_create_new_schema(conf)
  51. conf <- ruut::get_config()
  52. conf$schema <- "x_valga1"
  53. db_create_new_schema(conf)
  54. conf <- ruut::get_config()
  55. conf
  56. conf$schema <- "x_valga1"
  57. conf
  58. db_create_new_schema(conf)
  59. conf$schema
  60. db_create_new_schema <- function(conf) {
  61. source(paste0(getwd(), "/R/db_is_shema_exist.R"))
  62. if(!db_is_shema_exist(conf$schema)) {
  63. conn <- db_connect()
  64. DBI::dbExecute(conn, sprintf(
  65. "-- DROP SCHEMA x_matsalu;
  66. CREATE SCHEMA %s AUTHORIZATION %s;", conf$schema, conf$user
  67. ))
  68. }
  69. }
  70. conf <- ruut::get_config()
  71. conf$schema <- "x_valga1"
  72. db_create_new_schema(conf)
  73. conf <- ruut::get_config()
  74. conf$schema <- "x_valga1"
  75. db_create_new_schema(conf)
  76. library(ruut)
  77. conf <- ruut::get_config()
  78. conf
  79. conf$schema <- "x_valga1"
  80. db_create_new_schema(conf)
  81. db_create_new_schema <- function(conf) {
  82. source(paste0(getwd(), "/R/db_is_shema_exist.R"))
  83. if(!db_is_shema_exist(conf$schema)) {
  84. conn <- db_connect()
  85. DBI::dbExecute(conn, sprintf(
  86. "-- DROP SCHEMA x_matsalu;
  87. CREATE SCHEMA %s AUTHORIZATION %s;", conf$schema, conf$user
  88. ))
  89. }
  90. }
  91. db_create_new_schema(conf)
  92. DBI::dbDisconnect(conn)
  93. conf <- ruut::get_config()
  94. conf$schema <- "x_valga1"
  95. db_create_new_schema(conf)
  96. conf <- ruut::get_config()
  97. conf$schema <- "x_valga1"
  98. db_create_new_schema(conf)
  99. conf <- ruut::get_config()
  100. conf$schema <- "x_valga"
  101. db_create_new_schema(conf)
  102. conf <- ruut::get_config()
  103. conf$schema <- "x_valga"
  104. db_create_new_schema(conf)
  105. conf <- ruut::get_config()
  106. conf$schema <- "x_valga"
  107. db_create_new_schema(conf)
  108. conf <- ruut::get_config()
  109. conf$schema <- "x_valga"
  110. db_create_new_schema(conf)
  111. styler:::style_active_file()
  112. library(ruut)
  113. styler:::style_active_file()
  114. library(ruut)
  115. styler:::style_active_file()
  116. library(ruut)
  117. library(ruut)
  118. library(ruut)
  119. library(ruut)
  120. library(ruut)
  121. ogr2ogr --long-usage
  122. system("ogr2ogr --long-usage")
  123. library(ruut)
  124. library(ruut)
  125. library(ruut)
  126. styler:::style_active_file()
  127. styler:::style_active_file()
  128. system("ogr2ogr --long-usage")
  129. styler:::style_active_file()
  130. styler:::style_active_file()
  131. library(ruut)
  132. #'
  133. #' INSPIRE grid map
  134. #'
  135. library(dplyr)
  136. library(ruut)
  137. # Source: https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2
  138. # Temp directory
  139. tmp_dir <- tempdir()
  140. # Download link
  141. url <- "https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2/gis-files/estonia-shapefile/download"
  142. # Estonia shapefile (ZIP archive)
  143. map_shapefile <- "Estonia_shapefile.zip"
  144. # Download and sav
  145. saveTo <- sprintf("%s/%s", tmp_dir, map_shapefile)
  146. download.file(
  147. url = download_url,
  148. destfile = saveTo, method = "curl", extra = "-L"
  149. )
  150. # Unzip
  151. unzip(saveTo, overwrite = T, exdir = tmp_dir)
  152. # List of files
  153. ls <- list.files(path = tmp_dir, pattern = ".shp")
  154. ls_long <- list.files(path = tmp_dir, pattern = ".shp", full.names = T)
  155. tbl_names <- strsplit(x = ls, split = ".shp") %>% unlist()
  156. # Export to postgis
  157. schema <- "inspire"
  158. i <- 1
  159. config <- get_config()
  160. config$schema <- schema
  161. # New schema
  162. db_create_new_schema(conf = config)
  163. library(dplyr)
  164. library(ruut)
  165. # Source: https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2
  166. # Temp directory
  167. tmp_dir <- tempdir()
  168. # Download link
  169. url <- "https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2/gis-files/estonia-shapefile/download"
  170. # Estonia shapefile (ZIP archive)
  171. map_shapefile <- "Estonia_shapefile.zip"
  172. # Download and sav
  173. saveTo <- sprintf("%s/%s", tmp_dir, map_shapefile)
  174. download.file(
  175. url = url,
  176. destfile = saveTo, method = "curl", extra = "-L"
  177. )
  178. # Unzip
  179. unzip(saveTo, overwrite = T, exdir = tmp_dir)
  180. # List of files
  181. ls <- list.files(path = tmp_dir, pattern = ".shp")
  182. ls_long <- list.files(path = tmp_dir, pattern = ".shp", full.names = T)
  183. tbl_names <- strsplit(x = ls, split = ".shp") %>% unlist()
  184. # Export to postgis
  185. schema <- "inspire"
  186. i <- 1
  187. config <- get_config()
  188. config$schema <- schema
  189. # New schema
  190. db_create_new_schema(conf = config)
  191. print(tbl_names[i])
  192. config$table <- tbl_names[i]
  193. source <- sprintf('"%s" "%s"', tmp_dir, tbl_names[i])
  194. crs_source <- "-s_srs EPSG:3035"
  195. crs_target <- "-t_srs EPSG:4326"
  196. fid <- "fid"
  197. ruut::copy_shp_to_db(dir = tmp_dir, layer = tbl_names[i], conf = config,
  198. id = fid, crs_source = crs_source, crs_target = crs_target,
  199. geometry_type = 'POLYGON')
  200. dir = tmp_dir; layer = tbl_names[i]; conf = config;
  201. id = fid; crs_source = crs_source; crs_target = crs_target;
  202. geometry_type = 'POLYGON'
  203. length(list.files(path = dir, pattern = sprintf("%s*", layer)))
  204. length(list.files(path = dir, pattern = sprintf("%s*", layer))) > 0
  205. source <- sprintf('"%s" "%s"', dir, layer)
  206. source
  207. cmd <- sprintf(
  208. paste0(
  209. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  210. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  211. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  212. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  213. "%s %s -nlt %s"
  214. ),
  215. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  216. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  217. crs_source, crs_target, geometry_type
  218. )
  219. cmd
  220. system(cmd)
  221. dir = tmp_dir; layer = tbl_names[i]; conf = config;
  222. id = fid; crs_source = crs_source; crs_target = crs_target;
  223. geometry_type = 'PROMOTE_TO_MULTI'
  224. cmd <- sprintf(
  225. paste0(
  226. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  227. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  228. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  229. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  230. "%s %s -nlt %s"
  231. ),
  232. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  233. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  234. crs_source, crs_target, geometry_type
  235. )
  236. cmd
  237. ruut::db_create_new_schema(conf)
  238. system(cmd)
  239. cmd <- sprintf(
  240. paste0(
  241. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  242. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  243. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  244. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  245. "%s %s -nlt PROMOTE_TO_MULTI"
  246. ),
  247. config$dbname, config$host, config$port, config$user, config$password,
  248. config$sslmode, config$schema, source, fid, config$schema, config$table,
  249. crs_source, crs_target
  250. )
  251. cmd
  252. system(cmd)
  253. geometry_type = 'POLYGON'
  254. cmd <- sprintf(
  255. paste0(
  256. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  257. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  258. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  259. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  260. "%s %s -nlt %s"
  261. ),
  262. config$dbname, config$host, config$port, config$user, config$password,
  263. config$sslmode, config$schema, source, fid, config$schema, config$table,
  264. crs_source, crs_target, geometry_type
  265. )
  266. cmd
  267. system(cmd)
  268. system("ogr2ogr --long-usage")
  269. cmd <- sprintf(
  270. paste0(
  271. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  272. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  273. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  274. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  275. "-s_srs%s -t_srs -nlt %s"
  276. ),
  277. config$dbname, config$host, config$port, config$user, config$password,
  278. config$sslmode, config$schema, source, fid, config$schema, config$table,
  279. crs_source, crs_target, geometry_type
  280. )
  281. system(cmd)
  282. cmd <- sprintf(
  283. paste0(
  284. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  285. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  286. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  287. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  288. "%s %s -nlt %s"
  289. ),
  290. config$dbname, config$host, config$port, config$user, config$password,
  291. config$sslmode, config$schema, source, fid, config$schema, config$table,
  292. crs_source, crs_target, geometry_type
  293. )
  294. system(cmd)
  295. crs_target
  296. crs_source
  297. cmd
  298. cmd <- sprintf(
  299. paste0(
  300. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  301. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  302. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  303. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  304. "%s %s -nlt %s"
  305. ),
  306. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  307. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  308. crs_source, crs_target, geometry_type
  309. )
  310. cmd
  311. crs_target
  312. crs_source = "EPSG:4326"
  313. cmd <- sprintf(
  314. paste0(
  315. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  316. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  317. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  318. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  319. "%s %s -nlt %s"
  320. ),
  321. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  322. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  323. crs_source, crs_target, geometry_type
  324. )
  325. source('~/apps/R/packages/ruut/R/copy_shp_to_db.R', echo=TRUE)
  326. cmd
  327. cmd <- sprintf(
  328. paste0(
  329. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  330. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  331. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  332. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  333. "-s_srs %s -t_srs %s -nlt %s"
  334. ),
  335. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  336. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  337. crs_source, crs_target, geometry_type
  338. )
  339. copy_shp_to_db <- function(dir = NULL, layer = NULL, conf = NULL, id = "fid",
  340. crs_source = "EPSG:4326",
  341. crs_target = "EPSG:4326",
  342. geometry_type = "PROMOTE_TO_MULTI") {
  343. # Command 'ogr2ogr' help
  344. # system("ogr2ogr --long-usage")
  345. # Kontrollime kas etteantud kataloogis paiknevad failid
  346. if (length(list.files(path = dir, pattern = sprintf("%s*", layer))) > 0) {
  347. source <- sprintf('"%s" "%s"', dir, layer)
  348. cmd <- sprintf(
  349. paste0(
  350. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  351. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  352. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  353. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  354. "-s_srs %s -t_srs %s -nlt %s"
  355. ),
  356. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  357. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  358. crs_source, crs_target, geometry_type
  359. )
  360. ruut::db_create_new_schema(conf)
  361. Sys.sleep(1)
  362. system(cmd)
  363. } else {
  364. cat("\nEi leitud antud kataloogist faile.")
  365. return(NULL)
  366. }
  367. }
  368. ruut::copy_shp_to_db(dir = tmp_dir, layer = tbl_names[i], conf = config,
  369. id = fid, crs_source = crs_source, crs_target = crs_target,
  370. geometry_type = 'POLYGON')
  371. cmd <- sprintf(
  372. paste0(
  373. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  374. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  375. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  376. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  377. "-s_srs %s -t_srs %s -nlt %s"
  378. ),
  379. conf$dbname, conf$host, conf$port, conf$user, conf$password, conf$sslmode,
  380. conf$schema, x, id, conf$schema, conf$table, crs_source, crs_target,
  381. geometry_type
  382. )
  383. source <- sprintf('"%s" "%s"', dir, layer)
  384. cmd <- sprintf(
  385. paste0(
  386. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  387. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  388. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  389. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  390. "-s_srs %s -t_srs %s -nlt %s"
  391. ),
  392. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  393. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  394. crs_source, crs_target, geometry_type
  395. )
  396. cmd
  397. system(cmd)
  398. cmd <- sprintf(
  399. paste0(
  400. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  401. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  402. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  403. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  404. "%s %s -nlt %s"
  405. ),
  406. config$dbname, config$host, config$port, config$user, config$password,
  407. config$sslmode, config$schema, source, fid, config$schema, config$table,
  408. crs_source, crs_target, geometry_type
  409. )
  410. system(cmd)
  411. source <- sprintf('"%s" "%s"', tmp_dir, tbl_names[i])
  412. crs_source <- "EPSG:3035"
  413. crs_target <- "EPSG:4326"
  414. fid <- "fid"
  415. cmd <- sprintf(
  416. paste0(
  417. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  418. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  419. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  420. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  421. "-s_srs %s -t_srs %s -nlt %s"
  422. ),
  423. config$dbname, config$host, config$port, config$user, config$password,
  424. config$sslmode, config$schema, source, fid, config$schema, config$table,
  425. crs_source, crs_target, geometry_type
  426. )
  427. system(cmd)
  428. config
  429. conf
  430. config
  431. cmd <- sprintf(
  432. paste0(
  433. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  434. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  435. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  436. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  437. "-s_srs %s -t_srs %s -nlt %s"
  438. ),
  439. config$dbname, config$host, config$port, config$user, config$password,
  440. config$sslmode, config$schema, source, fid, config$schema, config$table,
  441. crs_source, crs_target, geometry_type
  442. )
  443. system(cmd)
  444. cmd <- sprintf(
  445. paste0(
  446. "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
  447. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  448. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  449. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  450. "-s_srs %s -t_srs %s -nlt %s"
  451. ),
  452. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  453. conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
  454. crs_source, crs_target, geometry_type
  455. )
  456. system(cmd)
  457. cmd <- sprintf(
  458. paste0(
  459. "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
  460. "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
  461. "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
  462. "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
  463. "-s_srs %s -t_srs %s -nlt %s"
  464. ),
  465. conf$dbname, conf$host, conf$port, conf$user, conf$password,
  466. conf$sslmode, conf$schema, source, fid, conf$schema, conf$table,
  467. crs_source, crs_target, geometry_type
  468. )
  469. system(cmd)
  470. styler:::style_active_file()
  471. library(ruut)
  472. styler:::style_active_file()
  473. styler:::style_active_file()
  474. library(ruut)
  475. styler:::style_active_file()
  476. styler:::style_active_file()
  477. library(ruut)
  478. styler:::style_active_file()
  479. library(ruut)
  480. styler:::style_active_file()
  481. styler:::style_active_file()
  482. library(ruut)
  483. styler:::style_active_file()
  484. styler:::style_active_file()
  485. styler:::style_active_file()
  486. styler:::style_active_file()
  487. library(ruut)
  488. conf <- ruut::get_config()
  489. conf
  490. styler:::style_active_file()
  491. library(ruut)
  492. library(ruut)
  493. conn <- ruut::db_connect()
  494. config <- get_config()
  495. config$schema <- "public"
  496. conf = config
  497. q <- sprintf("select t.table_name
  498. from information_schema.tables t
  499. where t.table_schema = '%s'
  500. and t.table_type = 'BASE TABLE'
  501. order by t.table_name;", conf$schema)
  502. conf$schema
  503. res <- DBI::dbGetQuery(conn, q)
  504. res
  505. res <- as.array(DBI::dbGetQuery(conn, q))
  506. res <- DBI::dbGetQuery(conn, q)
  507. res[,'table_name']
  508. styler:::style_active_file()
  509. library(ruut)
  510. config
  511. config$schema <- 'maaamet'
  512. db_schema_tablenames(conf = config)