pbrod / nvector Goto Github PK
View Code? Open in Web Editor NEWNvector is a suite of tools written in Python to solve geographical position calculations.
License: Other
Nvector is a suite of tools written in Python to solve geographical position calculations.
License: Other
Hi,
Using the latest version 0.7.5 the below example fails:
wgs84 = nv.FrameE(name='WGS84')
point1 = wgs84.GeoPoint(latitude=88, longitude=0, degrees=True)
point2 = wgs84.GeoPoint(latitude=89, longitude=-170, degrees=True)
s_12, _azi1, _azi2 = point1.distance_and_azimuth(point2)
p_12_E = point2.to_ecef_vector() - point1.to_ecef_vector()
d_12 = p_12_E.length[0]
msg = 'Ellipsoidal and Euclidean distance = {:5.2f} km, {:5.2f} km'
msg.format(s_12 / 1000, d_12 / 1000)
The error given is:
Attribute Error: 'list' object has no attribute 'T'
The example works correctly with version 0.7.4
As of 0.7.7, Cartopy
is a required dependency of nvector
. This is sometimes problematic since Cartopy
does not provide ready-built wheels on pypi, thus requiring every user to have a proper build environment (including a build of GEOS) to do pip install nvector
.
My suggestion would be to put the plotting part of nvector
as a an optional dependency so that users can do pip install nvector
to get the core functionality or pip install nvector[plots]
(or similar) to also require Cartopy (and perhaps matplotlib).
Right now, the "easy way out" for me is to do: pip install "nvector<=0.7.6"
Hello, thanks for this great library! Would it be possible to release a new package on PyPi with documentation built using Sphinx>=3.0.4? The newer version uses an updated version of jQuery (3.5) that addresses a security vulnerability.
According to numpy documentation (v1.19), isclose should not be used with default atol value for comparing numbers close to 0. See https://numpy.org/doc/stable/reference/generated/numpy.isclose.html
However, this is what is done in function on_great_circle in _core.py (and maybe other areas).
Hi,
I was doing some quick experimentation with nvector, and found this calculation of the cross-track distance on the great circle.
Lines 1140 to 1143 in bf1cf5e
The arccos function is inaccurate for small angles, as mentioned in the comment. When this function is called from cross_track_distance however, it is taken between the cross product of the n-vectors describing the path (c^E) and the position B. For small cross-track errors, shouldn't the expression with arccos be the most accurate (since arcsin is inaccurate at -pi/2 and pi/2)?
Hello,
First of all, thank you for making this package opensource. It is very useful to me.
I came across the following issue:
on_path when method='exact' will not return consistently True on the positionA of a path.
Below is an illustrating example. Having had a quick look at the code under the hood, it may be the checking the difference of azimuth is not meaningful when point_a==point
import nvector as nv
import numpy as np
wgs84 = nv.FrameE(name='WGS84')
pointA = wgs84.GeoPoint(latitude=81, longitude=0, degrees=True)
pointB = wgs84.GeoPoint(latitude=80, longitude=0, degrees=True)
path = nv.GeoPath(pointA, pointB)
print(np.allclose(path.on_path(path.positionA, method='exact'), True))
wgs84 = nv.FrameE(name='WGS84')
pointA = wgs84.GeoPoint(latitude=79, longitude=0, degrees=True)
pointB = wgs84.GeoPoint(latitude=80, longitude=0, degrees=True)
path = nv.GeoPath(pointA, pointB)
print(np.allclose(path.on_path(path.positionA, method='exact'), True))
nvector.version == 0.7.4
I have run the same test as in test_n_E_and_wa2R_EL
using the reference Matlab implementation (using Octave) and the result is not the one used as Python test
R_EL1 = [[0, 1.0, 0],
[1.0, 0, 0],
[0, 0, -1.0]]
but rather
>> n_E_and_wa2R_EL([0 0 1]', wander_azimuth = (pi / 2))
ans =
-6.1230e-17 -1.0000e+00 6.1230e-17
-1.0000e+00 6.1230e-17 -7.4983e-33
3.7492e-33 -6.1230e-17 -1.0000e+00
HTH
The intersect method on GeoPath
objects claims to return an instance of GeoPoint
, which seems like the desired behavior (at least, that is what I want it to return too). However it returns an instance of Nvector
.
From the last line of the intersect
method...
return frame.Nvector(normal_c, z=depth)
Would appreciate install availability with conda-forge. It's a little more stable with a conda environment than pypi. Thanks.
Python 3.9.2
nvector 0.7.7
Following Example 1:
import numpy as np
import nvector as nv
wgs84 = nv.FrameE(name='WGS84')
pointA = wgs84.GeoPoint(latitude=1, longitude=2, z=3, degrees=True)
pointB = wgs84.GeoPoint(latitude=4, longitude=5, z=6, degrees=True)
p_AB_N = pointA.delta_to(pointB)
print(p_AB_N)
gives
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/f380cedric/.local/lib/python3.9/site-packages/nvector/objects.py", line 138, in __repr__
params = fmt.join(['{}={!r}'.format(name, dict_params[name])
File "/home/f380cedric/.local/lib/python3.9/site-packages/nvector/objects.py", line 138, in <listcomp>
params = fmt.join(['{}={!r}'.format(name, dict_params[name])
File "/home/f380cedric/.local/lib/python3.9/site-packages/nvector/objects.py", line 138, in __repr__
params = fmt.join(['{}={!r}'.format(name, dict_params[name])
File "/home/f380cedric/.local/lib/python3.9/site-packages/nvector/objects.py", line 138, in <listcomp>
params = fmt.join(['{}={!r}'.format(name, dict_params[name])
KeyError: 'point'
It goes like this: Pvector.__dict__["frame"] → FrameN.__dict__["point"]
. FrameN._NAMES
gives "point"
while dict_params
only contains key nvector
.
This might not be a nvector code problem, but a numpy issue. But I thought I would mention it anyway.
I have the following code:
ecef = [[ 1782029.5702637 ]
[-5958967.13026865]
[ 1407960.53954478]]
ell = nv.FrameE(name='WGS84')
p_EB_E = ell.ECEFvector(ecef)
pnt = p_EB_E.to_geo_point()
lon, lat, z = pnt.latlon_deg
print(lon, lat)
print(type(lat))
With Windows, I get the following output:
[12.83821967] [-73.35070153]
<class 'numpy.ndarray'>
with linux, I get this:
12.838219667803369 -73.35070153096443
<class 'numpy.float64'>
Any idea why one returns single element array vs a floating point?
Hi,
I'm using this code for calculating the cartesian vector from "origin" to "target":
` wgs84 = nv.FrameE(name='WGS84')
origin = wgs84.GeoPoint(latitude=latitudeOrigin, longitude=longitudeOrigin, z=altitudeOrigin, degrees=False)
target = wgs84.GeoPoint(latitude=latitudeTarget, longitude=longitudeTarget, z=altitudeTarget, degrees=False)
p_AB_N = origin.delta_to(target)
x, y, z = p_AB_N.pvector.ravel()
`
Now, how can I reverse this operation? I have an origin and a cartesian vector and like to find the vector position as a GeoPosition (in my example "target").
In Pseudo-Code:
target = origin.to_geo_position(np.r_[x,y,z].reshape((-1, 1)))
Thank you,
Manfred
Hi, and thanks for this really nice concept and library. The paper is really interesting!
I ran into an inconsistency of return types from the GeoPath.track_distance
-method:
GeoPath.track_distance(method='great_circle')
returns a single-element arrayGeoPath.track_distance(method='euclidian')
returns a single-element arrayGeoPath.track_distance(method='exact')
returns a scalarFrom my point of view I would prefer it to consistently return scalars, that makes the most sense to me.
the numpy 'deprecate' function was deprecated in numpy 2.0. nvector uses this funcition in nvector\util.py
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.