I'm developing a basic application out of QGIS and am having trouble getting my code to generate all the layers I have set. Currently it only generates two of the four layers: "self.basemap_layer", which is a TIFF raster layer, and "self.pointlayer", which is a point layer generated by a text-delimited CSV. It does not generate the two vector shapefiles left over.
Instead, I get two instances of this error, like so:
QObject::connect: Cannot connect (null)::repaintRequested() to QgsMapCanvas::refresh() QObject::connect: Cannot connect (null)::repaintRequested() to QgsMapCanvas::refresh() I can't figure out why it does connect to two layers, but does not connect to the other two...
My code is below:
def loadMap(self): cur_dir = os.path.dirname(os.path.realpath(__file__)) #DOES LOAD filename = os.path.join(cur_dir, "data","NE1_50M_SR_W.tif") self.basemap_layer = QgsRasterLayer(filename, "basemap") QgsMapLayerRegistry.instance().addMapLayer( self.basemap_layer) #DOESN'T LOAD filename = os.path.join(cur_dir, "data", "ne_10m_roads.shp") self.roads_layer = QgsVectorLayer(filename, "roads", "ogr") QgsMapLayerRegistry.instance().addMapLayer(self.roads_layer) #DOES LOAD filename = "/home/me/Desktop/PyQGIS/appfiles/data/thiefsymbolcsv.csv?delimiter=%s&crs=epsg:3857&xField=%s&yField=%s" % ( ",", "X", "Y") self.pointlayer = QgsVectorLayer(filename, "point", "delimitedtext") QgsMapLayerRegistry.instance().addMapLayer(self.pointlayer) #DOESN'T LOAD filename = os.path.join(cur_dir, "data", "line_points.shp") self.loblayer = QgsVectorLayer(filename, "lobs", "ogr") QgsMapLayerRegistry.instance().addMapLayer(self.loblayer) self.showVisibleMapLayers() self.mapCanvas.setExtent(QgsRectangle(-127.7, 24.4, -79.3, 49.1)) It's not giving me errors related to my imported PyQT and PyQGIS libraries, and the application window works just as inteded, so I don't think I've set my environment variables incorrectly. But I did read elsewhere that this error might have to do with an incorrect wrapper script, so I'm not entirely sure.
Why are these errors occurring, and how do I get rid of them? Seeing as both the problem layers are .SHP files, and the ones that work are .TIF and .CSV, could their file type somehow be the issue?
My full code is here for reference
أكثر...
Instead, I get two instances of this error, like so:
QObject::connect: Cannot connect (null)::repaintRequested() to QgsMapCanvas::refresh() QObject::connect: Cannot connect (null)::repaintRequested() to QgsMapCanvas::refresh() I can't figure out why it does connect to two layers, but does not connect to the other two...
My code is below:
def loadMap(self): cur_dir = os.path.dirname(os.path.realpath(__file__)) #DOES LOAD filename = os.path.join(cur_dir, "data","NE1_50M_SR_W.tif") self.basemap_layer = QgsRasterLayer(filename, "basemap") QgsMapLayerRegistry.instance().addMapLayer( self.basemap_layer) #DOESN'T LOAD filename = os.path.join(cur_dir, "data", "ne_10m_roads.shp") self.roads_layer = QgsVectorLayer(filename, "roads", "ogr") QgsMapLayerRegistry.instance().addMapLayer(self.roads_layer) #DOES LOAD filename = "/home/me/Desktop/PyQGIS/appfiles/data/thiefsymbolcsv.csv?delimiter=%s&crs=epsg:3857&xField=%s&yField=%s" % ( ",", "X", "Y") self.pointlayer = QgsVectorLayer(filename, "point", "delimitedtext") QgsMapLayerRegistry.instance().addMapLayer(self.pointlayer) #DOESN'T LOAD filename = os.path.join(cur_dir, "data", "line_points.shp") self.loblayer = QgsVectorLayer(filename, "lobs", "ogr") QgsMapLayerRegistry.instance().addMapLayer(self.loblayer) self.showVisibleMapLayers() self.mapCanvas.setExtent(QgsRectangle(-127.7, 24.4, -79.3, 49.1)) It's not giving me errors related to my imported PyQT and PyQGIS libraries, and the application window works just as inteded, so I don't think I've set my environment variables incorrectly. But I did read elsewhere that this error might have to do with an incorrect wrapper script, so I'm not entirely sure.
Why are these errors occurring, and how do I get rid of them? Seeing as both the problem layers are .SHP files, and the ones that work are .TIF and .CSV, could their file type somehow be the issue?
My full code is here for reference
أكثر...