I am trying to import a geojson file of county in U.S. and editing it. Using the following code, I can get a features of the state (in this case "Missouri").
My question is when I edit the layer, features in the original file ("county.json") are also deleted. To avoid this, how should I do?
QgsProject.instance().clear()
county = QgsVectorLayer('[some path]/county.json',
'county',
'ogr')
QgsProject.instance().addMapLayer(county)
with edit(county):
request = QgsFeatureRequest().setFilterExpression('"STATE"!=\'%s\'' % 29)
request.setSubsetOfAttributes([])
request.setFlags(QgsFeatureRequest.NoGeometry)
for f in county.getFeatures(request):
county.deleteFeature(f.id())
For example, the first algorithm use the intersection between Missouri and rivers and the second algorithm use the intersection between Illinois and rivers.
When we use "pandas" in python, we use a data frame by reading a CSV file and manipulate the data frame, but the CSV file does not change. I would expect to get such a behavior.
– hiroaki Apr 17 '20 at 18:43