table of contents
other versions
- jessie 6.4.4-1
- stretch 7.2.0-2
- testing 7.6.0-1
- unstable 7.6.0-1
- experimental 7.6.1-1~exp1
| v.in.ascii(1grass) | Grass User's Manual | v.in.ascii(1grass) |
NAME¶
v.in.ascii - Creates a vector map from ASCII points file or ASCII vector file.KEYWORDS¶
vector, importSYNOPSIS¶
v.in.asciiFlags:¶
- -z
-
Create 3D vector map
- -e
-
Create a new empty vector map and exit. Nothing is read from input.
- -n
-
Don't expect a header when reading in standard format
- -t
-
Do not create table in points mode
- -b
-
Do not build topology in points mode
- -r
-
Only import points falling within current region (points mode)
- --overwrite
-
Allow output files to overwrite existing files
- --verbose
-
Verbose module output
- --quiet
-
Quiet module output
Parameters:¶
- input=name
-
ASCII file to be imported, if not given reads from standard input
- output=name
-
Name for output vector map
- format=string
-
Input file formatOptions: point,standardDefault: pointpoint: simple x,y[,z] liststandard: GRASS vector ASCII format
- fs=character
-
Field separatorSpecial characters: newline, space, comma, tabDefault: |
- skip=integer
-
Number of header lines to skip at top of input file (points mode)Default: 0
- columns=string
-
Column definition in SQL style (points mode)For example: 'x double precision, y double precision, cat int, name varchar(10)'
- x=integer
-
Number of column used as x coordinate (points mode)First column is 1Default: 1
- y=integer
-
Number of column used as y coordinate (points mode)First column is 1Default: 2
- z=integer
-
Number of column used as z coordinate (points mode)First column is 1. If 0, z coordinate is not usedDefault: 0
- cat=integer
-
Number of column used as category (points mode)First column is 1. If 0, unique category is assigned to each row and written to new column 'cat'Default: 0
DESCRIPTION¶
v.in.ascii converts a vector map in ASCII format to a vector map in binary format. The module may import two formats:- standard contains all data types, each coordinate on one row
- point (default) reads only points, each point defined on one row. Values are separated by a user-definable delimiter. If the columns option is not defined, default names are used. It is possible to specify the column order for the x,y,z coordinates and category values.
NOTES¶
The input is read from the file specified by the input option or from standard input. The field separator may be a character, the word 'tab' (or '\t') for tab, 'space' (or ' ') for a blank, or 'comma' (or ',') for a comma. An attribute table is only created if it is needed, i.e. when at least one attribute column is present in the input file besides geometry columns. The attribute column will be auto-scanned for type, but may be explicitly declared along with the geometry columns using the columns parameter. Latitude/Longitude data may be given in a number of ways. Decimal degrees must be positive or negative instead of using a hemisphere letter. Mixed coordinates must use a hemisphere letter. Whole minutes and seconds must always contain two digits (example: use 167:03:04.567; and not 167:3:4.567).X Y [Z]
X Y [Z]
- ’P': point
- ’L': line
- ’B': boundary
- ’C': centroid
- ’F': face (3D boundary)
- ’K': kernel (3D centroid)
- ’A': area (boundary) - better use 'B'; kept only for backward compatibility
X Y [Z]
Import of files without category ID column¶
If the input file does not contain a vector ID column, there is the possibility to auto-generate these IDs (categories). To automatically add an additional column named 'cat', the cat parameter must be set to the virtual column number 0 (cat=0). This is the default action if the cat parameter is not set.Importing from a spreadsheet¶
Data may be imported from many spreadsheet programs by saving the spreadsheet as a comma separated variable (.csv) text file, and then using the fs=',' option with v.in.ascii in points mode. If the input file contains any header lines, such as column headings, the skip parameter should be used. These skipped header lines will be written to the map's history file for later reference (read with v.info -h). The skip option only works in points mode. Any line starting with the hash character ('#') will be treated as a comment and skipped completely if located in the main data file. If located in the header, as defined by the skip parameter, it will be treated as a header line and written to the history file.Import of sexagesimal degree (degree, minutes, seconds, DMS)¶
The import of DMS formatted degrees is supported (in this case no sign but N/S, E/W characters are used to indicate the hemispheres). While the positions are internally translated into decimal degrees during the import, the original DMS values are maintained in the attribute table. This requires both the latitude and the longitude columns to be defined as varchars(), not as numbers. A warning will be issued which can be ignored.Importing only selected columns¶
Although v.in.ascii doesn't have an option to specify which columns should be imported, you can use a shell filter to achieve the same effect, e.g.:EXAMPLES¶
Example 1a) - standard format mode¶
Sample ASCII polygon vector map for 'standard' format mode. The two areas will be assigned categories 20 and 21. The example can be tested in the Spearfish sample dataset:5958812.48844435 3400828.84221011
5958957.29887089 3400877.11235229
5959021.65906046 3400930.7458436
5959048.47580612 3400973.65263665
5959069.92920264 3401032.64947709
5958812.48844435 3400828.84221011
5958952.42189184 3400918.23126419
1 20
5959010.9323622 3401338.36037757
5959096.7459483 3401370.54047235
5959091.38259917 3401450.99070932
5959010.9323622 3401338.36037757
5959063.08352122 3401386.98533277
1 21" | v.in.ascii format=standard output=test_polygons
Example 1b) - standard format mode¶
Sample ASCII 3D line vector map for 'standard' format mode with simplified input (note the space field separator). Note the -z flag indicating 3D vector input, and the -n flag indicating no vector header should be expected from the input file. The example can be tested in the Spearfish sample dataset:Example 2 - point format mode¶
Generate a 2D points vector map 'coords.txt' as ASCII file:Example 3 - point format mode¶
Generate a 2D points vector map 'points.dat' as ASCII file:columns='cat int, x double precision, y double precision, label varchar(20)'
Example 4 - point format mode¶
Generating a 3D points vector map from DBMS (idcol must be an integer column):Example 5 - point format mode¶
Generate a 3D points vector map 'points3d.dat' with attributes as ASCII file:columns='x double precision, y double precision, z double precision, \
label_cz varchar(20), label_en varchar(20)'
Example 6 - point format mode¶
Generate points file by clicking onto the map:columns='x double precision, y double precision, label varchar(20)'
columns='x double precision, y double precision, label varchar(20)'
Example 7 - point format mode¶
Convert ground control points from i.points into vector points:col='x double precision, y double precision, x_target double precision, \
y_target double precision, ok int'
REFERENCES¶
SQL command notes for creating databasesSEE ALSO¶
db.execute, r.in.ascii, r.in.xyz, v.build, v.build.polylines, v.centroids, v.clean, v.db.connect, v.info, v.out.ascii,AUTHORS¶
Michael Higgins, U.S.Army Construction Engineering Research Laboratory| GRASS 6.4.4 |