Title: Donut shape related to concentric circles in QGIS
Tags: pyqgis
Question: I would like to get an area between 10 miles and 20 miles from the center of counties. To do that, I wrote the code and got the following image. But, as you can see, there are some empty points, as the processing of &quot;difference&quot; clip the original 10 miles areas. I would like to get a donut shape.
Any idea?
```# Get centers of counties related to budgets
result = processing.run(&quot;native:meancoordinates&quot;, {
                        'INPUT': mem_layer,
                        'WEIGHT':None,
                        'UID':'fips_budgets',
                        'OUTPUT':'memory:'})
center = result['OUTPUT']

# Get buffers related to center from 10 miles
result = processing.run(&quot;native:buffer&quot;, {
                        'INPUT': center,
                        'DISTANCE':0.144985991,
                        'SEGMENTS':5,
                        'END_CAP_STYLE':0,
                        'JOIN_STYLE':0,
                        'MITER_LIMIT':2,
                        'DISSOLVE':False,
                        'OUTPUT':'memory:'})
buffer = result['OUTPUT']

# Get buffers related to center from 20 miles
result = processing.run(&quot;native:buffer&quot;, {
                        'INPUT': center,
                        'DISTANCE':0.289971982,
                        'SEGMENTS':5,
                        'END_CAP_STYLE':0,
                        'JOIN_STYLE':0,
                        'MITER_LIMIT':2,
                        'DISSOLVE':False,
                        'OUTPUT':'memory:'})
buffer2 = result['OUTPUT']

# Get 20-10 miles areas
result = processing.run(&quot;native:difference&quot;, {
                        'INPUT': buffer2,
                        'OVERLAY': buffer,
                        'OUTPUT':'memory:'})

buffer3 = result['OUTPUT']

QgsProject.instance().addMapLayer(buffer3)
```


I can get the result.
Actually, each center point has an ID (fips)[picture 2]. I would like to pass this information to the donut layer because I would like to define counties related to the center of the county. To do this, I am planning to use &quot;intersection&quot; such as the following code. Then, I would like to get information &quot;This centered county (A) may affect the following counties (B, C, D) within the donut area&quot;. But, I could not get this information like [picture 3] because of the lack of the information.


```Donuts = vl

# Get intersection of buffer and counties
result = processing.run(&quot;native:intersection&quot;, {
                        'INPUT': Donuts,
                        'OVERLAY': mem_layer,
                        'INPUT_FIELDS':[],
                        'OVERLAY_FIELDS':[],
                        'OVERLAY_FIELDS_PREFIX':'',
                        'OUTPUT':'memory:'})
intersection = result['OUTPUT']


QgsProject.instance().addMapLayer(intersection)
```


Here is the accepted answer: You can access the individual point geometries using getFeatures then use the methods of the geometry to buffer twice and then difference:
```#List the point layer fields
layer = iface.activeLayer()
layerfields = [f for f in layer.fields()]

#Create a memory layer and add the same fields (partly from https://anitagraser.com/pyqgis-101-introduction-to-qgis-python-programming-for-non-programmers/pyqgis101-creating-editing-a-new-vector-layer/)
vl = QgsVectorLayer(&quot;Polygon?crs={}&amp;index=yes&quot;.format(layer.crs().authid()), &quot;Donuts&quot;, &quot;memory&quot;)
pr = vl.dataProvider()
fieldlist = []
for f in layerfields:
    newfield = QgsField(name=f.name(), type=f.type())
    fieldlist.append(newfield)
pr.addAttributes(fieldlist)
vl.updateFields()

#Iterate over each point, buffer*2, difference, add geometry and attributes
for f in layer.getFeatures():
    geom = f.geometry()
    buff1 = geom.buffer(1000,5) #Small buffer 
    buff2 = geom.buffer(1500,5) #Bigger buffer
    donut = buff2.difference(buff1) #Difference between them
    #Add the new donut polygon feature
    newfeature = QgsFeature()
    newfeature.setGeometry(donut)
    newfeature.setAttributes(f.attributes())
    pr.addFeature(newfeature)

QgsProject.instance().addMapLayer(vl)
```




{'source': 'StackExchangeDataset', 'subset': 'gis.stackexchange.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:07/04/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<pyqgis>', 'Title': 'Donut shape related to concentric circles in QGIS', 'ViewCount': 156, 'id': 366797, 'user_AboutMe': '', 'user_AccountId': 16669280.0, 'user_DisplayName': 'hiroaki', 'user_Reputation': 187.0, 'user_Views': 15.0, 'user_id': 159775.0}}