Skip to content

Commit b84e167

Browse files
committed
Initial commit
0 parents  commit b84e167

File tree

9 files changed

+94
-0
lines changed

9 files changed

+94
-0
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
^sealR\.Rproj$
2+
^\.Rproj\.user$

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.Rproj.user

DESCRIPTION

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Package: sealR
2+
Title: What the Package Does (One Line, Title Case)
3+
Version: 0.0.0.9000
4+
Authors@R:
5+
person(given = "First",
6+
family = "Last",
7+
role = c("aut", "cre"),
8+
email = "[email protected]",
9+
comment = c(ORCID = "YOUR-ORCID-ID"))
10+
Description: What the package does (one paragraph).
11+
License: What license it uses
12+
Encoding: UTF-8
13+
LazyData: true
14+
RoxygenNote: 6.1.99.9001

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Generated by roxygen2: do not edit by hand
2+
3+
export(url_shp_to_spdf)

R/url_shp_to_spdf.R

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#' Mass download .shp files from URL
2+
#'
3+
#' The function allows you to download shapefile zip files into a temporary folder and directory, which are then unzipped and ready to use in R. Temp folders are automatically unlinked (deleted) and the working directory is set back to original within every iteration of the function. This means no shapefiles are stored to the drive.
4+
#'
5+
#' Source of function: Kay Cichini (https://www.r-bloggers.com/batch-downloading-zipped-shapefiles-with-r/)
6+
7+
#' @param URL URL containing download links of different .shp files
8+
#' @keywords shapefile
9+
#' @export
10+
#' @examples
11+
#' url_shp_to_spdf()
12+
13+
url_shp_to_spdf <- function(URL) {
14+
require(rgdal)
15+
wd <- getwd()
16+
td <- tempdir()
17+
setwd(td)
18+
temp <- tempfile(fileext = ".zip")
19+
download.file(URL, temp)
20+
unzip(temp)
21+
shp <- dir(tempdir(), "*.shp$")
22+
lyr <- sub(".shp$", "", shp)
23+
y <- lapply(X = lyr, FUN = function(x) readOGR(dsn=shp, layer=lyr))
24+
names(y) <- lyr
25+
unlink(dir(td))
26+
setwd(wd)
27+
return(y)
28+
}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# sealR
2+
Repo for common functions from SEAL lab at NCSU

man/url_shp_to_spdf.Rd

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sealR.Rproj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Version: 1.0
2+
3+
RestoreWorkspace: No
4+
SaveWorkspace: No
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 2
10+
Encoding: UTF-8
11+
12+
RnwWeave: Sweave
13+
LaTeX: pdfLaTeX
14+
15+
AutoAppendNewline: Yes
16+
StripTrailingWhitespace: Yes
17+
18+
BuildType: Package
19+
PackageUseDevtools: Yes
20+
PackageInstallArgs: --no-multiarch --with-keep.source
21+
PackageRoxygenize: rd,collate,namespace

0 commit comments

Comments
 (0)