What are QGIS Arcpy Equivalent Functions for Update/Delete Row/Field?

المشرف العام

Administrator
طاقم الإدارة
I am trying to reprogram some scripts from arcpy to qgis (1.8 or 2.0) and there are some simple functions that I want to be able to redo but unfortunately documentation in qgis is lacking in certain areas.

Namely the three most important for me are

Add Field - Add field

arcpy.AddField_management(Feature, "ID", "SHORT")Calculate Field Management - Update that field

arcpy.CalculateField_management(Feature,"ID","!FID!")Update/Delete Rows - Update/Delete rows based on condition (without copying the shapefile)

keep = ["Bob","Janet","John","Mike"]Counter = 0rows = arcpy.UpdateCursor(Feature)for row in rows: if row.Name in keep: row.ID = Counter rows.updateRow(row) else: rows.deleteRow(row) Counter += 1Now I can iterate through each feature in QGIS using SEXTANTE and obtain its geometry which I should be able to rewrite into a new shapefile and thereby update/delete a row or field. Starting with something along the lines of...

layer = st.getobject(Polygon)features = st.getfeatures(layer)for f in features: f.geometry().asPolygon()but I cant find a simple solution for those functions mentioned above?



أكثر...
 
أعلى