[Qgis-user] Open and read shapefile plugin in QGIS dufour

Suryo Miles suryomiles666 at gmail.com
Tue Dec 10 08:51:41 PST 2013


I try to make plugin to read shapefile with plugin builder in QGIS and i
try to import pyshp in plugin to read shapefiles but i got this error
message

 Traceback (most recent call last):
  File "C:\Users\Mr.Pakde/.qgis2/python/plugins\shpread\shpreaddialog.py",
line 42, in baca
    shapefile.Reader("shapefiles/blockgroups")
  File "C:\Users\Mr.Pakde/.qgis2/python/plugins\shpread\shapefile.py", line
220, in __init__
    self.load(args[0])
  File "C:\Users\Mr.Pakde/.qgis2/python/plugins\shpread\shapefile.py", line
253, in load
    raise ShapefileException("Unable to open %s.shp" % shapeName)
ShapefileException: Unable to open shapefiles/blockgroups.shp

Python version:
2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]

------and this is code i use ( i put it in dialog.py)-------

# insert every signal connection here!
        cariButton = self.ui.btnShp
        QtCore.QObject.connect(cariButton,
QtCore.SIGNAL('clicked()'),self.baca)

    def baca(self):
        sf = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '*.shp')
        shapefile.Reader("shapefiles/blockgroups")
        shapes = sf.shapes()
        # Read the bounding box from the 4th shape
        shapes[3].bbox
        [-122.485792, 37.786931000000003, -122.446285, 37.811019000000002]
        #  Read the 8th point in the 4th shape
        shapes[3].points[7]
        [-122.471063, 37.787402999999998]

        #panggil isi data
        self.isiDataFile(sf)

    def isiDataFile(self, nmfile):
        #buka dengan open mode baca
        teksFile = open(nmfile, 'r').read()

        self.ui.textShp.setText(teksFile)


can someone help me?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20131210/5c382c29/attachment.html>


More information about the Qgis-user mailing list