Covering a nonrectangle shape with s2sphere/Python
I am having a hard time figuring out how to create a region that would be defined by a set of geographical coordinates (more than 4) using s2sphere for Python 2.7. Does anyone have an idea how i could do this?
See also questions close to this topic

mimic JS decodeURIComponent and unescape in python
I want to mimic the decodeURIComponent and unescape that we have in JS in Python.
For example I get this string:
%25D7%2590%25D7%2591%25D7%2592
in JS I can do this:
decodeURIComponent(unescape('%25D7%2590%25D7%2591%25D7%2592'))
and get: אבג
I couldn't find any way to do it in Python, I'm using Tornado Web if it's relevant...

List keep on printing even when 0 was entered by the user
end = False numbers = [] while not end: i =(raw_input(" Enter the number(0 to end the input)")) if i ==0: end = True else: numbers.append(i) print numbers
List does not exit even when the input by the user entered is 0

how to fix TypeError: list indices must be integers, not list
I have this list, ı want use it in below code block, but it isnt run, it give error. how to handle this problem. I need new solving iteration.
features_DecisionTree_8 = ['fraction_to_poi_email', 'exercised_stock_options', 'expenses', 'bonus', 'other', 'shared_receipt_with_poi', 'total_stock_value', 'deferred_income' ] param_grid = dict(base_estimator__max_depth = [None, 1, 3, 5], base_estimator__class_weight = [None, 'balanced'], n_estimators = [25, 50, 100]) gs = GridSearchCV(estimator=AdaBoostClassifier(base_estimator=DecisionTreeClassifier(random_state=42), random_state=42), param_grid=param_grid, scoring='f1', cv=sss_100) gs.fit(features[features_DecisionTree_8], labels) clf = gs.best_estimator_ error: TypeError Traceback (most recent call last) <ipythoninput34004d3e5c3da95> in <module>() 7 scoring='f1', 8 cv=sss_100) > 9 gs.fit(features[features_DecisionTree_8], labels) 10 clf = gs.best_estimator_ TypeError: list indices must be integers, not list>

Fitting an ellipse to points in python
There is actually a post very similar to this but asking a different question from about 5 years ago.
I have a set of points which are not elliptical, and I would like to fit an ellipse to them in the least squares sense. These are the functions I found to do the computation. I checked them over briefly but couldn't find any errors.
http://nicky.vanforeest.com/misc/fitEllipse/fitEllipse.html
import numpy as np import numpy.linalg as linalg import matplotlib.pyplot as plt def fitEllipse(x,y): x = x[:,np.newaxis] y = y[:,np.newaxis] D = np.hstack((x*x, x*y, y*y, x, y, np.ones_like(x))) S = np.dot(D.T,D) C = np.zeros([6,6]) C[0,2] = C[2,0] = 2; C[1,1] = 1 E, V = linalg.eig(np.dot(linalg.inv(S), C)) #print E n = np.argmax(np.abs(E)) a = V[:,n] return a def ellipse_center(a): b,c,d,f,g,a = a[1]/2, a[2], a[3]/2, a[4]/2, a[5], a[0] num = b*ba*c x0=(c*db*f)/num y0=(a*fb*d)/num return np.array([x0,y0]) def ellipse_angle_of_rotation( a ): b,c,d,f,g,a = a[1]/2, a[2], a[3]/2, a[4]/2, a[5], a[0] return 0.5*np.arctan(2*b/(ac)) def ellipse_axis_length( a ): b,c,d,f,g,a = a[1]/2, a[2], a[3]/2, a[4]/2, a[5], a[0] up = 2*(a*f*f+c*d*d+g*b*b2*b*d*fa*c*g) down1=(b*ba*c)*( (ca)*np.sqrt(1+4*b*b/((ac)*(ac)))(c+a)) down2=(b*ba*c)*( (ac)*np.sqrt(1+4*b*b/((ac)*(ac)))(c+a)) res1=np.sqrt(up/down1) res2=np.sqrt(up/down2) return np.array([res1, res2])
My problem is this: I have sets of geospatial data to which I need to fit these ellipses. In order to compare ellipses at different latitudes I need to project them all to local tangent planes. This is easy. HOWEVER: With one such sample set of data, the functions work and give me a wellformed ellipse. When I do the projection, however, it gives me an ellipse whose major axis is somehow shorter than the the minor axis, which makes computing a nonimaginary eccentricity difficult :P ($e = \sqrt{1  b/a}$).
Even if my projection were wrong (it isn't), these functions should still be able to take these points and produce a fit. I can't figure out why with some datasets it produces nonsense geometrical data. Any ideas?
If not, does anybody have any other way to fit an ellipse to data in python?

Move points in the opposite direction
I am working on a project in Java. I am trying to move the points
p2
,p3
,p4
just outside the circumference of the circle in the opposite direction to the point p1. Below is the image, which describes the problem, I am trying to solve.//given two points, calculates the angle public static double calcAngle(Point2D.Double p1, Point2D.Double p2) { double deltaX = p2.x  p1.x; double deltaY = p2.y  p1.y; return (Math.atan2(deltaY, deltaX) * 180 / Math.PI); } //calculates a point on a circle given the angle, center of the circle and the radius public static Point2D.Double pointOnCircle(Point2D.Double point, double radius , double angle) { double x = Math.abs(point.x + (radius * Math.cos(angle * Math.PI / 180F))); double y = Math.abs(point.y + (radius * Math.sin(angle * Math.PI / 180F))); return new Point2D.Double(x,y); }
How do I calculate the angle in Java coordinate system and destination coordinates for each of the points
p2
,p3
,p4
?I am yet to try the code above and would like to know if my approach is right before proceeding, since it is a part of the bigger project. Thanks in advance!

tangent line with python
Could some one help me to calculate tangent line angle to curve. my curve is defined
x=0. 0.02743333 0.05486667 0.0823 0.10973333 0.13716667 0.1646 0.19203333 0.21946667 0.2469 0.27433333 0.30176667 0.3292 0.35663333 0.38406667 0.4115 y= 0.0, 0.041685454222222217, 0.078408362666666648, 0.11047814399999997, 0.13820421688888887, 0.16189599999999998, 0.18186291199999996, 0.19841437155555552, 0.21185979733333329, 0.22250860799999994, 0.23067022222222222, 0.23665405866666664, 0.24076953599999995, 0.24332607288888886, 0.244633088, 0.24499999999999986
I would need to know the angle between tangent line and xaxis at 0,0
I just don't understand how to do this.