Skip to content

Commit

Permalink
v1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nkarasiak authored Oct 6, 2016
1 parent a1cb8dc commit b92fed9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 45 deletions.
8 changes: 6 additions & 2 deletions function_historical_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,13 +522,16 @@ def postClassRaster(self,inRaster,sieveSize,inClassNumber,outShp):
def sieve(srcband,dstband,sieveSize):
gdal.SieveFilter(srcband,None,dstband,sieveSize,4)


sieve(srcband,dstband,sieveSize)
pixelSize = datasrc.GetGeoTransform()[1] #get pixel size
pixelSieve = int(sieveSize/(pixelSize*pixelSize)) #get number of pixel to sieve

sieve(srcband,dstband,pixelSieve)

dst_ds = None # close destination band

Progress.addStep()


rasterTemp = self.reclassAndFillHole(rasterTemp,inClassNumber)


Expand All @@ -538,6 +541,7 @@ def sieve(srcband,dstband,sieveSize):

except:
QgsMessageLog.logMessage("Cannot sieve with raster function")


outShp = self.polygonize(rasterTemp,outShp) # vectorize raster

Expand Down
22 changes: 3 additions & 19 deletions historical_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ def __init__(self, iface):
listFieldNames = [field.name() for field in fields]
self.dlg.inField.addItems(listFieldNames)

## Connect to change values if change post treatment value
self.dlg.filterByArea.clicked.connect(self.choosePostTreatment)
self.dlg.filterByPixel.clicked.connect(self.choosePostTreatment)


## hide/show nfolds spinbox
self.dlg.nFolds.hide()
Expand All @@ -124,21 +122,7 @@ def nfolds(self,index):
if self.dlg.inClassifier.currentText() == "GMM":
self.dlg.nFolds.hide()
else :
self.dlg.nFolds.show()

def choosePostTreatment(self,index):
"""!@brief Change post treatmen values if raster or vector """
if self.dlg.filterByArea.isChecked(): #if vector mod
self.dlg.inMinSize.setDecimals(2)
self.dlg.inMinSize.setValue(0.5)
self.dlg.inMinSize.setSingleStep(0.1)
self.dlg.inMinSize.setSuffix(' ha')
else: # if raster mod
self.dlg.inMinSize.setDecimals(0)
self.dlg.inMinSize.setValue(5)
self.dlg.inMinSize.setSingleStep(1)
self.dlg.inMinSize.setSuffix(' pixels')

self.dlg.nFolds.show()

def onChangedLayer(self,index):
"""!@brief If active layer is changed, change column combobox"""
Expand Down Expand Up @@ -453,6 +437,7 @@ def runClassify(self):
# do the job

classify=fhm.classifyImage()
inMinSize = inMinSize*10000 # convert ha to m squared

try:
temp=classify.initPredict(inFilteredStep3,inModel)
Expand All @@ -464,7 +449,6 @@ def runClassify(self):
if self.dlg.filterByPixel.isChecked(): # sieve by pixel number (raster)
temp=classify.postClassRaster(temp,int(inMinSize),inClassForest,outShp)
else : # sieve by area (vector)
inMinSize = inMinSize*10000 # convert ha to m squared
temp=classify.postClassVector(temp,inMinSize,inClassForest,outShp)

# Add layer
Expand Down
14 changes: 6 additions & 8 deletions historical_map_dialog_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,6 @@ def setupUi(self, HistoricalMap):
self.nFolds = QtGui.QSpinBox(self.tab_2)
self.nFolds.setGeometry(QtCore.QRect(350, 79, 111, 27))
self.nFolds.setProperty("value", 3)
self.nFolds.setMaximum(999)
self.nFolds.setMinimum(3)
self.nFolds.setObjectName(_fromUtf8("nFolds"))
self.tabWidget.addTab(self.tab_2, _fromUtf8(""))
self.tab_3 = QtGui.QWidget()
Expand Down Expand Up @@ -538,10 +536,11 @@ def setupUi(self, HistoricalMap):
self.inMinSize = QtGui.QDoubleSpinBox(self.groupBox_2)
self.inMinSize.setGeometry(QtCore.QRect(190, 86, 97, 23))
self.inMinSize.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.inMinSize.setDecimals(0)
self.inMinSize.setDecimals(2)
self.inMinSize.setMinimum(0.1)
self.inMinSize.setMaximum(1000.0)
self.inMinSize.setSingleStep(1.0)
self.inMinSize.setProperty("value", 10.0)
self.inMinSize.setSingleStep(0.1)
self.inMinSize.setProperty("value", 0.5)
self.inMinSize.setObjectName(_fromUtf8("inMinSize"))
self.tiffImageLabel_18 = QtGui.QLabel(self.groupBox_2)
self.tiffImageLabel_18.setGeometry(QtCore.QRect(17, 84, 167, 28))
Expand Down Expand Up @@ -605,7 +604,6 @@ def setupUi(self, HistoricalMap):
font = QtGui.QFont()
font.setPointSize(8)
self.label_14.setFont(font)
self.label_14.setPixmap(QtGui.QPixmap(_fromUtf8(":/plugins/HistoricalMap/img/help/information.png")))
self.label_14.setScaledContents(True)
self.label_14.setAlignment(QtCore.Qt.AlignBottom|QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing)
self.label_14.setOpenExternalLinks(True)
Expand Down Expand Up @@ -703,10 +701,10 @@ def retranslateUi(self, HistoricalMap):
self.tiffImageLabel_14.setText(_translate("HistoricalMap", "Class number :", None))
self.filterByPixel.setText(_translate("HistoricalMap", "Filter by pixel (faster)", None))
self.label_12.setToolTip(_translate("HistoricalMap", "<html><head/><body><p><span style=\" font-weight:600;\">filter by pixel</span></p><p>remove raster polygons by a sieve in pixel (diagonal pixels are not considered directly connected).</p><p><span style=\" font-weight:600;\">filter by area</span></p><p>keep default system divised by 100. If you use Lambert III (EPSG 2154), 0,5 means 0,5 hectares (5000m2). We usually consider a forest is at least 0,5 ha, so you can remove all polygons below a certain size, by default 0,5 acre.</p></body></html>", None))
self.inMinSize.setSuffix(_translate("HistoricalMap", " pixels", None))
self.inMinSize.setSuffix(_translate("HistoricalMap", " ha", None))
self.tiffImageLabel_18.setText(_translate("HistoricalMap", "Min parcel size :", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), _translate("HistoricalMap", "Classify (Step 3)", None))
self.label_14.setToolTip(_translate("HistoricalMap", "Go to our online wiki", None))
self.label_14.setText(_translate("HistoricalMap", "<html><head/><body><p>Need help ? You can consult our <a href=\"https://github.com/lennepkade/HistoricalMap/wiki\"><span style=\" text-decoration: underline; color:#0000ff;\">online wiki</span></a> or our <a href=\"https://github.com/lennepkade/HistoricalMap\"><span style=\" text-decoration: underline; color:#0000ff;\">github page</span></a>.</p></body></html>", None))
self.label_14.setText(_translate("HistoricalMap", "<html><head/><body><p>Need help ? You can consult our <a href=\"https://github.com/lennepkade/HistoricalMap/wiki\"><span style=\" text-decoration: underline; color:#0000ff;\">wiki</span></a> or our <a href=\"https://github.com/lennepkade/HistoricalMap/\"><span style=\" text-decoration: underline; color:#0000ff;\">github page</span></a>.</p></body></html>", None))

from qgis import gui
22 changes: 8 additions & 14 deletions historical_map_dialog_base.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1296,12 +1296,6 @@ For example 0,5 means that we use 50% of your parcel for making the model.</stri
</property>
<property name="value">
<number>3</number>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="minimum">
<number>3</number>
</property>
</widget>
</widget>
Expand Down Expand Up @@ -1690,19 +1684,22 @@ For example 0,5 means that we use 50% of your parcel for making the model.</stri
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string> pixels</string>
<string> ha</string>
</property>
<property name="decimals">
<number>0</number>
<number>2</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>1000.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
<double>0.100000000000000</double>
</property>
<property name="value">
<double>10.000000000000000</double>
<double>0.500000000000000</double>
</property>
</widget>
<widget class="QLabel" name="tiffImageLabel_18">
Expand Down Expand Up @@ -1935,10 +1932,7 @@ For example 0,5 means that we use 50% of your parcel for making the model.</stri
<string>Go to our online wiki</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Need help ? You can consult our &lt;a href=&quot;https://github.com/lennepkade/HistoricalMap/wiki&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;online wiki&lt;/span&gt;&lt;/a&gt; or our &lt;a href=&quot;https://github.com/lennepkade/HistoricalMap&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;github page&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/plugins/HistoricalMap/img/help/information.png</pixmap>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Need help ? You can consult our &lt;a href=&quot;https://github.com/lennepkade/HistoricalMap/wiki&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;wiki&lt;/span&gt;&lt;/a&gt; or our &lt;a href=&quot;https://github.com/lennepkade/HistoricalMap/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;github page&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="scaledContents">
<bool>true</bool>
Expand Down
4 changes: 2 additions & 2 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name=Historical Map
qgisMinimumVersion=2.0
description=Automatic vectorization of old forests from historical maps
version=1.1.2
version=1.1.3
author=Nicolas Karasiak, Antoine Lomellini
email=karasiak.nicolas@gmail.com

Expand All @@ -23,7 +23,7 @@ repository=https://github.com/lennepkade/HistoricalMap/
# Recommended items:

# Uncomment the following line and add your changelog:
changelog=Correct bug when filling hole for vector post classification and add folds number choice for algorithms
changelog=Raster post classification with hectare (area) instead of number of pixel

# Tags are comma separated with spaces allowed
tags=historical map,classification, classify,filter,old map,forest, random forest, gmm
Expand Down

0 comments on commit b92fed9

Please sign in to comment.