Add an ellipse on raster plot in R
<p>I need to plot an ellipse on a raster plot. I tried plotting raster with simple <code>plot(r1)</code> (r1 is the raster layer) and then <code>add=T</code> for ellipse plotting but it doesn't work. Then I tried <code>axes=F</code> for plotting raster and again tried <code>add=T</code> for ellipse. It still doesn't work.</p>

<p>So I tried converting the ellipse data to dataframe and try adding to raster plot. </p>

<pre><code>#Creating a raster
r &lt;- matrix(sample(1:400),20,20)
r1&lt;-raster(r)

#Creating ellipse with given mean and standard deviation values
theta &lt;- seq(0, 2 * pi, length=(2000))
x &lt;- 0.2 - 0.15 * cos(theta)
y &lt;- 0.5 - 0.15 * sin(theta)
elp&lt;- cbind(na.omit(x),na.omit(y))

#Converting ellipse data frame (elp) to SpatialDataFrame (ps)
ps &lt;- SpatialPolygons(list(Polygons(list(Polygon(elp)),2)))

#Plotting raster with ellipse
plot(r1)
plot(ps, add=T)
</code></pre>

<p>What I get is;
<a href="https://i.stack.imgur.com/mZOEe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mZOEe.png" alt="enter image description here"></a> </p>

<p>Ideally <code>ps</code> should appear as ellipse but it is a circle. On the other hand if I plot <code>elp</code> (data frame from which ps is created), I get an ellipse.</p>

<pre><code>plot(elp)
</code></pre>

<p><a href="https://i.stack.imgur.com/F67lb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F67lb.png" alt="enter image description here"></a></p>

<p>Can someone please help with this?</p>