I'm trying to access the CRS of a layer and use this to create a grid. I followed the answer in this post which works great in QGIS but I would like it to work in a standalone script. Here is a snippet:
for fname in glob.glob("C:\Users\moi\Desktop\Test\Grid\\" + "*.shp"):
extent = QgsVectorLayer( fname, '', 'ogr' ).extent()
centerx = (extent.xMinimum() + extent.xMaximum()) / 2
centery = (extent.yMinimum() + extent.yMaximum()) / 2
width = extent.xMaximum() - extent.xMinimum()
height = extent.yMaximum() - extent.yMinimum()
CRS = QgsMapLayer.crs(fname).authid()
general.runalg("qgis:creategrid", 1000, 1000, width, height, centerx, centery, 1, CRS, None)
Running the above gives me the following error message:
TypeError: QgsMapLayer.crs(): first argument of unbound method must have type 'QgsMapLayer'