New answers tagged

7

The geometry type does not need to be written in capital letters. But of course, the wkt string should have closing coordinates. Seems like a bug to me as on Windows 64bit version of 3.16.2 and 3.10.12 I get closing coordinates when using geom_to_wkt($geometry). However, as stated by Kadir Şahbaz, QGIS should be able to work without. However, just to ...


7

WKT is case-insensitive for definition of geometry (Reference) and QGIS accepts the WKT string without the first and last point being the same. For example: geom_from_wkt( 'Polygon ((27 52, 31 37, 18 21))' ) and geomWkt = QgsGeometry.fromWkt('Polygon ((27 52, 31 37, 18 21))') work. From documentation: Note that unlike some programs, QGIS will close the ...


5

The user Python functions are stored within the profile directory of your active profile. Under Mac it should be something like ~/Library/Application\Support/QGIS/QGIS3/profiles. The easiest thing will be use Menu: Settings->User Profiles->Open Active Profile Folder. There you will find a folder /python/expressions where the Python functions are stored....


4

I keep a copy of QGIS 2.18 to solve problems just like yours. Use the tool Points to Paths (note the plural Paths), which, sadly, was never ported to 3.x. This tool creates an output line from each point pair, where the attributes from the beginning and ending point in each pair are transferred to their respective line in the output layer. 2.18 is easily ...


6

If you want to retrieve the point layer ID, you can use these expressions as default values : For start point : array_first( aggregate( layer:='point', -- here put the name of the point layer aggregate:='array_agg', expression:="ID", -- here put the name of the point layer field you want to get filter:=...


5

If you need the IDs of the intersecting points, see J. Monticolo's answer. If you need the lines ID, keep on reading: Unfortunately, you can not use $id or @row_number directly. Not sure why, but I assume its because you can not determine the id of a not yet existing feature. You will also see this in preview, which returns a negative number, which is not ...


2

Instead go to field calculator, click on Update existing field, and then select the column where you have to add the value and in below Expression box Add the value in single inverted comma Ex 'No'


3

If you want to use regular expressions, you can do this with the following expression in the field calculator - see the PCRE Regex Cheatsheet (that's the regular expression engine QGIS uses) for functions and syntax. This solution first converts your input to an array (each element delimited with _ is considered a separate value in the array), then with a ...


5

One of the solutions in a long way may be the following. array_to_string( array_foreach( string_to_array(linecode, '_'), if( right(@element, 1) = 'F', substr(@element, 0, strpos(@element, 'F') - 1), '-' + substr(@element,0, strpos(@element, 'B') - 1) ) ) ) How does it work: split the value ...


4

You can use regexp_replace function in field calculator: The expression regexp_replace( "linecode", '^-(.*)$', '\\1B') will replace '-' + 'any string' with 'any string' + 'B'. So it will change string '-0345' to '0345B'. \\1 refer to the expression part in brackets. You may give more specific regexp instead of '.*'. The second expression will ...


4

Use this expression: if(left(linecode, 1) = '-', substr(linecode, 2) + 'B', linecode + 'F') I suggest to create new field instead of changing the existing one. You may need the original one later.


3

What you can do is using an expression to get the names of your attributes. The core of this solution is that you can use the expression attributes() in combinaiton with map_akeys. When you have the name of the field, you can get it's value for each feature with attribute(attribute_name). Thus you can use this to multiply it, let's say by 4, like this: ...


Top 50 recent answers are included