betmatt has asked for the wisdom of the Perl Monks concerning the following question:

I have a question in follow up to thoughts on the Geo bounding module question asked previously. It is more like a set of ideas and I wondered how well Perl would be able to facilitate.

I am interested in creating a 3D representation of a perfect sphere and then allowing a mapping of a real object like the earth on that representation. This would require the following:

1) A outer perfect sphere with a coordinated centre, and a known size.
2) Additional perfect spheres, within the outer sphere, with same centre, set at equidistance from the nearest neighbour sphere.
3) The surface of each sphere subdivided into polygons in a proportional, internally consistent and equivalent way.
4) Each polygon will have corners of an edge that is represented by a variable in a 3 dimensional array.
5) Each connection between individual corners of a polygon is defined by a set of equations.
6) Each polygon will not all be the same size obviously. But they are all definable through a two dimensional array, variable length horizontally.
7) With this array there can be reference numbers that optionally allow for more detailed description. This would allow more detail for each polygon on an optional basis. If the entire polygon represents fresh water there is no point in increasing the level of detail. Whereas if the polygon covered the Niagara falls then there might be.
8) Each variable of the different polygons for three different spheres will represent different geographic area sizes, however the level of potential detail will be the same for each variable in a one to many relationship, with use of references within a matrix.
9) Each descriptor will run to predefined characteristics that are expandable through a database. Types of top soil, for example, might be something one might want to add later.
10) There would have to be some capacity for describing distance above sphere surface. For example 50 meters above sphere is rock->water boundary. Similarly the other way around.


All this would allow for a complete X,Y,Z representation of the earth using arrays and database connections. What have I missed off, what modules can I use and what can I expect in terms of detail? Have I taken the best approach? Has anyone done anything like this before. It seems to be something that Perl could easily do. It doesn't even need object orientation I believe.

Replies are listed 'Best First'.
Re: Earth as a sphere
by haukex (Archbishop) on May 09, 2019 at 13:30 UTC

    May I ask what you want to use this for? I think that'll play a big role in determining the "best" representation for your purposes. Based on your point 9, you might want to look into Geographic information systems. For example, QGIS is an open-source GIS software, I played around with it a while back. It has fairly tight bindings with Python, but I think it should be possible to bind Perl into it as well. There are probably modules in the Geo:: namespace that could help.

      It is not going to be ordinary GIS work. I plan to do some thought experiments with imaginary forms. I will need access to code that creates the spheres. This is not ordinary GIS. By creating theoretical scenarios this will open the way to new statistical methods.
Re: Earth as a sphere
by swl (Prior) on May 10, 2019 at 06:25 UTC

    Given the answers to the other queries so far (1233505 and 1233545) I think you do want a GIS module, in which case Geo::GDAL::FFI will do what you need.

    As noted before, the Earth is not a sphere. It is a geoid that is normally modelled using an oblate spheroid (that requires a flattening parameter). However, there are coordinate systems that use spheres to model the underlying system. The coordinate systems definitions also include the radius of the sphere or spheroid, so one can model the sun or some planetary body like Mars, or anything one likes (it is just spherical geometry in the end).

    The likely approach for the problem is to work with the data as (latitude, longitude, height) triplets. This is already supported by GDAL and can be loaded using the Well Known Text system for geometric objects.

    If you follow this approach then GDAL (and GEOS and Proj underneath) will handle all the heavy lifting, including projecting onto a two-dimensional surface for display.

Re: Earth as a sphere
by davido (Cardinal) on May 10, 2019 at 02:29 UTC

    But the earth isn't a perfect sphere.

    What is a Datum and a Projection?

    A quick search isn't revealing much on metacpan relating to geo datum. I'm probably just not searching for the right things.


    Dave

Re: Earth as a sphere
by bliako (Abbot) on May 10, 2019 at 08:26 UTC

    Do you want to replace the current representation of the earth shape by a spheroid with a hopefully more accurate representation which is formed by the outer surface of many concatenated spheres of various sizes, a la Metaballs? POV-Ray has implemented metaballs in what they call blobs:

    http://www.f-lohmueller.de/pov_tut/all_shapes/shapes620e.htm

    Is your concept similar to representing a set of (x,y) points with a polynomial of increasing degree? From a straight line, to a parabola, to a spline? Or the Bézier_curve? Or something akeen to Fourier_series where the sum of various sin() and cos() of varying amplitude and frequency represents accurately a complex shape?