TimNorwey wrote:

  
Could there be other extraneous values somewhere in the original ascii 
file? Maybe rows with an extra comma, or other characters? Can you make 
a bunch of rows available online somewhere so that we can have a look?

    
Returns v.in.ascii no error if I´m importing something that isn´t in the
right format?
Here a part of my csv file: 
http://osgeo-org.1803224.n2.nabble.com/file/n6201677/testData.csv
testData.csv 


  
Hi Tim:
I was able to import your data with no problem. Here are the steps I did to also get the x-y-z values into the attrib table:

# Do the import. Note the -v to make a 3D vector
GRASS 6.4.0RC6 (Tim):/home/micha/geodata/tmp > v.in.ascii -z fs=, in=mytestData.csv col="x_coord double, y_coord double, z double" x=1 y=2 z=3 out=tim_points
Scanning input for column types...
Maximum input row length: 31
Maximum number of columns: 3
Minimum number of columns: 3
Importing points...
 100%
Building topology for vector map <tim_points>...
Registering primitives...
20000 primitives registered
20000 vertices registered
Building areas...
 100%
0 areas built
0 isles built
Attaching islands...
Attaching centroids...
 100%
Number of nodes: 20000
Number of primitives: 20000
Number of points: 20000
Number of lines: 0
Number of boundaries: 0
Number of centroids: 0
Number of areas: 0
Number of isles: 0
v.in.ascii complete.

# Set the default db conection to sqlite
GRASS 6.4.0RC6 (Tim):/home/micha/geodata/tmp > sqlite3 ../grass/Tim/PERMANENT/sqlite.db
SQLite version 3.7.3
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .q
GRASS 6.4.0RC6 (Tim):/home/micha/geodata/tmp > eval `g.gisenv`
GRASS 6.4.0RC6 (Tim):/home/micha/geodata/tmp > db.connect dri=sqlite database=$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db

# Now create the attribute table with 3 columns
GRASS 6.4.0RC6 (Tim):/home/micha/geodata/tmp > v.db.addtable tim_points col="x_coord double, y_coord double, elev double"
Using vector map name as table name: tim_points
Creating new DB connection based on default mapset settings...
Creating table with columns (cat integer, x_coord double, y_coord double,
elev double)
The table <tim_points> is now part of vector map <tim_points> and may be
deleted or overwritten by GRASS modules
Select privileges were granted on the table
Reading features...
 100%
Updating database...
 100%
20000 categories read from vector map (layer 1)
20000 categories read from vector map don't exist in selection from table
20000 records updated/inserted (layer 1)
Current attribute table links:
Vector map <tim_points@PERMANENT> is connected by:
layer <1> table <tim_points> in database </home/micha/geodata/grass/Tim/PERMANENT/sqlite.db> through driver <sqlite> with key <cat>

# And use v.to.db to get the coordinate values and elevation into the table
GRASS 6.4.0RC6 (Tim):/home/micha/geodata/tmp > v.to.db tim_points opt=coor columns="x_coord,y_coord,elev"
Reading features...
 100%
Updating database...
 100%
20000 categories read from vector map (layer 1)
20000 records selected from table (layer 1)
20000 categories read from vector map exist in selection from table
20000 records updated/inserted (layer 1)

# Check that the data are there...
GRASS 6.4.0RC6 (Tim):/home/micha/geodata/tmp > v.db.select tim_points
cat|x_coord|y_coord|elev
1|674065.186|3367985.593|25.83
2|674066.432|3367982.468|25.96
3|674065.991|3367983.836|40.24
4|674065.926|3367985.701|26
5|674064.648|3367988.887|26.13
6|674067.281|3367992.406|-7.76
....
many more rows
....
19991|674435.808|3368209.515|52.37
19992|674437.288|3368205.84|52.4
19993|674438.758|3368202.2|52.37
19994|674440.229|3368198.532|52.6
19995|674441.661|3368194.951|52.89
19996|674443.096|3368191.339|53.42
19997|674444.717|3368187.573|51.06
19998|674446.147|3368183.988|51.42
19999|674447.273|3368180.722|55.88
20000|674449.021|3368176.826|51.78
GRASS 6.4.0RC6 (Tim):/home/micha/geodata/tmp >


HTH
--
Micha

  
Another point you might want to take advantage of: v.in.ascii has an 
option (-z) to create a 3D vector. This means that each point's geometry 
consists of x,y, and z. So you then have the elevation available even if 
the values are not actually in the attribute table. For example, you can 
interpolate a dem from a 3D vector with no attribute table at all.

    
Thank you for the hint, but I used the -z option. I need the elevation in
addition.

Thanks,
Tim



--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/How-to-extract-z-coordiante-and-write-it-into-attribute-table-tp6199821p6201677.html
Sent from the Grass - Users mailing list archive at Nabble.com.
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

This mail was received via Mail-SeCure System.


  

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to