Clamping entities to ground after adding from datasource

I’m adding some buildings from a GeoJSON and looking to clamp these to the ground either while adding, or after adding to the scene.

I’m currenlty doing this:

async function loadEntitiesFromGeoJSON(dataSource) {
            return new Promise((resolve, reject) => {
                try {
                    let entities = dataSource.entities.values;
                    let colorHash = {};
                    for (let i = 0; i < entities.length; i++) {
                        let entity = entities[i];
                        let id =;
                        let normalisedId = id.substr(0, id.lastIndexOf('_'));
                        if (normalisedId.includes('TheParade') || normalisedId.includes('QueensSouth') || normalisedId.includes('QueensNorth')){
                        let color = colorHash[normalisedId];
                        if (!color) {
                            color = Color.fromRandom({
                                minimumRed: 0.6,
                                maximumRed: 0.7,
                                minimumBlue: 0.8,
                                maximumBlue: 0.9,
                                minimumGreen: 0.75,
                                maximumGreen: 0.8,
                                alpha: 1,
                            colorHash[normalisedId] = color;

                        entity.polygon.material = color;

                        entity.polygon.outline = false;
                        entity.polygon.outlineColor = Color.BLACK;
                        if (!'levels')) {
                   = 1;
                        entity.polygon.extrudedHeight = * 4
                } catch (err) {

After using the createWorldTerrain() function however, all of these are below the world terrain line (because there’s no height data so they’re added at 0m). How can I clamp these entities to ground?


Welcome to the community :grinning: :rocket: I would appreciate it if you sent over a sandcastle demo that showcases what you have so far. It is somewhat difficult for me to read through only a small subset of your code.

From what I can tell, it looks like you are adding your GeoJSON data as an Entity object - is that correct? If so, I suggest updating the position member of your Entity object with the desired geolocation.