<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
Hello,<br>
<br>
Actually in QGIS, updating an existing layer with data coming from
other layers, files or processing output is not trivial.<br>
=> It is possible to copy/paste features from one layer to
another, but no user friendly possibility to define fields mapping.<br>
=> Processing algorithms always create new layers, but do not
give the possibility to update an existing one.<br>
=> "Import to Postgis" algorithm can be used for table creation
too, no updating options.<br>
=> DB Manager have the same limitations.<br>
<br>
We want to improve this in QGIS and we have some propositions (see
below).<br>
Let me know what you think about this. Should we create a QEP ?<br>
<h4>1 - Create a new processing algorithm "Import into existing
layer"</h4>
This algorithm would give the possibility to update / insert into an
existing layer,<br>
with data coming from file, loaded layer or processing output .<br>
This would give the possibility to wrote, from processing, to any
type of datasource that support writing.<br>
<br>
Here's the inputs :<br>
Source layer (vector): Vector layer for reading<br>
Source identifier (field): Primary key in source layer<br>
<br>
Destination layer (vector) : Vector layer for writing<br>
Destination identifier (field) : Primary key in destination
layer<br>
<br>
Insert new features (checkbox) : Insert new features in
destination layer.<br>
Update existing features (checkbox) : Update existing
features in destination layer.<br>
Delete features (checkbox) : Should features, that do not
exits in source, be deleted from destination ?<br>
<br>
No output, as a result, inserted and updated features could be
selected.<br>
<br>
The identifier fields give a one/one relationship between source and
destination layer.<br>
<br>
Regarding the writing method, I see two possibilities :<br>
<br>
* Use the edition buffer, the user could see the result before
saving to disk or database.<br>
Note that this could use a lot of memory in case of treating
a lot of data.<br>
<br>
* Use directly the provider methods.<br>
<br>
Maybe we could propose a choice between this two methods.<br>
<br>
<span class="gt-baf-back">Thereafter, the user should expect a field
mapper from the source to the destination (possibly with the use
of expressions).<br>
For exporting, we can use the refactorfield as an final output </span><span
class="gt-baf-back"><span class="gt-baf-back">algorithm.<br>
For importing, fields already exists on destination, here it
should be simpler than </span></span><span class="gt-baf-back"><span
class="gt-baf-back"><span class="gt-baf-back">refactorfield
mapper.</span></span></span><span class="gt-baf-back"><span
class="gt-baf-back"><br>
Note that we will not have source/destination fields definition
in all cases, only for loaded layers.<br>
</span></span>
<h4><span class="gt-baf-back"><span class="gt-baf-back">2 - Update
input layer with "Import into existing layer" after existing
algorithms<br>
</span></span></h4>
<h4><span class="gt-baf-back"><span class="gt-baf-back"></span></span></h4>
<span class="gt-baf-back"><span class="gt-baf-back">As a second
time, we could add an option on some existing algorithm,<br>
with only one input layer,<br>
that do not change fields definition,</span></span><br>
<span class="gt-baf-back"><span class="gt-baf-back"><span
class="gt-baf-back"><span class="gt-baf-back">that add a
checkbox or output option in algorithm dialog, </span></span>to
update the input layer as an output.<br>
<br>
For example, I want to make a buffer on a selection in a loaded
vector layer.<br>
In most case, I want this to be done on the source layer, not in
a new layer.<br>
Processing do not give this possibility for now.<br>
<br>
What I propose is not to change existing algorithms, but to add
an output option in the dialog.<br>
As a result, after running the base algorithm, an import would
be done using the feature Id as a primary key to update the
input layer using </span></span><span class="gt-baf-back"><span
class="gt-baf-back"><span class="gt-baf-back"><span
class="gt-baf-back">edition buffer</span></span>.<br>
<br>
This would be user friendly for common operations on existing
layers.<br>
</span></span>
<h4>3 - Propose a field mapping for paste operation</h4>
<p>This take place on the c++ part of QGIS, in the Edit / Paste
features (Ctrl+V) action in main menu.<br>
Actually, when we paste features from one layer to another, fields
that do not exists on destination layer are lost without warning.<br>
We should expect a field mapper dialog here, close to the one in
previous proposition.<br>
<br>
</p>
<p>Best regards.<br>
</p>
<pre class="moz-signature" cols="72">--
Arnaud Morvan
Ingénieur logiciel
Tél: +33 (0)4 58 48 20 32
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac Cedex
<a class="moz-txt-link-freetext" href="http://www.camptocamp.com">http://www.camptocamp.com</a></pre>
</body>
</html>