Create unique buffers in Notebook

414
1
Jump to solution
11-03-2022 01:55 PM
DominicRoberge2
Occasional Contributor III

Hello

I have an AGOL item with 3 layers: Site Location (pts), Site Buffer (poly) and Site Area (poly). The Site Area has a field with a Distance value that I would like to use to create my buffers (different value for each area).

So in my Notebook, I have a piece of code that select all the Site Location where the BufferFlag='N' then I intersect each of the records with my Site Area to get the proper value of the Distance to create the buffer…. AND THEN I AM STUCK! below is the section of code that I can't figure it out.(line 15 to 20)

 

i=0
###for each Site Location WORKING
for f in SLHFLcount:
    print(f.attributes['FUID'] + ' -- '+ f.attributes['BufFlag2'])
    ptFeat = SLHFLcount.features[i].geometry
    print(ptFeat)
    print("~~~~~~~~~")
    ###Intersect with my Site Location WORKING
    AreaHFLqry = AreaHFL.query(where='1=1', geometry_filter=filters.intersects(ptFeat))
    print(len(AreaHFLqry))
    if len(AreaHFLqry) >=1:
        AreaHFLqryFeatures = AreaHFLqry.features
        print(AreaHFLqryFeatures[0].attributes['Area1']+ ' -- '+ AreaHFLqryFeatures[0].attributes['Area2']  + ' -- '+ str(AreaHFLqryFeatures[0].attributes['Dist']))
        
        ###Create individual buffers NOT WORKING
        dDist = AreaHFLqryFeatures[0].attributes['Dist']
        buffLyr = use_proximity.create_buffers(SLHFL, distances=[dDist], units = 'Feet',output_name=BufferHFL)
        #buffLyr_fc = buffLyr.layer
        #print(buffLyr_fc)
        map1.add_layer(BufferHFL)
        
        ###update BufFlag to Y
        #strExpression = "FUID='"+str(f.attributes['FUID']+"'")
        #SLHFL.calculate(where=strExpression,calc_expression={"field":"BufFlag2", "value": "Y"})
    else:
        print("we don't have a polygon yet")
    i +=1
    print("----------------")

print("Process completed")

 

 

How can I create the buffer JUST for that selected Site Location and append the buffer to my Site Buffer layer?

Any help would be much appreciated.

 

Thanks!

0 Kudos
1 Solution

Accepted Solutions
DominicRoberge2
Occasional Contributor III

Ok I solved my own problem:

1) I added a Filter on my Feature layer to get one Site Location the time

fExpression = "FUID='" + f.attributes['FUID'] +"'"
SLHFL.filter = fExpression

 

and then , after I ran the buffer I am adding the new feature to my Buffer Layer using the following code

buffLyr = use_proximity.create_buffers(SLHFL, distances=[dDist], units = 'Feet')

#Append to Buffer HFL
BufferHFL.edit_features(adds=buffLyr.layer.featureSet.features)

 

working great!

 

 

View solution in original post

0 Kudos
1 Reply
DominicRoberge2
Occasional Contributor III

Ok I solved my own problem:

1) I added a Filter on my Feature layer to get one Site Location the time

fExpression = "FUID='" + f.attributes['FUID'] +"'"
SLHFL.filter = fExpression

 

and then , after I ran the buffer I am adding the new feature to my Buffer Layer using the following code

buffLyr = use_proximity.create_buffers(SLHFL, distances=[dDist], units = 'Feet')

#Append to Buffer HFL
BufferHFL.edit_features(adds=buffLyr.layer.featureSet.features)

 

working great!

 

 

0 Kudos