QgsVectorLayer* layer = new QgsVectorLayer("/path/to/shapefile.shp", "Layer Name", "ogr"); QgsCoordinateReferenceSystem crs("EPSG:4326"); // WGS 84 layer->setCrs(crs);
QgsVectorLayer* layer = new QgsVectorLayer("/path/to/shapefile.shp", "Layer Name", "ogr"); QgsCoordinateReferenceSystem crs = layer->crs(); if (crs.isValid()) { qDebug() << "Layer CRS : " << crs.authid(); }This code creates a new QgsVectorLayer object with a shapefile path and layer name, then retrieves the CRS of the layer. The code checks if the CRS is valid and outputs the CRS's authid (EPSG code) if it is. These code examples show how to set and get the CRS of a QgsVectorLayer using the QGIS C++ API. The package library for this API is likely the QGIS core library (`libqgis_core`) which provides the core functionality of QGIS.