Announcement

Collapse
No announcement yet.

Map Coordinates

Collapse
This is a sticky topic.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Map Coordinates

    I was wondering if it was possible to figure out the lat/lon coordinates for each map in the cache. For example, I downloaded the NASA AMES cache and took a look at the dds files. Each file has a name like 2036_0929.dds, depending on what directory it is in. Is there a way to find the lat/lon coordinates for a file like that?

  • #2
    Originally posted by ukenuke@Nov 9 2004, 07:16 PM
    I was wondering if it was possible to figure out the lat/lon coordinates for each map in the cache. For example, I downloaded the NASA AMES cache and took a look at the dds files. Each file has a name like 2036_0929.dds, depending on what directory it is in. Is there a way to find the lat/lon coordinates for a file like that?
    AFAIR its:
    L/X_Y.dds
    lon = Y * LevelZeroTileSizeDegrees * 0.5^L - 180
    lat = X * LevelZeroTileSizeDegrees * 0.5^L - 90

    Comment


    • #3
      Originally posted by ukenuke@Nov 9 2004, 12:16 PM
      I was wondering if it was possible to figure out the lat/lon coordinates for each map in the cache. For example, I downloaded the NASA AMES cache and took a look at the dds files. Each file has a name like 2036_0929.dds, depending on what directory it is in. Is there a way to find the lat/lon coordinates for a file like that?
      Hmm.. We just had a chat about that a couple of days ago in IRC.

      34, -99 maps to 0062_0040 at level 0

      tilesize = 2 / 2^(level)

      RoundDown( ( ( 90.0 + latitude) mod 180 ) / tileSize)
      RoundDown( ( ( 180 + longitude) mod 360) / tileSize)

      so..

      tilesize = 2 / 2^0 = 2
      62 = RoundDown( ( (90 + 34) mod 180) / 2 )
      40 = RoundDown( ( (180 + -99) mod 360) / 2 )
      Llynix AT gmail.com
      -------
      Not working for NASA (Am for hire)
      Installer Maintainer
      FAQ Extrodinare
      Founder of World Wind Central :
      Wiki (and FAQ) * Chat * Hotspots * Geocoder
      and OneDittyADay

      Comment


      • #4
        How precise are these conversions into lat/lon. It seems that when I tried them out, it was off from the actual lat/lon coordinates.

        Comment


        • #5
          Originally posted by ukenuke@Nov 11 2004, 05:01 PM
          How precise are these conversions into lat/lon. It seems that when I tried them out, it was off from the actual lat/lon coordinates.
          You should be fairly close. The only place you lose percission is in the floor function, which would at most make you off by .5 lat or .5 lon me thinks.
          Llynix AT gmail.com
          -------
          Not working for NASA (Am for hire)
          Installer Maintainer
          FAQ Extrodinare
          Founder of World Wind Central :
          Wiki (and FAQ) * Chat * Hotspots * Geocoder
          and OneDittyADay

          Comment


          • #6
            Yeah, I was off by less than .2 lat/lon. It makes a difference, though, when zoomed in.

            Comment


            • #7
              Do these conversions work for the blue marble textures? I have not had trouble with the maps from OnEarth, but the conversion to lat/lon for the blue marble textures does not seem to work at all.

              Comment


              • #8
                Hi ukenuke,

                I was looking at this yesterday and took some notes !

                The image folder and filename in each data set is <level>/<row>_<col>.dds

                Looking at Blue Marble level 0 tiles, the row numbers go 0000 through 0004
                => the world is 5 tiles high from south to north
                => each tile is (180 / 5) = 36 deg high

                and the col numbers go 0000 through 0009
                => the world is 10 tileswide going from -180 to +180 around the equator
                => each tile is (360 / 10) = 36 deg wide

                So the tile size for level 0 in blue marble seems to be 36 deg high x 36 deg wide.

                The tiles start at (row,col) = (0,0) = (lat -90, lon -180). This gives the bottom left coorrdinate of each tile in Blue Marble level 0 as :

                lat = row * 36 - 90
                lon = column * 36 - 180

                This agrees with the observation; using the thumbnail viewer, the only tile with its bottom left in Canada is the file 0/0004_0002.dds
                row = 4
                col = 2
                lat = 4 * 36 - 90 = 54 deg
                lon = 2 * 36 - 180 = -108 deg

                The general formulae for all Blue Marble levels will be :

                lat = row * (36 / 2 ** level) - 90 deg
                lon = col * (36 / 2 ** level) - 180 deg

                since the number of tiles in the same angle doubles with each level.

                Generalising a bit more for other data sets with different level 0 tile sizes gives :

                lat = row * (level0_tilesize / 2 ** level) - 90
                lon = col * (level0_tilesize / 2 ** level) - 180

                For Blue Marble, level0_tilesize is 36 deg, for Landsat7 it&#39;s 2 deg.

                HTH.

                Comment


                • #9
                  Thanks a lot for the help&#33;

                  Comment


                  • #10
                    Here&#39;s the code that I use to name files. Source Lat and Lon is the Lower-Left corner of the image:

                    public static int GetRowFromLatitude(float latitude, float tileSize)
                    {
                    return (int)System.Math.Floor((System.Math.Abs(-90.0 - latitude)%180)/tileSize);
                    }

                    public static int GetColFromLongitude(float longitude, float tileSize)
                    {
                    return (int)System.Math.Floor((System.Math.Abs(-180.0 - longitude)%360)/tileSize);
                    }

                    Hope that helps.
                    ~ just a programmer ~

                    Comment


                    • #11
                      Call me dumb but what would tile 2259_2877 at level 5 get me in Lat/long

                      thanks

                      Comment


                      • #12
                        Originally posted by Guest@Nov 29 2004, 10:09 PM
                        Call me dumb but what would tile 2259_2877 at level 5 get me in Lat/long

                        thanks
                        51.1875, -0.1875

                        I believe.

                        EDIT:

                        Short formula for Landsat only (modified from buachaille&#39;s post)

                        lat = row * ( 2 ^ (1 - level) ) - 90
                        lon = col * (2 ^ (1 - level) ) - 180

                        51.1875 = 2259 * ( 2 ^ ( 1 - 5) ) -90 = 2259 * 2^-4 - 90
                        -0.1875 = 2877 * ( 2 ^ (1 - 5) ) -180 = 2877 * 2^-4 -180
                        Llynix AT gmail.com
                        -------
                        Not working for NASA (Am for hire)
                        Installer Maintainer
                        FAQ Extrodinare
                        Founder of World Wind Central :
                        Wiki (and FAQ) * Chat * Hotspots * Geocoder
                        and OneDittyADay

                        Comment


                        • #13
                          Tks, you couldn&#39;t show me how you got to that could you?

                          Thanks.

                          Comment


                          • #14
                            Oh forgot, I take it thats decimal degrees?

                            Thanks again

                            Comment


                            • #15
                              Originally posted by Guest@Nov 30 2004, 02:39 AM
                              Oh forgot, I take it thats decimal degrees?

                              Thanks again

                              See above, and yes it&#39;s decimal degrees.
                              Llynix AT gmail.com
                              -------
                              Not working for NASA (Am for hire)
                              Installer Maintainer
                              FAQ Extrodinare
                              Founder of World Wind Central :
                              Wiki (and FAQ) * Chat * Hotspots * Geocoder
                              and OneDittyADay

                              Comment

                              Working...
                              X