Skip to content

Commit e127809

Browse files
7.9.0
1 parent c96774b commit e127809

26 files changed

Lines changed: 23847 additions & 23810 deletions

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def description():
4242

4343

4444
def version():
45-
return 'Version 7.8.36 - Matera'
45+
return 'Version 7.9.0 - Matera'
4646

4747

4848
def icon():

core/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@
631631
spectralDistNm = 'SpectralDistanceBandSets_'
632632
reflectanceRasterNm = 'reflectance_temp'
633633
NoDataVal = -32768
634+
NoDataValUInt16 = 32767
634635
NoDataValInt32 = 2147483647
635636
NoDataValFloat32 = -3.4028235e+38
636637
NoDataValUInt32 = 4294967295

core/utils.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3017,9 +3017,13 @@ def writeArrayBlock(self, gdalRaster, bandNumber, dataArray, pixelStartColumn, p
30173017
b = None
30183018

30193019
# write an array to band
3020-
def writeRasterBlock(self, gdalRaster, bandNumber, dataArray, pixelStartColumn, pixelStartRow, nodataValue=None):
3020+
def writeRasterBlock(self, gdalRaster, bandNumber, dataArray, pixelStartColumn, pixelStartRow, nodataValue = None, scale = None, offset = None, outputNoData = None):
30213021
b = gdalRaster.GetRasterBand(bandNumber)
30223022
y, x = dataArray.shape
3023+
if scale is not None or offset is not None:
3024+
dataArray = cfg.np.subtract(dataArray/scale, offset/scale)
3025+
b.SetScale(scale)
3026+
b.SetOffset(offset)
30233027
#b.WriteRaster(pixelStartColumn, pixelStartRow, x, y, dataArray.tostring())
30243028
b.WriteArray(dataArray, pixelStartColumn, pixelStartRow)
30253029
if nodataValue is not None:
@@ -3107,7 +3111,7 @@ def createRasterFromReferenceMultiprocess(self, raster, bandNumber, outputRaster
31073111
return outputRasterList
31083112

31093113
# create raster from another raster
3110-
def createRasterFromReference(self, gdalRasterRef, bandNumber, outputRasterList, nodataValue = None, driver = 'GTiff', format = 'Float32', previewSize = 0, previewPoint = None, compress = 'No', compressFormat = 'DEFLATE21', projection = None, geotransform = None, constantValue = None):
3114+
def createRasterFromReference(self, gdalRasterRef, bandNumber, outputRasterList, nodataValue = None, driver = 'GTiff', format = 'Float32', previewSize = 0, previewPoint = None, compress = 'No', compressFormat = 'DEFLATE21', projection = None, geotransform = None, constantValue = None, scale = None, offset = None):
31113115
oRL = []
31123116
if format == 'Float64':
31133117
format = cfg.gdalSCP.GDT_Float64
@@ -3117,6 +3121,8 @@ def createRasterFromReference(self, gdalRasterRef, bandNumber, outputRasterList,
31173121
format = cfg.gdalSCP.GDT_Int32
31183122
elif format == 'Int16':
31193123
format = cfg.gdalSCP.GDT_Int16
3124+
elif format == 'UInt16':
3125+
format = cfg.gdalSCP.GDT_UInt16
31203126
elif format == 'Byte':
31213127
format = cfg.gdalSCP.GDT_Byte
31223128
for o in outputRasterList:
@@ -3180,6 +3186,16 @@ def createRasterFromReference(self, gdalRasterRef, bandNumber, outputRasterList,
31803186
b = oR.GetRasterBand(x)
31813187
b.Fill(constantValue)
31823188
b = None
3189+
if scale is not None:
3190+
for x in range(1, bandNumber+1):
3191+
b = oR.GetRasterBand(x)
3192+
b.SetScale(scale)
3193+
b = None
3194+
if offset is not None:
3195+
for x in range(1, bandNumber+1):
3196+
b = oR.GetRasterBand(x)
3197+
b.SetOffset(offset)
3198+
b = None
31833199
# logger
31843200
cfg.utls.logCondition(str(__name__) + '-' + str(cfg.inspectSCP.stack()[0][3])+ ' ' + cfg.utls.lineOfCode(), 'raster ' + str(outputRasterList))
31853201
return oRL
@@ -3722,7 +3738,7 @@ def calculateRaster(self, gdalBandList, rasterSCPArrayfunctionBand, columnNumber
37223738
f = f.replace(i , ' rasterSCPArrayfunctionBand[::, ::,' + str(b) + '] ')
37233739
b = b + 1
37243740
# replace numpy operators
3725-
f = cfg.utls.replaceNumpyOperators(f)
3741+
f = cfg.utls.replaceNumpyOperators(f)
37263742
# logger
37273743
cfg.utls.logToFile(str(__name__) + '-' + str(cfg.inspectSCP.stack()[0][3])+ ' ' + cfg.utls.lineOfCode(), 'f ' + str(f))
37283744
cfg.utls.logToFile(str(__name__) + '-' + str(cfg.inspectSCP.stack()[0][3])+ ' ' + cfg.utls.lineOfCode(), 'rasterSCPArrayfunctionBand shape' + str(rasterSCPArrayfunctionBand.shape))
@@ -3734,7 +3750,14 @@ def calculateRaster(self, gdalBandList, rasterSCPArrayfunctionBand, columnNumber
37343750
o = eval(f)
37353751
# output raster
37363752
oR = cfg.gdalSCP.Open(outputRaster, cfg.gdalSCP.GA_Update)
3737-
cfg.utls.writeRasterBlock(oR, int(outputBandNumber), o, pixelStartColumn, pixelStartRow)
3753+
scale = gdalBandList[0]
3754+
offset = gdalBandList[1]
3755+
outputNoData = gdalBandList[2]
3756+
# logger
3757+
cfg.utls.logToFile(str(__name__) + '-' + str(cfg.inspectSCP.stack()[0][3])+ ' ' + cfg.utls.lineOfCode(), 'or1 ' + str(o))
3758+
# logger
3759+
cfg.utls.logToFile(str(__name__) + '-' + str(cfg.inspectSCP.stack()[0][3])+ ' ' + cfg.utls.lineOfCode(), 'or2 ' + str(o))
3760+
cfg.utls.writeRasterBlock(oR, int(outputBandNumber), o, pixelStartColumn, pixelStartRow, scale = scale, offset = offset, outputNoData = outputNoData)
37383761
o = None
37393762
oR = None
37403763
return outputRaster
@@ -4900,7 +4923,7 @@ def processRasterDev(self, raster = None, signatureList = None, functionBand = N
49004923
if functionBand == 'No':
49014924
# logger
49024925
cfg.utls.logToFile(str(__name__) + '-' + str(cfg.inspectSCP.stack()[0][3])+ ' ' + cfg.utls.lineOfCode(), 'outputBandNumber ' + str(outputBandNumber))
4903-
oo = functionRaster(gdalBandList, array, nodataMask, bSY, x, y, outputArrayFile, functionBandArgument, functionVariable, outputBandNumber)
4926+
oo = functionRaster([scl, offs, outputNoData], array, nodataMask, bSY, x, y, outputArrayFile, functionBandArgument, functionVariable, outputBandNumber)
49044927
# logger
49054928
cfg.utls.logToFile(str(__name__) + '-' + str(cfg.inspectSCP.stack()[0][3])+ ' ' + cfg.utls.lineOfCode(), 'oo ' + str(oo))
49064929
if isinstance(oo, list):

docs/repository.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version = '1.0' encoding = 'UTF-8'?>
22
<plugins>
3-
<pyqgis_plugin name="Semi-Automatic Classification Plugin - master" version="7.8.36" plugin_id="284">
3+
<pyqgis_plugin name="Semi-Automatic Classification Plugin - master" version="7.9.0" plugin_id="284">
44
<description><![CDATA[The Semi-Automatic Classification Plugin (SCP) allows for the supervised classification of remote sensing images, providing tools for the download, the preprocessing and postprocessing of images.]]></description>
55
<about><![CDATA[Developed by Luca Congedo, the Semi-Automatic Classification Plugin (SCP) allows for the supervised classification of remote sensing images, providing tools for the download, the preprocessing and postprocessing of images. Search and download is available for ASTER, GOES, Landsat, MODIS, Sentinel-1, Sentinel-2, and Sentinel-3 images. Several algorithms are available for the land cover classification. This plugin requires the installation of GDAL, OGR, Numpy, SciPy, and Matplotlib. Some tools require also the installation of SNAP (ESA Sentinel Application Platform). For more information please visit https://fromgistors.blogspot.com .]]></about>
6-
<version>7.8.36</version>
6+
<version>7.9.0</version>
77
<qgis_minimum_version>3.0.0</qgis_minimum_version>
88
<qgis_maximum_version>3.99.0</qgis_maximum_version>
99
<homepage><![CDATA[https://fromgistors.blogspot.com/p/semi-automatic-classification-plugin.html]]></homepage>

i18n/models/semiautomaticclassificationplugin.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5481,12 +5481,12 @@ Do you want to add the required fields to this shapefile?</source>
54815481
<translation type="unfinished"></translation>
54825482
</message>
54835483
<message>
5484-
<location filename="../core/utils.py" line="7297"/>
5484+
<location filename="../core/utils.py" line="7320"/>
54855485
<source>Build overviews</source>
54865486
<translation type="unfinished"></translation>
54875487
</message>
54885488
<message>
5489-
<location filename="../core/utils.py" line="7297"/>
5489+
<location filename="../core/utils.py" line="7320"/>
54905490
<source>Do you want to build the external overviews of bands?</source>
54915491
<translation type="unfinished"></translation>
54925492
</message>
@@ -5516,7 +5516,7 @@ Do you want to add the required fields to this shapefile?</source>
55165516
<translation type="unfinished"></translation>
55175517
</message>
55185518
<message>
5519-
<location filename="../maininterface/classreportTab.py" line="127"/>
5519+
<location filename="../maininterface/classreportTab.py" line="130"/>
55205520
<source>Percentage %</source>
55215521
<translation type="unfinished"></translation>
55225522
</message>
@@ -6101,7 +6101,7 @@ Do you want to add the required fields to this shapefile?</source>
61016101
<translation type="unfinished"></translation>
61026102
</message>
61036103
<message>
6104-
<location filename="../core/utils.py" line="9397"/>
6104+
<location filename="../core/utils.py" line="9420"/>
61056105
<source>SCP: completed process</source>
61066106
<translation type="unfinished"></translation>
61076107
</message>
@@ -6511,27 +6511,27 @@ Do you want to add the required fields to this shapefile?</source>
65116511
<translation type="unfinished"></translation>
65126512
</message>
65136513
<message>
6514-
<location filename="../core/utils.py" line="6191"/>
6514+
<location filename="../core/utils.py" line="6214"/>
65156515
<source>Calculating signature</source>
65166516
<translation type="unfinished"></translation>
65176517
</message>
65186518
<message>
6519-
<location filename="../core/utils.py" line="7571"/>
6519+
<location filename="../core/utils.py" line="7594"/>
65206520
<source>Writing file</source>
65216521
<translation type="unfinished"></translation>
65226522
</message>
65236523
<message>
6524-
<location filename="../core/utils.py" line="5485"/>
6524+
<location filename="../core/utils.py" line="5508"/>
65256525
<source>Conversion to vector</source>
65266526
<translation type="unfinished"></translation>
65276527
</message>
65286528
<message>
6529-
<location filename="../core/utils.py" line="7246"/>
6529+
<location filename="../core/utils.py" line="7269"/>
65306530
<source>Sieve</source>
65316531
<translation type="unfinished"></translation>
65326532
</message>
65336533
<message>
6534-
<location filename="../core/utils.py" line="7376"/>
6534+
<location filename="../core/utils.py" line="7399"/>
65356535
<source>Building overviews</source>
65366536
<translation type="unfinished"></translation>
65376537
</message>
@@ -6571,12 +6571,12 @@ Do you want to add the required fields to this shapefile?</source>
65716571
<translation type="unfinished"></translation>
65726572
</message>
65736573
<message>
6574-
<location filename="../core/utils.py" line="8844"/>
6574+
<location filename="../core/utils.py" line="8867"/>
65756575
<source>Remove rows</source>
65766576
<translation type="unfinished"></translation>
65776577
</message>
65786578
<message>
6579-
<location filename="../core/utils.py" line="8844"/>
6579+
<location filename="../core/utils.py" line="8867"/>
65806580
<source>Are you sure you want to remove highlighted rows from the table?</source>
65816581
<translation type="unfinished"></translation>
65826582
</message>
@@ -6616,7 +6616,7 @@ Do you want to add the required fields to this shapefile?</source>
66166616
<translation type="unfinished"></translation>
66176617
</message>
66186618
<message>
6619-
<location filename="../maininterface/landsatTab.py" line="436"/>
6619+
<location filename="../maininterface/landsatTab.py" line="437"/>
66206620
<source>Pansharpening</source>
66216621
<translation type="unfinished"></translation>
66226622
</message>

i18n/semiautomaticclassificationplugin.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5481,12 +5481,12 @@ Do you want to add the required fields to this shapefile?</source>
54815481
<translation type="unfinished"></translation>
54825482
</message>
54835483
<message>
5484-
<location filename="../core/utils.py" line="7297"/>
5484+
<location filename="../core/utils.py" line="7320"/>
54855485
<source>Build overviews</source>
54865486
<translation type="unfinished"></translation>
54875487
</message>
54885488
<message>
5489-
<location filename="../core/utils.py" line="7297"/>
5489+
<location filename="../core/utils.py" line="7320"/>
54905490
<source>Do you want to build the external overviews of bands?</source>
54915491
<translation type="unfinished"></translation>
54925492
</message>
@@ -5516,7 +5516,7 @@ Do you want to add the required fields to this shapefile?</source>
55165516
<translation type="unfinished"></translation>
55175517
</message>
55185518
<message>
5519-
<location filename="../maininterface/classreportTab.py" line="127"/>
5519+
<location filename="../maininterface/classreportTab.py" line="130"/>
55205520
<source>Percentage %</source>
55215521
<translation type="unfinished"></translation>
55225522
</message>
@@ -6101,7 +6101,7 @@ Do you want to add the required fields to this shapefile?</source>
61016101
<translation type="unfinished"></translation>
61026102
</message>
61036103
<message>
6104-
<location filename="../core/utils.py" line="9397"/>
6104+
<location filename="../core/utils.py" line="9420"/>
61056105
<source>SCP: completed process</source>
61066106
<translation type="unfinished"></translation>
61076107
</message>
@@ -6511,27 +6511,27 @@ Do you want to add the required fields to this shapefile?</source>
65116511
<translation type="unfinished"></translation>
65126512
</message>
65136513
<message>
6514-
<location filename="../core/utils.py" line="6191"/>
6514+
<location filename="../core/utils.py" line="6214"/>
65156515
<source>Calculating signature</source>
65166516
<translation type="unfinished"></translation>
65176517
</message>
65186518
<message>
6519-
<location filename="../core/utils.py" line="7571"/>
6519+
<location filename="../core/utils.py" line="7594"/>
65206520
<source>Writing file</source>
65216521
<translation type="unfinished"></translation>
65226522
</message>
65236523
<message>
6524-
<location filename="../core/utils.py" line="5485"/>
6524+
<location filename="../core/utils.py" line="5508"/>
65256525
<source>Conversion to vector</source>
65266526
<translation type="unfinished"></translation>
65276527
</message>
65286528
<message>
6529-
<location filename="../core/utils.py" line="7246"/>
6529+
<location filename="../core/utils.py" line="7269"/>
65306530
<source>Sieve</source>
65316531
<translation type="unfinished"></translation>
65326532
</message>
65336533
<message>
6534-
<location filename="../core/utils.py" line="7376"/>
6534+
<location filename="../core/utils.py" line="7399"/>
65356535
<source>Building overviews</source>
65366536
<translation type="unfinished"></translation>
65376537
</message>
@@ -6571,12 +6571,12 @@ Do you want to add the required fields to this shapefile?</source>
65716571
<translation type="unfinished"></translation>
65726572
</message>
65736573
<message>
6574-
<location filename="../core/utils.py" line="8844"/>
6574+
<location filename="../core/utils.py" line="8867"/>
65756575
<source>Remove rows</source>
65766576
<translation type="unfinished"></translation>
65776577
</message>
65786578
<message>
6579-
<location filename="../core/utils.py" line="8844"/>
6579+
<location filename="../core/utils.py" line="8867"/>
65806580
<source>Are you sure you want to remove highlighted rows from the table?</source>
65816581
<translation type="unfinished"></translation>
65826582
</message>
@@ -6616,7 +6616,7 @@ Do you want to add the required fields to this shapefile?</source>
66166616
<translation type="unfinished"></translation>
66176617
</message>
66186618
<message>
6619-
<location filename="../maininterface/landsatTab.py" line="436"/>
6619+
<location filename="../maininterface/landsatTab.py" line="437"/>
66206620
<source>Pansharpening</source>
66216621
<translation type="unfinished"></translation>
66226622
</message>

i18n/semiautomaticclassificationplugin_ar.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5481,12 +5481,12 @@ Do you want to add the required fields to this shapefile?</source>
54815481
<translation type="unfinished"></translation>
54825482
</message>
54835483
<message>
5484-
<location filename="../core/utils.py" line="7297"/>
5484+
<location filename="../core/utils.py" line="7320"/>
54855485
<source>Build overviews</source>
54865486
<translation type="unfinished"></translation>
54875487
</message>
54885488
<message>
5489-
<location filename="../core/utils.py" line="7297"/>
5489+
<location filename="../core/utils.py" line="7320"/>
54905490
<source>Do you want to build the external overviews of bands?</source>
54915491
<translation type="unfinished"></translation>
54925492
</message>
@@ -5516,7 +5516,7 @@ Do you want to add the required fields to this shapefile?</source>
55165516
<translation type="unfinished"></translation>
55175517
</message>
55185518
<message>
5519-
<location filename="../maininterface/classreportTab.py" line="127"/>
5519+
<location filename="../maininterface/classreportTab.py" line="130"/>
55205520
<source>Percentage %</source>
55215521
<translation type="unfinished"></translation>
55225522
</message>
@@ -6101,7 +6101,7 @@ Do you want to add the required fields to this shapefile?</source>
61016101
<translation type="unfinished"></translation>
61026102
</message>
61036103
<message>
6104-
<location filename="../core/utils.py" line="9397"/>
6104+
<location filename="../core/utils.py" line="9420"/>
61056105
<source>SCP: completed process</source>
61066106
<translation type="unfinished"></translation>
61076107
</message>
@@ -6511,27 +6511,27 @@ Do you want to add the required fields to this shapefile?</source>
65116511
<translation type="unfinished"></translation>
65126512
</message>
65136513
<message>
6514-
<location filename="../core/utils.py" line="6191"/>
6514+
<location filename="../core/utils.py" line="6214"/>
65156515
<source>Calculating signature</source>
65166516
<translation type="unfinished"></translation>
65176517
</message>
65186518
<message>
6519-
<location filename="../core/utils.py" line="7571"/>
6519+
<location filename="../core/utils.py" line="7594"/>
65206520
<source>Writing file</source>
65216521
<translation type="unfinished"></translation>
65226522
</message>
65236523
<message>
6524-
<location filename="../core/utils.py" line="5485"/>
6524+
<location filename="../core/utils.py" line="5508"/>
65256525
<source>Conversion to vector</source>
65266526
<translation type="unfinished"></translation>
65276527
</message>
65286528
<message>
6529-
<location filename="../core/utils.py" line="7246"/>
6529+
<location filename="../core/utils.py" line="7269"/>
65306530
<source>Sieve</source>
65316531
<translation type="unfinished"></translation>
65326532
</message>
65336533
<message>
6534-
<location filename="../core/utils.py" line="7376"/>
6534+
<location filename="../core/utils.py" line="7399"/>
65356535
<source>Building overviews</source>
65366536
<translation type="unfinished"></translation>
65376537
</message>
@@ -6571,12 +6571,12 @@ Do you want to add the required fields to this shapefile?</source>
65716571
<translation type="unfinished"></translation>
65726572
</message>
65736573
<message>
6574-
<location filename="../core/utils.py" line="8844"/>
6574+
<location filename="../core/utils.py" line="8867"/>
65756575
<source>Remove rows</source>
65766576
<translation type="unfinished"></translation>
65776577
</message>
65786578
<message>
6579-
<location filename="../core/utils.py" line="8844"/>
6579+
<location filename="../core/utils.py" line="8867"/>
65806580
<source>Are you sure you want to remove highlighted rows from the table?</source>
65816581
<translation type="unfinished"></translation>
65826582
</message>
@@ -6616,7 +6616,7 @@ Do you want to add the required fields to this shapefile?</source>
66166616
<translation type="unfinished"></translation>
66176617
</message>
66186618
<message>
6619-
<location filename="../maininterface/landsatTab.py" line="436"/>
6619+
<location filename="../maininterface/landsatTab.py" line="437"/>
66206620
<source>Pansharpening</source>
66216621
<translation type="unfinished"></translation>
66226622
</message>

0 commit comments

Comments
 (0)