0

Custom python scripts do not appear in Scripts menu in SEXTANTE plugin unless they are either empty or are as simple (and useless) as:

##foo=group
##input=raster

OS is openSUSE 12.3; QGIS 1.8 and Master both demonstrate the same behaviour.

I was told that the issue may be caused by insufficient permission rights for the scripts folder. The path to the script's (for Master in this case) is that is defined by default: /home/username/.qgis2/processing/scripts. For both 'processing' and 'scripts' folders I have the following permissions: drwxr-xr-x. For the scripts in 'scripts' folder the permissions by default are -rw-r--r--, but even if I enable execution rights manually to be -rwxr-xr-x this doesn't affect their appearance in SEXTANTE scripts. So I suppose that permissions doesn't seem to cause trouble here...

Please advise me how to overcome this issue.

1

Can't confirm (Using QGIS dev.). All scripts appear in processing after i placed them here ./qgis2/processing/scripts. Check also the processing options if the folder is correctly set. Furthermore note that if you make any typos in your script, then it won't appear.

Test it out with this script here (makes a quick copy of a raster using gdal/numpy). To be saved as CopyRaster.py in the above mentioned folder.

#Definition of inputs and outputs
#==================================
##[Raster scripts]=group
##input=raster
##b=number 1
##output=output raster

#Import body
#==================================
from qgis.core import *
from qgis.gui import *
import numpy
from osgeo import gdal

#Algorithm body
#==================================
# Get Raster input
ras = processing.getobject(input)

# Load in as GDAL Array
rasterPath = ras.source()
raster = gdal.Open(str(rasterPath))
rows = raster.RasterYSize
cols = raster.RasterXSize
nodata = raster.GetRasterBand(b).GetNoDataValue()
array = raster.GetRasterBand(b).ReadAsArray() 

# Create new File
driver = gdal.GetDriverByName('GTiff')
out = driver.Create(output, cols, rows, b, gdal.GDT_Float32)

# Write array
band = out.GetRasterBand(b)
band.WriteArray(array) 

# flush data to disk, set the NoData value
band.FlushCache()
band.SetNoDataValue(nodata)

# Set Geotransform
out.SetGeoTransform(raster.GetGeoTransform())
out.SetProjection(raster.GetProjection())

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.