Skip to main content
added 6 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130

I suppose your question does not include change detection, as your sample only concerns QgsMapCanvas.refresh()QgsMapCanvas.refresh()

Instead you have to call QgsRasterLayer.triggerRepaint()QgsRasterLayer.triggerRepaint()

If your layer is called myLayer:

myLayer.setCacheImage( None )
myLayer.triggerRepaint()

The same method exists for vector layers as well.

For low overhead file change notification I'd propose looking into Qt's QFileSystemWatcherQFileSystemWatcher, which makes use of inotify on linux and similar techniques on other platforms.

from PyQt4.QtCore import QFileSystemWatcher

def refreshLayer():
    myLayer.setCacheImage( None )
    myLayer.triggerRepaint()

watcher = QFileSystemWatcher()
watcher.addPath( '/path/to/your/raster' )
watcher.fileChanged.connect( refreshLayer )

Of course this can be combined with an MD5 check as proposed by nickves or a modification time check with os.stat (Nathan W proposal).

I suppose your question does not include change detection, as your sample only concerns QgsMapCanvas.refresh()

Instead you have to call QgsRasterLayer.triggerRepaint()

If your layer is called myLayer:

myLayer.setCacheImage( None )
myLayer.triggerRepaint()

The same method exists for vector layers as well.

For low overhead file change notification I'd propose looking into Qt's QFileSystemWatcher, which makes use of inotify on linux and similar techniques on other platforms.

from PyQt4.QtCore import QFileSystemWatcher

def refreshLayer():
    myLayer.setCacheImage( None )
    myLayer.triggerRepaint()

watcher = QFileSystemWatcher()
watcher.addPath( '/path/to/your/raster' )
watcher.fileChanged.connect( refreshLayer )

Of course this can be combined with an MD5 check as proposed by nickves.

I suppose your question does not include change detection, as your sample only concerns QgsMapCanvas.refresh()

Instead you have to call QgsRasterLayer.triggerRepaint()

If your layer is called myLayer:

myLayer.setCacheImage( None )
myLayer.triggerRepaint()

The same method exists for vector layers as well.

For low overhead file change notification I'd propose looking into Qt's QFileSystemWatcher, which makes use of inotify on linux and similar techniques on other platforms.

from PyQt4.QtCore import QFileSystemWatcher

def refreshLayer():
    myLayer.setCacheImage( None )
    myLayer.triggerRepaint()

watcher = QFileSystemWatcher()
watcher.addPath( '/path/to/your/raster' )
watcher.fileChanged.connect( refreshLayer )

Of course this can be combined with an MD5 check as proposed by nickves or a modification time check with os.stat (Nathan W proposal).

added 232 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130

I suppose your question does not include change detection, as your sample only concerns QgsMapCanvas.refresh()

Instead you have to call QgsRasterLayer.triggerRepaint()

If your layer is called myLayer:

myLayer.setCacheImage( None )
myLayer.triggerRepaint()

The same method exists for vector layers as well.

For low overhead file change notification I'd propose looking into Qt's QFileSystemWatcher, which makes use of inotify on linux and similar techniquessimilar techniques on other platformsother platforms.

from PyQt4.QtCore import QFileSystemWatcher

def refreshLayer():
    myLayer.setCacheImage( None )
    myLayer.triggerRepaint()

watcher = QFileSystemWatcher()
watcher.addPath( '/path/to/your/raster' )
watcher.fileChanged.connect( refreshLayer )

Of course this can be combined with an MD5 check as proposed by nickves.

I suppose your question does not include change detection, as your sample only concerns QgsMapCanvas.refresh()

Instead you have to call QgsRasterLayer.triggerRepaint()

If your layer is called myLayer:

myLayer.setCacheImage( None )
myLayer.triggerRepaint()

The same method exists for vector layers as well.

For low overhead file change notification I'd propose looking into Qt's QFileSystemWatcher, which makes use of inotify on linux and similar techniques on other platforms.

from PyQt4.QtCore import QFileSystemWatcher

def refreshLayer():
    myLayer.setCacheImage( None )
    myLayer.triggerRepaint()

watcher = QFileSystemWatcher()
watcher.addPath( '/path/to/your/raster' )
watcher.fileChanged.connect( refreshLayer )

Of course this can be combined with an MD5 check as proposed by nickves.

I suppose your question does not include change detection, as your sample only concerns QgsMapCanvas.refresh()

Instead you have to call QgsRasterLayer.triggerRepaint()

If your layer is called myLayer:

myLayer.setCacheImage( None )
myLayer.triggerRepaint()

The same method exists for vector layers as well.

For low overhead file change notification I'd propose looking into Qt's QFileSystemWatcher, which makes use of inotify on linux and similar techniques on other platforms.

from PyQt4.QtCore import QFileSystemWatcher

def refreshLayer():
    myLayer.setCacheImage( None )
    myLayer.triggerRepaint()

watcher = QFileSystemWatcher()
watcher.addPath( '/path/to/your/raster' )
watcher.fileChanged.connect( refreshLayer )

Of course this can be combined with an MD5 check as proposed by nickves.

exchanged platform specific versions
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130

I suppose your question does not include change detection, as your sample only concerns QgsMapCanvas.refresh()

Instead you have to call QgsRasterLayer.triggerRepaint()

If your layer is called myLayer:

myLayer.setCacheImage( None )
myLayer.triggerRepaint()

The same method exists for vector layers as well.

For low overhead file change detectionnotification I'd propose looking into the followingQt's (unfortunately platform specific) API'sQFileSystemWatcher, which makes use of inotify on linux and similar techniques on other platforms.

from PyQt4.QtCore import QFileSystemWatcher

def refreshLayer():
    myLayer.setCacheImage( None )
    myLayer.triggerRepaint()

watcher = QFileSystemWatcher()
watcher.addPath( '/path/to/your/raster' )
watcher.fileChanged.connect( refreshLayer )

Of course this can be combined with an MD5 check as proposed by nickves.

I suppose your question does not include change detection, as your sample only concerns QgsMapCanvas.refresh()

Instead you have to call QgsRasterLayer.triggerRepaint()

If your layer is called myLayer:

myLayer.setCacheImage( None )
myLayer.triggerRepaint()

The same method exists for vector layers as well.

For low overhead change detection I'd propose looking into the following (unfortunately platform specific) API's

I suppose your question does not include change detection, as your sample only concerns QgsMapCanvas.refresh()

Instead you have to call QgsRasterLayer.triggerRepaint()

If your layer is called myLayer:

myLayer.setCacheImage( None )
myLayer.triggerRepaint()

The same method exists for vector layers as well.

For low overhead file change notification I'd propose looking into Qt's QFileSystemWatcher, which makes use of inotify on linux and similar techniques on other platforms.

from PyQt4.QtCore import QFileSystemWatcher

def refreshLayer():
    myLayer.setCacheImage( None )
    myLayer.triggerRepaint()

watcher = QFileSystemWatcher()
watcher.addPath( '/path/to/your/raster' )
watcher.fileChanged.connect( refreshLayer )

Of course this can be combined with an MD5 check as proposed by nickves.

added 303 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130
Loading
added 35 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130
Loading
added 119 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130
Loading
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130
Loading