2012-10-04 19:33:47 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
GdalAlgorithmProvider.py
|
|
|
|
---------------------
|
|
|
|
Date : August 2012
|
|
|
|
Copyright : (C) 2012 by Victor Olaya
|
|
|
|
Email : volayaf at gmail dot com
|
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = 'Victor Olaya'
|
|
|
|
__date__ = 'August 2012'
|
|
|
|
__copyright__ = '(C) 2012, Victor Olaya'
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2012-09-15 18:25:25 +03:00
|
|
|
import os
|
2013-09-12 21:28:27 +03:00
|
|
|
|
2017-04-04 11:38:49 +10:00
|
|
|
from qgis.PyQt.QtCore import QCoreApplication
|
2017-04-04 12:58:25 +10:00
|
|
|
from qgis.core import (QgsApplication,
|
|
|
|
QgsProcessingProvider)
|
2017-01-09 15:32:42 +02:00
|
|
|
from processing.core.ProcessingConfig import ProcessingConfig, Setting
|
2016-03-21 04:58:12 +01:00
|
|
|
from .GdalUtils import GdalUtils
|
2013-09-12 21:28:27 +03:00
|
|
|
|
2017-08-14 05:41:54 +10:00
|
|
|
from .AssignProjection import AssignProjection
|
2017-08-14 05:05:39 +10:00
|
|
|
from .aspect import aspect
|
2017-08-15 21:29:47 +10:00
|
|
|
from .buildvrt import buildvrt
|
2017-09-08 15:47:44 +03:00
|
|
|
from .ClipRasterByExtent import ClipRasterByExtent
|
|
|
|
from .ClipRasterByMask import ClipRasterByMask
|
2017-08-14 05:55:50 +10:00
|
|
|
from .ColorRelief import ColorRelief
|
2017-08-31 16:11:12 +03:00
|
|
|
from .contour import contour
|
2017-08-31 20:09:56 +03:00
|
|
|
from .fillnodata import fillnodata
|
2017-09-08 15:47:44 +03:00
|
|
|
from .gdalinfo import gdalinfo
|
2017-09-07 14:13:32 +03:00
|
|
|
from .gdal2tiles import gdal2tiles
|
2017-09-07 19:29:46 +03:00
|
|
|
from .gdal2xyz import gdal2xyz
|
2017-09-07 19:59:15 +03:00
|
|
|
from .gdaladdo import gdaladdo
|
2018-05-14 23:59:00 +02:00
|
|
|
from .gdalcalc import gdalcalc
|
2017-09-01 12:10:25 +03:00
|
|
|
from .gdaltindex import gdaltindex
|
2017-09-01 14:30:52 +03:00
|
|
|
from .GridAverage import GridAverage
|
2017-09-05 16:25:23 +03:00
|
|
|
from .GridDataMetrics import GridDataMetrics
|
2017-09-05 16:54:18 +03:00
|
|
|
from .GridInverseDistance import GridInverseDistance
|
2017-09-05 20:22:10 +03:00
|
|
|
from .GridInverseDistanceNearestNeighbor import GridInverseDistanceNearestNeighbor
|
2017-09-05 20:30:12 +03:00
|
|
|
from .GridLinear import GridLinear
|
2017-09-05 19:36:53 +03:00
|
|
|
from .GridNearestNeighbor import GridNearestNeighbor
|
2017-08-31 12:10:45 +03:00
|
|
|
from .hillshade import hillshade
|
2017-09-19 14:32:44 +03:00
|
|
|
from .merge import merge
|
2017-08-31 12:10:45 +03:00
|
|
|
from .nearblack import nearblack
|
|
|
|
from .pct2rgb import pct2rgb
|
2017-08-31 13:15:29 +03:00
|
|
|
from .polygonize import polygonize
|
2017-09-06 12:27:03 +03:00
|
|
|
from .proximity import proximity
|
2018-01-23 12:27:04 +02:00
|
|
|
from .rasterize import rasterize
|
2018-08-24 13:50:51 +07:00
|
|
|
from .rearrange_bands import rearrange_bands
|
2017-09-07 19:13:06 +03:00
|
|
|
from .retile import retile
|
2017-08-30 17:53:14 +10:00
|
|
|
from .rgb2pct import rgb2pct
|
2017-08-31 15:03:33 +03:00
|
|
|
from .roughness import roughness
|
2017-08-31 19:43:54 +03:00
|
|
|
from .sieve import sieve
|
2017-08-31 14:39:51 +03:00
|
|
|
from .slope import slope
|
2017-08-30 18:13:51 +10:00
|
|
|
from .translate import translate
|
2017-08-31 14:21:20 +03:00
|
|
|
from .tpi import tpi
|
2017-08-14 05:49:18 +10:00
|
|
|
from .tri import tri
|
2017-08-14 05:05:39 +10:00
|
|
|
from .warp import warp
|
2019-03-10 12:07:18 +02:00
|
|
|
from .pansharp import pansharp
|
2017-08-30 17:53:14 +10:00
|
|
|
|
2018-10-30 17:01:06 +01:00
|
|
|
from .extractprojection import ExtractProjection
|
2017-06-05 15:32:38 +10:00
|
|
|
# from .rasterize_over import rasterize_over
|
2017-08-14 05:41:54 +10:00
|
|
|
|
2017-09-15 11:30:16 +03:00
|
|
|
from .Buffer import Buffer
|
2017-09-15 14:23:02 +03:00
|
|
|
from .ClipVectorByExtent import ClipVectorByExtent
|
2017-09-15 16:07:37 +03:00
|
|
|
from .ClipVectorByMask import ClipVectorByMask
|
2017-09-19 12:23:45 +03:00
|
|
|
from .Dissolve import Dissolve
|
2017-09-19 12:50:09 +03:00
|
|
|
from .ExecuteSql import ExecuteSql
|
2017-09-08 16:57:36 +03:00
|
|
|
from .OffsetCurve import OffsetCurve
|
2017-09-18 19:50:45 +03:00
|
|
|
from .ogr2ogr import ogr2ogr
|
2017-09-08 15:47:44 +03:00
|
|
|
from .ogrinfo import ogrinfo
|
|
|
|
from .OgrToPostGis import OgrToPostGis
|
2017-12-08 15:18:03 +10:00
|
|
|
from .ogr2ogrtopostgislist import Ogr2OgrToPostGisList
|
2017-09-15 13:46:50 +03:00
|
|
|
from .OneSideBuffer import OneSideBuffer
|
2017-09-08 15:47:44 +03:00
|
|
|
from .PointsAlongLines import PointsAlongLines
|
2017-08-14 05:05:39 +10:00
|
|
|
|
2017-06-05 15:32:38 +10:00
|
|
|
# from .ogr2ogrtabletopostgislist import Ogr2OgrTableToPostGisList
|
2013-09-12 21:28:27 +03:00
|
|
|
|
2015-05-18 19:51:26 +03:00
|
|
|
pluginPath = os.path.normpath(os.path.join(
|
|
|
|
os.path.split(os.path.dirname(__file__))[0], os.pardir))
|
|
|
|
|
2012-09-15 18:25:25 +03:00
|
|
|
|
2017-04-04 12:58:25 +10:00
|
|
|
class GdalAlgorithmProvider(QgsProcessingProvider):
|
2015-08-22 14:29:41 +02:00
|
|
|
|
2012-09-15 18:25:25 +03:00
|
|
|
def __init__(self):
|
2017-01-09 09:18:25 +10:00
|
|
|
super().__init__()
|
2017-04-04 11:04:36 +10:00
|
|
|
self.algs = []
|
2012-09-15 18:25:25 +03:00
|
|
|
|
2017-04-04 09:46:46 +10:00
|
|
|
def load(self):
|
2017-04-04 12:22:29 +10:00
|
|
|
ProcessingConfig.settingIcons[self.name()] = self.icon()
|
|
|
|
ProcessingConfig.addSetting(Setting(self.name(), 'ACTIVATE_GDAL',
|
|
|
|
self.tr('Activate'), True))
|
2017-04-04 13:28:44 +10:00
|
|
|
ProcessingConfig.readSettings()
|
|
|
|
self.refreshAlgorithms()
|
2017-04-04 09:46:46 +10:00
|
|
|
return True
|
2017-01-09 15:32:42 +02:00
|
|
|
|
|
|
|
def unload(self):
|
2017-04-04 12:22:29 +10:00
|
|
|
ProcessingConfig.removeSetting('ACTIVATE_GDAL')
|
2017-01-09 15:32:42 +02:00
|
|
|
|
2017-04-04 12:22:29 +10:00
|
|
|
def isActive(self):
|
|
|
|
return ProcessingConfig.getSetting('ACTIVATE_GDAL')
|
|
|
|
|
|
|
|
def setActive(self, active):
|
|
|
|
ProcessingConfig.setSettingValue('ACTIVATE_GDAL', active)
|
|
|
|
|
2017-01-09 09:18:25 +10:00
|
|
|
def name(self):
|
2017-10-16 19:39:29 +10:00
|
|
|
return 'GDAL'
|
2012-09-15 18:25:25 +03:00
|
|
|
|
2017-10-19 13:12:31 +10:00
|
|
|
def longName(self):
|
|
|
|
version = GdalUtils.readableVersion()
|
|
|
|
return 'GDAL ({})'.format(version)
|
|
|
|
|
2017-01-09 09:18:25 +10:00
|
|
|
def id(self):
|
2016-12-29 15:16:37 +02:00
|
|
|
return 'gdal'
|
2012-09-15 18:25:25 +03:00
|
|
|
|
2018-09-25 13:33:51 +10:00
|
|
|
def helpId(self):
|
|
|
|
return 'gdal'
|
|
|
|
|
2017-01-09 09:18:25 +10:00
|
|
|
def icon(self):
|
2017-01-09 12:34:46 +10:00
|
|
|
return QgsApplication.getThemeIcon("/providerGdal.svg")
|
|
|
|
|
|
|
|
def svgIconPath(self):
|
|
|
|
return QgsApplication.iconPath("providerGdal.svg")
|
2012-09-15 18:25:25 +03:00
|
|
|
|
2017-04-04 09:46:46 +10:00
|
|
|
def loadAlgorithms(self):
|
2017-06-05 15:32:38 +10:00
|
|
|
self.algs = [
|
2017-08-14 05:41:54 +10:00
|
|
|
AssignProjection(),
|
2017-08-14 05:05:39 +10:00
|
|
|
aspect(),
|
2017-08-15 21:29:47 +10:00
|
|
|
buildvrt(),
|
2017-09-08 15:47:44 +03:00
|
|
|
ClipRasterByExtent(),
|
|
|
|
ClipRasterByMask(),
|
2017-08-14 05:55:50 +10:00
|
|
|
ColorRelief(),
|
2017-08-31 16:11:12 +03:00
|
|
|
contour(),
|
2017-08-31 20:09:56 +03:00
|
|
|
fillnodata(),
|
2017-09-08 15:47:44 +03:00
|
|
|
gdalinfo(),
|
2017-09-07 14:13:32 +03:00
|
|
|
gdal2tiles(),
|
2017-09-07 19:29:46 +03:00
|
|
|
gdal2xyz(),
|
2017-09-07 19:59:15 +03:00
|
|
|
gdaladdo(),
|
2018-05-14 23:59:00 +02:00
|
|
|
gdalcalc(),
|
2017-09-01 12:10:25 +03:00
|
|
|
gdaltindex(),
|
2017-09-01 14:30:52 +03:00
|
|
|
GridAverage(),
|
2017-09-05 16:25:23 +03:00
|
|
|
GridDataMetrics(),
|
2017-09-05 16:54:18 +03:00
|
|
|
GridInverseDistance(),
|
2017-09-05 20:22:10 +03:00
|
|
|
GridInverseDistanceNearestNeighbor(),
|
2017-09-05 20:30:12 +03:00
|
|
|
GridLinear(),
|
2017-09-05 19:36:53 +03:00
|
|
|
GridNearestNeighbor(),
|
2017-08-31 12:10:45 +03:00
|
|
|
hillshade(),
|
2017-09-19 14:32:44 +03:00
|
|
|
merge(),
|
2017-08-30 17:44:52 +10:00
|
|
|
nearblack(),
|
2017-08-31 12:10:45 +03:00
|
|
|
pct2rgb(),
|
2017-08-31 13:15:29 +03:00
|
|
|
polygonize(),
|
2017-09-06 12:27:03 +03:00
|
|
|
proximity(),
|
2018-01-23 12:27:04 +02:00
|
|
|
rasterize(),
|
2018-08-24 13:50:51 +07:00
|
|
|
rearrange_bands(),
|
2017-09-07 19:13:06 +03:00
|
|
|
retile(),
|
2017-08-30 17:53:14 +10:00
|
|
|
rgb2pct(),
|
2017-08-31 15:03:33 +03:00
|
|
|
roughness(),
|
2017-08-31 19:43:54 +03:00
|
|
|
sieve(),
|
2017-08-31 14:39:51 +03:00
|
|
|
slope(),
|
2017-08-30 18:13:51 +10:00
|
|
|
translate(),
|
2017-08-31 14:21:20 +03:00
|
|
|
tpi(),
|
2017-08-14 05:49:18 +10:00
|
|
|
tri(),
|
2017-06-27 16:15:28 +10:00
|
|
|
warp(),
|
2019-03-10 12:07:18 +02:00
|
|
|
pansharp(),
|
2017-06-05 15:32:38 +10:00
|
|
|
# rasterize(),
|
2018-10-30 17:01:06 +01:00
|
|
|
ExtractProjection(),
|
2017-06-05 15:32:38 +10:00
|
|
|
# rasterize_over(),
|
|
|
|
# ----- OGR tools -----
|
2017-09-15 11:30:16 +03:00
|
|
|
Buffer(),
|
2017-09-15 14:23:02 +03:00
|
|
|
ClipVectorByExtent(),
|
2017-09-15 16:07:37 +03:00
|
|
|
ClipVectorByMask(),
|
2017-09-19 12:23:45 +03:00
|
|
|
Dissolve(),
|
2017-09-19 12:50:09 +03:00
|
|
|
ExecuteSql(),
|
2017-09-08 16:57:36 +03:00
|
|
|
OffsetCurve(),
|
2017-09-18 19:50:45 +03:00
|
|
|
ogr2ogr(),
|
2017-09-08 15:47:44 +03:00
|
|
|
ogrinfo(),
|
|
|
|
OgrToPostGis(),
|
2017-12-08 15:18:03 +10:00
|
|
|
Ogr2OgrToPostGisList(),
|
2017-09-15 13:46:50 +03:00
|
|
|
OneSideBuffer(),
|
2017-09-08 15:47:44 +03:00
|
|
|
PointsAlongLines(),
|
2017-06-05 15:32:38 +10:00
|
|
|
# Ogr2OgrTableToPostGisList(),
|
|
|
|
]
|
2017-04-04 11:04:36 +10:00
|
|
|
for a in self.algs:
|
2017-04-04 09:46:46 +10:00
|
|
|
self.addAlgorithm(a)
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2017-04-03 15:37:55 +10:00
|
|
|
def supportedOutputRasterLayerExtensions(self):
|
2012-09-15 18:25:25 +03:00
|
|
|
return GdalUtils.getSupportedRasterExtensions()
|
2017-04-04 11:38:49 +10:00
|
|
|
|
2018-01-29 11:48:23 +10:00
|
|
|
def supportsNonFileBasedOutput(self):
|
|
|
|
"""
|
|
|
|
GDAL Provider doesn't support non file based outputs
|
|
|
|
"""
|
|
|
|
return False
|
|
|
|
|
2017-04-04 11:38:49 +10:00
|
|
|
def tr(self, string, context=''):
|
|
|
|
if context == '':
|
|
|
|
context = 'GdalAlgorithmProvider'
|
|
|
|
return QCoreApplication.translate(context, string)
|