<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html style="direction: ltr;">
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
<style>body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body style="direction: ltr;"
bidimailui-detected-decoding-type="latin-charset" bgcolor="#ffffff"
text="#000000">
On 01/03/2012 04:50 PM, Bulent Arikan wrote:
<blockquote
cite="mid:CAA5wL0jKizxBnsKxMecu-Lf=xvY-bD11zoJv61r-KB-U2DgK=g@mail.gmail.com"
type="cite">Dear List,
<div><br>
</div>
<div>I rasterized a centroid and ran 'r.univar', whose extended
stats are saved as a text file. Then, I ran 'v.db.addtable' to
create a second layer in the attribute table of the centroid and
I had columns added in this second layer using 'v.db.addcol'. I
want GRASS to upload values from the text file but I am not sure
how to perform this task. </div>
<div><br>
</div>
<div>Is there a shorter way of creating a second layer and
uploading values from the text file or what should I do next so
that the columns in the second layer will be populated using the
text file I have?</div>
<div><br>
</div>
</blockquote>
<br>
I'm not sure about a shorter way, but here's an option:<br>
First setup your mapset to save attributes to sqlite. <br>
> v.db.connect centroid driver=sqlite database=.... <br>
<br>
Now add the columns which will accept r.univar values to the sqlite
table:<br>
> v.db.addcol centroid col="n double, null_cells double, cells
double, min double, max double, range double, mean double,
mean_of_abs double, stddev double, variance double, coeff_var
double, sum double"<br>
<br>
Run r.univar on your raster, putting results into a text file<br>
> r.univar your_rast -g > univar.txt<br>
<br>
Now do this loop to update values for the centroid:<br>
> while read l; do \<br>
col=`echo $l | cut -d= -f1`; val=`echo $l | cut -d= -f2`; \<br>
sqlite3 sqlite.db "UPDATE centroid SET ${col}=${val} ;"; \<br>
> done < univar.txt<br>
<br>
Assuming you want to run this for several centroids/areas, you'll
probably want to add a WHERE clause to the UPDATE statement so as to
put values for only one certain row (centroid).<br>
<br>
HTH, Micha<br>
<br>
<br>
<blockquote
cite="mid:CAA5wL0jKizxBnsKxMecu-Lf=xvY-bD11zoJv61r-KB-U2DgK=g@mail.gmail.com"
type="cite">
<div>Thank you for your time.<br clear="all">
<div><br>
</div>
<div>GRASS 6.5 svn on Snow Leopard</div>
<div><br>
</div>
<div><br>
</div>
-- <br>
BÜLENT<br>
</div>
<br>
This mail was received via Mail-SeCure System.<br>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
grass-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/grass-user">http://lists.osgeo.org/mailman/listinfo/grass-user</a>
This mail was received via Mail-SeCure System.
</pre>
</blockquote>
<p><br>
</p>
<br>
<pre class="moz-signature" cols="72">--
Micha Silver
GIS Consultant, Arava Development Co.
<a class="moz-txt-link-freetext" href="http://www.surfaces.co.il">http://www.surfaces.co.il</a></pre>
</body>
</html>