.TH v.in.ascii 1grass "" "GRASS 6.4.2" "Grass User's Manual" .SH NAME \fI\fBv.in.ascii\fR\fR - Creates a vector map from ASCII points file or ASCII vector file. .SH KEYWORDS vector, import .SH SYNOPSIS \fBv.in.ascii\fR .br \fBv.in.ascii help\fR .br \fBv.in.ascii\fR [-\fBzentbr\fR] [\fBinput\fR=\fIname\fR] \fBoutput\fR=\fIname\fR [\fBformat\fR=\fIstring\fR] [\fBfs\fR=\fIcharacter\fR] [\fBskip\fR=\fIinteger\fR] [\fBcolumns\fR=\fIstring\fR] [\fBx\fR=\fIinteger\fR] [\fBy\fR=\fIinteger\fR] [\fBz\fR=\fIinteger\fR] [\fBcat\fR=\fIinteger\fR] [--\fBoverwrite\fR] [--\fBverbose\fR] [--\fBquiet\fR] .SS Flags: .IP "\fB-z\fR" 4m .br Create 3D vector map .IP "\fB-e\fR" 4m .br Create a new empty vector map and exit. Nothing is read from input. .IP "\fB-n\fR" 4m .br Don't expect a header when reading in standard format .IP "\fB-t\fR" 4m .br Do not create table in points mode .IP "\fB-b\fR" 4m .br Do not build topology in points mode .IP "\fB-r\fR" 4m .br Only import points falling within current region (points mode) .IP "\fB--overwrite\fR" 4m .br Allow output files to overwrite existing files .IP "\fB--verbose\fR" 4m .br Verbose module output .IP "\fB--quiet\fR" 4m .br Quiet module output .PP .SS Parameters: .IP "\fBinput\fR=\fIname\fR" 4m .br ASCII file to be imported, if not given reads from standard input .IP "\fBoutput\fR=\fIname\fR" 4m .br Name for output vector map .IP "\fBformat\fR=\fIstring\fR" 4m .br Input file format .br Options: \fIpoint,standard\fR .br Default: \fIpoint\fR .br \fBpoint\fR: simple x,y[,z] list .br \fBstandard\fR: GRASS vector ASCII format .IP "\fBfs\fR=\fIcharacter\fR" 4m .br Field separator .br Default: \fI|\fR .IP "\fBskip\fR=\fIinteger\fR" 4m .br Number of header lines to skip at top of input file (points mode) .br Default: \fI0\fR .IP "\fBcolumns\fR=\fIstring\fR" 4m .br Column definition in SQL style (points mode) .br For example: 'x double precision, y double precision, cat int, name varchar(10)' .IP "\fBx\fR=\fIinteger\fR" 4m .br Number of column used as x coordinate (points mode) .br First column is 1 .br Default: \fI1\fR .IP "\fBy\fR=\fIinteger\fR" 4m .br Number of column used as y coordinate (points mode) .br First column is 1 .br Default: \fI2\fR .IP "\fBz\fR=\fIinteger\fR" 4m .br Number of column used as z coordinate (points mode) .br First column is 1. If 0, z coordinate is not used .br Default: \fI0\fR .IP "\fBcat\fR=\fIinteger\fR" 4m .br Number of column used as category (points mode) .br First column is 1. If 0, unique category is assigned to each row and written to new column 'cat' .br Default: \fI0\fR .PP .SH DESCRIPTION \fIv.in.ascii\fR converts a vector map in ASCII format to a vector map in binary format. The module may import two formats: .RS .IP \fBstandard\fR contains all data types, each coordinate on one row .IP \fBpoint\fR (default) reads only points, each point defined on one row. Values are separated by a user-definable delimiter. If the \fBcolumns\fR 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. .RE .PP The v.out.ascii GRASS module performs the function of \fIv.in.ascii\fR in reverse; i.e., it converts vector maps in binary format to ASCII format. These two companion programs are useful both for importing and exporting vector maps between GRASS and other software, and for transferring data between machines. .SH NOTES The input is read from the file specified by the \fBinput\fR option or from standard input. .PP The field separator may be a character, the word 'tab' (or '\(rst') for tab, 'space' (or ' ') for a blank, or 'comma' (or ',') for a comma. .PP 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 \fBcolumns\fR parameter. .PP 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). .br Acceptable formats: .br \fIkey: D=Degrees; M=Minutes; S=Seconds; h=Hemisphere (N,S,E,W)\fR .RE (+/-)DDD.DDDDD DDDh DDD:MMh DDD:MM.MMMMMh DDD:MM:SSh DDD:MM:SS.SSSSSh .RE .PP Use the \fB-z\fR flag to convert ASCII data into a 3D vector map. .PP In special cases of data import, such as the import of large LIDAR datasets (millions of data points), it may be necessary to disable topology support (creating a GRASS vector level 1 vector map) due to memory constraints. This is done with the \fB-b\fR flag. As only very few vector modules support points data processing at vector level 1, usually topology is required (vector level 2). Therefore it is recommened that the user first try to import the data without creating a database (the \fB-t\fR flag) or within a subregion (the \fB-r\fR flag) before resorting the to disabling of topology. .PP A GRASS ASCII vector map (in \fBstandard format\fR mode) may contain a mix of primitives including points, lines, boundaries, centroids, areas, faces, and kernels. The GRASS ASCII vector format may contain a header with various metadata (see example below). The header is not required if the \fB-n\fR flag is used. .PP The header is similar as the head file of vector binary format but contains bounding box also. Key words are: \fC .DS .br ORGANIZATION .br DIGIT DATE .br DIGIT NAME .br MAP NAME .br MAP DATE .br MAP SCALE .br OTHER INFO .br ZONE .br WEST EDGE .br EAST EDGE .br SOUTH EDGE .br NORTH EDGE .br MAP THRESH .br .DE \fR .PP The body begins with the row: \fC .DS .br VERTI: .br .DE \fR followed by records of primitives: \fC .DS .br TYPE NUMBER_OF_COORDINATES [NUMBER_OF_CATEGORIES] .br X Y [Z] .br .... .br X Y [Z] .br [ LAYER CATEGORY] .br .... .br [ LAYER CATEGORY] .br .DE \fR Everything above in [ ] is optional. .PP The primitive codes are as follows: .RS .IP \(cqP': point .IP \(cqL': line .IP \(cqB': boundary .IP \(cqC': centroid .IP \(cqF': face (3D boundary) .IP \(cqK': kernel (3D centroid) .IP \(cqA': area (boundary) - better use 'B'; kept only for backward compatibility .RE The coordinates are listed following the initial line containing the primitive code, the total number of vectors in the series, and (optionally) the number of categories (1 for a single layer, higher for multiple layers). Below that 1 or several lines follow to indicate the layer number and the category number (ID). .br The order of coordinates is \fC .DS .br X Y [Z] .br .DE \fR In pre-GRASS 6 versions of the ASCII file, the order of coordinates is: \fC .DS .br Y X .br .DE \fR If old version is requested, the \fBoutput\fR files from \fIv.out.ascii\fR is placed in the $LOCATION/$MAPSET/dig_ascii/ and $LOCATION/$MAPSET/dig_att directory. .SS 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 \fBcat\fR parameter must be set to the virtual column number 0 (cat=0). This is the default action if the \fBcat\fR parameter is not set. .SS 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 \fBfs=','\fR option with \fIv.in.ascii\fR in \fBpoints\fR mode. If the input file contains any header lines, such as column headings, the \fBskip\fR 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. .PP 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 \fBskip\fR parameter, it will be treated as a header line and written to the history file. .SS 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. .SS Importing only selected columns Although \fIv.in.ascii\fR 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.: \fC .DS .br # Print out the column number for each field, supposing the file has a header .br head -1 input_file | tr '' '\(rsn' | cat -n .br # From the listing, select the columns you want and feed them to v.in.ascii .br # do not use the input= option .br cut -d -f input_file | v.in.ascii .br .DE \fR .SH EXAMPLES .SS 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: .PP \fC .DS .br echo "ORGANIZATION: GRASS Development Team .br DIGIT DATE: 1/9/2005 .br DIGIT NAME: - .br MAP NAME: test .br MAP DATE: 2005 .br MAP SCALE: 10000 .br OTHER INFO: Test polygons .br ZONE: 0 .br MAP THRESH: 0.500000 .br VERTI: .br B 6 .br 5958812.48844435 3400828.84221011 .br 5958957.29887089 3400877.11235229 .br 5959021.65906046 3400930.7458436 .br 5959048.47580612 3400973.65263665 .br 5959069.92920264 3401032.64947709 .br 5958812.48844435 3400828.84221011 .br C 1 1 .br 5958952.42189184 3400918.23126419 .br 1 20 .br B 4 .br 5959010.9323622 3401338.36037757 .br 5959096.7459483 3401370.54047235 .br 5959091.38259917 3401450.99070932 .br 5959010.9323622 3401338.36037757 .br C 1 1 .br 5959063.08352122 3401386.98533277 .br 1 21" | v.in.ascii format=standard output=test_polygons .br .DE \fR .SS 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 \fB-z\fR flag indicating 3D vector input, and the \fB-n\fR flag indicating no vector header should be expected from the input file. The example can be tested in the Spearfish sample dataset: \fC .DS .br echo "L 5 1 .br 591336 4927369 1224 .br 594317 4925341 1292 .br 599356 4925162 1469 .br 602396 4926653 1235 .br 607524 4925431 1216 .br 1 321 " | v.in.ascii -zn out=line3d format=standard .br .DE \fR This can be used to create a vector line of a GPS track: the GPS points have to be stored into a file with a preceding 'L' and the number of points (per line). .SS Example 2 - point format mode Generate a 2D points vector map 'coords.txt' as ASCII file: \fC .DS .br 1664619|5103481 .br 1664473|5095782 .br 1664273|5101919 .br 1663427|5105234 .br 1663709|5102614 .br .DE \fR .PP Import into GRASS: \fC .DS .br v.in.ascii input=coords.txt output=mymap .br .DE \fR As the \fBcat\fR option is set to 0 by default, an extra column 'cat' containing the IDs will be auto-generated. .SS Example 3 - point format mode Generate a 2D points vector map 'points.dat' as ASCII file: \fC .DS .br 1|1664619|5103481|studna .br 2|1664473|5095782|kadibudka .br 3|1664273|5101919|hruska .br 4|1663427|5105234|mysi dira .br 5|1663709|5102614|mineralni pramen .br .DE \fR .PP Import into GRASS: \fC .DS .br cat points.dat | v.in.ascii out=mypoints x=2 y=3 cat=1 \(rs .br columns='cat int, x double precision, y double precision, label varchar(20)' .br .DE \fR .PP The module is reading from standard input, using the default '|' (pipe) delimiter. .SS Example 4 - point format mode Generating a 3D points vector map from DBMS (idcol must be an integer column): .br \fC .DS .br echo "select east,north,elev,idcol from mytable" | db.select -c | v.in.ascii -z out=mymap .br .DE \fR The module is reading from standard input, using the default '|' (pipe) delimiter. .br The import works for 2D maps as well (no elev column and no '-z' flag). .SS Example 5 - point format mode Generate a 3D points vector map 'points3d.dat' with attributes as ASCII file: \fC .DS .br 593493.1|4914730.2|123.1|studna|well .br 591950.2|4923000.5|222.3|kadibudka|closet .br 589860.5|4922000.0|232.3|hruska|pear .br 590400.5|4922820.8|143.2|mysi dira|mouse hole .br 593549.3|4925500.7|442.6|mineralni pramen|mineral spring .br 600375.7|4925235.6|342.2|kozi stezka|goat path .br .DE \fR .PP Import into GRASS: \fC .DS .br #As the 'cat' option is set to 0 by default, an extra column 'cat' .br #containing the IDs will be auto-generated (no need to define that): .br cat points3d.dat | v.in.ascii -z z=3 cat=0 out=mypoints3D \(rs .br columns='x double precision, y double precision, z double precision, \(rs .br label_cz varchar(20), label_en varchar(20)' .br v.info -c mypoints3D .br v.info mypoints3D .br .DE \fR .SS Example 6 - point format mode Generate points file by clicking onto the map: \fC .DS .br #For LatLong locations: .br d.where -d -l | awk '{printf "%f|%f|point\(rsn", $1, $2}' | v.in.ascii out=points \(rs .br columns='x double precision, y double precision, label varchar(20)' .br .br #For other projections: .br d.where | awk '{printf "%f|%f|point\(rsn", $1, $2}' | v.in.ascii out=points \(rs .br columns='x double precision, y double precision, label varchar(20)' .br .DE \fR The 'point' string (or some similar entry) is required to generate a database table. When simply piping the coordinates (and optionally height) without additional column(s) into \fIv.in.ascii\fR, only the vector map geometry will be generated. .SS Example 7 - point format mode Convert ground control points from i.points into vector points: \fC .DS .br cat $MAPSET/group/$GROUP/POINTS | v.in.ascii out=$GROUP_gcp fs=space skip=3 \(rs .br col='x double precision, y double precision, x_target double precision, \(rs .br y_target double precision, ok int' .br .DE \fR .SH REFERENCES SQL command notes for creating databases .SH SEE ALSO \fI 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, \fR .SH AUTHORS Michael Higgins, U.S.Army Construction Engineering Research Laboratory .br James Westervelt, U.S.Army Construction Engineering Research Laboratory .br Radim Blazek, ITC-Irst, Trento, Italy .PP \fILast changed: $Date: 2011-11-08 12:29:50 +0100 (Tue, 08 Nov 2011) $\fR .PP Full index .PP © 2003-2011 GRASS Development Team