Feature request #11319

Allow to (re)add features to null geometries

Added by Giovanni Manghi over 2 years ago. Updated over 1 year ago.

Status:Closed Start Date:10/03/2014
Priority:High Due date:
Assigned to:- % Done:

0%

Category:Digitising
Target version:Future Release - High Priority
Platform: Resolution:
Platform version: Pull Request or Patch supplied:No
Status info: Tag:

Description

It seems that since 2.4 the node tool allow to remove every node of a line/polygon feature, but this does not triggers the removal of the relative record in th attribute table.

Until 2.2 the last segment/triangle was impossible to be removed, as expected.

The specification for shapefiles says that

"The table must contain one record per shape feature."

Not sure about other formats/models.


Related issues

related to QGIS Application - Bug report #12885: cannot add part to empty geometries anymore Closed 06/04/2015
related to QGIS Application - Bug report #10976: attribute table refresh problems after edits Closed 07/29/2014

Associated revisions

Revision ad10b5264e45e4d298c5a256618d6bbb96a84944
Added by Nyall Dawson over 1 year ago

Fix using add part tool to add part to geometryless rows
(fix #12885, #11319)

Also fix some potential crashes with edit tools and null geometry

History

Updated by Arnaud Morvan over 2 years ago

For myself, it seems normal that a feature geometry can be null.

But after having removed the last point, it is impossible to create a new first point with the node tool.
It says : "could not snap to a segment on the current layer".

I've tried to had a new part, but it says: "Selected geometry could not be found".

No way found to get out of this (create a new geometry for the feature).

Updated by Giovanni Manghi over 2 years ago

Arnaud Morvan wrote:

For myself, it seems normal that a feature geometry can be null.

But after having removed the last point, it is impossible to create a new first point with the node tool. It says : "could not snap to a segment on the current layer".

I've tried to had a new part, but it says: "Selected geometry could not be found".

No way found to get out of this (create a new geometry for the feature).

I think that this case is allowed in certain data types (ex. PostGIS) but it seems it is not on shapes. And anyway as you say the process is not reversible, so it should be not allowed in QGIS (as it was until 2.2). Cheers!

Updated by Matthias Kuhn over 2 years ago

I work with database tables that are allowed to have NULL geometries. I therefore vote for allowing those.
To fix the current unsatisfying situation my approach would be two things:

  • A layer setting "Allow NULL geometry"
    • If this is set to False, pre 2.4 behavior should be applied
    • If it is set to True, removing vertices leads to NULL geometry, pressing delete with a feature selection deletes the feature
    • If the above interpretation of the shapefile standard is correct, this option should be disabled for shapefiles
  • Add a tool to the attribute dialog that allows to digitize a geometry for a record without geometry a posteriori

Updated by Giovanni Manghi over 2 years ago

Matthias Kuhn wrote:

I work with database tables that are allowed to have NULL geometries. I therefore vote for allowing those.

yes that's what I said, allowed by certain models, not allowed certainly in shapefiles.

To fix the current unsatisfying situation my approach would be two things:

  • A layer setting "Allow NULL geometry"
  • If this is set to False, pre 2.4 behavior should be applied
  • If it is set to True, removing vertices leads to NULL geometry, pressing delete with a feature selection deletes the feature
  • If the above interpretation of the shapefile standard is correct, this option should be disabled for shapefiles
  • Add a tool to the attribute dialog that allows to digitize a geometry for a record without geometry a posteriori

that's ok for me

Updated by Jürgen Fischer over 2 years ago

  • Status changed from Open to Feedback

Are null geometries actually a invalid geometry for shape files? Are there errors on save? Can features with null geometry be removed? In that case I'd consider this a feature request for replacing the geometry of an existing feature and not a blocker.

Updated by Giovanni Manghi over 2 years ago

  • Status changed from Feedback to Open

Jürgen Fischer wrote:

Are null geometries actually a invalid geometry for shape files?

I cannot find a specific reference in shapefile specifications, but this

http://resources.esri.com/help/9.3/arcgisdesktop/com/gp_toolref/data_management_toolbox/checking_and_repairing_geometries.htm

suggests that empty geometries are not allowed by it:

...

Below is the list of geometry problems:

...

Null geometry: The feature has no geometry or nothing in the SHAPE field. Null geometry errors will be deleted.
...
...
...

Are there errors on save?

there aren't, but in previous qgis releases it wasn't possible to remove (with the node tool) the very last segment of a line or the last polygon made of 3 nodes (and it also should not be possible to remove a node from a 3 nodes polygon).

Can features with null geometry be removed?

yes

In that case I'd consider this a feature request for replacing the geometry of an existing feature and not a blocker.

see link above, in my opinion it would not be a feature request, but a bug in first place. If you do not agree I suggest to at least throw a warning when the user deletes the very last node of a geometry, saying that is going to leave a orphan record (that will likely cause issues in other software packages able to read shapefiles).

Updated by Jürgen Fischer over 2 years ago

Giovanni Manghi wrote:

see link above, in my opinion it would not be a feature request, but a bug in first place. If you do not agree I suggest to at least throw a warning when the user deletes the very last node of a geometry, saying that is going to leave a orphan record (that will likely cause issues in other software packages able to read shapefiles).

Well, that just lists possible problems - null geometry being one, self intersections being another - and we don't force people to avoid self intersections either. And the title just complains that the feature is not deleted, when the geometry is removed. IMHO that would be a bug - still if the user want to remove the feature with null geometry, it still can.

The shape spec states:

Null Shapes: A shape type of 0 indicates a null shape, with no geometric data for the shape. Each feature type (point, line, polygon, etc.) supports nulls it is valid to have points and null points in the same shapefile. Often null shapes are place holders; they are used during shapefile creation and are populated with geometric data soon after they are created.

So null geometries are fine. We just can't currently populate them later - but that's a missing feature.

"The table must contain one record per shape feature."

just means that shape file and dbf must have the same number of records - which is the case.

Updated by Giovanni Manghi over 2 years ago

  • Tracker changed from Bug report to Feature request
  • Subject changed from Node tool allow to remove every node of lines and polygons but does not remove the relative record in the table of attributes to Allow to (re)add features to null geometries
  • Priority changed from Severe/Regression to High
  • Target version changed from Version 2.6 to Future Release - High Priority

Jürgen Fischer wrote:

And the title just complains that the feature is not deleted, when the geometry is removed. IMHO that would be a bug -

by the way:
I'm checking this reports

#11007
#11398
#11296

and I'm confirming them all. There is a serious issue at least in qgis master.

and we don't force people to avoid self intersections either

and we should really add at least an option to do not allow most of the most common mistakes: duplicate node, auto intersections, etc.

So null geometries are fine. We just can't currently populate them later - but that's a missing feature.

fine with me.

Updated by Nyall Dawson over 1 year ago

  • Status changed from Open to Closed

Also available in: Atom