# Can I safely reduce the resolution of the numbers in approximateTerrainHeights.json?

**URL:** <https://community.cesium.com/t/can-i-safely-reduce-the-resolution-of-the-numbers-in-approximateterrainheights-json/7436>\
**Category:** CesiumJS\
**Created:** [September 13, 2018, 4:39pm UTC](https://community.cesium.com/t/can-i-safely-reduce-the-resolution-of-the-numbers-in-approximateterrainheights-json/7436 "2018-09-13T16:39:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sven\_Neumann](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@Sven\_Neumann](https://community.cesium.com/u/Sven_Neumann)\
**Post date:** [September 13, 2018, 4:39pm UTC](https://community.cesium.com/t/can-i-safely-reduce-the-resolution-of-the-numbers-in-approximateterrainheights-json/7436/1 "2018-09-13T16:39:12Z")

</div>

**I haven’t been able to find more details, but it appears the numbers in approximateTerrainHeights.json are minimum and maximum elevations in meters. Sometimes to 8+ decimal places. Is it save to reduce these to 2 decimal places (cm) to massively reduce the size of this file?**

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [September 14, 2018, 11:48am UTC](https://community.cesium.com/t/can-i-safely-reduce-the-resolution-of-the-numbers-in-approximateterrainheights-json/7436/2 "2018-09-14T11:48:10Z")

</div>

I would say “sure” with the caveat that it depends on what you’re doing. For example, [from Gabby’s response here](https://groups.google.com/d/msg/cesium-dev/kwch9JimDho/mrA9ABKwAAAJ), it looks like if you’re not clamping anything to terrain you could safely emit the whole file. I think it would just affect the precision of objects clamped to terrain.

Further digging into it, from this [GitHub issue](https://github.com/AnalyticalGraphicsInc/cesium/issues/6557) it looks like it’s mostly used as a fallback if the terrain provider doesn’t provide this information. So if you’re using Cesium World Terrain I think it can do without it as well.

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [September 14, 2018, 11:51am UTC](https://community.cesium.com/t/can-i-safely-reduce-the-resolution-of-the-numbers-in-approximateterrainheights-json/7436/3 "2018-09-14T11:51:14Z")

</div>

On further inspection, I think it still does use in various places (see [https://github.com/AnalyticalGraphicsInc/cesium/search?p=3&q=approximateTerrainHeights&unscoped\_q=approximateTerrainHeights](https://github.com/AnalyticalGraphicsInc/cesium/search?p=3&q=approximateTerrainHeights&unscoped_q=approximateTerrainHeights) ). So I think reducing the precision of the numbers will just reduce the precision of things using it.

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [September 14, 2018, 11:57am UTC](https://community.cesium.com/t/can-i-safely-reduce-the-resolution-of-the-numbers-in-approximateterrainheights-json/7436/4 "2018-09-14T11:57:22Z")

</div>

Actually, rounding to 2 decimal places is a great idea and something we should have done when we first created this file. Even rounding to whole numbers or 1 decimal may be okay (if it further significantly reduces file sizes). You just need to make sure you round down for the minimums and up for the maximums. This file needs to be regenerated anyway, so I’ll write up an issue for us to do this at the same time.

Rounding here will actually have no impact on visualization or performance, this is a good change all around.

---

<div class="post-metadata">

**Author:** ![Tinco\_Andringa](https://avatars.discourse-cdn.com/v4/letter/t/ea666f/32.png) [@Tinco\_Andringa](https://community.cesium.com/u/Tinco_Andringa)\
**Post date:** [April 30, 2019, 12:29pm UTC](https://community.cesium.com/t/can-i-safely-reduce-the-resolution-of-the-numbers-in-approximateterrainheights-json/7436/5 "2019-04-30T12:29:44Z")

</div>

Thanks! Downloading this file was taking 700ms for me. I ran this little script to round the numbers:

```auto
#!/usr/bin/env ruby
require 'json'

filename = ARGV[1] || "./dist/Assets/approximateTerrainHeights.json"
objects = JSON.load(File.new(filename))
objects.each do |k,v|
  objects[k] = v.map {|i| i.round }
end

puts JSON.dump(objects)

```

And used webpack to copy it over the `dist/Assets/approximateTerrainHeights.json` file whenever we compile our app, and it reduced the loading time to just 30ms, drastically reducing our time to first draw 🙂

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [April 30, 2019, 3:16pm UTC](https://community.cesium.com/t/can-i-safely-reduce-the-resolution-of-the-numbers-in-approximateterrainheights-json/7436/6 "2019-04-30T15:16:42Z")

</div>

That sounds like a pretty significant optimization! Would you care to open a pull request to contribute this back to Cesium? The [contributing guide](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md) is a good place to start.

This is the GitHub issue that had discussion relevant to this:

[https://github.com/AnalyticalGraphicsInc/cesium/issues/6557](https://github.com/AnalyticalGraphicsInc/cesium/issues/6557)

Iw ould just make sure you round minimums down and maximums up to make sure it’s still a valid approximation.

---

<div class="post-metadata">

**Author:** ![Tinco\_Andringa](https://avatars.discourse-cdn.com/v4/letter/t/ea666f/32.png) [@Tinco\_Andringa](https://community.cesium.com/u/Tinco_Andringa)\
**Post date:** [June 24, 2019, 3:37pm UTC](https://community.cesium.com/t/can-i-safely-reduce-the-resolution-of-the-numbers-in-approximateterrainheights-json/7436/7 "2019-06-24T15:37:43Z")

</div>

Hi Omar,

Sorry for the late response, I’ve made a PR here: [https://github.com/AnalyticalGraphicsInc/cesium/pull/7959](https://github.com/AnalyticalGraphicsInc/cesium/pull/7959)

Kind regards,

Tinco
