Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Vitaliy-R
Developer Advocate
Developer Advocate
Sorry for the title. The "polar azimuthal equidistant projection" sounds so smart, I could not resist adding it there... But I would not know its meaning myself without the corresponding article in Wikipedia 😄

In my previous blog I used the simplest projection of the Earth: cylindrical with constant intervals of meridians and parallels. Therefore it was quite simple to transform the data in the relational columnar table of SAP HANA. Later I learned that projection had smart name too: equirectangular.

This time I am going to produce the azimuthal equidistant projection from the North Pole as a center. This projection has distances from the center conserved (i.e. the same). You might have seen it many times, as it is being used in the United Nations emblem:


Source: Wikipedia


The UN's emblem shows our planet from the above the North Pole, but then flattening the Earth making areas beyond the equator still visible - up to the 70° South parallel.

I wanted to the the ASCII art map of the same with the difference of going all the way to 87° South to add the ring of a land of Antarctica surrounding all other continents. Greenwich meridian 0° is looking down.

This projection was somewhat bigger challenge for my grey matter: transforming the Cartesian coordinate system of loaded shape files into the polar coordinate system of the azimuthal projection, and then recalculating it back into the Cartesian system of SAP HANA relational table for output. It is not something I have been doing daily since closing the university door behind me. But you can see, I had fun coming up with formulas on my own.



Here is my final SQLScript procedure. The input data is still the same as in previous blogs. I recommend you going through SAP HANA Spatial tutorials, if haven't done so yet.
create procedure "NATURAL_EARTH"."ASCII_MAP_AZIMUTHAL_EQUIDISTANT" (IN resolution INT)
LANGUAGE SQLSCRIPT AS
loopX, loopY, calcLon, calcLat FLOAT;
stringSurface, pointSurface STRING;
BEGIN
loopY := -resolution;
WHILE loopY<=resolution DO
loopX := -resolution;
stringSurface := '';
WHILE loopX<=resolution DO
calcLon := 180*ATAN2 (loopX, loopY)/3.141592653589793238;
calcLat := 90 - 180 * sqrt(power(loopX,2) + power(loopY,2)) / resolution;
IF calcLat >= -87
THEN
select new st_point('POINT ('||:calcLon||' '||:calcLat||')', 1000004326).ST_CoveredBy(SHAPE) into pointSurface FROM "NATURAL_EARTH"."NE_EARTH";
ELSE
pointSurface := 0;
END IF;
stringSurface := concat (stringSurface, pointSurface);
loopX := loopX+1;
END WHILE;
INSERT INTO "NATURAL_EARTH"."DRAW_EARTH" VALUES (:loopY, :stringSurface);
loopY := loopY+1;
END WHILE;
END

Executing it...
TRUNCATE TABLE "NATURAL_EARTH"."DRAW_EARTH";
CALL "NATURAL_EARTH"."ASCII_MAP_AZIMUTHAL_EQUIDISTANT"(RESOLUTION => 80);
SELECT replace(replace("SSTRING", '0', ' '), '1', '*') as "ASCIIMAP" FROM "NATURAL_EARTH"."DRAW_EARTH";

...gave me exactly what I had been looking for!



I am happy and excited. Hope you too?

-Vitaliy, aka @Sygyzmundovych

 

PS. Same as in my previous blog - prime meridian here is arbitrary. And history had different examples. Including those used as a proof that Earth is flat.

SourceBoston Public Library