SPLIT_LAYER
The SPLIT_LAYER command allows you to split a layer into multiple layers based on some attribute value. The original layer is closed if there was any split that happened.
The following parameters are supported by the command:
- FILENAME - filename of the layer to split. If an empty value is passed in, all loaded vector layers will be split. This parameter can be listed more than once to specify multiple input files, like FILENAME="FILENAME_1" FILENAME="FILENAME_2". When running the script in the context of the main map view (including loading a workspace) you can also pass in the value 'USER CREATED FEATURES' to have the 'User Created Features' layer split or 'SELECTED LAYERS' to have any layers selected in the Control Center split. If you don't pass anything in all vector layers will be operated on.
- SPLIT_BY_ATTR - specifies the attribute to split on. A new layer will be generated for each set of attributes values in the input data. This can be a normal attribute name or a special one. See special Attribute Name parameter details.
- SPLIT_ATTR_SEP - specifies a separator to check for in the split attribute. If multiple values are in the split attribute a separate layer will be created for each. You can use special values like COMMA, TAB, SPACE, and SEMICOLON in addition to just specifying the separator string directly. For example if you use SPLIT_BY_ATTR="PROPERTY_ID" and a feature has a PROPERTY_ID attribute with the value "A,B,C" and you add SPLIT_ATTR_SEP=COMMA, you will get 3 copies of the feature, one in layer A, one in layer B, and one in layer C.
- LAYER_DESC_ATTR_ONLY - specifies that the description assigned to newly created layers will just consist of the attribute value rather than the original layer description with the attribute value appended.
- CLOSE_ORIG_LAYER - specifies that the layer that was split into new sub-layers should be closed when the operation completes. This is done by default, so add CLOSE_ORIG_LAYER=NO to keep the original layer open.