New answers tagged

0

How can I use the ModelBuilder solution but using a raster attribute table? Sort apparently works only with vector features


4

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 ...


2

CONTAINS KEYWORD 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. CASE WHEN "DESCRIPT" ILIKE '%Undifferentiated%' THEN 'dog' ELSE 'cat' END EQUALS EXACT KEYWORD If you want to categorize by exact word, the use this code: CASE ...


4

Just offset the logical operators and petr's syntax is right (imho) if("VALUE1"<0.01,2,if("VALUE1">=0.01 AND "VALUE1"<0.1,3,if("VALUE1" >=0.1 OR "VALUE2">=2,4,0)))


6

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 ELSE 4 END I applied this formula to the VALUE2 field, here is the result:


1

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 * @qgsfunction(args='auto', group='Custom') def splitText(labeltext, feature, parent): split_text = labeltext....


1

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: substr("descript_title",0,17) Which will extract only Oligocene-miocene from the descript_title and add it to the descript_category. Another way is to create a custom ...


1

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 FROM "points" GROUP BY "X, Y" The output ...


0

Probably a bit old-fashion approach but also gives a desired output using the follwoing expression to_int(replace(left("text", regexp_match("text",' ') - 1), ',', ''))


1

Another regex expression to use is the following: regexp_substr("FieldName",'\\d,+\\d+|\\d+') 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.


0

Try using the regular expression provided in this answer. regexp_substr( "location", '\b\d[\d,.]*\b' )


1

When using VBScript, do not specify the variable type. Instead of dim TS_seconds as date simply use dim TS_seconds


5

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: array_find(array_sort(array_agg("field_name")), "field_name")+1 In your case it will be: array_find(array_sort(array_agg("ha")), "ha")+1


7

You may use this expression in your field calculator. if( @row_number % 90=0,90,@row_number % 90)


0

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" end if 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.


0

The Merge tool is what you want. (I'll add that since you noticed sliver polygons after running Union, there will be overlapping areas -- but no slivers -- in the output.)


2

Try: 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 GPS else: return ((PA + defor) * GPS) Call with coop_score= calc(!PA_score!,!def_score!,!GPS_score!) #You need the actual fieldnames here enclosed in !!


1

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 ...


2

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)


0

I checked first for one file the code here Adding a new field and calculating area using Python , then I edited my code: import arcpy from arcpy import env import os 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(...


2

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 ...


1

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 ...


2

The correct syntax for your expression is IF (aggregate(layer:='Layer B', aggregate:= 'count', expression:= $id, filter:=intersects($geometry, geometry(@parent))), concat ('yes'), concat('no')) This is the result:


3

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)))...


Top 50 recent answers are included