1. addVectorLayer接口调用1). QgisInterface提供接口addVectorLayer用以添加矢量图层,该接口由QgisAppInterface实现QgisInterface::addVectorLayer()↓ 实现 QgisAppInterface::addVectorLayer() 2).QgisAppInterface::addVectorLayer()内调用QgisApp::addVectorLayer()Qgis...
lineVecLayer = QgsVectorLayer("LineString", layername,"memory") lineProvider = lineVecLayer.dataProvider() lineProvider.addAttributes( [ QgsField("seq", QVariant.Int),QgsField("name", QVariant.String)] ) lineVecLayer.startEditing()print("editing layer:%s..."% (layername)) points = [QgsPo...
前言本章讲述使用qgis c++ Api加载各种类型的矢量地图数据显示。 - 说明:文章中的示例代码均来自 雷动软件工作室/qgis_cpp_api_apps加载矢量(vector)图层 在QGIS中,图层并不保存数据的实体,而是引用各种类型的…
//步骤2:创建QgsVectorLayer类 QgsVectorLayer* vecLayer=new QgsVectorLayer(filename,basename,"ogr",false); if(!vecLayer->isValid())//如果图层不合法 { QMessageBox::critical(this,"error","图层无效!"); return; } //步骤3:注册添加矢量数据,并个并添加到画布中 QgsMapLayerRegistry::instance()-...
self.addVectorLayer(data_file) # 添加栅格图层def addRasterLayer(self,rasterFilePath): rasterLayer = readRasterFile(rasterFilePath) if self.firstAdd: addMapLayer(rasterLayer,self.mapCanvas,True) self.firstAdd = False else: addMapLayer(rasterLayer,self.mapCanvas) ...
QList<QgsMapLayer*>layers;publicslots:voidon_openFileAction_triggered();//public:voidaddVectorLayer(); }; 2、qtwidgetsapplication.cpp #include"qtwidgetsapplication.h"#include#include#include<qfiledialog.h>#include<qgsvectorlayer.h>QtWidgetsApplication::QtWidgetsApplication(QWidget*parent) : QMainWindo...
mcreateLayer(path) 打开下面红色圈出按钮 图1 shp已经创建成功 # 添加点数据,以这几个点为例子 pointlist = [(1,3),(2,5),(3,3),(5,3)] # 获取刚才创建的shp点图层 layer = QgsVectorLayer(path,"point","ogr") if layer.isValid(): ...
QgsVectorLayer*layer=(QgsVectorLayer*)mApp->addVectorLayer(filename,ff.baseName());zoomToFirst...
QgsVectorDataProvider* vectorProvider = newLayer->dataProvider(); vectorProvider->addAttributes( newFieldList ); //新字段中插入值 QMap<int, int> idmap = generateIdIndex(); //由原shp图层得到QMap<ID, featureId> int fieldIndex = -1; //每个待插入字段的索引号 ...
mApp->addVectorLayer(filename,ff.baseName()); zoomToFirstLayer<QgsVectorLayer*>(); //定义三个点 QgsPointXYpoint1(20.34013,-33.90453); QgsPointXYpoint2(20.49744,-33.91126); QgsPointXYpoint3(20.41396,-33.93079); //新建PolygonGeometry类型的RubberBand ...