I have PyQGIS scripts that output vector memory layers with the correct CRS (EPSG:3006) and all seems fine but when I make these permanent or export them they lose their CRS completely.

Exporting to GeoPackage/make permanent results in a new layer that looks OK but a look at Layer Properties reveals "Undefined geographic SRS".
Exporting to shape gives a different error, which is immediately seen in the ToC; it has an "invalid projection".

I am guessing that this is a bug but I need to check here first.
I am running QGIS 3.36.2 and cannot change versions (work computer).

Still a problem. I thought I had found the answer:
" The spatial index was not correct in the memory layers. Fixing this solves the problem.
Dumb question but maybe it will help someone else who encounters the same problem."

Edit. Problem NOT solved. It seemed like it was for a while but then changed its mind. My script outputs layers to memory that upon inspection have a correctly assigned crs and are spatially indexed. However, when exporting to geopcakage the crs is lost.
Layer Properties - Source and Information both say "Undefined geographic SRS" but also that the Spatial Index exists.

  • 2
    Can you please show us how you make layers permanent or export them?
    – Taras
    Commented Jul 11 at 10:10
  • Using the standard QGIS interface, i.e. right click on the layer. Commented Jul 11 at 12:05
  • What is off topic about this? I don't know that this is a bug, it may be that I am doing something wrong, something that someone has an answer to. Commented Jul 12 at 8:51


Browse other questions tagged or ask your own question.