Bug report #21616

CRS not written to file

Added by Mélanie Weynants over 5 years ago. Updated over 5 years ago.

Status:Open
Priority:High
Assignee:-
Category:Python bindings / sipify
Affected QGIS version:3.6.0 Regression?:Yes
Operating System:Windows 10 Enterprise Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:29432

Description

With QGIS 3.4.2 and 3.6.0, but not with 3.2.3:
When writing a vector layer to file, the CRS is not written, depending on the driver.
It happens with GPKG and GeoJSON but not with ESRI Shapefile.

Example:

error = QgsVectorFileWriter.writeAsVectorFormat({

... layer:layer, # layer in epsg:4326
... fileName:"layer_54009",
... fileEncoding:"utf-8",
... destCRS:QgsCoordinateReferenceSystem(54009),
... driverName:"GPKG",
... onlySeleted:True
... })

error0 == QgsVectorFileWriter.NoError

True

File layer_54009.gpkg|layername=layer_54009 is written to disk with the correct geometries (transformation from WGS84 to Mollweide is done) but has undefined CRS.

The same problem happens with all algorithms I've tested, including "qgis:definecurrentprojection" and "native:assignprojection", which is really annoying.

History

#1 Updated by Giovanni Manghi over 5 years ago

  • Priority changed from Normal to High
  • Category changed from Vectors to Python bindings / sipify

Also available in: Atom PDF