I am trying to create an ellipse to be stored in my django project. I'm provided a lat, lon, major/minor in Nautical Miles, and an orientation in degrees. Between this post and the docs I've been able to piece together the below code, however, when I compare the final outputs from an export of my django to what I have generated from the arcgis "Table to Ellipse tool" they don't match. I've tried to account for Arc's different methodology of using azimuth and clockwise rotation in my code but the orientation and scale don't match. I think the issue stems from starting in cartesian space as meters, converting to WGS-84, and then translating origin position. Here is my code with random test data.
from functools import partial
from shapely.ops import transform
from shapely.affinity import translate
from django.contrib.gis.geos import GEOSGeometry
from django.contrib.gis.geos import MultiPolygon
import pyproj
lat = -78.150511
lon = 39.190978
major = 13.114 #Nmi
minor = 8.58 #Nmi
metersconversion = 1852
smajormeters = (major * metersconversion) / 2
sminormeters = (minor * metersconversion) / 2
orient = 61.9 #Degrees Rotation
#Ellipse parameters
ellipse = ((0, 0), (smajormeters, sminormeters), orient)
#create circle with radius of 1
circ = shapely.geometry.Point(ellipse[0]).buffer(1)
#create ellipse along x and y
ell = shapely.affinity.scale(circ, int(ellipse[1][0]), int(ellipse[1][1]))
#Rotate ellipse
elrv = shapely.affinity.rotate(ell, 90 + (ellipse[2] * -1))
project = partial(pyproj.transform, pyproj.Proj(init='epsg:3857'),
pyproj.Proj(init='epsg:4326'))
geom4326 = transform(project, elrv)
transgeom = shapely.affinity.translate(geom4326, lon, lat)
ellpoly = GEOSGeometry(transgeom.wkt)
#Define the srid/epsg as 4326 for ingest into django postgresql
ellpoly.srid = 4326
What has gone wrong?