I'm currently working on world map visualizations. For now, I can use a home-made software for visualizations and point projections (Java), but I would like to upgrade the soft to be able to use a similar tool in Python.
Thus, I wanted to use cartopy with the module PROJ4, not to re-code everything, and use the wonderfull existing libraries.
It perfectly works for the PlateCarree projection, but when I want to use the Nearside Perspective, I observe a small difference between the two methods.
The two following pictures are extracted from the Java software (1) and the cartopy plot (2).
Cartopy (0.17) is used with matplotlib (3.0.2) and proj4 (4.9.1). In both pictures, we are observing at lon=lat=0° and at 400 km.
Here is the first image (Java):
Java visualization
Here is the second one (Cartopy):
Cartopy representation
As one can observe, lands are over-represented in the cartopy plot. Asuming that I want to get exactly the same projection as the one in my Java software (same representation as the "TrueView angles" in Telecom fields), I discovered in the cartopy crs module:
class NearsidePerspective(_Satellite):
"""
Perspective view looking directly down from above a point on the globe.
In this projection, the projected coordinates are x and y measured from
the origin of a plane tangent to the Earth directly below the perspective
point (e.g. a satellite).
"""
So I got this question: which projection is this about? Are the angles kept, which would means that I have an undetected problem? Or is it an orthogonal projection on the tangent plane? In this case, angles are not conserved, and I would need a solution to apply another projection (the correct one in my case). I might use the wrong one...
Thanks for your time,
Lou
I'm not sure if it's an orthogonal projection, but what CartoPy is using is directly from Proj4:
https://proj4.org/operations/projections/nsper.html
I think coordinates in this Nearside Perspective coordinates are Cartesian distances (distances from the origin on a plane), not angles. It sounds like angles are what's being used for your projection. Have you looked at using the Geostationary projection, but with a different satellite height?
https://scitools.org.uk/cartopy/docs/latest/crs/projections.html#geostationary
I can say that in this projection, the coordinates are angles (multiplied by the satellite height). Might be what you're looking for.
Related
I am making maps of meteorological data (x,y-coordinates in m) using matplotlib.pyplot.contourf(). I want to plot a coastline, but all the examples I find on internet use lat-lon data (with cartopy or basemap).
Is there a way (without transforming the data to a lat-lon grid) to plot a coastline on my cartesian grid? I know size of the grid, and its center's lat-lon coordinates.
I haven't tried anything but look for similar examples, which I could not find.
The solution is to use cartopy's gnomonic projection: https://scitools.org.uk/cartopy/docs/v0.15/crs/projections.html#gnomonic , e.g.
proj =ccrs.Gnomonic(central_latitude=0, central_longitude= 0)
The origin of the data need to be specified (in lat-lon), and it expects the data coordinates to be distance in meters from that origin. Then, the normal cartopy features (like coastlines) work as usual.
I have a dataset of Points of Interest (via latitude/longitude) and want to generate a graph out of them. The aim is to have a routeable graph. So I want to have the "nearest" POIs to be connected via an edge.
I came up with Delaunay, cause this will create a simple planar graph out of the points. As far as good, i got some results. But the problem is, the edges are not good connected, due to the fact that the earth is not flat. In the northern and southern hemisphere the triangles are vertically strechted.
Is there a way to use the scipy.spatial.Delaunay package in order to accept latitude / longitude as positioning information, instead having a flat area?
Or does it make sense to use another procedure? Would be great to have some solutionen for python.
I got it running. I read this article and did the first steps to create the delaunay.
The main point is to make a stereographic projection and afterwards the regular 2D delaunay triangulation.
Now i got a nice basic graph.
I'm trying to plot a satellite orbit around the Earth. This is what I currrently have:
I made this plot using the Axes3D function in mpl_toolkits.mplot3d. Ideally what I would like to do, is to replace the simple sphere with an actual Earth with topology.
If you're not sure what I mean, take a look at a MATLAB implementation:
http://uk.mathworks.com/matlabcentral/fileexchange/13823-3d-earth-example
The Basemap package could be of help (especially the bluemarble() function), but unforunately I can't make it work on 3D objects. There is a similar question here, but the answer to that question results in a projection of a 3D sphere on a 2D plot. I want a 3D sphere on a 3D plot, so that I'm able to rotate around it.
Does anybody know of another package/implementation. Or is there a way to make Basemap work with 3D objects?
---EDIT---
Somebody asked the same question, but nobody has answered it yet
I have asked something similar some times ago
PyOpenGL sphere with texture
If I were you I would pick a OpenGL and use a texture of Earth on it just like this one
https://i.stack.imgur.com/ojwD8.jpg
In any case there is my second thread where I needed to make a Mars planet which is basically the same as you want except different texture:
Why my texture is not showing PyOpenGL
I'm trying to plot my data with the Aitoff Projection using matplotlib
An example is here, but I would like to set xaxis limit and visualize only a portion of the sphere. For instance, what should I use to visualize only latitude between 0 and 90 degrees and longitudes between -90 and 90 degrees?
The Aitoff projection in matplotlib cannot have its limits changed - they are fixed to a global extent (I think it is because it simplifies axis creation).
Of the other tools available to you, neither Basemap nor Cartopy support the Aitoff projection.
Because its fairly easy to do, I just created an Aitoff projection definition in Cartopy, but things did not work smoothly as proj.4 has not got the inverse Aitoff definition.
I'm afraid that, for now, there doesn't appear to be a good solution to this. I'll continue to look at the possibility of doing this with Cartopy, and let you know if I find anything.
HTH
I have data points in x,y,z format. They form a point cloud of a closed manifold. How can I interpolate them using R-Project or Python? (Like polynomial splines)
It depends on what the points originally represented. Just having an array of points is generally not enough to derive the original manifold from. You need to know which points go together.
The most common low-level boundary representation ("brep") is a bunch of triangles. This is e.g. what OpenGL and Directx get as input. I've written a Python software that can convert triangular meshes in STL format to e.g. a PDF image. Maybe you can adapt that to for your purpose. Interpolating a triangle is usually not necessary, but rather trivail to do. Create three new points each halfway between two original point. These three points form an inner triangle, and the rest of the surface forms three triangles. So with this you have transformed one triangle into four triangles.
If the points are control points for spline surface patches (like NURBS, or Bézier surfaces), you have to know which points together form a patch. Since these are parametric surfaces, once you know the control points, all the points on the surface can be determined. Below is the function for a Bézier surface. The parameters u and v are the the parametric coordinates of the surface. They run from 0 to 1 along two adjecent edges of the patch. The control points are k_ij.
The B functions are weight functions for each control point;
Suppose you want to approximate a Bézier surface by a grid of 10x10 points. To do that you have to evaluate the function p for u and v running from 0 to 1 in 10 steps (generating the steps is easily done with numpy.linspace).
For each (u,v) pair, p returns a 3D point.
If you want to visualise these points, you could use mplot3d from matplotlib.
By "compact manifold" do you mean a lower dimensional function like a trajectory or a surface that is embedded in 3d? You have several alternatives for the surface-problem in R depending on how "parametric" or "non-parametric" you want to be. Regression splines of various sorts could be applied within the framework of estimating mean f(x,y) and if these values were "tightly" spaced you may get a relatively accurate and simple summary estimate. There are several non-parametric methods such as found in packages 'locfit', 'akima' and 'mgcv'. (I'm not really sure how I would go about statistically estimating a 1-d manifold in 3-space.)
Edit: But if I did want to see a 3D distribution and get an idea of whether is was a parametric curve or trajectory, I would reach for package:rgl and just plot it in a rotatable 3D frame.
If you are instead trying to form the convex hull (for which the word interpolate is probably the wrong choice), then I know there are 2-d solutions and suspect that searching would find 3-d solutions as well. Constructing the right search strategy will depend on specifics whose absence the 2 comments so far reflects. I'm speculating that attempting to model lower and higher order statistics like the 1st and 99th percentile as a function of (x,y) could be attempted if you wanted to use a regression effort to create boundaries. There is a quantile regression package, 'rq' by Roger Koenker that is well supported.