[Qgis-user] Edit attribute table rows

Lester Anderson arctica1963 at gmail.com
Tue Apr 12 03:25:20 PDT 2016


Hi all,

Thanks for the pointers. I finally ended up just recoding the Python
script to fill the data in.

Useful to know there are alternative routes when working on databases.

Cheers
Lester

On 8 April 2016 at 19:34, Micha Silver <micha at arava.co.il> wrote:
> Here's a way to accomplish what you want in a Spatialite table
>
> I saved your sample 4 rows as a CSV:
>
> row_id,strike,dip,rake,magnitude,quadrant,depth
> 0,,,,,Tensional and Compressional,
> 1,233,38,-96,6.77,Compressional,623
> 2,,,,,Tensional and Compressional,
> 3,68,36,83,5.7,Compressional,39
>
> Then I imported the CSV to Spatialite_gui and ran this query:
>
> UPDATE earthquakes SET depth=(SELECT e.depth FROM earthquakes AS e WHERE
> e.rowid=(earthquakes.rowid+1))
> WHERE depth IS NULL;
>
> Then I got:
> 0    0    0    NULL    NULL    NULL    NULL    Tensional and Compressional
> 623
> 1    1    1    233    38    -96    6.770000    Compressional    623
> 2    2    2    NULL    NULL    NULL    NULL    Tensional and Compressional
> 39
> 3    3    3    68    36    83    5.700000    Compressional    39
>
> HTH,
> Micha
>
> ------ Original Message ------ Subject: Re: [Qgis-user] Edit attribute table
> rows Date: Fri, 8 Apr 2016 17:17:09 +0100 To: Andreas Neumann, Qgis-user
> From: Lester Anderson
>
>
> On 04/08/2016 07:17 PM, Lester Anderson wrote:
>
> Hi Andreas,
>
> Still having issues. I can see the logic of the CASE WHEN END, but I
> am wondering if the problem is because "Depth" has both a NULL value
> and a real value. I have tried all sorts of variants and cannot get
> the NULL depth changed.
>
> Attributes: strike dip rake magnitude quadrant depth
> 0 null null null null null "Tensional and compressional" null
> 1 233 38 -96 6.77 Compressional 623
>
> So scanning for Depth=NULL is fine; this is actually all of the event
> solutions, where the row with the values defines the nodal planes. I
> have around 2928 events in the shapefile!
>
> Can this be solved by scanning for the quadrant attribute, but then
> how does one specify the value for "Depth". I think if one applies
> "Depth" NOT NULL it returns 1
>
> I could not find a guide in the documentation for the field calculator
> that was similar.
>
> Cheers
> Lester
>
> On 8 April 2016 at 15:00, Neumann, Andreas <a.neumann at carto.net> wrote:
>
> Hi Lester,
>
> The field calculator is meant to change "a lot" of values. It will update
> all selected records with the new value or calculation (expression).
>
> With CASE WHEN END you can introduce switches for different rules.
>
> So - please don't export to Excel. You can do it all with the field
> calculator.
>
> Andreas
>
> On 2016-04-08 15:28, Lester Anderson wrote:
>
> Hi Andreas,
>
> I am trying change a lot of values, if it was a few that is no problem.
>
> The other option is to export the attribute table as a database and
> edit in Excel etc and then join the table in QGIS
>
> Cheers
> Lester
>
> On 8 April 2016 at 14:23, Neumann, Andreas <a.neumann at carto.net> wrote:
>
> Hi Lester,
>
> I thought you want to set the value to 623 where the value was NULL before?
> - so just write 623 in the left field after you selected the values.
>
> Alternatively, you can do without the previous selection and use the
> following expression.
>
> CASE WHEN depth IS NULL THEN 623 ELSE depth END
>
> Hope this helps,
>
> Andreas
>
>
>
> On 2016-04-08 15:13, Lester Anderson wrote:
>
> Hello Andreas,
>
> Selecting the rows where depth = NULL is fine. The field calculator
> does not update the depth with the depth where known values are
> present.
>
> Only update selected features is checked, update existing field
> checked, with output field set to depth:
> Expression: tried just "depth" and also "depth"="depth".
>
> Have I missed something here?
>
> Thanks
>
> On 8 April 2016 at 12:30, Neumann, Andreas <a.neumann at carto.net> wrote:
>
> Sure.
>
> It is a two-step thing:
>
> 1. Select all records where Depth IS NULL. Use the "Select Features using an
> expression" button (the Epsilon sign) for that and "depth IS NULL" as an
> expression
>
> 2. Use the field calculator and only update the selected records (the top
> checkbox in the field calculator).
>
> You can find details about the field calculator in the QGIS manual.
>
> Hope this helps,
>
> Andreas
>
> On 2016-04-08 13:18, Lester Anderson wrote:
>
> Hello,
>
> I have an attribute table of earthquake data (focal mechanism beach
> balls) and need to edit the depth attribute. Each ball is defined by
> two rows in the table, eg first ball
>
> Row_ID Strike Dip Rake Magnitude Quadrant Depth
> ----------------------------------------------------------
> 0 NULL NULL NULL NULL Tensional and Compressional NULL
> 1 233 38 -96 6.77 Compressional 623
> 2 NULL NULL NULL NULL Tensional and Compressional NULL
> 3 68 36 83 5.7 Compressional 39
> etc
>
> where rows 0,1 and 2,3 represent separate beach balls, so basically it
> is a row calculation
>
> What I need to do is replace the Depth NULL value with the depth 623
> etc for each entry. Is there an easy way of doing this?
>
> Thanks
>
> Lester
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user
> This mail was received via Mail-SeCure System.
>
> Micha Silver
> Arava Drainage Authority
> +972-523-665918



More information about the Qgis-user mailing list