Skip to content

Instantly share code, notes, and snippets.

@luisalucchese
Created January 21, 2022 12:57
generates numsectors circular sectors with the same width and varying radius
# generates "numsectors" circular sectors with the same
# width and varying radius
#
# by Luisa V. Lucchese
# January 2022
#
# MIT License
# Copyright (c) 2022 Luisa V. Lucchese
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
numsectors=20
width=360.0/numsectors
azim_init=90
radius_cresc=0.2
loop1=int(numsectors/2.0)
for k in range(0,loop1):
azim=width/2+k*width+azim_init
radius_cresc=radius_cresc+0.1
paramwedge={ 'AZIMUTH' : azim, 'INNER_RADIUS' : 0.0, 'INPUT' : 'point.shp', 'OUTER_RADIUS' : radius_cresc, 'OUTPUT' : 'memory:' , 'WIDTH' : width} #
layer_wedge=processing.run("native:wedgebuffers", paramwedge)
QgsProject.instance().addMapLayer(layer_wedge['OUTPUT'])
for k in range(loop1,numsectors):
azim=width/2+k*width+azim_init
radius_cresc=radius_cresc-0.1
paramwedge={ 'AZIMUTH' : azim, 'INNER_RADIUS' : 0.0, 'INPUT' : 'point.shp', 'OUTER_RADIUS' : radius_cresc, 'OUTPUT' : 'memory:' , 'WIDTH' : width} #
layer_wedge=processing.run("native:wedgebuffers", paramwedge)
QgsProject.instance().addMapLayer(layer_wedge['OUTPUT'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment