/** * Constructor. Constructs a new QgsField object. * \param name Field name * \param type Field variant type, currently supported: String / Int / Double * \param typeName Field type (e.g., char, varchar, text, int, serial, double). * Field types are usually unique to the source and are stored exactly * as returned from the data store. * \param len Field length * \param prec Field precision. Usually decimal places but may also be * used in conjunction with other fields types (e.g., variable character fields) * \param comment Comment for the field * \param subType If the field is a collection, its element's type. When * all the elements don't need to have the same type, leave * this to QVariant::Invalid. */ QgsField( const QString &name = QString(), QVariant::Type type = QVariant::Invalid, const QString &typeName = QString(), int len = 0, int prec = 0, const QString &comment = QString(), QVariant::Type subType = QVariant::Invalid );
classDiagram
class QgsAbstractGeometry
class QgsPoint
class QgsGeometry
class QgsPointXY
QgsPoint --|> QgsAbstractGeometry
QgsPoint..> QgsPointXY
QgsGeometry ..> QgsAbstractGeometry
# QgsPolylineXY → QgsLineString line_string = QgsLineString() for point in polyline_xy: line_string.addVertex(QgsPoint(point)) print(f"QgsPolylineXY → QgsLineString: {line_string.asWkt()}")
# QgsLineString → QgsPolylineXY polyline_from_line_string = [QgsPointXY(point) for point in line_string.points()] print(f"QgsLineString → QgsPolylineXY: {polyline_from_line_string}")
# QgsPolygonXY → QgsPolygon qgs_polygon = QgsPolygon() exterior_line_string = QgsLineString([QgsPoint(p) for p in exterior_ring]) interior_line_string = QgsLineString([QgsPoint(p) for p in interior_ring])
# QgsPolygon → QgsPolygonXY polygon_xy_from_qgs = [] if qgs_polygon.exteriorRing(): exterior = [QgsPointXY(point) for point in qgs_polygon.exteriorRing().points()] polygon_xy_from_qgs.append(exterior) for i inrange(qgs_polygon.numInteriorRings()): interior = [QgsPointXY(point) for point in qgs_polygon.interiorRing(i).points()] polygon_xy_from_qgs.append(interior)
from qgis.core import Qgis from qgis.core import QgsApplication if __name__ == '__main__': qgs = QgsApplication([], True) qgs.setPrefixPath('qgis', True) qgs.initQgis() version = Qgis.version() print(QgsApplication.prefixPath()) print("Hello qgis, version is {} ".format( version)) qgs.exitQgis() ## C:/OSGeo4W/apps/qgis-ltr ## Hello qgis, version is 3.34.6-Prizren