I would like to put background border - with negative values - in my squere landscape in order to use in fragstats. I'm trying to do it with pyqgis. Exemple what in figure 3.
So, I have a land use map (vector) and a grid (vector) (fig 1). I would like to clip land use map with this grid (one by one square grid) through pyqgis script. I have to do it because I need to do many operations with a clipped land use separately. I try to do it with pyqgis but I dind't. There was a problem with my script. When I have run it, the land use didn't clip completely. What is the problem? The clip was running however it was only do in few polygons (fig 2).
Here is my code:
# coding: utf-8import processing from qgis.analysis import *from PyQt4.QtGui import QInputDialog#Defining vector land use patchpath_map = QgsVectorLayer("/media/dogosousa/56A22ED6A22EBA7F/Geoprocessamento/Projetos_2015/Sisbiota/Vetor/Dados_Brutos/mapeamento_total.shp", "landscape use", "ogr")try
ath_grid = QgsVectorLayer("/media/dogosousa/56A22ED6A22EBA7F/Geoprocessamento/Projetos_2015/Sisbiota/Vetor/buffer_square_point/square_3700m/square_3700m_join_sirgas200024S.shp", "grid", "ogr")#Load layer grid into canvasQgsMapLayerRegistry.instance().addMapLayers([path_grid])#Doing loop in grid vector rowscanvas_layer = iface.activeLayer()features = canvas_layer.getFeatures()for feat in features: attrs = feat.attributes() print feat.id() print attrs[4] overlaylayer = path_grid.setSelectedFeatures([feat.id()]) clip = processing.runalg("qgis:clip", path_grid, path_map, "/tmp/"+"clip_"+str(attrs[4])+".shp")except: #Conferir se a layer foi criada como esperado if not path_grid.isValid(): print "Layer %s did not load" % path_grid.name()
أكثر...
So, I have a land use map (vector) and a grid (vector) (fig 1). I would like to clip land use map with this grid (one by one square grid) through pyqgis script. I have to do it because I need to do many operations with a clipped land use separately. I try to do it with pyqgis but I dind't. There was a problem with my script. When I have run it, the land use didn't clip completely. What is the problem? The clip was running however it was only do in few polygons (fig 2).



Here is my code:
# coding: utf-8import processing from qgis.analysis import *from PyQt4.QtGui import QInputDialog#Defining vector land use patchpath_map = QgsVectorLayer("/media/dogosousa/56A22ED6A22EBA7F/Geoprocessamento/Projetos_2015/Sisbiota/Vetor/Dados_Brutos/mapeamento_total.shp", "landscape use", "ogr")try
أكثر...