.Rhistory 16 KB

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