Openstreetmap rectangular grid for whole planet





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I`m trying to generate rectangular grid for whole world with fixed cell size in 350 meters (width and height are equals).



What i tried to do:



1) in main loop iterate trough longitude in range [-180; 180]



2) in nested loop iterate trough latitude in range [-85.06; 85.06] (Web mercator bounds)



3) increment cells bound to 350 meters on East (in main loop) and North (in nested loop) using Java GeographicLib Geodesic.WGS84.Direct().



Java code:



double lon_min = -180;
double lon_max = 180;
double lat_min = -85.06;
double lat_max = 85.06;

double lon_max_c = lon_min;
double lon_min_c = lon_min;

int grid_x = 0;
int grid_y = 0;
int cell_id = 0;

while(lon_max_c < lon_max)
{
double lat_min_c = lat_min;
double lat_max_c = lat_min;

lon_min_c = lon_max_c;
GeodesicData g = Geodesic.WGS84.Direct(lat_min_c, lon_min_c, 90, 350);

boolean isXlast = g.lon2 > lon_max || (lon_min_c > 0 && g.lon2 < 0);
lon_max_c = isXlast? lon_max : g.lon2;

grid_y = 0;

while(lat_max_c < lat_max)
{
lat_min_c = lat_max_c;

GeodesicData g1 = Geodesic.WGS84.Direct(lat_min_c, lon_min_c, 0, 350);

boolean isYlast = g1.lat2 > lat_max;
lat_max_c = isYlast? lat_max : g1.lat2;

System.out.print("rid: " + cell_id + " lon: " + lon_max_c + " lat: " + lat_max_c);

grid_y = grid_y + 1;
cell_id = cell_id + 1;
}
grid_x = grid_x + 1;
}


As a result, ~530 million cells were generated. Howewer, area of whole planet is ~510M squared kilometers. So, the total number of cells should be about 4 billion. I'm pretty new to geodesic math, so what is wrong? What should I do to generate this grid correctly?










share|improve this question




















  • 1





    crosspost: gis.stackexchange.com/questions/302962/…

    – scai
    Nov 19 '18 at 7:06


















0















I`m trying to generate rectangular grid for whole world with fixed cell size in 350 meters (width and height are equals).



What i tried to do:



1) in main loop iterate trough longitude in range [-180; 180]



2) in nested loop iterate trough latitude in range [-85.06; 85.06] (Web mercator bounds)



3) increment cells bound to 350 meters on East (in main loop) and North (in nested loop) using Java GeographicLib Geodesic.WGS84.Direct().



Java code:



double lon_min = -180;
double lon_max = 180;
double lat_min = -85.06;
double lat_max = 85.06;

double lon_max_c = lon_min;
double lon_min_c = lon_min;

int grid_x = 0;
int grid_y = 0;
int cell_id = 0;

while(lon_max_c < lon_max)
{
double lat_min_c = lat_min;
double lat_max_c = lat_min;

lon_min_c = lon_max_c;
GeodesicData g = Geodesic.WGS84.Direct(lat_min_c, lon_min_c, 90, 350);

boolean isXlast = g.lon2 > lon_max || (lon_min_c > 0 && g.lon2 < 0);
lon_max_c = isXlast? lon_max : g.lon2;

grid_y = 0;

while(lat_max_c < lat_max)
{
lat_min_c = lat_max_c;

GeodesicData g1 = Geodesic.WGS84.Direct(lat_min_c, lon_min_c, 0, 350);

boolean isYlast = g1.lat2 > lat_max;
lat_max_c = isYlast? lat_max : g1.lat2;

System.out.print("rid: " + cell_id + " lon: " + lon_max_c + " lat: " + lat_max_c);

grid_y = grid_y + 1;
cell_id = cell_id + 1;
}
grid_x = grid_x + 1;
}


As a result, ~530 million cells were generated. Howewer, area of whole planet is ~510M squared kilometers. So, the total number of cells should be about 4 billion. I'm pretty new to geodesic math, so what is wrong? What should I do to generate this grid correctly?










share|improve this question




















  • 1





    crosspost: gis.stackexchange.com/questions/302962/…

    – scai
    Nov 19 '18 at 7:06














0












0








0








I`m trying to generate rectangular grid for whole world with fixed cell size in 350 meters (width and height are equals).



What i tried to do:



1) in main loop iterate trough longitude in range [-180; 180]



2) in nested loop iterate trough latitude in range [-85.06; 85.06] (Web mercator bounds)



3) increment cells bound to 350 meters on East (in main loop) and North (in nested loop) using Java GeographicLib Geodesic.WGS84.Direct().



Java code:



double lon_min = -180;
double lon_max = 180;
double lat_min = -85.06;
double lat_max = 85.06;

double lon_max_c = lon_min;
double lon_min_c = lon_min;

int grid_x = 0;
int grid_y = 0;
int cell_id = 0;

while(lon_max_c < lon_max)
{
double lat_min_c = lat_min;
double lat_max_c = lat_min;

lon_min_c = lon_max_c;
GeodesicData g = Geodesic.WGS84.Direct(lat_min_c, lon_min_c, 90, 350);

boolean isXlast = g.lon2 > lon_max || (lon_min_c > 0 && g.lon2 < 0);
lon_max_c = isXlast? lon_max : g.lon2;

grid_y = 0;

while(lat_max_c < lat_max)
{
lat_min_c = lat_max_c;

GeodesicData g1 = Geodesic.WGS84.Direct(lat_min_c, lon_min_c, 0, 350);

boolean isYlast = g1.lat2 > lat_max;
lat_max_c = isYlast? lat_max : g1.lat2;

System.out.print("rid: " + cell_id + " lon: " + lon_max_c + " lat: " + lat_max_c);

grid_y = grid_y + 1;
cell_id = cell_id + 1;
}
grid_x = grid_x + 1;
}


As a result, ~530 million cells were generated. Howewer, area of whole planet is ~510M squared kilometers. So, the total number of cells should be about 4 billion. I'm pretty new to geodesic math, so what is wrong? What should I do to generate this grid correctly?










share|improve this question
















I`m trying to generate rectangular grid for whole world with fixed cell size in 350 meters (width and height are equals).



What i tried to do:



1) in main loop iterate trough longitude in range [-180; 180]



2) in nested loop iterate trough latitude in range [-85.06; 85.06] (Web mercator bounds)



3) increment cells bound to 350 meters on East (in main loop) and North (in nested loop) using Java GeographicLib Geodesic.WGS84.Direct().



Java code:



double lon_min = -180;
double lon_max = 180;
double lat_min = -85.06;
double lat_max = 85.06;

double lon_max_c = lon_min;
double lon_min_c = lon_min;

int grid_x = 0;
int grid_y = 0;
int cell_id = 0;

while(lon_max_c < lon_max)
{
double lat_min_c = lat_min;
double lat_max_c = lat_min;

lon_min_c = lon_max_c;
GeodesicData g = Geodesic.WGS84.Direct(lat_min_c, lon_min_c, 90, 350);

boolean isXlast = g.lon2 > lon_max || (lon_min_c > 0 && g.lon2 < 0);
lon_max_c = isXlast? lon_max : g.lon2;

grid_y = 0;

while(lat_max_c < lat_max)
{
lat_min_c = lat_max_c;

GeodesicData g1 = Geodesic.WGS84.Direct(lat_min_c, lon_min_c, 0, 350);

boolean isYlast = g1.lat2 > lat_max;
lat_max_c = isYlast? lat_max : g1.lat2;

System.out.print("rid: " + cell_id + " lon: " + lon_max_c + " lat: " + lat_max_c);

grid_y = grid_y + 1;
cell_id = cell_id + 1;
}
grid_x = grid_x + 1;
}


As a result, ~530 million cells were generated. Howewer, area of whole planet is ~510M squared kilometers. So, the total number of cells should be about 4 billion. I'm pretty new to geodesic math, so what is wrong? What should I do to generate this grid correctly?







grid openstreetmap mercator geodesic-sphere






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









Su0011

102411




102411










asked Nov 16 '18 at 17:40









gorillgorill

71521224




71521224








  • 1





    crosspost: gis.stackexchange.com/questions/302962/…

    – scai
    Nov 19 '18 at 7:06














  • 1





    crosspost: gis.stackexchange.com/questions/302962/…

    – scai
    Nov 19 '18 at 7:06








1




1





crosspost: gis.stackexchange.com/questions/302962/…

– scai
Nov 19 '18 at 7:06





crosspost: gis.stackexchange.com/questions/302962/…

– scai
Nov 19 '18 at 7:06












1 Answer
1






active

oldest

votes


















0















rectangular grid for whole world with fixed cell size in 350 meters (width and height are equals)




What you are trying to do is impossible as Earth is not a rectangle. See https://en.wikipedia.org/wiki/Map_projection for starting point to learn more.



While this effect can be ignored for small areas, on scale like "longitude in range [-180; 180]", "latitude in range [-85.06; 85.06]" ignoring it is not feasible.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53342859%2fopenstreetmap-rectangular-grid-for-whole-planet%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0















    rectangular grid for whole world with fixed cell size in 350 meters (width and height are equals)




    What you are trying to do is impossible as Earth is not a rectangle. See https://en.wikipedia.org/wiki/Map_projection for starting point to learn more.



    While this effect can be ignored for small areas, on scale like "longitude in range [-180; 180]", "latitude in range [-85.06; 85.06]" ignoring it is not feasible.






    share|improve this answer




























      0















      rectangular grid for whole world with fixed cell size in 350 meters (width and height are equals)




      What you are trying to do is impossible as Earth is not a rectangle. See https://en.wikipedia.org/wiki/Map_projection for starting point to learn more.



      While this effect can be ignored for small areas, on scale like "longitude in range [-180; 180]", "latitude in range [-85.06; 85.06]" ignoring it is not feasible.






      share|improve this answer


























        0












        0








        0








        rectangular grid for whole world with fixed cell size in 350 meters (width and height are equals)




        What you are trying to do is impossible as Earth is not a rectangle. See https://en.wikipedia.org/wiki/Map_projection for starting point to learn more.



        While this effect can be ignored for small areas, on scale like "longitude in range [-180; 180]", "latitude in range [-85.06; 85.06]" ignoring it is not feasible.






        share|improve this answer














        rectangular grid for whole world with fixed cell size in 350 meters (width and height are equals)




        What you are trying to do is impossible as Earth is not a rectangle. See https://en.wikipedia.org/wiki/Map_projection for starting point to learn more.



        While this effect can be ignored for small areas, on scale like "longitude in range [-180; 180]", "latitude in range [-85.06; 85.06]" ignoring it is not feasible.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 27 '18 at 11:00









        Mateusz KoniecznyMateusz Konieczny

        83611232




        83611232
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53342859%2fopenstreetmap-rectangular-grid-for-whole-planet%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python