# Creating ellipse with SatScan output using QGIS

I need to use QGIS to create an ellipse employing a SatScan output with information on spatial risk clusters for the occurrence of an.

The output contains the coordinates of the centroid point of the ellipse, as well as E-MINOR, E-MAJOR, E-ANGLE and E-SHAPE.

I've already created a circular buffer using MMQGIS plugin, but I could not do the same for an elliptical shape. Any ideas?

I can't see any option in MMQGIS plugin for creating buffers shaped as ellipses. So, if you are really interested in create this kind of objects, you can learn about how to run following PyGIS code in Python Console of QGIS.

It produces ellipses based in its parametric equations. Parameters that you have to change in this code (at the beginning) are center, semi axis a, semi axis b, angle and EPSG code projection (in meters, not degrees).

``````from math import pi, cos, sin

##################################################
pt = (392127.908689, 4449521.71257) #center

a = 200 #semi axis a
b = 100 #semi axis b

angle = 45

epsg = 32612

###################################################
ctr = QgsPointXY(pt, pt)

x0 = pt
y0 = pt

interv = 2*pi

parts = 60

t = 0

t_values = [ 0 ]

for i in range(parts-1):
t_values.append(t)

points = [ QgsPointXY( x0 + a*cos(t), y0 + b*sin(t)) for t in t_values ]

points.append(points)

uri = "Polygon?crs=epsg:" + str(epsg) + "&field=id:integer""&index=yes"

mem_layer = QgsVectorLayer(uri,
'polygon',
'memory')

prov = mem_layer.dataProvider()

polygon = [ [ points ] ]

feats = [ QgsFeature() for i in range(len(polygon)) ]

for i, feat in enumerate(feats):
feat.setAttributes([i])
geom = QgsGeometry.fromPolygonXY(polygon[i])
geom.rotate(angle, ctr)
feat.setGeometry(geom) 