[Qgis-developer] 'reload' a layer

Germán Carrillo carrillo.german at gmail.com
Tue Jun 26 07:20:25 PDT 2012


Hi QGIS devs,


same question here but regarding rasters. I load a GDAL virtual raster that
is being overwritten every time a new raster is available in a raster
repository. Is there any way of reflecting the layer source updates
(changes in the vrt file) in the map?

In a more generic way, I'm attempting to visualize a tile-based raster,
from which I cannot get all tiles at once. Do you think it could be
possible in QGIS?

P.S. Loading each tile as a separate layer wouldn't be possible because of
performance.


Thanks in advance,

Germán Carrillo


2012/5/21 Germán Carrillo <carrillo.german at gmail.com>

> Hi Carson,
>
> have you tried updateFieldMap() from QgsVectorLayer? I've just had a
> similar problem with memory layers and it turned out to do the trick.
>
> Regards,
>
> Germán
> -----------------------------
> [1]
> http://qgis.org/api/classQgsVectorLayer.html#ae7777703a20367b66ef0200e972f83d1
>
> 2012/5/17 G. Allegri <giohappy at gmail.com>
>
> You're right Carson. I used it only with a WFS layer, and in fact I see
>> that WFS is the only providers that implements it.
>> There would be the setDataProvider method on the vector layer but it's
>> private...
>>
>> You've raised an important point, that I took for granted :(
>> I fear that in this moment the only solution is remove it and reload it.
>> giovanni
>>
>>
>>
>> 2012/5/17 Carson Farmer <carson.farmer at gmail.com>
>>
>>> Hi Giovanni,
>>>
>>> Thanks for the tip. To answer your question: I am trying to
>>> synchronise the layer with the datasource. Having said that, I don't
>>> seem to be able to get 'reload' to work. It looks like reload is
>>> reimplemented in QgsVectorLayer, which in turns calls the
>>> dataProvider's reloadData method, so this may vary by provider type? I
>>> tried it with a shapefile and a spatialite layer, and it did not seem
>>> to do anything: I deleted several fields from the shapefile and added
>>> a field to the spatialite layer in an external program, and these
>>> changes were not reflected when I 'reloaded' the layers. Am I missing
>>> something here? Perhaps there is something else needed to get the
>>> changes to 'show up'?
>>>
>>> Cheers,
>>>
>>> Carson
>>>
>>> On Wed, May 16, 2012 at 4:36 PM, G. Allegri <giohappy at gmail.com> wrote:
>>> > Do you mean refresh the rendering or synchronizing the layer with the
>>> data
>>> > source?
>>> > I usually use QgsMapLayer::reload() for the latter, and
>>> > QgsMapCanvas::refresh() for the first.
>>> >
>>> > giovanni
>>> >
>>> > 2012/5/16 Carson Farmer <carson.farmer at gmail.com>
>>> >>
>>> >> Hi list, does anyone know of a clever way to (programmatically) reload
>>> >> a layer without actually removing it and re-adding it to the layer
>>> >> list. Some context: I have a layer that sometimes gets updated by an
>>> >> external application, and I want to be able to 'refresh' the layer
>>> >> from the Python console to reflect these changes (new features,
>>> >> deleted features, new attributes, etc.). I *could* simply load the
>>> >> layer again, but I'm hoping there is a more efficient way to do this
>>> >> (also I want to keep the current styling, layer order, unique layer
>>> >> id, etc).
>>> >>
>>> >> Any thoughts/ideas? Note: assume we are working with a spatialite
>>> layer
>>> >> for now.
>>> >>
>>> >> Carson
>>> >>
>>> >> --
>>> >> Dr. Carson J. Q. Farmer
>>> >> Centre for GeoInformatics (CGI)
>>> >> School of Geography and Geosciences
>>> >> Irvine Building, University of St Andrews
>>> >> St Andrews, Fife, KY16 9AL
>>> >> Scotland, UK
>>> >> _______________________________________________
>>> >> Qgis-developer mailing list
>>> >> Qgis-developer at lists.osgeo.org
>>> >> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> Dr. Carson J. Q. Farmer
>>> Centre for GeoInformatics (CGI)
>>> School of Geography and Geosciences
>>> Irvine Building, University of St Andrews
>>> St Andrews, Fife, KY16 9AL
>>> Scotland, UK
>>>
>>
>>
>> _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>>
>
>
> --
> -----------
>    |\__
> (:>__)(
>    |/
>
> Soluciones Geoinformáticas Libres
> http://geotux.tuxfamily.org/
> http://twitter.com/GeoTux2
>
>
-- 
-----------
   |\__
(:>__)(
   |/

Soluciones Geoinformáticas Libres
http://geotux.tuxfamily.org/
http://twitter.com/GeoTux2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20120626/fe5f3cc1/attachment-0001.html>


More information about the Qgis-developer mailing list