This is my first script and I having a problem trying to clip a shp file.
I'm running on a linux server and this is my code:
#! python
from datetime import date
from qgis.core import *
from PyQt4.QtGui import *
import sys
#disable gui
qgs = QApplication([], False)
#call qgis
QgsApplication.setPrefixPath("/usr/bin/qgis", True)
#scrip start
QgsApplication.initQgis()
#call processing plugin
sys.path.append("/usr/share/qgis/python/plugins")
from processing.core.Processing import Processing
Processing.initialize()
from processing.tools import *
import processing
#centroamerica
centroamerica = QgsVectorLayer("/pronosticos/centroamerica/ca.shp", "Centroamerica")
#date
date = date.today().strftime('%Y%m%d')
#global data
precipitacion_24h = QgsVectorLayer("/pronosticos/global/gfs_precip_shp_tif_" + date + "/gfs_precip_gis_24_" + date + ".shp", "Precipitacion 24 horas")
#clip
processing.runalg('qgis:clip', precipitacion_24h, centroamerica,'/pronosticos/salidas/precipitacion_24h.shp')
# Exit applications
QgsApplication.exitQgis()
QApplication.exit()
I got this message:
python clip.py
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
Traceback (most recent call last):
File "clip.py", line 51, in <module>
processing.runalg('qgis:clip', precipitacion_48h, centroamerica, "/pronosticos/salidas/precipitacion_48h.shp")
File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 66, in runalg
alg = Processing.runAlgorithm(algOrName, None, *args)
File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 305, in runAlgorithm
if not alg.checkInputCRS():
File "/usr/share/qgis/python/plugins/processing/core/GeoAlgorithm.py", line 292, in checkInputCRS
layers = QGisLayers.getAllLayers()
File "/usr/share/qgis/python/plugins/processing/core/QGisLayers.py", line 93, in getAllLayers
layers += QGisLayers.getRasterLayers();
File "/usr/share/qgis/python/plugins/processing/core/QGisLayers.py", line 69, in getRasterLayers
layers = QGisLayers.iface.legendInterface().layers()
AttributeError: 'NoneType' object has no attribute 'legendInterface'