coordinates

Using python to find the missing coordinate of a rectangle

Using python to find the missing coordinate of a rectangle Question: Problem: Given integer coordinates of three vertices of a rectangle whose sides are parallel to coordinate axes, find the coordinates of the fourth vertex of the rectangle. I have written the code to answer the problem as follows (but it’s not correct): coord_1_x = …

Total answers: 3

How to get coordinates from postal codes and add them into df using a loop

How to get coordinates from postal codes and add them into df using a loop Question: I have the following dataframe: d = {‘Postcode’: [‘M3A’,’M4A’,’M5A’,’M6A’,’M9A’,’M1B’], ‘Borough’: [‘North York’, ‘Downtown Toronto’, ‘Etobicoke’, ‘Scarborough’, ‘East York’, ‘York’], ‘Neighbourhood’: [‘Parkwoods’, ‘Victoria Village’, ‘Harbourfront’, ‘Regent Park’, ‘Lawrence Heights’, ‘Lawrence Manor’]} post_df = pd.DataFrame(data = d) Which yields something like: …

Total answers: 2

Radius search in list of coordinates

Radius search in list of coordinates Question: I’m using python 2.7 and numpy (import numpy as np). I have a list of x-y coordinates in the following shape: coords = np.zeros((100, 2), dtype=np.int) I have a list of values corresponding to these coordinates: values = np.zeros(100, dtype=np.int) My program is populating these arrays. Now, for …

Total answers: 2

Python Turtle – How do I stop the turtle at a specific distance or coordinate?

Python Turtle – How do I stop the turtle at a specific distance or coordinate? Question: This is my attempt to make the turtle stop after traveling nearly 400 pixels. def race(): while True: alex.forward(r_alex) a = a + r_alex if a > 399.9: break And this is what I got back UnboundLocalError: local variable …

Total answers: 1

Calculate area of polygon given (x,y) coordinates

Calculate area of polygon given (x,y) coordinates Question: I have a set of points and would like to know if there is a function (for the sake of convenience and probably speed) that can calculate the area enclosed by a set of points. for example: x = np.arange(0,1,0.001) y = np.sqrt(1-x**2) points = zip(x,y) given …

Total answers: 12

Plotting a list of (x, y) coordinates in python matplotlib

Plotting a list of (x, y) coordinates in matplotlib Question: I have a list of pairs (a, b) that I would like to plot with matplotlib in python as actual x-y coordinates. Currently, it is making two plots, where the index of the list gives the x-coordinate, and the first plot’s y values are the …

Total answers: 4

Sort the points/coordinates of a circle into a logical sequence

Sort the points/coordinates of a circle into a logical sequence Question: Basically, I have a list of x,y,z coordinates read from a csv file that forms a rough circle and are not in order [[82.41657257, 0.863095999, -5400.0], [82.4160614, 0.0, -5400.0], [82.41255188, -0.863053977, -5400.0], [82.40731812, 1.726186991, -5400.0],……. I have the centre of the circle but cannot …

Total answers: 2

Inline labels in Matplotlib

Inline labels in Matplotlib Question: In Matplotlib, it’s not too tough to make a legend (example_legend(), below), but I think it’s better style to put labels right on the curves being plotted (as in example_inline(), below). This can be very fiddly, because I have to specify coordinates by hand, and, if I re-format the plot, …

Total answers: 5

How to perform bilinear interpolation in Python

How to perform bilinear interpolation in Python Question: I would like to perform blinear interpolation using python. Example gps point for which I want to interpolate height is: B = 54.4786674627 L = 17.0470721369 using four adjacent points with known coordinates and height values: n = [(54.5, 17.041667, 31.993), (54.5, 17.083333, 31.911), (54.458333, 17.041667, 31.945), …

Total answers: 8