[x3d-public] efficient json for 2d grid data

Andreas Plesch andreasplesch at gmail.com
Wed May 25 13:33:18 PDT 2016


Hi,

given the json x3d activity and availability of firebase as performant,
easy to use, online json database engine, I started to think about a json
structure for tiled elevation grid data.

As an example dataset I am using a global 1km (30 arcsecond) resolution
dataset, cut down to the continental U.S. or California.

The simplest structure is an untiled, flat list like this:
{ "lon1:lat1" : elev1,
  "lon2:lat2" : elev2,
 ... }
I transformed the dataset to this structure, and uploaded the json to
firebase. It works as expected, eg. you can query the database but you need
to know the exact keys, or array of keys for an area. It is actually pretty
fast.

This where tiling comes in. My favorite idea sofar is to use the digits of
lon.,lat. as hierarchical keys, with an addtional key "h" for the actual
data. For a three by three digit, one degree grid, It would look like this:

{"0:0" : {"h": h00_ave,
          "0:0" : { "h": h00_ave,
                    "0:0" : { h: elev },
                    "0:1" : { h: elev }, ...
                    "9:9" : { h: elev }
                  },
          "0:1" : { "h": h01_ave,
                    "0:0" : { h: elev },
                    "0:1" : { h: elev }, ...
                    "9:9" : { h: elev }
                  }, ...
          "9:9" : { "h": h99_ave,
                    "0:0" : { h: elev },
                    "0:1" : { h: elev }, ...
                    "9:9" : { h: elev }
                  }
  "0:1" : {"h": h01_ave, //100N does not actually exist
          "0:0" : { ... }, ...
          "9:9" : { ... }
         }, ...
 "9:9" : { ... }
}

The elev. data are actual elevation, the h??_ave value are representative
(average) elevation for a complete tile.

A json path to an elevation at 123E longitude and 40N latitude looks like
this:
/1:0/2:4/3:0/h
A json path to all elevations in the area between 120 and 129E longitude
and 40 and 49N latitude is:
/1:0/2:4/
This path refers to an object:
{ "h": 356, //average elevation in this area
  "0:0" : {"h": 344 }, // ...
  "9:9" : {"h": 377 }
}

which has all grid point elevations in this 10x10 degree tile.
So 129E,049N has an elevation of 377.

Hm, there is an issue. A json path
/2:0/
would refer to an area between 200E,000N to 299E,099N and would require
loading all of the subtree although we are only interested in the h??_ave
values.

-Andreas

Thinking out loud: This probably means putting the tile level first in the
hierarchy like in slippy maps. The tile level would be the number of
significant digits.
/3/0:0  //average for 000:000 to 099:099
/2/0:0  //average for 000:000 to 009:009
/2/1:0  //average for 010:000 to 019:009
/2/ // all averages in 10x10 cells
/1/222:89 // data in 222:89
/1/ // all data in 1x1 cells
looks better ...















-- 
Andreas Plesch
39 Barbara Rd.
Waltham, MA 02453
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160525/937ec6de/attachment.html>


More information about the x3d-public mailing list