I have a plugin that works with QGIS 2.2 but does not work with 2.8. Only deleteFeatures() works fine, but changeAttributeValues(), changeGeometryValues() and addFeatures() not.  I receive r == False on the code below. The layer is an SpatiaLite table.  for feat_vias in lay_vias.getFeatures(req):      if  feat_vias.attributes()[idx_pkvia] == div_rowid:         fid = feat_vias.id()         attrs = { idx_setvia : s_geocodi }         r = lay_vias.dataProvider().changeAttributeValues({ fid : attrs })   I'm using QGIS 2.8.1 - Windows  In another question () I found an Matthias Kuhn's answer that solve this question too.  I put the commit sentence outside the loop as below. Work fine!  for feat_vias in lay_vias.getFeatures(req):      if  feat_vias.attributes()[idx_pkvia] == div_rowid:         fid = feat_vias.id()         attrs[fid] = { idx_setvia : s_geocodi }  r = lay_vias.dataProvider().changeAttributeValues(attrs)
122164
I'm trying to edit the value of an attribute for each feature in a layer using a QGIS Python plugin. I've found that doing this outside of editing mode is much slower than while editing (even including committing the edits). See code below (lines interchangeable at the same point in a loop). The difference in speed for my sample dataset is 2 seconds (edit mode) vs 72 seconds (not edit mode).  Modifying an attribute in edit mode:  layer.changeAttributeValue(feature.id(), 17, QtCore.QVariant(value))   Modifying an attribute outside of edit mode:  layer.dataProvider().changeAttributeValues({ feature.id() : { 17 : QtCore.QVariant(value) } })   Is this an expected behavior? I don't need the user to be able to undo the changes, so I don't think I need to use edit mode.  Edit 1: See full code below with both versions included (but commented out):  def run(self):     try:         # create spatial index of buffered layer         index = QgsSpatialIndex()         self.layer_buffered.select()         for feature in self.layer_buffered:             index.insertFeature(feature)          # enable editing         #was_editing = self.layer_target.isEditable()         #if was_editing is False:         #    self.layer_target.startEditing()          # check intersections         self.layer_target.select()         self.feature_count = self.layer_target.featureCount()         for feature in self.layer_target:             distance_min = None             fids = index.intersects(feature.geometry().boundingBox())             for fid in fids:                 # feature's bounding box and buffer bounding box intersect                 feature_buffered = QgsFeature()                 self.layer_buffered.featureAtId(fid, feature_buffered)                 if feature.geometry().intersects(feature_buffered.geometry()):                     # feature intersects buffer                     attrs = feature_buffered.attributeMap()                     distance = attrs[0].toPyObject()                     if distance_min is None or distance &lt; distance_min:                         distance_min = distance                 if self.abort is True: break             if self.abort is True: break              # update feature's distance attribute             self.layer_target.dataProvider().changeAttributeValues({feature.id(): {self.field_index: QtCore.QVariant(distance_min)}})             #self.layer_target.changeAttributeValue(feature.id(), self.field_index, QtCore.QVariant(distance_min))              self.calculate_progress()          # disable editing         #if was_editing is False:         #    self.layer_target.commitChanges()      except:         import traceback         self.error.emit(traceback.format_exc())     self.progress.emit(100)     self.finished.emit(self.abort)   Both methods produce the same result, but writing via the data provider takes much longer. The function classifies proximity of building features to nearby fields (purple) using pre-created buffers (brown-ish).
43918
I have been trying for a long time to connect a external table data[csv] through Excel (for exmaple) with QGis with the objective to each time i change any data in table(for example data location - coordinates [X ; Y]),this changes occur in QGis real time.  Is there any procedure to get it?.
66114
I haven't found a similar question that already has an answer so I hope I can get one... Please forgive me if the answer is obvious. I'm using QGIS version 2.14.0-Essen on my macbook pro with OSX Yosemite 10.10.5. I am trying the simplest select features using an expression  Here is the window I get:  I right-click the field (e.g. here "DIVISION") and select say Load all unique values but nothing happens. I can check layer values beforehand and enter the correct value and it works (e.g. "DIVISION"='CENTRAL') but it's cumbersome.  So my question is: How can I get this unique values window to show?
19295
I'm having trouble adding a field to a PostGIS table using PyQGIS. Here's my code:  from PyQt4.QtCore import QVariant from qgis.core import *  inLayer = iface.activeLayer() provider = inLayer.dataProvider()  # add field field = QgsField('test_field', QVariant.String) inLayer.startEditing() provider.addAttributes([field]) inLayer.updateFields()  # commit inLayer.commitChanges()   The commit fails and the PostGIS log shows an error:     2015-10-27T08:13:28    1   Erroneous query: ALTER TABLE "received"."env" ADD COLUMN "test_field"  returned 7 [ERROR:  syntax error at end of input      LINE 1: ALTER TABLE "received"."env" ADD COLUMN "test_field"    Seems the call to PostGIS fails to include the column type. Is this a bug, or am I going about this the wrong way?
120772
I am trying to build a pc in blender and I just updated my blender to 2.91 but the boolean modifier doesn't seem to work as expected on a specific area.I am attaching a video below
12308
I'm trying to record some changes using the changes package - I've already done a lot of the text, and had to work around display maths but I've got a simple value typeset using siunitx, and changing that value doesn't appear to work:  \documentclass{article} \usepackage{siunitx} \usepackage{changes} \begin{document}     \replaced{\SI{1}{\volt}}{\SI{2}{\volt}} \end{document}   gives:  ! Extra }, or forgotten \endgroup. \UL@stop ...z@ \else \UL@putbox \fi \else \egroup                                                    \egroup \UL@putbox \fi \if... l.5 ...\SI{1}{\volt}}{\SI{2}{\volt}}   If I continue to compile (getting the same error again and 2 missing } inserteds, the output is actually exactly as expected:    adding \protect before the \SI gives exactly the same error, and of course trying \SI{\replaced{1}{2}}{\volt} was never going to work:  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! siunitx error: "invalid-token-in-number" !  ! Invalid token '\let ' in numerical input. !  ! See the siunitx documentation for further information. !  ! For immediate help type H &lt;return&gt;. !...............................................     Is there some workaround that will get this to run without errors?  I don't really want to run in nonstopmode in case of "real" errors, and besides, I used a build script that's designed to stop on errors.
24575
Using QGIS 2.16.2, I can successfully select records from a shapefile attribute table using the following expression:  left("start_time", 10) = '2015-08-01'   Please note that start_time is a string field.  However, when I copy and paste the same expression into the shapefile's Layer Properties>General>feature filter>Query Builder I get the following error:    I would expect that the same expression would work everywhere in QGIS.  What am I doing wrong?
108491
I'm facing troubles to import a layer into a PostGIS database with pyqgis in a script. Here is my code:  Nombre_BBDD='test' host='localhost'  puerto='5432' usuario='postgres' password='xxxxxxx' Nombre_Tabla='table' Llave_primaria='id' Capa_a_procesar='/xxxxxxx/shapefile.SHP' Tipo_geometria='POLYGON'  capaImportar = QgsVectorLayer(Capa_a_procesar, 'capaImportar', 'ogr') uri = """dbname='"""+Nombre_BBDD+"""' host='"""+host+"""'    port="""+puerto+""" user='"""+usuario+"""' password='"""+password+"""' key="""+Llave_primaria+""" type="""+Tipo_geometria+""" table=\"public\".\""""+Nombre_Tabla+"""\" (geom) sql=""" crs = QgsCoordinateReferenceSystem(25830) error = QgsVectorLayerImport.importLayer(capaImportar, uri, "postgres", crs, False, True)   I was trying to do it how is recommended in this .  It seems everything is right, but when I try to load the layer this is empty and the python console throws this error:     Exception RuntimeError: 'wrapped C/C++ object of type PGVectorTable has been deleted' in bound method PGTableDataModel.del of db_manager.db_plugins.postgis.data_model.PGTableDataModel object at 0x7f3f24190d60 ignored   I'm working with qgis 2.18.10 in a Kubuntu 16.04
6083
This problem appears only on one particular Document Library. I use   TaxonomyField.SetFieldValue(myItem, myTaxonomyFieldValue);   and it works fine everywhere except this lib. Can anyone suggest a workaround?
103677
I have a polygon layer loaded from POSTGIS database. This layer has a default value for the first column. I can create a new feature set that attribute to some predefined value with      newFeature = QgsFeature()     newFeature.setFields(activeLayer.pendingFields())     newFeature.setAttribute(0, "someValue")   But I want to set it to the default value that comes from the layer. When I try to add a feature with QGIS 2.10 it automatically sets the default value for that column. How can I achieve that with PyQGIS?
5172
I'm hoping someone out there might be able to help or suggest some tests to try and resolve some very odd QGIS behaviour of late...  Our core GIS team of 4 users has been testing v2.10 prior to roll-out for the remainder of the organization.  In the past couple of weeks we have had some very odd shapefile corruption things happening and are yet to isolate or identify a potential cause...  These have included:   Editing one line (using the scissor tool to split into two records) and having the resulting records attributes completely replaced by attributes from another geometry no-where near the edited row (spatially or in the attribute dbf) Line geometries completely disappear while their attributes get associated with an unrelated geometry  Line geometry get partially deleted and replaced with a vertice in infinity (line visually extends beyond the dataset and no matter how far zoomed out you never see the end)   The above is happening in a polyline layer, that we did discover has some multi-line geometries..? Perhaps this is impacting... but never saw this issue with v2.8 and the same layer. The layer has undergone MANY save-as's in the past week and many verify geometry checks as we thought invalid geometry may have been the cause...  In another separate layer yesterday, to a separate user (me) i created a layer with approx 30 polygons... adding, deleting some and doing some 'avoid intersection' to remove overlaps. Layer looks fine in qgis, saved and also a save-as to a completely new file but when i load into ArcGIS online (and later is ArcMap as a test) some of the overlaps and deleted objects are still there. Close and reopen qgis,  reopen the file and they are definitely not.  The project was created in v2.8 that i was editing in (but had been saved in 2.10).  Does anyone have any ideas/suggestions.  We do still have 2.8 installed as well as 2.10? We have never encountered issues like this when testing other new qgis versions while still running old ones?
69237
I am trying to do field data collection using QGIS.  One of the features that I regard as necessary for data management is timestamps.  For example, a timestamp can indicate that an inspection record has been updated.    I have figured out how to add triggers using Spatialite to add a timestamp on update, however the timestamp is added when the edited records are saved and not when the identify dialog box is closed.  This means that timestamps can be out by many minutes.  One solution would be to force the updated record to be saved by using a custom form with an OK button (Can do the form with Qt-Designer but don't know how to add the save command to the button yet.)  However my preferred solution would be to take a timestamp for new records, when the point or line is created.  The reason for this is if I am surveying a road, I can stand on the road, collect the point and them move to the side to complete data collection.    I have been unable to work out how to get Spatialite to run a trigger that puts in the start of feature editing.  Perhaps this is also something that needs to be done by code in a custom form.  Is there an On-dirty event or signal in QGIS that indicates when someone starts editing a record and that can be used to capture the time?  Could I also ask what the Python code (and what to hook it to) that would put such a timestamp in the timestamp field.  AndrewM
56805
I work on QGIS 2.2, and I am unable to edit my attribute table to change the field type from string to double.  I have gone through several tutorials. - I can not run the table manager plugin, probably because its latest version is for qgis 2.0, (well it appears broken on my plugin manager UI).   I am unable to edit my layer so that I can use the field calculator (as several tutorials stipulated). I am not versed with python to use the python console
91340
I need to obtain, for each feature of a layer, a dictionary with the attribute names and their values using PyQGIS. I can get all the attributes of the layer using indiv = QgsProject.instance().mapLayersByName('Individuos')[0]  for feature in features:     value = feature[field.name()]     attrs = feature.attributes()     print(attrs)  But what I need is to create a dictionary with field names as key and their value for each feature.
105083
I have a points shapefile that originally came from a GPX file (imported using QGIS). The original GPX file contained waypoints only and has disappeared.  The shapefile has many attributes, but only some have data. Below are these attributes with two example data records (some decimal values discarded  to fit onto one row).    TYPE    IDENT    LAT     LONG      Y_PROJ        X_PROJ          COMMENT WAYPOINT    JS    -31.6    22.6    -23610488.1    8084542.7    29-AUG-09 13:56 WAYPOINT    PS    -31.6    22.7    -23610333.7    8084487.4    29-AUG-09 14:01   A client of mine would like to convert the shapefile back into GPX, retaining the IDENT attribute as the label for each waypoint; he wants to use the GPX file in Garmin's Basecamp software. I have exported the shapefile sucessfully from both QGIS and ExpertGPS, but when I open the files in Garmin's Basecamp softare, each waypoint has only a sequential number as label.   When I look at the GPX files in a text editor, all the atrribute information is there. For example:  &lt;wpt lat="-31.695305019999999" lon="22.647454610000000"&gt;   &lt;type&gt;WAYPOINT&lt;/type&gt;   &lt;extensions&gt;     &lt;ogr:IDENT&gt;JS&lt;/ogr:IDENT&gt;     &lt;ogr:LAT&gt;-31.69530502&lt;/ogr:LAT&gt;     &lt;ogr:LONG&gt;22.64745461&lt;/ogr:LONG&gt;     &lt;ogr:Y_PROJ&gt;-23610488.11619880&lt;/ogr:Y_PROJ&gt;     &lt;ogr:X_PROJ&gt;8084542.75904646&lt;/ogr:X_PROJ&gt;     &lt;ogr:COMMENT&gt;29-AUG-09 13:56&lt;/ogr:COMMENT&gt;     &lt;ogr:DISPLAY&gt;&lt;/ogr:DISPLAY&gt;     &lt;ogr:SYMBOL&gt;&lt;/ogr:SYMBOL&gt;     &lt;ogr:UNUSED1&gt;&lt;/ogr:UNUSED1&gt;     &lt;ogr:DIST&gt;0.00&lt;/ogr:DIST&gt;     &lt;ogr:PROX_INDEX&gt;&lt;/ogr:PROX_INDEX&gt;     &lt;ogr:COLOR&gt;&lt;/ogr:COLOR&gt;     &lt;ogr:ALTITUDE&gt;1382.49&lt;/ogr:ALTITUDE&gt;     &lt;ogr:DEPTH&gt;0.00&lt;/ogr:DEPTH&gt;     &lt;ogr:TEMP&gt;0.00&lt;/ogr:TEMP&gt;     &lt;ogr:WPT_CLASS&gt;&lt;/ogr:WPT_CLASS&gt;     &lt;ogr:SUB_CLASS&gt;&lt;/ogr:SUB_CLASS&gt;     &lt;ogr:ATTRIB&gt;&lt;/ogr:ATTRIB&gt;     &lt;ogr:LINK&gt;&lt;/ogr:LINK&gt;     &lt;ogr:STATE&gt;&lt;/ogr:STATE&gt;     &lt;ogr:COUNTRY&gt;&lt;/ogr:COUNTRY&gt;     &lt;ogr:CITY&gt;&lt;/ogr:CITY&gt;     &lt;ogr:ADDRESS&gt;&lt;/ogr:ADDRESS&gt;     &lt;ogr:FACILITY&gt;&lt;/ogr:FACILITY&gt;     &lt;ogr:CROSSROAD&gt;&lt;/ogr:CROSSROAD&gt;     &lt;ogr:UNUSED2&gt;&lt;/ogr:UNUSED2&gt;     &lt;ogr:ETE&gt;&lt;/ogr:ETE&gt;     &lt;ogr:DTYPE&gt;&lt;/ogr:DTYPE&gt;     &lt;ogr:MODEL&gt;&lt;/ogr:MODEL&gt;     &lt;ogr:FILENAME&gt;&lt;/ogr:FILENAME&gt;     &lt;ogr:LTIME&gt;&lt;/ogr:LTIME&gt;   &lt;/extensions&gt;     Does anyone know how I could achieve this?  Thanks Hanlie
90721
Does anyone of you know a QGIS-Plugin for Versioning PostGIS-Data? I know there was pgVersion of Horst Düster but as far as I know this was not updated for QGIS 2.x (at least not for the "normal" QGIS aside from QGIS Enterprise. The searched functionality is: Setting up versioning for a Layer Managing conflicts that were detected (resulting from concurrent editing)  old Plugin pgVersion:
84801
I want to add the ADMIN2_CODE from the dataset FAO/GAUL/2015/level2 to a featurecollection I have created to get information on some forests in Wales. I have added the elevation to the polygons but I can't work out how to add the (first) ADMIN2_CODE. My code doesn't work - can someone help please - I know I am doing something blatantly wrong!  var fromList = ee.FeatureCollection("FAO/GAUL/2015/level2");  var filter = ee.Filter.inList('ADM2_NAME', ['Gwent']); var filteredArea = fromList.filter(filter);  Map.setCenter(1.1, 51.5, 8); Map.addLayer(filteredArea, {}, 'Regions');  var gfc2018= ee.Image('UMD/hansen/global_forest_change_2018_v1_6').clip(filteredArea);  var lossImage = gfc2018.select(['lossyear']).gte(7); var lossBand = lossImage.and(gfc2018.select(['lossyear']).lte(20)); var zones = lossBand.updateMask(lossBand.neq(0));  // Add the loss layer in red. Map.addLayer(lossImage.updateMask(lossBand),             {palette: ['FF0000']}, 'Loss 2007 onwards');  var area_threshold = 300; // about 30 hectares?  // Define whole county as a region var geom = filteredArea.geometry();  // Convert the zones of the forest loss areas to vectors. var vectors = zones.addBands(zones).reduceToVectors({   geometry: geom,   crs: lossBand.projection(),   scale: 30,   geometryType: 'polygon',   eightConnected: true,   labelProperty: 'zone',   reducer: ee.Reducer.count() }).filterMetadata("count","greater_than", area_threshold);  // Make a display image for the vectors, add it to the map. var display = ee.Image(0).updateMask(0).paint(vectors, '000000', 1); Map.addLayer(display, {palette: '000000'}, 'vectors');  var SRTM = ee.Image("USGS/SRTMGL1_003"); // exampleelevation image  var slope = ee.Terrain.slope(SRTM);  // add min, max and mean elevation of each geometry var reducers = ee.Reducer.median()                 .combine(ee.Reducer.min(), 'Elevation', true)                 .combine(ee.Reducer.max(), 'Elevation', true)                 .combine(ee.Reducer.mean(), 'Elevation', true);  vectors = SRTM.reduceRegions(vectors, reducers, 30);  // Get Admin Districts var fromList = ee.FeatureCollection("FAO/GAUL/2015/level2"); var filter = ee.Filter.inList('ADM0_NAME', ['Romania']); var filteredArea = fromList.filter(filter);  var AreaName = filteredArea.aggregate_first("ADM2_CODE")  reducers = ee.Reducer.first();  // This next line is wrong! vectors = AreaName.reduceRegions(vectors, reducers, 10);  // Export the FeatureCollection to a CSV file. Export.table.toDrive({   collection: vectors,   description: 'Forest',   fileFormat: 'CSV' });