2

I'm trying to automate some tasks in Qgis, using the built-in python console. I have around 20 layers with different CRS, which I would all like to have the same one.

I'm not sure how to approach this. The cookbook (https://docs.qgis.org/2.18/en/docs/pyqgis_developer_cookbook/crs.html) only gives information about how to transform a single point, but I assume it will be somewhat similar.

This is from point transformation from the cookbook:

crsSrc = QgsCoordinateReferenceSystem(4326)    # WGS 84
crsDest = QgsCoordinateReferenceSystem(32633)  # WGS 84 / UTM zone 33N
xform = QgsCoordinateTransform(crsSrc, crsDest)

pt1 = xform.transform(QgsPoint(18,5))
print "Transformed point:", pt1
1
  • 1
    I think this answer by @Joseph might help you. If you just want to change the crs of a layer in your project and not save it in the layer you can do this : layer_crs = layer.crs() layer_crs.createFromString("EPSG:32633") layer.setCrs(layer_crs)
    – JULESG
    Commented Apr 20, 2022 at 8:45

0

Your Answer

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