3

I ran into this error when I wanted to edit a shapefile (I was using the editor and mainly dealing with changing polygons - cutting, etc.- ) and then wanted to save the edits. The error message reads says:

Feature creation error (OGR error: Coordinates with non-finite values are not allowed)

I checked all the answers I could find online (I have integer64 fid, I have the same coordinate system, ...) but I can not find the problem.

If I save the same shapefile (without editing) in GeoPackage or SpatiaLite, I can work with editor and then saving without problems. When I check the validity of the same layer, it says that the polygon has an invalid coordinate, but it works fine. The moment I want to save the same project as a shapefile (since shapefile is a required data type for our client), all polygons that have this problem are deleted - the same happens when I use Fix geometries on this SpatiaLite or GeoPackage.

0

7 Answers 7

7

So I have solved the problem. Maybe my solution can help other people. The problem is in the nan value. If you go into edit mode - click on vertex editor and then right click on the polygon with the problem, you will find a table with the coordinates of the vertices. In the list there is probably a vertex with "nan" value in the x and y coordinates. Just delete it... and that's it.

1
  • 2
    Thanks Jana. It worked for me. I had issues exporting a Goepackage to shapefile. I overlaid the exported shapefile on top of the Geopackage in order to see what elements (lines in my case) were not exported. Then I discovered there were vertices in the lines with a Z value of "nan". I replaced the "nan" value with a zero (0). I only wished there could be some way to assign a 0 value to all the vertices of the selected lines in a single command, but it worked like a charm !!! Thanks again.
    – Abs
    Commented Jul 28, 2022 at 14:21
1

I had the same problem. Unfortunately, JanaB's solution didn't work for me, as I couldn't right click on some vertices in my shapefile. I was about to make a bug report when I found this:

"Did you try with a new QGIS profile? Some issues or crashes might be related to plugins or user configuration. You must try with a new profile to check if the issue remains. Read this link how to create a new profile https://docs.qgis.org/latest/en/docs/user_manual/introduction/qgis_configuration.html#working-with-user-profiles".

I changed my profile and so far, so good, the bug doesn't seem to appear. For the last hour or so, anyway.

1

I have had this problem many times when editing a polygon shape and needing to add additional vertices. My solution I just discovered is that if you edit > vertex tool > right click on polygon, a table will appear with the 'x' and 'y' coordinates. An additional column 'm' will also appear and display either '0.0000' or 'nan'. Ive found that you can manually change the 'nan' values to '0.0000' and it works perfectly for me.

0

In my case I created new profile and I opened the shapefile, but the bug still appeared, so I exported to geopackage and the bug disappeared

0

I have found a better solution based on the previous replies (since I couldn't locate the entity by the number), so the steps are as follows:

  • Using the vector tools/ geometry tools/ extract vertices you'll get a temporary layer with all the vertices, the ID of the entity that contains them, and their coordinates.

  • You can either locate the vertex with 'nan' coordinates or performe a manual selection while you're zoomed out and reverse the selection (since the damaged vertex won't be selected.

  • Next you can verify the entity ID and select it on the shapefile table, locate it on the map, right click with the vertex editor tool to get the list of vertices and select the one with 'nan' coordinates and delete it.

Thanks @Jana_B for letting me know about the vertices list on right click.

Goodluck everyone

0

I've just got the same error. While looking for a "nan" vertex coordinate, I noticed that one of the vertices had a very low Z value. Hence, I just applied "Drop M/Z values" function and then I saved it with no further problems.

0

I also ran into this issue when merging vector layers and then trying to export as a geopackage. The above answers didn't solve my issue, but removing the 'FID' column, as there was autogenerating fid numbers from the multiple layers that overlapped when merging, solved the problem. In my situation, the duplicate fid numbers created the OGR error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.