9

I downloaded QGIS 3.4.0 and try to save edits in .geojson file. I can save new objects, but not edits in attributes. Insted of it, QGIS creates .tmp file with my chаnges into the same folder with editing .geojson. To save my edits I had to copy the text of .tmp file and put it by hand in my .geojson. How to enforse QGIS 3.4.0 save changes in layer like it was in 3.2.3 and do not create .tmp files?

UPD: For further validation analysis I use .geojson in classic JSON tree-like structure, but QGIS - in his own structure stroke-by-stroke. And if I export my .geojson by QGIS, it saves the file in his structure and this new one could be edited and saved with no any .tmp files. So it looks like QGIS 3.4 cannot save edits if .geojson file has tree-like structure (unlike QGIS 3.2).

UPD2:Below parts of broken and working GeoJSONs

Broken: Broken GeoJSON

Working: Working GeoJSON

7
  • At first I thought that it depends on version (3.4.0 or 3.4.1), but the problem occurs in both versions.
    – mikhukh
    Nov 6, 2018 at 13:57
  • 1
    Its the same for the current QGIS-LTR (2.18.26). I assume it's related to GDAL/OGR 2.3.2. Dec 17, 2018 at 8:16
  • Save As, export to a new file does not appear to fix it for me (2.18.27, GDAL 2.4, Win 10). Can you post example of broken vs working json files @mikhukh? Feb 5, 2019 at 21:43
  • 1
    There is a bug report on issues.qgis.org: issues.qgis.org/issues/20760. The issue seems to occur on Windows only. Apr 16, 2019 at 9:55
  • 1
    Same here, on windows 10, QGIS 3.8.1. I also found I have to close my QGIS project before renaming my copies of .tmp files, otherwise QGIS overwrites them with the original data when I close (with or without saving project).
    – Mike Honey
    Aug 18, 2019 at 5:42

2 Answers 2

2

I had the same issue and had to find a workaround. If you have access to PostGIS, you can export a valid geojson with the following statement. This can also be used to create a function in PostGIS. You can edit postgis layers directly in QGIS and then export using the statement below:

copy (
SELECT jsonb_build_object(
  'type',     'FeatureCollection',
  'features', jsonb_agg(feature)
)
FROM (
  SELECT jsonb_build_object(
    'type',       'Feature',
    'id',         id,
    'geometry',   ST_AsGeoJSON(geom)::jsonb,
    'properties', to_jsonb(inputs) - 'id' - 'geom'
  ) AS feature
  FROM (
    SELECT * FROM output_table
  ) inputs
) features
) to 'C:\temp\output.json';
1

It seems the issue has been solved, as QGIS 3.10 uses GDAL 3.0.2.enter image description here But at the same time it removes from GeoJSON a row with projection (in case you edit and save a file in JSON tree-like structure, rather than QGIS one). enter image description here

2
  • It appears that the row with projection are not specified in GeoJSON standart: "Note: the use of alternative coordinate reference systems was specified in [GJ2008], but it has been removed from this version of the specification" tools.ietf.org/html/rfc7946#page-12
    – mikhukh
    Dec 23, 2019 at 16:17
  • Anyway most stable QGIS version 3.4 saves GeoJSONs correctly.
    – mikhukh
    Feb 4, 2020 at 12:14

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.