I want to create a vector layer in the this CRS : USER:100001 but i doesn't work. It always tells me, i need to choose the CRS by myself.

vl = QgsVectorLayer("Point?crs=user:100001", "Project_center", "memory")

But when i try it with ESPG:4326, it works as expected. Can anyone help me?

  • Are you sure that the crs USER:100001 already exists? What QGIS-version? – Mike May 13 '18 at 15:46
  • Yes, it is. QGIS 2.18 – hano hano May 13 '18 at 19:09

I think your code vl = QgsVectorLayer("Point?crs=user:100001", "Project_center", "memory") only works from QGIS3.0. For 2.xx you can test the following:

from PyQt4.QtCore import QSettings

# save actualy value
crsType = QSettings().value('/Projections/defaultBehaviour') # only 2.x

target_crs = QgsCoordinateReferenceSystem()
target_crs.createFromId(100001, QgsCoordinateReferenceSystem.InternalCrsId)

vl = QgsVectorLayer("Point", "Project_center", "memory")
print vl.crs().authid()

# set saved  value
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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