openSTARS (version 1.2.2)

import_vector_data: Import vector data into GRASS.

Description

Generic function to import vector data of various formats into the GRASS environment.

Usage

import_vector_data(data, name, layer = NULL, proj_ref_obj = NULL, snap = -1)

Arguments

data

character string or object; path to data vector file (shape), postgis data source name (dsn; see details), or sp or sf data object.

name

string giving the base name of the vector data within the GRASS environment (i.e. output)

layer

character string; default 1, particularly needed if data is a dsn for importing postgis data (see details)

proj_ref_obj

character; path to a georeferenced data file to be used as reference; only used if data is an sf of sp object, then, the two projections are compared to check if on-the-fly reprojection is needed for importing; typically the dem raster file used in this project.

snap

float; snapping threshold in map units. If != -1 (default) vertices are snapped to other vertices in this snapping distance during import. If used, the features are automatically cleaned afterwards (see GRASS tools v.import and v.clean )

Value

Nothing.

Details

For importing data from Postgis, all data base credentials must be supplied in data and the correct layer and, if the table containing the polygons are in a specific schema also that one (see example)

Examples

Run this code
# NOT RUN {
# import data from Postgis
# }
# NOT RUN {
import_vector_data(data = "PG: 'pgname=postgit_DB', 'host=123.45.67.890', 
'port='1234', 'user=username', 'password=password'",
 name = "forest", layer = "landuse_schema.forest")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab