Example #1
0
 def accept(self):
     self.buttonOk.setEnabled( False )
     if self.inPoint1.currentText() == "":
         QMessageBox.information(self, self.tr("Create Point Distance Matrix"), self.tr("Please specify input point layer"))
     elif self.outFile.text() == "":
         QMessageBox.information(self, self.tr("Create Point Distance Matrix"), self.tr("Please specify output file"))
     elif self.inPoint2.currentText() == "":
         QMessageBox.information(self, self.tr("Create Point Distance Matrix"), self.tr("Please specify target point layer"))
     elif self.inField1.currentText() == "":
         QMessageBox.information(self, self.tr("Create Point Distance Matrix"), self.tr("Please specify input unique ID field"))
     elif self.inField2.currentText() == "":
         QMessageBox.information(self, self.tr("Create Point Distance Matrix"), self.tr("Please specify target unique ID field"))
     else:
         point1 = self.inPoint1.currentText()
         point2 = self.inPoint2.currentText()
         field1 = self.inField1.currentText()
         field2 = self.inField2.currentText()
         outPath = self.outFile.text()
         if self.rdoLinear.isChecked(): matType = "Linear"
         elif self.rdoStandard.isChecked(): matType = "Standard"
         else: matType = "Summary"
         if self.chkNearest.isChecked(): nearest = self.spnNearest.value()
         else: nearest = 0
         outName = ftools_utils.getShapefileName(outPath,'.csv')
         self.outFile.clear()
         self.compute(point1, point2, field1, field2, outPath, matType, nearest, self.progressBar)
         self.progressBar.setValue(100)
         addToTOC = QMessageBox.information(self, "Create Point Distance Matrix", self.tr("Created output matrix:\n") + outPath)
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled( True )
Example #2
0
 def accept(self):
     self.buttonOk.setEnabled( False )
     if self.inPolygon.currentText() == "":
         QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify input polygon vector layer"))
     elif self.outShape.text() == "":
         QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify output shapefile"))
     elif self.inPoint.currentText() == "":
         QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify input line vector layer"))
     elif self.lnField.text() == "":
         QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify output length field"))
     else:
         inPoly = self.inPolygon.currentText()
         inLns = self.inPoint.currentText()
         inField = self.lnField.text()
         outPath = self.outShape.text()
         outName = ftools_utils.getShapefileName( outPath )
         self.compute(inPoly, inLns, inField, outPath, self.progressBar)
         self.outShape.clear()
         addToTOC = QMessageBox.question(self, self.tr("Sum line lengths"), self.tr("Created output shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % (unicode(outPath)), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
         if addToTOC == QMessageBox.Yes:
             self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
             QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
             self.populateLayers()
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled( True )
Example #3
0
 def accept(self):
     self.buttonOk.setEnabled(False)
     if self.inShape.currentText() == "":
         QMessageBox.information(self, self.tr("Random Points"),
                                 self.tr("No input layer specified"))
     elif self.outShape.text() == "":
         QMessageBox.information(self, self.tr("Random Points"),
                                 self.tr("Please specify output shapefile"))
     else:
         inName = self.inShape.currentText()
         self.progressBar.setValue(1)
         outPath = self.outShape.text()
         self.progressBar.setValue(2.5)
         outName = ftools_utils.getShapefileName(outPath)
         self.progressBar.setValue(5)
         mLayer = ftools_utils.getMapLayerByName(unicode(inName))
         if mLayer.type() == mLayer.VectorLayer:
             inLayer = ftools_utils.getVectorLayerByName(unicode(inName))
             if self.rdoUnstratified.isChecked():
                 design = self.tr("unstratified")
                 value = self.spnUnstratified.value()
             elif self.rdoStratified.isChecked():
                 design = self.tr("stratified")
                 value = self.spnStratified.value()
             elif self.rdoDensity.isChecked():
                 design = self.tr("density")
                 value = self.spnDensity.value()
             else:
                 design = self.tr("field")
                 value = unicode(self.cmbField.currentText())
         elif mLayer.type() == mLayer.RasterLayer:
             inLayer = ftools_utils.getRasterLayerByName(unicode(inName))
             design = self.tr("unstratified")
             value = self.spnUnstratified.value()
         else:
             QMessageBox.information(self, self.tr("Random Points"),
                                     self.tr("Unknown layer type..."))
         minimum = 0.00
         self.progressBar.setValue(10)
         if self.randomize(inLayer, outPath, minimum, design, value):
             self.progressBar.setValue(100)
             self.outShape.clear()
             if self.addToCanvasCheck.isChecked():
                 addCanvasCheck = ftools_utils.addShapeToCanvas(
                     unicode(outPath))
                 if not addCanvasCheck:
                     QMessageBox.warning(
                         self, self.tr("Random Points"),
                         self.tr("Error loading output shapefile:\n%s") %
                         (unicode(outPath)))
                 self.populateLayers()
             else:
                 QMessageBox.information(
                     self, self.tr("Random Points"),
                     self.tr("Created output shapefile:\n%s") %
                     (unicode(outPath)))
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled(True)
Example #4
0
 def accept(self):
     self.buttonOk.setEnabled(False)
     if not self.rdoCoordinates.isChecked() and self.inShape.currentText(
     ) == "":
         QMessageBox.information(self, self.tr("Generate Regular Points"),
                                 self.tr("Please specify input layer"))
     elif self.rdoCoordinates.isChecked() and (self.xMin.text() == ""
                                               or self.xMax.text() == ""
                                               or self.yMin.text() == ""
                                               or self.yMax.text() == ""):
         QMessageBox.information(
             self, self.tr("Generate Regular Points"),
             self.tr("Please properly specify extent coordinates"))
     elif self.outShape.text() == "":
         QMessageBox.information(self, self.tr("Generate Regular Points"),
                                 self.tr("Please specify output shapefile"))
     else:
         inName = self.inShape.currentText()
         outPath = self.outShape.text()
         self.outShape.clear()
         outName = ftools_utils.getShapefileName(outPath)
         if self.rdoSpacing.isChecked(): value = self.spnSpacing.value()
         else: value = self.spnNumber.value()
         if self.chkRandom.isChecked(): offset = True
         else: offset = False
         if self.rdoBoundary.isChecked():
             mLayer = ftools_utils.getMapLayerByName(unicode(inName))
             boundBox = mLayer.extent()
             crs = mLayer.crs()
         else:
             boundBox = QgsRectangle(float(self.xMin.text()),
                                     float(self.yMin.text()),
                                     float(self.xMax.text()),
                                     float(self.yMax.text()))
             crs = self.mapCanvas.mapRenderer().destinationCrs()
             print crs.isValid()
             if not crs.isValid(): crs = None
         self.regularize(boundBox, outPath, offset, value,
                         self.rdoSpacing.isChecked(), self.spnInset.value(),
                         crs)
         if self.addToCanvasCheck.isChecked():
             addCanvasCheck = ftools_utils.addShapeToCanvas(
                 unicode(outPath))
             if not addCanvasCheck:
                 QMessageBox.warning(
                     self, self.tr("Generate Regular Points"),
                     self.tr("Error loading output shapefile:\n%s") %
                     (unicode(outPath)))
             self.populateLayers()
         else:
             QMessageBox.information(
                 self, self.tr("Generate Regular Points"),
                 self.tr("Created output shapefile:\n%s") %
                 (unicode(outPath)))
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled(True)
Example #5
0
 def accept(self):
     self.buttonOk.setEnabled(False)
     if self.inShape.currentText() == "":
         QMessageBox.information(self, self.tr("Random Points"),
                                 self.tr("No input layer specified"))
     elif self.outShape.text() == "":
         QMessageBox.information(self, self.tr("Random Points"),
                                 self.tr("Please specify output shapefile"))
     else:
         inName = self.inShape.currentText()
         self.progressBar.setValue(1)
         outPath = self.outShape.text()
         self.progressBar.setValue(2.5)
         outName = ftools_utils.getShapefileName(outPath)
         self.progressBar.setValue(5)
         mLayer = ftools_utils.getMapLayerByName(unicode(inName))
         if mLayer.type() == mLayer.VectorLayer:
             inLayer = ftools_utils.getVectorLayerByName(unicode(inName))
             if self.rdoUnstratified.isChecked():
                 design = self.tr("unstratified")
                 value = self.spnUnstratified.value()
             elif self.rdoStratified.isChecked():
                 design = self.tr("stratified")
                 value = self.spnStratified.value()
             elif self.rdoDensity.isChecked():
                 design = self.tr("density")
                 value = self.spnDensity.value()
             else:
                 design = self.tr("field")
                 value = unicode(self.cmbField.currentText())
         elif mLayer.type() == mLayer.RasterLayer:
             inLayer = ftools_utils.getRasterLayerByName(unicode(inName))
             design = self.tr("unstratified")
             value = self.spnUnstratified.value()
         else:
             QMessageBox.information(self, self.tr("Random Points"),
                                     self.tr("Unknown layer type..."))
         minimum = 0.00
         self.progressBar.setValue(10)
         if self.randomize(inLayer, outPath, minimum, design, value):
             self.progressBar.setValue(100)
             self.outShape.clear()
             addToTOC = QMessageBox.question(
                 self, self.tr("Random Points"),
                 self.
                 tr("Created output point shapefile:\n%s\n\nWould you like to add the new layer to the TOC?"
                    ) % (outPath), QMessageBox.Yes, QMessageBox.No,
                 QMessageBox.NoButton)
             if addToTOC == QMessageBox.Yes:
                 self.vlayer = QgsVectorLayer(outPath, unicode(outName),
                                              "ogr")
                 QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
                 self.populateLayers()
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled(True)
Example #6
0
 def accept(self):
     self.buttonOk.setEnabled(False)
     if self.inShape.currentText() == "":
         QMessageBox.information(
             self, self.tr("Spatial Join"),
             self.tr("Please specify target vector layer"))
     elif self.outShape.text() == "":
         QMessageBox.information(self, self.tr("Spatial Join"),
                                 self.tr("Please specify output shapefile"))
     elif self.joinShape.currentText() == "":
         QMessageBox.information(
             self, self.tr("Spatial Join"),
             self.tr("Please specify join vector layer"))
     elif self.rdoSummary.isChecked() and not (
             self.chkMean.isChecked() or self.chkSum.isChecked()
             or self.chkMin.isChecked() or self.chkMax.isChecked()
             or self.chkMean.isChecked() or self.chkMedian.isChecked()):
         QMessageBox.information(
             self, self.tr("Spatial Join"),
             self.tr("Please specify at least one summary statistic"))
     else:
         inName = self.inShape.currentText()
         joinName = self.joinShape.currentText()
         outPath = self.outShape.text()
         if self.rdoSummary.isChecked():
             summary = True
             sumList = []
             if self.chkSum.isChecked(): sumList.append("SUM")
             if self.chkMean.isChecked(): sumList.append("MEAN")
             if self.chkMin.isChecked(): sumList.append("MIN")
             if self.chkMax.isChecked(): sumList.append("MAX")
             if self.chkMedian.isChecked(): sumList.append("MED")
         else:
             summary = False
             sumList = ["all"]
         if self.rdoKeep.isChecked(): keep = True
         else: keep = False
         outName = ftools_utils.getShapefileName(outPath)
         res = self.compute(inName, joinName, outPath, summary, sumList,
                            keep, self.progressBar)
         self.outShape.clear()
         if res:
             addToTOC = QMessageBox.question(
                 self, self.tr("Spatial Join"),
                 self.
                 tr("Created output shapefile:\n%s\n\nWould you like to add the new layer to the TOC?"
                    ) % (unicode(outPath)), QMessageBox.Yes, QMessageBox.No,
                 QMessageBox.NoButton)
             if addToTOC == QMessageBox.Yes:
                 self.vlayer = QgsVectorLayer(outPath, unicode(outName),
                                              "ogr")
                 QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled(True)
Example #7
0
 def accept(self):
     self.buttonOk.setEnabled(False)
     if not self.rdoCoordinates.isChecked() and self.inShape.currentText(
     ) == "":
         QMessageBox.information(self, self.tr("Generate Regular Points"),
                                 self.tr("Please specify input layer"))
     elif self.rdoCoordinates.isChecked() and (self.xMin.text() == ""
                                               or self.xMax.text() == ""
                                               or self.yMin.text() == ""
                                               or self.yMax.text() == ""):
         QMessageBox.information(
             self, self.tr("Generate Regular Points"),
             self.tr("Please properly specify extent coordinates"))
     elif self.outShape.text() == "":
         QMessageBox.information(self, self.tr("Generate Regular Points"),
                                 self.tr("Please specify output shapefile"))
     else:
         inName = self.inShape.currentText()
         outPath = self.outShape.text()
         self.outShape.clear()
         outName = ftools_utils.getShapefileName(outPath)
         if self.rdoSpacing.isChecked(): value = self.spnSpacing.value()
         else: value = self.spnNumber.value()
         if self.chkRandom.isChecked(): offset = True
         else: offset = False
         if self.rdoBoundary.isChecked():
             mLayer = ftools_utils.getMapLayerByName(unicode(inName))
             boundBox = mLayer.extent()
             crs = mLayer.crs()
         else:
             boundBox = QgsRectangle(float(self.xMin.text()),
                                     float(self.yMin.text()),
                                     float(self.xMax.text()),
                                     float(self.yMax.text()))
             crs = self.mapCanvas.mapRenderer().destinationCrs()
             print crs.isValid()
             if not crs.isValid(): crs = None
         self.regularize(boundBox, outPath, offset, value,
                         self.rdoSpacing.isChecked(), self.spnInset.value(),
                         crs)
         addToTOC = QMessageBox.question(
             self, self.tr("Generate Regular Points"),
             self.
             tr("Created output point shapefile:\n%s\n\nWould you like to add the new layer to the TOC?"
                ) % (outPath), QMessageBox.Yes, QMessageBox.No,
             QMessageBox.NoButton)
         if addToTOC == QMessageBox.Yes:
             self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
             QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
             self.populateLayers()
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled(True)
Example #8
0
 def accept(self):
     self.buttonOk.setEnabled( False )
     if self.inShape.currentText() == "":
         QMessageBox.information(self, self.tr("Random Points"), self.tr("No input layer specified"))
     elif self.outShape.text() == "":
         QMessageBox.information(self, self.tr("Random Points"), self.tr("Please specify output shapefile"))
     else:
         inName = self.inShape.currentText()
         self.progressBar.setValue(1)
         outPath = self.outShape.text()
         self.progressBar.setValue(2.5)
         outName = ftools_utils.getShapefileName( outPath )
         self.progressBar.setValue(5)
         mLayer = ftools_utils.getMapLayerByName(unicode(inName))
         if mLayer.type() == mLayer.VectorLayer:
             inLayer = ftools_utils.getVectorLayerByName(unicode(inName))
             if self.rdoUnstratified.isChecked():
                 design = self.tr("unstratified")
                 value = self.spnUnstratified.value()
             elif self.rdoStratified.isChecked():
                 design = self.tr("stratified")
                 value = self.spnStratified.value()
             elif self.rdoDensity.isChecked():
                 design = self.tr("density")
                 value = self.spnDensity.value()
             else:
                 design = self.tr("field")
                 value = unicode(self.cmbField.currentText())
         elif mLayer.type() == mLayer.RasterLayer:
             inLayer = ftools_utils.getRasterLayerByName(unicode(inName))
             design = self.tr("unstratified")
             value = self.spnUnstratified.value()
         else:
             QMessageBox.information(self, self.tr("Random Points"), self.tr("Unknown layer type..."))
         minimum = 0.00
         self.progressBar.setValue(10)
         if self.randomize(inLayer, outPath, minimum, design, value):
           self.progressBar.setValue(100)
           self.outShape.clear()
           if self.addToCanvasCheck.isChecked():
             addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
             if not addCanvasCheck:
                 QMessageBox.warning( self, self.tr("Random Points"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
             self.populateLayers()
           else:
             QMessageBox.information(self, self.tr("Random Points"),self.tr("Created output shapefile:\n%s" ) % ( unicode( outPath )))
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled( True )
Example #9
0
 def accept(self):
     self.buttonOk.setEnabled( False )
     if self.inShape.currentText() == "":
         QMessageBox.information(self, self.tr("Random Points"), self.tr("No input layer specified"))
     elif self.outShape.text() == "":
         QMessageBox.information(self, self.tr("Random Points"), self.tr("Please specify output shapefile"))
     else:
         inName = self.inShape.currentText()
         self.progressBar.setValue(1)
         outPath = self.outShape.text()
         self.progressBar.setValue(2.5)
         outName = ftools_utils.getShapefileName( outPath )
         self.progressBar.setValue(5)
         mLayer = ftools_utils.getMapLayerByName(unicode(inName))
         if mLayer.type() == mLayer.VectorLayer:
             inLayer = ftools_utils.getVectorLayerByName(unicode(inName))
             if self.rdoUnstratified.isChecked():
                 design = self.tr("unstratified")
                 value = self.spnUnstratified.value()
             elif self.rdoStratified.isChecked():
                 design = self.tr("stratified")
                 value = self.spnStratified.value()
             elif self.rdoDensity.isChecked():
                 design = self.tr("density")
                 value = self.spnDensity.value()
             else:
                 design = self.tr("field")
                 value = unicode(self.cmbField.currentText())
         elif mLayer.type() == mLayer.RasterLayer:
             inLayer = ftools_utils.getRasterLayerByName(unicode(inName))
             design = self.tr("unstratified")
             value = self.spnUnstratified.value()
         else:
             QMessageBox.information(self, self.tr("Random Points"), self.tr("Unknown layer type..."))
         minimum = 0.00
         self.progressBar.setValue(10)
         self.randomize(inLayer, outPath, minimum, design, value)
         self.progressBar.setValue(100)
         self.outShape.clear()
         addToTOC = QMessageBox.question(self, self.tr("Random Points"),
         self.tr("Created output point shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % (outPath), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
         if addToTOC == QMessageBox.Yes:
             self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
             QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
             self.populateLayers()
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled( True )
Example #10
0
 def accept(self):
     self.buttonOk.setEnabled(False)
     if self.inShape.currentText() == "":
         QMessageBox.information(self, self.tr("Spatial Join"), self.tr("Please specify target vector layer"))
     elif self.outShape.text() == "":
         QMessageBox.information(self, self.tr("Spatial Join"), self.tr("Please specify output shapefile"))
     elif self.joinShape.currentText() == "":
         QMessageBox.information(self, self.tr("Spatial Join"), self.tr("Please specify join vector layer"))
     elif self.rdoSummary.isChecked() and not (self.chkMean.isChecked() or self.chkSum.isChecked() or self.chkMin.isChecked() or self.chkMax.isChecked() or self.chkMean.isChecked() or self.chkMedian.isChecked()):
         QMessageBox.information(self, self.tr("Spatial Join"), self.tr("Please specify at least one summary statistic"))
     else:
         inName = self.inShape.currentText()
         joinName = self.joinShape.currentText()
         outPath = self.outShape.text()
         if self.rdoSummary.isChecked():
             summary = True
             sumList = []
             if self.chkSum.isChecked():
                 sumList.append("SUM")
             if self.chkMean.isChecked():
                 sumList.append("MEAN")
             if self.chkMin.isChecked():
                 sumList.append("MIN")
             if self.chkMax.isChecked():
                 sumList.append("MAX")
             if self.chkMedian.isChecked():
                 sumList.append("MED")
         else:
             summary = False
             sumList = ["all"]
         if self.rdoKeep.isChecked():
             keep = True
         else:
             keep = False
         outName = ftools_utils.getShapefileName(outPath)
         res = self.compute(inName, joinName, outPath, summary, sumList, keep, self.progressBar)
         self.outShape.clear()
         if res:
             addToTOC = QMessageBox.question(
                 self, self.tr("Spatial Join"),
                 self.tr("Created output shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % (unicode(outPath)),
                 QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
             if addToTOC == QMessageBox.Yes:
                 self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
                 QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled(True)
Example #11
0
 def accept(self):
     self.buttonOk.setEnabled(False)
     if self.inPoint1.currentText() == "":
         QMessageBox.information(
             self, self.tr("Create Point Distance Matrix"),
             self.tr("Please specify input point layer"))
     elif self.outFile.text() == "":
         QMessageBox.information(self,
                                 self.tr("Create Point Distance Matrix"),
                                 self.tr("Please specify output file"))
     elif self.inPoint2.currentText() == "":
         QMessageBox.information(
             self, self.tr("Create Point Distance Matrix"),
             self.tr("Please specify target point layer"))
     elif self.inField1.currentText() == "":
         QMessageBox.information(
             self, self.tr("Create Point Distance Matrix"),
             self.tr("Please specify input unique ID field"))
     elif self.inField2.currentText() == "":
         QMessageBox.information(
             self, self.tr("Create Point Distance Matrix"),
             self.tr("Please specify target unique ID field"))
     else:
         point1 = self.inPoint1.currentText()
         point2 = self.inPoint2.currentText()
         field1 = self.inField1.currentText()
         field2 = self.inField2.currentText()
         outPath = self.outFile.text()
         if self.rdoLinear.isChecked(): matType = "Linear"
         elif self.rdoStandard.isChecked(): matType = "Standard"
         else: matType = "Summary"
         if self.chkNearest.isChecked(): nearest = self.spnNearest.value()
         else: nearest = 0
         outName = ftools_utils.getShapefileName(outPath, '.csv')
         self.outFile.clear()
         self.compute(point1, point2, field1, field2, outPath, matType,
                      nearest, self.progressBar)
         self.progressBar.setValue(100)
         addToTOC = QMessageBox.information(
             self, "Create Point Distance Matrix",
             self.tr("Created output matrix:\n") + outPath)
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled(True)
Example #12
0
 def accept(self):
     self.buttonOk.setEnabled(False)
     if self.inPolygon.currentText() == "":
         QMessageBox.information(
             self, self.tr("Sum Line Lengths In Polyons"),
             self.tr("Please specify input polygon vector layer"))
     elif self.outShape.text() == "":
         QMessageBox.information(self,
                                 self.tr("Sum Line Lengths In Polyons"),
                                 self.tr("Please specify output shapefile"))
     elif self.inPoint.currentText() == "":
         QMessageBox.information(
             self, self.tr("Sum Line Lengths In Polyons"),
             self.tr("Please specify input line vector layer"))
     elif self.lnField.text() == "":
         QMessageBox.information(
             self, self.tr("Sum Line Lengths In Polyons"),
             self.tr("Please specify output length field"))
     else:
         inPoly = self.inPolygon.currentText()
         inLns = self.inPoint.currentText()
         inField = self.lnField.text()
         outPath = self.outShape.text()
         outName = ftools_utils.getShapefileName(outPath)
         self.compute(inPoly, inLns, inField, outPath, self.progressBar)
         self.outShape.clear()
         if self.addToCanvasCheck.isChecked():
             addCanvasCheck = ftools_utils.addShapeToCanvas(
                 unicode(outPath))
             if not addCanvasCheck:
                 QMessageBox.warning(
                     self, self.tr("Sum line lengths"),
                     self.tr("Error loading output shapefile:\n%s") %
                     (unicode(outPath)))
             self.populateLayers()
         else:
             QMessageBox.information(
                 self, self.tr("Sum line lengths"),
                 self.tr("Created output shapefile:\n%s") %
                 (unicode(outPath)))
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled(True)
Example #13
0
 def accept(self):
     self.buttonOk.setEnabled(False)
     if self.inPolygon.currentText() == "":
         QMessageBox.information(
             self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify input polygon vector layer")
         )
     elif self.outShape.text() == "":
         QMessageBox.information(
             self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify output shapefile")
         )
     elif self.inPoint.currentText() == "":
         QMessageBox.information(
             self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify input line vector layer")
         )
     elif self.lnField.text() == "":
         QMessageBox.information(
             self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify output length field")
         )
     else:
         inPoly = self.inPolygon.currentText()
         inLns = self.inPoint.currentText()
         inField = self.lnField.text()
         outPath = self.outShape.text()
         outName = ftools_utils.getShapefileName(outPath)
         self.compute(inPoly, inLns, inField, outPath, self.progressBar)
         self.outShape.clear()
         if self.addToCanvasCheck.isChecked():
             addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
             if not addCanvasCheck:
                 QMessageBox.warning(
                     self,
                     self.tr("Sum line lengths"),
                     self.tr("Error loading output shapefile:\n%s") % (unicode(outPath)),
                 )
             self.populateLayers()
         else:
             QMessageBox.information(
                 self, self.tr("Sum line lengths"), self.tr("Created output shapefile:\n%s") % (unicode(outPath))
             )
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled(True)
Example #14
0
    def accept(self):
        self.buttonOk.setEnabled( False )
        if self.inShape.currentText() == "":
            QMessageBox.information(self, self.tr("Coordinate statistics"), self.tr("No input vector layer specified"))
        elif self.outShape.text() == "":
            QMessageBox.information(self, self.tr("Coordinate statistics"), self.tr("Please specify output shapefile"))
        else:
            inName = self.inShape.currentText()
            outPath = self.outShape.text()
            outName = ftools_utils.getShapefileName(outPath)

            self.compute(inName, outPath, self.weightField.currentText(), self.sizeValue.value(), self.uniqueField.currentText())
            self.progressBar.setValue(100)
            self.outShape.clear()
            addToTOC = QMessageBox.question(self, self.tr("Coordinate statistics"), self.tr("Created output point shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % ( outPath ), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
            if addToTOC == QMessageBox.Yes:
                vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
                QgsMapLayerRegistry.instance().addMapLayers([vlayer])
                self.populateLayers()
        self.progressBar.setValue(0)
        self.buttonOk.setEnabled( True )
Example #15
0
 def accept(self):
     self.buttonOk.setEnabled(False)
     if self.inPolygon.currentText() == "":
         QMessageBox.information(
             self, self.tr("Sum Line Lengths In Polyons"),
             self.tr("Please specify input polygon vector layer"))
     elif self.outShape.text() == "":
         QMessageBox.information(self,
                                 self.tr("Sum Line Lengths In Polyons"),
                                 self.tr("Please specify output shapefile"))
     elif self.inPoint.currentText() == "":
         QMessageBox.information(
             self, self.tr("Sum Line Lengths In Polyons"),
             self.tr("Please specify input line vector layer"))
     elif self.lnField.text() == "":
         QMessageBox.information(
             self, self.tr("Sum Line Lengths In Polyons"),
             self.tr("Please specify output length field"))
     else:
         inPoly = self.inPolygon.currentText()
         inLns = self.inPoint.currentText()
         inField = self.lnField.text()
         outPath = self.outShape.text()
         outName = ftools_utils.getShapefileName(outPath)
         self.compute(inPoly, inLns, inField, outPath, self.progressBar)
         self.outShape.clear()
         addToTOC = QMessageBox.question(
             self, self.tr("Sum line lengths"),
             self.
             tr("Created output shapefile:\n%s\n\nWould you like to add the new layer to the TOC?"
                ) % (unicode(outPath)), QMessageBox.Yes, QMessageBox.No,
             QMessageBox.NoButton)
         if addToTOC == QMessageBox.Yes:
             self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
             QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
             self.populateLayers()
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled(True)
Example #16
0
    def accept(self):
        self.buttonOk.setEnabled( False )
        if self.inShape.currentText() == "":
            QMessageBox.information(self, self.tr("Coordinate statistics"), self.tr("No input vector layer specified"))
        elif self.outShape.text() == "":
            QMessageBox.information(self, self.tr("Coordinate statistics"), self.tr("Please specify output shapefile"))
        else:
            inName = self.inShape.currentText()
            outPath = self.outShape.text()
            outName = ftools_utils.getShapefileName(outPath)

            self.compute(inName, outPath, self.weightField.currentText(), self.sizeValue.value(), self.uniqueField.currentText())
            self.progressBar.setValue(100)
            self.outShape.clear()
            if self.addToCanvasCheck.isChecked():
                addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
                if not addCanvasCheck:
                    QMessageBox.warning( self, self.tr("Coordinate statistics"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
                self.populateLayers()
            else:
                QMessageBox.information(self, self.tr("Coordinate statistics"),self.tr("Created output shapefile:\n%s" ) % ( unicode( outPath )))
        self.progressBar.setValue(0)
        self.buttonOk.setEnabled( True )
Example #17
0
 def accept(self):
     self.buttonOk.setEnabled( False )
     if not self.rdoCoordinates.isChecked() and self.inShape.currentText() == "":
         QMessageBox.information(self, self.tr("Generate Regular Points"), self.tr("Please specify input layer"))
     elif self.rdoCoordinates.isChecked() and (self.xMin.text() == "" or self.xMax.text() == "" or self.yMin.text() == "" or self.yMax.text() == ""):
         QMessageBox.information(self, self.tr("Generate Regular Points"), self.tr("Please properly specify extent coordinates"))
     elif self.outShape.text() == "":
         QMessageBox.information(self, self.tr("Generate Regular Points"), self.tr("Please specify output shapefile"))
     else:
         inName = self.inShape.currentText()
         outPath = self.outShape.text()
         self.outShape.clear()
         outName = ftools_utils.getShapefileName( outPath )
         if self.rdoSpacing.isChecked(): value = self.spnSpacing.value()
         else: value = self.spnNumber.value()
         if self.chkRandom.isChecked(): offset = True
         else: offset = False
         if self.rdoBoundary.isChecked():
             mLayer = ftools_utils.getMapLayerByName(unicode(inName))
             boundBox = mLayer.extent()
             crs = mLayer.crs()
         else:
             boundBox = QgsRectangle(float(self.xMin.text()), float(self.yMin.text()), float(self.xMax.text()), float(self.yMax.text()))
             crs = self.mapCanvas.mapRenderer().destinationCrs()
             print crs.isValid()
             if not crs.isValid(): crs = None
         self.regularize(boundBox, outPath, offset, value, self.rdoSpacing.isChecked(), self.spnInset.value(), crs)
         if self.addToCanvasCheck.isChecked():
             addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
             if not addCanvasCheck:
                 QMessageBox.warning( self, self.tr("Generate Regular Points"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
             self.populateLayers()
         else:
             QMessageBox.information(self, self.tr("Generate Regular Points"),self.tr("Created output shapefile:\n%s" ) % ( unicode( outPath )))
     self.progressBar.setValue(0)
     self.buttonOk.setEnabled( True )