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?

asked May 13, 2018 at 13:47
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 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) 
answered May 14, 2018 at 6:54
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.