Idrisi - how can I convert x/y into lat/long? - coordinate-systems

I have coordinates (Idrisi) x: 550000, 580000 y: 4840000, 4810000, but I need latitude and longitude... how can I convert it? :(
Thanx

Related

Which spatial Data structure to use when Coordinates of the features is updating frequently? I have tried R tree, 2d Grid

I have N numbers of geographical points and coordinates of the points are being updated frequently. And the number N is very big.
I need to find points within a rectangle.
I have tried searching by all points, by using 2d Array grid and R tree.
I had to remove and then insert again which is costly operation.
Indexing spatial data is a complex topic. If you just have points you can index them using a sparse grid (better memory utilization than just 2d array):
class SpatialGrid:
def __init__(self, cell_size):
self._cells: DefaultDict[Tuple, Set] = defaultdict(set)
self._cell_size = cell_size
def __len__(self):
return len(self._cells)
def _key(self, x: float, y: float) -> Tuple:
return int(x / self._cell_size), int(y / self._cell_size)
def add(self, x: float, y: float, obj: object) -> None:
i_x, i_y = self._key(x, y)
for i in (-1, 0, 1):
for j in (-1, 0, 1):
self._cells[(i_x + i, i_y + j)].add(obj)
def get(self, x: float, y: float) -> Set:
return self._cells[self._key(x, y)]
def contains(self, x: float, y: float) -> bool:
return self._key(x, y) in self._cells
if you need to find by rectangle then you can just iterate over grid cells that are in that rectangle
But of course you will need to remove and insert points whenever the coordinates change. Indexing is costly.

torch concat 1D to a 2D tensor

I have a issue on concat 2 tensor,
say I have x and y:
x = torch.randn(35, 50)
y = torch.randn(35)
How do I concat every y value in to x[0] to make x has a shape 35,51?
I tried:
for i in y:
for a in range(x.shape[0]):
x[a] = torch.cat((x[a],i),0)
Still getting shape error. Any smart way of doing it?
This should work:
z = torch.cat([x,y.reshape(-1,1)], axis=1)
print(z.shape)
Output:
torch.Size([35, 51])

Calculating the height of a CSS 3D rotationX transform

I'd like to find out the height of an element, of a specific width and height, after a rotationX transform has been applied to it.
Would be ideal to be able find out the angle of an element's rotationX transform given the desired height.
rotateX() preserves the x-coordinate. The y-coordinate scales with the cosine of the rotation angle:
new_height = old_height * cos(angle)
The other way around is:
angle = arc cos(new_height / old_height)
Found 2 ways on finding dimensions of a DOM element after css 3D transforms have been applied to it.
1.By using element.getBoundingClientRect() which will return a ClientRect object with the correct dimensions of an elements after the transforms has been applied to it
{
bottom: 90.07061767578125
height: 90.07061767578125
left: 0
right: 891
top: 0
width: 891
}
A module called domvertices will return the xyz positions of 4 corner vertices for a DOM element, accounting for any transformatons:
{
a: {x: , y: , z: },
b: {x: , y: , z: },
c: {x: , y: , z: },
d: {x: , y: , z: }
}

What are the best methods to measure velocity given

Given that you have thousands of 3D vectors with their time of insertion, and you want to find the instantaneous velocity at the current time? Also, the primary criterion is accuracy, with the secondary criterion being performance.
Sample data:
t is in milliseconds (low resolution)
:> t: 19624, x: -221.68, y: 394.46, z: 127.66
:> t: 19656, x: -222.07, y: 394.26, z: 127.54
:> t: 19671, x: -222.47, y: 394.06, z: 127.43
:> t: 19687, x: -222.53, y: 394.03, z: 127.36
:> t: 19718, x: -222.95, y: 393.81, z: 127.23
:> t: 19734, x: -222.95, y: 393.81, z: 127.23
:> t: 19749, x: -223.42, y: 393.58, z: 127.05
:> t: 19765, x: -223.42, y: 393.58, z: 127.05
:> t: 19796, x: -223.86, y: 393.36, z: 126.91
:> t: 19812, x: -224.30, y: 393.13, z: 126.77
:> t: 19827, x: -224.36, y: 393.11, z: 126.71
:> t: 19843, x: -224.36, y: 393.11, z: 126.71
:> t: 19858, x: -224.82, y: 392.87, z: 126.55
:> t: 19874, x: -225.27, y: 392.65, z: 126.48
:> t: 19890, x: -225.32, y: 392.63, z: 126.49 [current time]
velocity with respect to OX, OY and OZ axes is the second derivative of x(t), y(t) and z(t).
The first defivative (suppose t=1) if easy to find
x'(1) = x(1) - x(0)
and
x''(2) = x'(2) - x'(1)
it will be fast enough but it wount be accurate. So I recoment you to approximate the series of x(t) with continious function (polynom), and calculate the second derivative of that polynom. Try to read about interpolation polynomes here.

Calculate second point knowing the starting point and distance

using a Latitude and Longitude value (Point A), I am trying to calculate another Point B, X meters away bearing 0 radians from point A. Then display the point B Latitude and Longitude values.
Example (Pseudo code):
PointA_Lat = x.xxxx;
PointA_Lng = x.xxxx;
Distance = 3; //Meters
bearing = 0; //radians
new_PointB = PointA-Distance;
I was able to calculate the distance between two Points but what I want to find is the second point knowing the distance and bearing.
Preferably in PHP or Javascript.
Thank you
It seems you are measuring distance (R) in meters, and bearing (theta) counterclockwise from due east. And for your purposes (hundereds of meters), plane geometry should be accurate enough. In that case,
dx = R*cos(theta) ; theta measured counterclockwise from due east
dy = R*sin(theta) ; dx, dy same units as R
If theta is measured clockwise from due north (for example, compass bearings),
the calculation for dx and dy is slightly different:
dx = R*sin(theta) ; theta measured clockwise from due north
dy = R*cos(theta) ; dx, dy same units as R
In either case, the change in degrees longitude and latitude is:
delta_longitude = dx/(111320*cos(latitude)) ; dx, dy in meters
delta_latitude = dy/110540 ; result in degrees long/lat
The difference between the constants 110540 and 111320 is due to the earth's oblateness
(polar and equatorial circumferences are different).
Here's a worked example, using the parameters from a later question of yours:
Given a start location at longitude -87.62788 degrees, latitude 41.88592 degrees,
find the coordinates of the point 500 meters northwest from the start location.
If we're measuring angles counterclockwise from due east, "northwest" corresponds
to theta=135 degrees. R is 500 meters.
dx = R*cos(theta)
= 500 * cos(135 deg)
= -353.55 meters
dy = R*sin(theta)
= 500 * sin(135 deg)
= +353.55 meters
delta_longitude = dx/(111320*cos(latitude))
= -353.55/(111320*cos(41.88592 deg))
= -.004266 deg (approx -15.36 arcsec)
delta_latitude = dy/110540
= 353.55/110540
= .003198 deg (approx 11.51 arcsec)
Final longitude = start_longitude + delta_longitude
= -87.62788 - .004266
= -87.632146
Final latitude = start_latitude + delta_latitude
= 41.88592 + .003198
= 41.889118
It might help if you knew that 3600 seconds of arc is 1 degree (lat. or long.), that there are 1852 meters in a nautical mile, and a nautical mile is 1 second of arc. Of course you're depending on the distances being relatively short, otherwise you'd have to use spherical trigonometry.
Here is an updated version using Swift:
let location = CLLocation(latitude: 41.88592 as CLLocationDegrees, longitude: -87.62788 as CLLocationDegrees)
let distanceInMeter : Int = 500
let directionInDegrees : Int = 135
let lat = location.coordinate.latitude
let long = location.coordinate.longitude
let radDirection : CGFloat = Double(directionInDegrees).degreesToRadians
let dx = Double(distanceInMeter) * cos(Double(radDirection))
let dy = Double(distanceInMeter) * sin(Double(radDirection))
let radLat : CGFloat = Double(lat).degreesToRadians
let deltaLongitude = dx/(111320 * Double(cos(radLat)))
let deltaLatitude = dy/110540
let endLat = lat + deltaLatitude
let endLong = long + deltaLongitude
Using this extension:
extension Double {
var degreesToRadians : CGFloat {
return CGFloat(self) * CGFloat(M_PI) / 180.0
}
}
dx = sin(bearing)
dy = cos(bearing)
x = center.x + distdx;
y = center.y + distdy;

Resources