I created a python qgis action that open the dialog form so the user can add a new feature.  maintenance_lyr = QgsMapLayerRegistry.instance().mapLayer('od_maintenance_event20180212171049766')  maintenance_lyr.startEditing() qgis.utils.iface.setActiveLayer(maintenance_lyr) qgis.utils.iface.actionAddFeature().trigger()   My question: How can I get the id of the newly created feature?
124261
I'm trying to make an edit form in QGIS (Python code) ,and i want after feature drawing to get the id, and the feature to be selected. Do you have any ideas to do that?  Tried so far:  self.iface.activeLayer().featureAdded.connect(self.myfonction)  def myfonction(self):      for feat in self.iface.activeLayer().getFeatures():         self.iface.activeLayer().setSelectedFeatures([feat.id()])
108478
I got this identifier inputevenmousebutton is not declared in the current scope; should I use another identifier?  func _ready():     position = get_viewport_rect().size / 2     direction.x = rand_range(-1, 1)     direction.y = rand_range(-1, 1)     direction = direction.normalized()     width = get_viewport_rect().size.x     height = get_viewport_rect().size.y  func _process(delta):     position += direction * speed * delta     if position.x &lt; 0 or position.x &gt; width:         direction.x = -direction.x     if position.y &lt; 0 or position.y &gt; height:         direction.y = -direction.y  func _on_UFO_input_event( viewport, event, shape_idx ):     if event is InputEvenMouseButton and event.button_index ==          BUTTON_LEFT and event.pressed:         direction.x = rand_range(-1, 1)         direction.y = rand_range(-1, 1)           direction = direction.normalized()         position.x = rand_range(1, width -1)         position.y = rand_range(1, height -1)         speed += 5
104865
How can I access (read/write) m values of a line Shapefile using pyqgis?   I know how to do it with arcpy cursors ( ) but I don't know how to do it with pyqgis.   Is it possible with the QGIS python library?
23445
I am looking to get a count on the polygonNieghbor and if it has polygons in it then I want to move to the next step MakeFeatureLayer. and If it doesn't have any features I would like it to finish.   Is there any other way to do this?      arcpy.GetCount_management(PolygonNeighbor_TableSelect) arcpy.AddMessage(arcpy.GetMessages())  if arcpy.GetCount_management(PolygonNeighbor_TableSelect) &gt; 0:     arcpy.MakeFeatureLayer_management(MapUnitPolys, inFeatures_lyr)  else      print "done"
38330
I'm developing a LWC Combobox and I want to get the label of the selected value in the handleChange() method, not the id. I filled the combobox with JSON Items in this form :   {value :'Id', label:'Label'}   I used this in JS : event.detail.value but it gives the id not the Label.
24886
I am having some issues. In ArcGIS, I created a custom toolbar (with the python addin wizard) to do the following: 1. Button to connect to feature class, 2-5. A series of comboboxes to view, edit data in a field in the feature class. I want each of the combo box classes to directly connect to the field. And be able to write new data from the boxes into the fields.  Example: Combobox 1 to connect to field 1. So that when I deploy this a user can edit data without doing this the traditional way. Its a way to have inexperienced users edit data. I am new to python and willing to pay for the time required to help me as I am out of ideas. And ESRI doesn't have a solution either.   import arcpy import pythonaddins from arcpy import env   class ButtonClass1(object):     """Implementation for QuickTableEdit_addin.button (Button)"""     def __init__(self):         self.enabled = True         self.checked = False     def onClick(self):         print("Button1 Clicked")         env.workspace = "C:/data"         arcpy.CreateTable_management("C:/data", "test_table.dbf","template.dbf")         mxd = arcpy.mapping.MapDocument("CURRENT")         df = arcpy.mapping.ListDataFrames(mxd)[0]         dbf_Table = arcpy.mapping.TableView(r"C:\data\test_table.dbf")         arcpy.mapping.AddTableView(df, dbf_Table)         arcpy.RefreshTOC()         pass  class ComboBoxClass2(object):     """Implementation for QuickTableEdit_addin.combobox_1 (ComboBox)"""     def __init__(self):         self.items = [1,2]         self.editable = True         self.enabled = True         self.dropdownWidth = 'WWWWWW'         self.width = 'WWWWWW'     def onSelChange(self, selection):         global cb1         cb1 = self.value         pass     def onEditChange(self, text):         pass     def onFocus(self, focused):         pass     def onEnter(self):         pass     def refresh(self):         pass
12452
I am trying to automate various tasks in ArcGIS Desktop (using ArcMap generally) with Python, and I keep needing a way to add a shapefile to the current map. (And then do stuff to it, but that's another story).  The best I can do so far is to add a layer file to the current map, using the following ("addLayer" is a layer file object):  def AddLayerFromLayerFile(addLayer):  import arcpy  mxd = arcpy.mapping.MapDocument("CURRENT")  df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]  arcpy.mapping.AddLayer(df, addLayer, "AUTO_ARRANGE")  arcpy.RefreshActiveView()  arcpy.RefreshTOC()  del mxd, df, addLayer   However, my raw data is always going be shapefiles, so I need to be able to open them. (Equivalently: convert a shapefile to a layer file without opening it, but I'd prefer not to do that).
72632
I am using QGIS. I have two exports of vector data created some 6 months apart. How do I find any new objects added in the 6 months, and any attribute changes in the original objects? An asset_id field exists in both tables as a unique identifier, and will carry through both tables. I can use the &quot;Difference&quot; tool to get geometry changes but can't get the attribute table changes too.
23336
When I change symbology for a given QgsVectorLayer (QGIS 2.14.16 LTR) by  r=iface.activeLayer().rendererV2() r.symbol().symbolLayers()[0].setColor(0,0,255,255)   as shown here:    and refreshing the map content by  iface.mapCanvas().refreshAllLayers()   I get the expected result, but the Layer Tree does not update as shown here:    What am I missing, and how can I update the Layer tree from PyQGIS programmatically?
11649
I've created polygons from a table that has two columns- an OBJECTID and a string of coordinates (Polygon_Coordinates). The resulting polygons (called &quot;testing&quot; in the code below) are in the correct locations, but I can't seem to figure out how to carry over the ID, which I need for a join later in the workflow. Any idea on how to build geometry, but maintain the attributes? fields = ['Polygon_Coordinates', 'OBJECTID']  with arcpy.da.SearchCursor(table, fields) as table_cursor:     for row in table_cursor:         #skip null rows         if row[0] != '-9999':                          #turn string of coordinates into a list but split them at the commas             coords= list(row[0].split(','))                          #break up list into list of pairs             pairs = [coords[i:i + 2] for i in range(0, len(coords), 2)]             coord_ints = [[float(i) for i in p] for p in pairs]              #create insert cursor for geometry creation             geocursor = arcpy.da.InsertCursor(testing, [&quot;SHAPE@&quot;])             array = arcpy.Array()                          #grab pairs from list, put into array             for a in pairs:                 array.add(arcpy.Point(a[1],a[0], ID=row[1]))                          #set crs, build polygon              wgs = arcpy.SpatialReference(4326)             poly = arcpy.Polygon(array, wgs)             geocursor.insertRow([poly])
111414
Using QGIS v2.6.0-Brighton.  This question is not about editing layers geographically in anyway. It is merely trying to find data from two layers as you would in an SQL Query and append an extra ID to the second layer.  I have one polyline layer each identified with two different IDs. There is a point layer also with one of these IDs, I wish to find this corresponding ID and append them as a column to the point layer.  How do I do this without finding each row individually and typing it in manually (i.e. larger scale)? I would prefer to use SQL like syntax but if there is a GUI as well that would be ideal. Happy to install official plugins.
77803
I have a vector layer, populated with points, and I want to programmatically add to this layer.  The part related to the geometry works just out of the box, but I was having trouble with adding attribute values to the new features.  The problem is, when I add a new feature to the layer, I do not manage to specify fields. The feature would complain on exceptions.KeyError.          featureList = []         ## now add the computed points to the layer         for p in [p for p in points.values() if p['computed']]:             x, y = p['coordinates']             feature = QgsFeature()             layerPoint = transf.transform(QgsPoint(x, y))             feature.setGeometry(QgsGeometry.fromPoint(layerPoint))             feature['id'] = p['id']             featureList.append(feature)          layer.dataProvider().addFeatures(featureList)         layer.commitChanges()   And before you ask, obviously I'm sure it's the feature['id'] which is giving trouble, not the p['id'].  So the short version of the question was "how do I specify fields of a feature before it was ever part of a layer?"
87971
I would like to make by programmation (python) the same thing than we can do directly in QGIS when you create a list of values for a field. I would like to create a new field and specify a list of possible values for this field. I didn't find any function for that in the API. Is there anyone who has the solution?
58546
I'm new to pyqgis and I'm tryig to make a combobox with list of fields (from layer also selected in combobox).      layers = self.iface.legendInterface().layers()     layer_list = []     for layer in layers:         layer_list.append(layer.name())     self.dlg.comboBox.addItems(layer_list)       selectedLayerIndex = self.dlg.comboBox.currentIndex()     selectedLayer = layers[selectedLayerIndex]     fields = selectedLayer.pendingFields()     fieldnames = [field.name() for field in fields]     self.dlg.comboBox_2.addItems(fieldnames)   The problem is, that in second combobox there are fields from first on layerlist layer, not the selected one.
106389
How do I create a new layer using a selection from an attribute table in QGIS 2.10.1?  Previous answers on this topic do not help -perhaps because they relate to older versions of QGIS
79177
I am using  to update the roads in OpenStreetMap. I have a copy they published last year and one that was just published, and I would like to find all the LineStrings that have either had their attributes or their geometry changed. This will assist me in making sure all the new and modified streets are updated in OpenStreetMap. The street segments should have a unique identifier, so my only thought is to write a Python script which opens both Shapefiles, finds any segments in the new that aren't present in the old (added segments), and the reverse (removed segments), and then loop over matched pairs comparing their constituent coordinates to see if anything has changed. Is there a way to do this using QGIS?
90280
I am using LWCs to display lightning cards in a list.  The list shows information about Programs.  Each Program card has a button, and this button needs to take the user to the 'new object' screen of the Application object.  Here is my code:   applyToProgram(event) {     // The recordTypeId is coming from the .html     // I have verified that the value is correct.     var rtId = event.target.id;      // How do I use rtId below?     this[NavigationMixin.Navigate]({         type: 'standard__objectPage',         attributes: {             objectApiName: 'Application__c',             actionName: 'new',             nooverride: '1',             recordTypeId: rtId  // This does not work         }     }); }   This is not working.  The user is presented with the 'new object' screen for the object's default record type and NOT the one specified in rtId.  I tried putting 'nooverride' and 'recordTypeId' in the state:{} argument, and I also renamed 'recordTypeId' to just 'recordType'.  None of these worked.  Can anyone help me with the correct syntax?  Is this even possible in LWCs?  Thanks, Jeff