I want to batch process with Clip function (also problem with any other). I have several input layers. I would like to autofill the output Clipped
parameter with name of the input feature and _clipped
suffix, such as in this example:
The Expression String Builder acts oddly when I use @INPUT
parameter, there is a name of the input feature along with some weird memory address or something.
Why does this happen with the INPUT layer name? Where do I find the name without the odd suffix?
I found out I can go around this when I tinker with the string a bit like so:
string_to_array(@INPUT,'_')[0]
Then I get:
However, what if the name itself contain underscores?
-
If you use OUTPUT instead will that work?John– John2021年10月06日 13:13:22 +00:00Commented Oct 6, 2021 at 13:13
1 Answer 1
That weird string is not a memory address, but the layer's id. You can use the following expression to construct INPUTLAYERNAME_clipped
string. And no need string_to_array(@INPUT,'_')[0]
.
layer_property( @INPUT, 'name' ) + '_clipped'
layer_property(@INPUT, 'name')
returns the layer name. If you need the layer source file name, use this:
base_file_name( layer_property( @INPUT, 'source' ) ) + '_clipped'
-
Thanks! This is a good workaround a partly offers a solution. I wrote it earlier here as a Q&A style but it was deleted by the moderator as apparently a new question... Nevertheless, how comes that you don't get to acquire base file name in the query builder?janchytry– janchytry2021年10月06日 13:33:26 +00:00Commented Oct 6, 2021 at 13:33
-
@janchytry Do you need the input file name instead of layer name?Kadir Şahbaz– Kadir Şahbaz2021年10月06日 13:39:00 +00:00Commented Oct 6, 2021 at 13:39
-
Not exactly in this case, but often I do.janchytry– janchytry2021年10月06日 13:41:12 +00:00Commented Oct 6, 2021 at 13:41
-
@janchytry I see, I've added how to get file name.Kadir Şahbaz– Kadir Şahbaz2021年10月06日 13:42:55 +00:00Commented Oct 6, 2021 at 13:42
-
Thanks, that's an nice combination of functions I haven't known about.janchytry– janchytry2021年10月06日 14:52:49 +00:00Commented Oct 6, 2021 at 14:52
Explore related questions
See similar questions with these tags.