girs.feat.layers.LayersSet.copy¶
-
LayersSet.
copy
(target='', **kwargs)¶ Return a copy of the layers
The copy can be:
- a full copy of all fields and field values
- a copy of all field values of selected attribute fields
- a copy of selected field values (filter) from selected attribute fields
If target is given, save the copy before returning the new LayersWriter object.
As per default, all fields are copied. The kwargs key ofields (output fields) defines the field name or list of field names to be copied. Per default this applies to layer number zero. Output fields for specific layers are defined by the layer number appended to ofields. For example, ofields2=[‘NAME’, ‘AREA’] applies to layer number two (which is the third layer). ofields0=[‘NAME’, ‘AREA’] is equivalent to ofields=[‘NAME’, ‘AREA’].
As per default, all field values are copied. The kwargs key filter defines a filter to be applied to the features. Per default this applies to layer number zero. Filters for specific layers are defined by the layer number appended to filter. For example, filter2=lambda a: a < 1000 applies to all features in layer number two (which is the third layer). If filter is used, then ffields (filter fields) must be also defined. In the example above this could be filter2=lambda a: a < 1000, ffields2=[‘AREA’]. Another example: lrs.copy(filter2=lambda a, n: a < 1000 and n.startswith(‘A’), ffields2=[‘AREA’, ‘NAME’]). The filter parameters follow the same order of the list in ffields.
Parameters: - target – file name. Default on memory
- **kwargs –
- ofields: name, list of names, list of (name, new name), dictionary {layer number: name},
- dictionary {layer number: list of names}, or dictionary {layer number: list of (name, new name)}
filter: filter function ffields: list of field names to apply the filter function, or a single field name
Returns: LayerWriter