<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html style="direction: ltr;">
<head>
<meta content="text/html; charset=UTF-8" 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="UTF-8" bgcolor="#ffffff"
text="#000000">
On 01/03/2012 10:44 PM, Bulent Arikan wrote:
<blockquote
cite="mid:CAA5wL0gMLpry5wdhapHUtgwUsRJtHENSW3DRtTiKze6UHhDWeA@mail.gmail.com"
type="cite">Thank you! This seems to be an interesting solution to
the problem especially because it involves changing the driver
from DBF to SQLITE. I ended up using 'v.rast.stats', which adds
columns for extended statistics and uploads values all at once.
The only thing is: data are recorded as part of the same layer
(i.e., Layer 1). So, I cheated!
<div>
<br>
</div>
</blockquote>
<br>
<br>
Yes, v.rast.stats is definitely the way to go if you want raster
univariate statistics pushed into a polygon vector.<br>
<br>
<br>
<blockquote
cite="mid:CAA5wL0gMLpry5wdhapHUtgwUsRJtHENSW3DRtTiKze6UHhDWeA@mail.gmail.com"
type="cite">
<div>However, I started trying your method. I created a new mapset
to use sqlite and copied some vector maps from a mapset where
default driver is DBF. I defined SQLITE as the new driver in the
new mapset using 'db.connect' </div>
<div>(driver=sqlite,
database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db', no flags
checked). Then I wanted to use 'v.db.connect' for a vector map
but I cannot select table name etc. I also tried just using
'v.db.connect' but I still cannot see anything under Table. So.
I am confused about how to define a new driver in a mapset.</div>
<div><br>
</div>
</blockquote>
<br>
I do as follows:<br>
eval `g.gisenv`<br>
(This creates the environment variables for GISDBASE, etc.)<br>
Now:<br>
db.connect driv=sqlite
database=$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db<br>
<br>
Next:<br>
g.copy vect=old,new<br>
to create a new copy of the original vector. The original will still
have its attrib table as dbf. THe new copy will have an sqlite based
attribute table.<br>
Now you can do:<br>
<br>
v.db.addcol <new_vector> col="..., ..." .<br>
<br>
BTW, I think that v.rast.stats will automatically create the needed
columns .<br>
<br>
Cheers,<br>
Micha<br>
<br>
<blockquote
cite="mid:CAA5wL0gMLpry5wdhapHUtgwUsRJtHENSW3DRtTiKze6UHhDWeA@mail.gmail.com"
type="cite">
<div>Thank you again,</div>
<div><br>
</div>
<div>Bulent<br>
<br>
<div class="gmail_quote">On Tue, Jan 3, 2012 at 9:13 PM, Micha
Silver <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:micha@arava.co.il" target="_blank">micha@arava.co.il</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<div style="direction: ltr;" bgcolor="#ffffff"
text="#000000">
<div> On 01/03/2012 04:50 PM, Bulent Arikan wrote:
<blockquote 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>
</div>
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 type="cite">
<div>
<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>
</div>
This mail was received via Mail-SeCure System.<br>
<pre><fieldset></fieldset>
_______________________________________________
grass-user mailing list
<a moz-do-not-send="true" href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a>
<a moz-do-not-send="true" href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a>
This mail was received via Mail-SeCure System.
</pre>
<span><font color="#888888"> </font></span></blockquote>
<span><font color="#888888">
<p><br>
</p>
<br>
<pre cols="72">--
Micha Silver
GIS Consultant, Arava Development Co.
<a moz-do-not-send="true" href="http://www.surfaces.co.il" target="_blank">http://www.surfaces.co.il</a></pre>
</font></span></div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
BÜLENT ARIKAN, PhD
<div>Senior Research Fellow</div>
<div>Research Center for Anatolian Civilizations<br>
Koç University<br>
İstiklal Caddesi No: 181 Merkez Han</div>
<div>Beyoğlu - ISTANBUL</div>
<div>TURKEY<br>
34433</div>
<div><a moz-do-not-send="true"
href="tel:%28%2B%2090%29%20212-393-6036"
value="+902123936036" target="_blank">(+ 90) 212-393-6036</a></div>
<br>
</div>
<br>
This mail was received via Mail-SeCure System.<br>
</blockquote>
<p><br>
</p>
</body>
</html>