.Rhistory 16 KB

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