geo_import: Import spatial or attribute data from an existing file

Description Usage Arguments Value Examples

View source: R/geo_import.R

Description

This function imports spatial or attribute data from an existing source file. Spatial files must be valid shapefiles (.shp), whereas attribute files can be any georeferenced data from a standard csv file. Spatial and attribute data can be imported separately and then linked based on matching geographic units. The source files must be local (e.g., on your computer) or reside at an accessible network location.

Usage

1
geo_import(path, filetype, simplify = FALSE, validity_check = FALSE)

Arguments

path

Filepath specifying location of source file. REQUIRED.

filetype

Name of file type: must be either 'spatial' (.shp file) or 'attribute' (.csv file). REQUIRED.

simplify

TRUE or FALSE (default). If importing a shapefile, optionally create a simplified dataset by removing vertices; useful for creating smaller, more manageable working versions of large shapefiles. OPTIONAL.

validity_check

TRUE or FALSE (default). If importing a shapefile, optionally runs a validity check on each of the geometries and adds the results as a new column "valid_geometry" in the imported data object. Invalid geometries are automatically fixed during import. Geometries may be invalid due to, for example, slivers or self-intersections; such issues may be present in the imported source file, or arise during simplification. OPTIONAL.

Value

Returns a simple features (if source is a shapefile) or tibble (if source is a csv file) data object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Import spatial data (shapefile) ------------------------------------------
geo_import(path = "C:/Users/Michael/Documents/my_shapefile.shp",
           filetype = 'spatial')

# Import attribute data (csv file) -----------------------------------------
geo_import(path = "C:/Users/Michael/Documents/my_attribute_data.csv",
           filetype = 'attribute')

# Optionally simplify imported spatial data and run validity check ---------
geo_import(path = "C:/Users/Michael/Documents/my_shapefile.shp",
           filetype = 'spatial',
           simplify = TRUE,
           validity_check = TRUE)

cpacc/geode documentation built on Feb. 13, 2022, 2:33 p.m.