1v.in.ascii(1)                 Grass User's Manual                v.in.ascii(1)
2
3
4

NAME

6       v.in.ascii   -  Creates a vector map from an ASCII points file or ASCII
7       vector file.
8

KEYWORDS

10       vector, import, ASCII, level1, area, line, point
11

SYNOPSIS

13       v.in.ascii
14       v.in.ascii --help
15       v.in.ascii [-zentbri] input=name output=name  [format=string]    [sepa‐
16       rator=character]   [text=character]   [skip=integer]   [columns=string]
17       [x=integer]   [y=integer]   [z=integer]   [cat=integer]   [--overwrite]
18       [--help]  [--verbose]  [--quiet]  [--ui]
19
20   Flags:
21       -z
22           Create 3D vector map
23
24       -e
25           Create a new empty vector map and exit. Nothing is read from input.
26
27       -n
28           Do not expect a header when reading in standard format
29
30       -t
31           Do not create table in points mode
32
33       -b
34           Do not build topology
35           Do not build topology in points mode
36
37       -r
38           Only import points falling within current region (points mode)
39
40       -i
41           Ignore broken line(s) in points mode
42
43       --overwrite
44           Allow output files to overwrite existing files
45
46       --help
47           Print usage summary
48
49       --verbose
50           Verbose module output
51
52       --quiet
53           Quiet module output
54
55       --ui
56           Force launching GUI dialog
57
58   Parameters:
59       input=name [required]
60           Name of input file to be imported
61           ’-’ for standard input
62
63       output=name [required]
64           Name for output vector map
65
66       format=string
67           Input file format
68           Options: point, standard
69           Default: point
70           point: simple x,y[,z] list
71           standard: GRASS vector ASCII format
72
73       separator=character
74           Field separator
75           Special characters: pipe, comma, space, tab, newline
76           Default: pipe
77
78       text=character
79           Text delimiter
80           Special characters: doublequote, singlequote, none
81
82       skip=integer
83           Number of header lines to skip at top of input file (points mode)
84           Default: 0
85
86       columns=string
87           Column definition in SQL style (points mode)
88           For example: ’x double precision, y double precision, cat int, name
89           varchar(10)’
90
91       x=integer
92           Number of column used as x coordinate (points mode)
93           First column is 1
94           Default: 1
95
96       y=integer
97           Number of column used as y coordinate (points mode)
98           First column is 1
99           Default: 2
100
101       z=integer
102           Number of column used as z coordinate (points mode)
103           First column is 1. If 0, z coordinate is not used
104           Default: 0
105
106       cat=integer
107           Number of column used as category (points mode)
108           First column is 1. If 0, unique category is assigned  to  each  row
109           and written to new column ’cat’
110           Default: 0
111

DESCRIPTION

113       v.in.ascii converts a vector map in GRASS ASCII vector format to a vec‐
114       tor map in binary format. The module may import two formats:
115
116           ·   standard contains all data types, each coordinate on one row
117
118           ·   point (default) reads only points, each point  defined  on  one
119               row. Values are separated by a user-definable delimiter. If the
120               columns option is not defined, default names are  used.  It  is
121               possible  to specify the column order for the x,y,z coordinates
122               and category values.
123
124       v.out.ascii performs the function of v.in.ascii in  reverse;  i.e.,  it
125       converts  vector  maps  in  binary format to GRASS ASCII vector format.
126       These two companion programs are useful both for importing and  export‐
127       ing  vector maps between GRASS and other software, and for transferring
128       data between machines.
129

NOTES

131       The input is read from the file specified by the input option  or  from
132       standard input.
133
134       The  field  separator  may be a character, the word ’tab’ (or ’\t’) for
135       tab, ’space’ (or ’ ’) for a blank, or ’comma’ (or ’,’) for a comma.
136
137       An attribute table is only created if it is needed, i.e. when at  least
138       one attribute column is present in the input file besides geometry col‐
139       umns. The attribute column will be auto-scanned for type,  but  may  be
140       explicitly  declared  along with the geometry columns using the columns
141       parameter.
142
143       Use the -z flag to convert ASCII data into a 3D vector map.
144
145       In special cases of data import, such as  the  import  of  large  LIDAR
146       datasets  (millions  of  data  points),  it may be necessary to disable
147       topology support (vector level 1) due to memory constraints.   This  is
148       done  with  the -b flag. As only very few vector modules support points
149       data processing at vector level 1, usually topology is required (vector
150       level 2). Therefore it is recommended that the user first try to import
151       the data without creating a database (the -t flag) or within  a  subre‐
152       gion (the -r flag) before resorting to the disabling of topology.
153
154       If  old  version  is  requested,  the  output files from v.out.ascii is
155       placed    in    the     $LOCATION/$MAPSET/dig_ascii/     and     $LOCA‐
156       TION/$MAPSET/dig_att directory.
157
158   Import of files without category column
159       If the input file does not contain a category column, there is the pos‐
160       sibility to auto-generate these IDs (categories). To automatically  add
161       an  additional column named ’cat’, the cat parameter must be set to the
162       virtual column number 0 (cat=0). This is the default action if the  cat
163       parameter is not set.
164
165   Importing from a spreadsheet
166       Data  may  be  imported  from  many  spreadsheet programs by saving the
167       spreadsheet as a comma separated variable (.csv) text  file,  and  then
168       using  the  separator=’,’  or separator=comma option with v.in.ascii in
169       points mode.  If the input file contains any header lines, such as col‐
170       umn  headings,  the skip parameter should be used. These skipped header
171       lines will be written to the map’s history  file  for  later  reference
172       (read with v.info -h). The skip option only works in points mode.
173
174       Any  line  starting  with the hash character (’#’) will be treated as a
175       comment and skipped completely if located in the  main  data  file.  If
176       located  in  the  header,  as defined by the skip parameter, it will be
177       treated as a header line and written to the history file.
178
179   Import of sexagesimal degree (degree, minutes, seconds, DMS)
180       The import of DMS formatted degrees is supported (in this case no  sign
181       but  N/S,  E/W characters are used to indicate the hemispheres).  While
182       the positions are internally translated into decimal degrees during the
183       import,  the original DMS values are maintained in the attribute table.
184       This requires both the latitude and the longitude columns to be defined
185       as  varchar(),  not  as numbers.  A warning will be issued which can be
186       ignored. See GRASS ASCII vector format specification for details.
187
188   Importing only selected columns
189       Although v.in.ascii doesn’t have an option  to  specify  which  columns
190       should  be  imported,  you  can  use a shell filter to achieve the same
191       effect, e.g.:
192       # Print out the column number for each field, supposing the file has a header
193       head -1 input_file | tr ’<the_field_separator_character>’ ’\n’ | cat -n
194       # From the listing, select the columns you want and feed them to v.in.ascii
195       # use input=- to read from stdin
196       cut -d<the_field_separator_character> -f<comma-separated_list_of_columns> input_file | v.in.ascii in=- <your_options>
197

EXAMPLES

199   Example 1a) - standard format mode
200       Sample ASCII polygon vector map for ’standard’ format  mode.   The  two
201       areas  will be assigned categories 20 and 21. For details on the struc‐
202       ture of standard format data files see the second reference at the bot‐
203       tom of this page.
204
205       echo "ORGANIZATION: GRASS Development Team
206       DIGIT DATE:   1/9/2005
207       DIGIT NAME:   -
208       MAP NAME:     test
209       MAP DATE:     2005
210       MAP SCALE:    10000
211       OTHER INFO:   Test polygons
212       ZONE:  0
213       MAP THRESH:   0.500000
214       VERTI:
215       B  6
216        5958812.48844435 3400828.84221011
217        5958957.29887089 3400877.11235229
218        5959021.65906046 3400930.7458436
219        5959048.47580612 3400973.65263665
220        5959069.92920264 3401032.64947709
221        5958812.48844435 3400828.84221011
222       C  1 1
223        5958952.42189184 3400918.23126419
224        1 20
225       B  4
226        5959010.9323622 3401338.36037757
227        5959096.7459483 3401370.54047235
228        5959091.38259917 3401450.99070932
229        5959010.9323622 3401338.36037757
230       C  1 1
231        5959063.08352122 3401386.98533277
232        1 21" | v.in.ascii in=- format=standard output=test_polygons
233
234   Example 1b) - standard format mode
235       Sample ASCII 3D line vector map for ’standard’ format mode with simpli‐
236       fied input (note the space field separator).  Note the -z flag indicat‐
237       ing 3D vector input, and the -n flag indicating no vector header should
238       be expected from the input file.
239       echo "L 5 1
240       591336 4927369 1224
241       594317 4925341 1292
242       599356 4925162 1469
243       602396 4926653 1235
244       607524 4925431 1216
245       1 321 " | v.in.ascii -zn in=- out=line3d format=standard
246       This can be used to create a vector line of a GPS track: the GPS points
247       have  to  be  stored into a file with a preceding ’L’ and the number of
248       points (per line).
249
250   Example 2 - point format mode
251       Generate a 2D points vector map ’coords.txt’ as ASCII file:
252       1664619|5103481
253       1664473|5095782
254       1664273|5101919
255       1663427|5105234
256       1663709|5102614
257
258       Import into GRASS:
259       v.in.ascii input=coords.txt output=mymap
260       As the cat option is set to 0 by default, an extra  column  ’cat’  con‐
261       taining the category numbers will be auto-generated.
262
263   Example 3 - point format mode
264       Generate a 2D points vector map ’points.dat’ as ASCII file:
265       1|1664619|5103481|studna
266       2|1664473|5095782|kadibudka
267       3|1664273|5101919|hruska
268       4|1663427|5105234|mysi dira
269       5|1663709|5102614|mineralni pramen
270
271       Import into GRASS:
272       cat points.dat | v.in.ascii in=- out=mypoints x=2 y=3 cat=1 \
273           columns=’cat int, x double precision, y double precision, label varchar(20)’
274
275       The module is reading from standard input, using the default ’|’ (pipe)
276       delimiter.
277
278   Example 4 - point format mode - CSV table
279       Import of a 3D points CSV table (’points3d.csv’) with attributes:
280       "num","X","Y","Z","T"
281       1,2487491.643,5112118.33,120.5,18.62
282       2,2481985.459,5109162.78,123.9,18.46
283       3,2478284.289,5105331.04,98.3,19.61
284
285       Import into GRASS:
286       # import: skipping the header line, categories generated automatically,
287       # column names defined with type:
288       v.in.ascii -z in=points3d.csv out=mypoints3D separator=comma \
289         columns="num integer, x double precision, y double precision, z double precision, temp double precision" \
290         x=2 y=3 z=4 skip=1
291       # verify column types
292       v.info -c mypoints3D
293       # verify table content
294       v.db.select mypoints3D
295
296   Example 5 - point format mode
297       Generating a 3D points vector map from DBMS (idcol must be  an  integer
298       column):
299       echo "select east,north,elev,idcol from mytable" | db.select -c | v.in.ascii in=- -z out=mymap
300       With in=-, the module is reading from standard input, using the default
301       ’|’ (pipe) delimiter.
302       The import works for 2D maps as well (no elev column and no ’-z’ flag).
303
304   Example 6 - point format mode
305       Generate a 3D points vector map ’points3d.dat’ with attributes as ASCII
306       file:
307       593493.1|4914730.2|123.1|studna|well
308       591950.2|4923000.5|222.3|kadibudka|outhouse
309       589860.5|4922000.0|232.3|hruska|pear
310       590400.5|4922820.8|143.2|mysi dira|mouse hole
311       593549.3|4925500.7|442.6|mineralni pramen|mineral spring
312       600375.7|4925235.6|342.2|kozi stezka|goat path
313
314       Import into GRASS:
315       #As the ’cat’ option is set to 0 by default, an extra column ’cat’
316       #containing the IDs will be auto-generated (no need to define that):
317       cat points3d.dat | v.in.ascii in=- -z z=3 cat=0 out=mypoints3D \
318           columns=’x double precision, y double precision, z double precision, \
319           label_cz varchar(20), label_en varchar(20)’
320       v.info -c mypoints3D
321       v.info mypoints3D
322
323   Example 7 - point format mode
324       Generate points file by clicking onto the map:
325       #For LatLong locations:
326       d.where -d -l | awk ’{printf "%f|%f|point\n", $1, $2}’ | v.in.ascii in=- out=points \
327           columns=’x double precision, y double precision, label varchar(20)’
328       #For other projections:
329       d.where | awk ’{printf "%f|%f|point\n", $1, $2}’ | v.in.ascii in=- out=points \
330           columns=’x double precision, y double precision, label varchar(20)’
331       The  ’point’  string  (or some similar entry) is required to generate a
332       database table.  When simply piping  the  coordinates  (and  optionally
333       height)  without  additional column(s) into v.in.ascii, only the vector
334       map geometry will be generated.
335
336   Example 8 - point format mode
337       Convert ground control points into vector points:
338       cat $MAPSET/group/$GROUP/POINTS | v.in.ascii in=- out=$GROUP_gcp separator=space skip=3 \
339           col=’x double precision, y double precision, x_target double precision, \
340           y_target double precision, ok int’
341

REFERENCES

343       SQL command notes for creating databases
344       GRASS ASCII vector format specification
345

SEE ALSO

347        db.execute, r.in.ascii, r.in.poly,  r.in.xyz,  v.build,  v.build.poly‐
348       lines,    v.centroids,   v.clean,   v.db.connect,   v.import,   v.info,
349       v.in.lines, v.in.mapgen, v.out.ascii
350

AUTHORS

352       Michael Higgins, U.S.Army Construction Engineering Research Laboratory
353       James Westervelt, U.S.Army Construction Engineering Research Laboratory
354       Radim Blazek, ITC-Irst, Trento, Italy
355

SOURCE CODE

357       Available at: v.in.ascii source code (history)
358
359       Main index | Vector index | Topics index | Keywords index  |  Graphical
360       index | Full index
361
362       © 2003-2019 GRASS Development Team, GRASS GIS 7.8.2 Reference Manual
363
364
365
366GRASS 7.8.2                                                      v.in.ascii(1)
Impressum