2

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?

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

1 Answer 1

2

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

QSettings().setValue('/Projections/defaultBehaviour','')
target_crs = QgsCoordinateReferenceSystem()
target_crs.createFromId(100001, QgsCoordinateReferenceSystem.InternalCrsId)

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

# set saved  value
QSettings().setValue('/Projections/defaultBehaviour',crsType) 
0

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.