hainegroup / oceanspy

A Python package to facilitate ocean model data analysis and visualization.
https://oceanspy.readthedocs.io
MIT License
96 stars 32 forks source link

Allow compat of viewer_to_range with multiple "points" selected from poseidon_viewer #369

Closed Mikejmnez closed 1 year ago

Mikejmnez commented 1 year ago

There are three types of data provided by the poseidon viewer via the argument p. The three types are: Point, Polygon and LineString. Both Polygon and LineString have multiple entries while Point is a single (lon, lat) location. Oceanspy can extract the relevant coordinates of these three types via ospy.utils.viever_to_range(p) function.

We just realized that poseidon_viewer can select multiple points at a time. So for example

The set of data Points are selected via shit+select from the poseidon viewer (they look blue), and can be assigned on a notebook for example points below

points = [{"type":"Point","coordinates":[-186.30895766364205,45.997065665998235]},{"type":"Point","coordinates":[-177.70518407873635,34.27641832009816]},{"type":"Point","coordinates":[-208.27122181458543,17.887813379018667]},{"type":"Point","coordinates":[-181.32782558817036,16.155919260064564]},{"type":"Point","coordinates":[-152.79952370137786,13.969713020398984]},{"type":"Point","coordinates":[-148.49763690892505,26.067097018569513]},{"type":"Point","coordinates":[-155.29008973911374,36.309032158084094]},{"type":"Point","coordinates":[-133.7806557768496,38.11208362420939]},{"type":"Point","coordinates":[-122.23348596552883,9.090700548691416]},{"type":"Point","coordinates":[-100.27122181458543,-23.052715582369387]},{"type":"Point","coordinates":[0.2570800722070334,-46.522997962607825]},{"type":"Point","coordinates":[-98.23348596552881,-49.84257375048559]},{"type":"Point","coordinates":[-129.25235389005715,-34.716752922033]},{"type":"Point","coordinates":[-163.21461804100053,-32.07069120179737]},{"type":"Point","coordinates":[-145.78065577684958,-14.70671264522342]}]

We would like to extract all points, but viewer_to_range(points) only returns the first one, as it was developed with the idea of an isolated Point.

lon, lat = ospy.utils.viewer_to_range(points)
extracting Point

lon, lat
([173.69104233635795], [45.997065665998235])

work:

I am working on allowing viewer_to_range(points) like in the the example above to return all coordinates, and not just the first one.