Note: A new GRASS GIS stable version has been released: GRASS GIS 7. Go directly to the new manual page here
The v.out.ascii GRASS module performs the function of v.in.ascii 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.
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).
Acceptable formats:
key: D=Degrees; M=Minutes; S=Seconds; h=Hemisphere (N,S,E,W)
Use the -z flag to convert ASCII data into a 3D vector map.
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 -b 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 recommended that the user first try to import the data without creating a database (the -t flag) or within a subregion (the -r flag) before resorting to the disabling of topology.
A GRASS ASCII vector map (in standard format 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 -n flag is used.
The header is similar as the head file of vector binary format but contains bounding box also. Key words are:
ORGANIZATION DIGIT DATE DIGIT NAME MAP NAME MAP DATE MAP SCALE OTHER INFO ZONE WEST EDGE EAST EDGE SOUTH EDGE NORTH EDGE MAP THRESH
The body begins with the row:
VERTI:followed by records of primitives:
TYPE NUMBER_OF_COORDINATES [NUMBER_OF_CATEGORIES] X Y [Z] .... X Y [Z] [ LAYER CATEGORY] .... [ LAYER CATEGORY]Everything above in [ ] is optional.
The primitive codes are as follows:
X Y [Z]
Y X
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.
# Print out the column number for each field, supposing the file has a header head -1 input_file | tr '<the_field_separator_character>' '\n' | cat -n # From the listing, select the columns you want and feed them to v.in.ascii # do not use the input= option cut -d<the_field_separator_character> -f<comma-separated_list_of_columns> input_file | v.in.ascii <your_options>
echo "ORGANIZATION: GRASS Development Team DIGIT DATE: 1/9/2005 DIGIT NAME: - MAP NAME: test MAP DATE: 2005 MAP SCALE: 10000 OTHER INFO: Test polygons ZONE: 0 MAP THRESH: 0.500000 VERTI: B 6 5958812.48844435 3400828.84221011 5958957.29887089 3400877.11235229 5959021.65906046 3400930.7458436 5959048.47580612 3400973.65263665 5959069.92920264 3401032.64947709 5958812.48844435 3400828.84221011 C 1 1 5958952.42189184 3400918.23126419 1 20 B 4 5959010.9323622 3401338.36037757 5959096.7459483 3401370.54047235 5959091.38259917 3401450.99070932 5959010.9323622 3401338.36037757 C 1 1 5959063.08352122 3401386.98533277 1 21" | v.in.ascii format=standard output=test_polygons
echo "L 5 1 591336 4927369 1224 594317 4925341 1292 599356 4925162 1469 602396 4926653 1235 607524 4925431 1216 1 321 " | v.in.ascii -zn out=line3d format=standard
1664619|5103481 1664473|5095782 1664273|5101919 1663427|5105234 1663709|5102614
Import into GRASS:
v.in.ascii input=coords.txt output=mymap
1|1664619|5103481|studna 2|1664473|5095782|kadibudka 3|1664273|5101919|hruska 4|1663427|5105234|mysi dira 5|1663709|5102614|mineralni pramen
Import into GRASS:
cat points.dat | v.in.ascii out=mypoints x=2 y=3 cat=1 \ columns='cat int, x double precision, y double precision, label varchar(20)'
The module is reading from standard input, using the default '|' (pipe) delimiter.
echo "select east,north,elev,idcol from mytable" | db.select -c | v.in.ascii -z out=mymap
593493.1|4914730.2|123.1|studna|well 591950.2|4923000.5|222.3|kadibudka|closet 589860.5|4922000.0|232.3|hruska|pear 590400.5|4922820.8|143.2|mysi dira|mouse hole 593549.3|4925500.7|442.6|mineralni pramen|mineral spring 600375.7|4925235.6|342.2|kozi stezka|goat path
Import into GRASS:
#As the 'cat' option is set to 0 by default, an extra column 'cat' #containing the IDs will be auto-generated (no need to define that): cat points3d.dat | v.in.ascii -z z=3 cat=0 out=mypoints3D \ columns='x double precision, y double precision, z double precision, \ label_cz varchar(20), label_en varchar(20)' v.info -c mypoints3D v.info mypoints3D
#For LatLong locations: d.where -d -l | awk '{printf "%f|%f|point\n", $1, $2}' | v.in.ascii out=points \ columns='x double precision, y double precision, label varchar(20)' #For other projections: d.where | awk '{printf "%f|%f|point\n", $1, $2}' | v.in.ascii out=points \ columns='x double precision, y double precision, label varchar(20)'
cat $MAPSET/group/$GROUP/POINTS | v.in.ascii out=$GROUP_gcp fs=space skip=3 \ col='x double precision, y double precision, x_target double precision, \ y_target double precision, ok int'
Last changed: $Date: 2013-05-03 12:47:09 -0700 (Fri, 03 May 2013) $
Main index - vector index - Full index
© 2003-2016 GRASS Development Team