Hot answers tagged field-calculator
You are doing nothing wrong: In QGIS Lisboa and 2.1.0 (dev) the areas calculate perfectly, in QGIS 2.01-3 (standalone) not. This is a known QGIS 2.0.1 bug and has a ticket: https://hub.qgis.org/issues/9031 Simply turn off On-the-fly-reprojection while calculating the new field, or try again with the latest dev build from OSGEO4W.
An automated way of doing this task is running a python function within Field Calculator (no selecting and reverse selecting required), see example below: Additionally, if you wanted to replace NULL with an empty string just add these two statements: elif value is None: return ''
Here is how I would do this: Select all rows where oneway = "+" then run a field calculate to set them to "F" Select all rows where oneway = "-" then run a field calculate to set them to "T" Select all rows where oneway = "F" AND oneway = "T", reverse the selection then run the field calculate and set remaining rows to "null".
I do not think you will find a way to do this because there is an existing, not yet Under Consideration, ArcGIS Idea to have the default parser for the Field Calculator be Python, or to at least have a configurable default.
Try something like this where I have assumed that the third field you are wanting to update is of type float or double ... Code Block: def conditional (FarmCateg,PercentArea): if FarmCateg == '4': return PercentArea else: return 0.0 Expression: conditional(!FarmCateg!,!PercentArea!)
Field calculator accepts Python expressions. Unfortunately trunc() function is not available in Python (and so in field calculator) by default and you can't import math module inside field calculator. The easiest way to achieve your goal since floor() is working well is to increment your $x values with the high enough number N that ensures that in the end ...
This is not possible in field calculator. The intersect function in the field calculator does not work with two layers. What you can do is calculate intersections with specific geometries, e.g. intersects( $geometry, geomFromWKT( 'LINESTRING(765145.88 6274561.22, 776031.67 6284189.52)' ) ) For more on these spatial operators check ...
In the Field Calculator; a "field" a 'value in the field' what you do is : replace in field "Type2" field "p" by field "pan" then what you want to do is: replace in field "Type2" value 'p' by value 'pan' so: replace("Type_2", 'p', 'pan')
Solution 1. QGIS&Excel Create new column (objectnumber) in shapefile with unique values ($rownum). Export attribute table of point layer to dbf/ or csv file. In Excel copy values in new column and shift them (for point 1 goes to point 10, the value for point 2 goes to point 11 and so on). Then Join dbf/ or csv table in qgis to shapefile by common field ...
OK! Now I think I have this fully covered. I think the formula to obtain the trunc value (for $x, for instance) is: (abs(ceil($x))-abs(floor($x)))*floor(abs($x)) . The first part ((abs(ceil($x))-abs(floor($x)))) will determine the sign. The second part (floor(abs($x))) will determine the value (using the absolute function).
A suggestion: I too have had GPS'd polygons return negative area values before. I finally figured out why. When I zoomed in really close to a cluster of odd dangles, I found that a few vertices were overlapping themselves, creating the negative value. If you delete the odd nodes, then it becomes a whole polygon and should have a positive value for the ...
It's a bit more complicated than that in QGis. As per this article, you have to create your own function definition in Python, then import it into QGis (this can be done automatically on startup). This may seem tricky, but you only need to do it once and it will always be there! This is the function I used, based on dmahr's above. Not sure how it deals with ...
Only top voted, non community-wiki answers of a minimum length are eligible