To add to your model the two required tasks, you must use the Algorithms Field Calculator and Set Style for Vector Layer.
This is how your model should appear:
Using the Field Calculator algorithm you can create a new field using an expression ($length in your case).
This is how the algorithm should be compilated:
Now you can add to the output of ...
You can make a field that writes the "category" of 'DESCRIPT' features if it has a certain keyword using this code in the field calculator in the attribute table.
WHEN "DESCRIPT" ILIKE '%Undifferentiated%' THEN 'dog'
EQUALS EXACT KEYWORD
If you want to categorize by exact word, the use this code:
You can use the CASE WHEN statement.
I will give you an example, adapt it.
CASE WHEN "VALUE1" < 0.01 THEN 2
WHEN "VALUE1" >= 0.01 AND "VALUE1" < 0.1 THEN 3
I applied this formula to the VALUE2 field, here is the result:
ahmadhanb's answer works, but it seems to me that the part you want to remove always is in paranthesis, so if you split on '(', you can simplify as the first part split is returning is always what you are looking for:
from qgis.gui import *
def splitText(labeltext, feature, parent):
split_text = labeltext....
If only you need to extract Oligocene-miocene and put it in the category column, you can use the substr() function from Field Calculator to update the descript_category column as follows:
Which will extract only Oligocene-miocene from the descript_title and add it to the descript_category.
Another way is to create a custom ...
In QGIS I can suggest using a Virtual Layer through Layer > Add Layer > Add/Edit Virtual Layer...
Let's assume there is a layer with it's corresponding attribute table, see image below.
With the following query, it is possible to achieve the result.
SELECT "X, Y", GROUP_CONCAT(info, ' | ') AS info_concat
GROUP BY "X, Y"
The output ...
Another regex expression to use is the following:
Substitute "FieldName" with the name of the field that you want to extract the digits from. "descriptio" in your case.
The above will extract digits with comma or digits without comma.
You can use use the Field Calculator to create a new field using the size of the polygons to sort your objects.
This is the expression that you can use:
In your case it will be:
if [value] = 1 Then
n = "lowest"
elseif [value] = 2 Then
n = "low"
elseif [value] = 3 Then
n = "moderate"
elseif [value] = 4 Then
n = "high"
elseif [value] = 5 Then
n = "highest"
I used this code similar to above and found it useful in my case. I tried to assign the name of a separate column using another column on big data.
def calc(PA, defor, GPS): #The input fields here, not the output field. The field order need to be the same as when you call the function.
if PA == 0 and defor == 0:
return ((PA + defor) * GPS)
Call with coop_score=
calc(!PA_score!,!def_score!,!GPS_score!) #You need the actual fieldnames here enclosed in !!
If not getting very accurate area calculations does not bother you (or if you do not want to play with different options in the field calculator as mentioned by some of the answers and comments above), in the current version of QGIS (i.e., QGIS 3.12) there is an easy way to deal with this. Go to "Project >> Properties >> General" and change the units for ...
If you just added the excel file to the map, you are trying to edit it using ArcMap which you should avoid.
Right-click the added table and export to a file geodatabase and try your code again on the file geodatabase table.
(btw you should try and learn python instead of vb in Field Calculator, vb is going away)
I checked first for one file the code here Adding a new field and calculating area using Python , then I edited my code:
from arcpy import env
sourceFolderPath = 'MyPath'
for root, dirs, files in arcpy.da.Walk(sourceFolderPath):
for name in files:
if name[-4:] == '.shp':
arcpy.env.workspace = os.path.join(...
Make sure you get correct syntax for Calculate Field. It is best to include parameter names (for example in_table='blablabla') instead of just relying on order/index of parameters:
arcpy.CalculateField_management (in_table="sometable", field="somefield", expression="someexpression",...)
For example you are providing outputFilePath + '/' + name[:-4] as ...
Your problem is that you're missing a parameter in your expression - it needs a non-null field from your points layer to count (and therefore display), then you include the spatial predicate as a filter. Right now, it's interpreting your spatial predicate as the thing to count - and it's going to be the same for the whole layer.
So for example if your ...
The correct syntax for your expression is
IF (aggregate(layer:='Layer B', aggregate:= 'count', expression:= $id,
concat ('yes'), concat('no'))
This is the result:
The problem is that is not possible to consider the spatial relation intersects between points and lines.
Use this expression, that creates a temporary small buffer around the line and applied the count of point inside a polygon.
aggregate(layer:='point', aggregate:='count', expression:="id", filter:=intersects(geometry(@parent), buffer($geometry,0.01)))...