| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512 |
- geometry_type = "PROMOTE_TO_MULTI"
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=ISO-8859-4; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING ISO-8859-4 -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=ISO-8859-4; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING ISO-8859-4 -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- paste0(
- "export PGCLIENTENCODING=ISO-8859-4; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING ISO-8859-4 -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- )
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=ISO-8859-4; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING ISO-8859-4 -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- conf$dbname
- conf$host
- conf$port
- conf$user
- conf$password
- conf$sslmode
- conf$schema
- source
- source <- sprintf('"%s" "%s"', tmp_dir_kihid, tbl_names[i])
- source
- source
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=ISO-8859-4; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING ISO-8859-4 -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- cmd
- system(cmd)
- conf$table
- print(tbl_names[i])
- conf$table <- tolower(tbl_names[i])
- source <- sprintf('"%s" "%s"', tmp_dir_kihid, tbl_names[i])
- ## Export to postgis database.
- conf$primary_key = 'id'
- conf$s_srs = "EPSG:3301"
- conf$t_srs = "EPSG:3301"
- geometry_type = "PROMOTE_TO_MULTI"
- # ruut::copy_shp_to_db(
- # dir = tmp_dir_kihid, layer = tbl_names[i], conf = conf,
- # id = "id", crs_source = "EPSG:3301", crs_target = "EPSG:3301",
- # geometry_type = "PROMOTE_TO_MULTI"
- # )
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=ISO-8859-4; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING ISO-8859-4 -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- cat(sprintf(
- "\nShp fail %s kopeeriti POSTGIS andmebaasi %s.%s\n\n",
- ls[i], conf$schema, conf$table
- ))
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=ISO-8859-4; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING UTF-8 -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=UTF-8; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING UTF-8 -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- styler:::style_active_file()
- library(estmap)
- encoding <- 'UTF-8'
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=%s; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING %s -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ), encoding, encoding,
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- cmd
- tbl_names
- i = 33
- print(tbl_names[i])
- conf$table <- tolower(tbl_names[i])
- source <- sprintf('"%s" "%s"', tmp_dir_kihid, tbl_names[i])
- ## Export to postgis database.
- conf$primary_key <- "id"
- conf$s_srs <- "EPSG:3301"
- conf$t_srs <- "EPSG:3301"
- geometry_type <- "PROMOTE_TO_MULTI"
- encoding <- 'UTF-8'
- encoding <- 'CP1257'
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=%s; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING %s -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ), encoding, encoding,
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- # Unzip
- utils::unzip(saveTo, overwrite = T, exdir = tmp_dir)
- print(tbl_names[i])
- conf$table <- tolower(tbl_names[i])
- source <- sprintf('"%s" "%s"', tmp_dir_kihid, tbl_names[i])
- ## Export to postgis database.
- conf$primary_key <- "id"
- conf$s_srs <- "EPSG:3301"
- conf$t_srs <- "EPSG:3301"
- geometry_type <- "PROMOTE_TO_MULTI"
- encoding <- 'UTF-8'
- encoding <- 'CP1257'
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=%s; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING %s -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ), encoding, encoding,
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- encoding <- 'ISO-8859-4'
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=%s; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING %s -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ), encoding, encoding,
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- encoding <- 'ISO-8859-4'
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=%s; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING %s -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ), encoding, encoding,
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- encoding <- 'ISO-8859-4'
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=%s; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING %s -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s -skipfailures"
- ), encoding, encoding,
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- encoding <- 'UTF-8'
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=%s; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING %s -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s -skipfailures"
- ), encoding, encoding,
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- tbl_names
- i=15
- print(tbl_names[i])
- conf$table <- tolower(tbl_names[i])
- source <- sprintf('"%s" "%s"', tmp_dir_kihid, tbl_names[i])
- ## Export to postgis database.
- conf$primary_key <- "id"
- conf$s_srs <- "EPSG:3301"
- conf$t_srs <- "EPSG:3301"
- geometry_type <- "PROMOTE_TO_MULTI"
- encoding <- 'UTF-8'
- # encoding <- 'ISO-8859-4'
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=%s; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING %s -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s -skipfailures"
- ), encoding, encoding,
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- tbl_names
- i = 41
- print(tbl_names[i])
- conf$table <- tolower(tbl_names[i])
- source <- sprintf('"%s" "%s"', tmp_dir_kihid, tbl_names[i])
- ## Export to postgis database.
- conf$primary_key <- "id"
- conf$s_srs <- "EPSG:3301"
- conf$t_srs <- "EPSG:3301"
- geometry_type <- "PROMOTE_TO_MULTI"
- encoding <- 'UTF-8'
- # encoding <- 'ISO-8859-4'
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=%s; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING %s -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s -skipfailures"
- ), encoding, encoding,
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- encoding <- 'UTF-16'
- # encoding <- 'ISO-8859-4'
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=%s; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING %s -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s -skipfailures"
- ), encoding, encoding,
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- encoding <- 'UTF-16'
- # encoding <- 'ISO-8859-4'
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=%s; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING %s -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s -skipfailures"
- ), encoding, encoding,
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- encoding <- 'ISO-8859-4'
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=%s; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING %s -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s -skipfailures"
- ), encoding, encoding,
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- tbl_names[i]
- if(tbl_names[i] %in% c('Kirik_p')) encoding <- 'ISO-8859-4' else encoding <- 'UTF-8'
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=%s; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING %s -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s -skipfailures"
- ), encoding, encoding,
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- styler:::style_selection()
- styler:::style_active_file()
- url <- "https://geoportaal.maaamet.ee/docs/muld"
- # Estonia shapefile (ZIP archive)
- map_shapefile <- "Mullakaart_SHP.zip"
- # Download and save
- url_download <- sprintf("%s", url)
- saveTo <- sprintf("%s/%s", tmp_dir, map_shapefile)
- url_download
- url <- "https://geoportaal.maaamet.ee/docs/muld/Mullakaart_SHP.zip"
- # Estonia shapefile (ZIP archive)
- map_shapefile <- "Mullakaart_SHP.zip"
- # Download and save
- url_download <- sprintf("%s", url)
- url_download
- saveTo <- sprintf("%s/%s", tmp_dir, map_shapefile)
- saveTo
- # Temp directory
- tmp_dir <- sprintf("%s/tmp/%s", system.file(package = "estmap"), "maaamet_mullakaart")
- if (!dir.exists(tmp_dir)) {
- dir.create(tmp_dir)
- }
- # Download link
- url <- "https://geoportaal.maaamet.ee/docs/muld/Mullakaart_SHP.zip"
- # Estonia shapefile (ZIP archive)
- map_shapefile <- "Mullakaart_SHP.zip"
- # Download and save
- url_download <- sprintf("%s", url)
- saveTo <- sprintf("%s/%s", tmp_dir, map_shapefile)
- saveTo
- file.exists(saveTo)
- # Unzip
- utils::unzip(saveTo, overwrite = T, exdir = tmp_dir)
- # List of files
- tmp_dir_kihid <- sprintf("%s/%s", tmp_dir, map_shapefile)
- ls <- list.files(path = tmp_dir_kihid, pattern = ".dbf")
- ls_long <- list.files(path = tmp_dir_kihid, pattern = ".dbf", full.names = T)
- tbl_names <- unlist(strsplit(x = ls, split = ".dbf"))
- tbl_names
- ls
- tmp_dir
- tmp_dir
- ls <- list.files(path = tmp_dir, pattern = ".dbf")
- ls
- ls <- list.files(path = tmp_dir, pattern = ".dbf")
- ls_long <- list.files(path = tmp_dir, pattern = ".dbf", full.names = T)
- tbl_names <- unlist(strsplit(x = ls, split = ".dbf"))
- tbl_names
- conf$schema <- "eesti"
- ruut::db_create_new_schema(conf = conf)
- length(tbl_names)
- i=1
- print(tbl_names[i])
- conf$table <- tolower(tbl_names[i])
- source <- sprintf('"%s" "%s"', tmp_dir_kihid, tbl_names[i])
- ## Export to postgis database.
- conf$primary_key <- "id"
- conf$s_srs <- "EPSG:3301"
- conf$t_srs <- "EPSG:3301"
- geometry_type <- "PROMOTE_TO_MULTI"
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=UTF-8; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING UTF-8 -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- cmd
- system(cmd)
- print(tbl_names[i])
- conf$table <- tolower(tbl_names[i])
- source <- sprintf('"%s" "%s"', tmp_dir_kihid, tbl_names[i])
- source
- conf$primary_key <- "id"
- conf$s_srs <- "EPSG:3301"
- conf$t_srs <- "EPSG:3301"
- geometry_type <- "PROMOTE_TO_MULTI"
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=UTF-8; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING UTF-8 -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- cmd
- source
- source <- sprintf('"%s" "%s"', tmp_dir, tbl_names[i])
- source('~/apps/R/packages/estmap/R/maaamet_mullakaart.R', echo=TRUE)
- source
- print(tbl_names[i])
- conf$table <- tolower(tbl_names[i])
- source <- sprintf('"%s" "%s"', tmp_dir, tbl_names[i])
- ## Export to postgis database.
- conf$primary_key <- "id"
- conf$s_srs <- "EPSG:3301"
- conf$t_srs <- "EPSG:3301"
- geometry_type <- "PROMOTE_TO_MULTI"
- cmd <- sprintf(
- paste0(
- "export PGCLIENTENCODING=UTF-8; ",
- "ogr2ogr -progress --config PG_USE_COPY YES --config PGCLIENTENCODING UTF-8 -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geom -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, conf$primary_key, conf$schema, conf$table,
- conf$s_srs, conf$t_srs, geometry_type
- )
- system(cmd)
- # Delete unnecessary files.
- system(sprintf("find %s -type f -not -name '%s' -print0 | xargs -0 rm --", tmp_dir, map_shapefile))
- styler:::style_active_file()
- library(estmap)
- library(estmap)
- styler:::style_active_file()
- library(estmap)
- library(estmap)
- library(estmap)
- library(estmap)
- library(estmap)
|