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 -EZUSoft-– Mike -EZUSoft-2018年05月13日 15:46:30 +00:00Commented May 13, 2018 at 15:46
-
Yes, it is. QGIS 2.18hano hano– hano hano2018年05月13日 19:09:08 +00:00Commented May 13, 2018 at 19:09
1 Answer 1
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)
Explore related questions
See similar questions with these tags.