-1

I'm trying to make a building-density map for Africa. Currently, I have polygons representing each building.

    var t = ee.FeatureCollection('GOOGLE/Research/open-buildings/v1/polygons');
// t represents buildings

Is there a way, on Google Earth Engine, to count the number of buildings (or 'centres of buildings') in each square km?

I can currently count the buildings in a specific area, but am not sure how to loop that over each square km in Africa and display it.

Current code is:

var onebyone = ee.Geometry.Polygon(
        [[[27.267432336497937, -26.34118164739369],
          [27.267432336497937, -26.606706603577045],
          [27.564063195872937, -26.606706603577045],
          [27.564063195872937, -26.34118164739369]]], null, false);
// Filter buildings by area
var t = ee.FeatureCollection('GOOGLE/Research/open-buildings/v1/polygons');
var buildingdens = t.filterBounds(onebyone)
print('Count:', buildingdens.size());
2
  • Well, what have you tried? What have you searched for and deem useful for your usecase? Do you have any code?
    – Erik
    Commented Aug 4, 2021 at 11:18
  • I've managed to count number of buildings in a specific area, but now want to loop over each square km in Africa and get that number.
    – Emma
    Commented Aug 4, 2021 at 14:08

2 Answers 2

0

Without your actual code, it will be a difficult to give you a working example, but if you have a collection of every square km of Africa, you could do the following.

var squareKM_Africa = ee.FeatureCollection("YourFeatureCollectionHere");

var countBuildings = function(feature){
    //your function Counting the Buildings in the polygon
    var buildingCount = ...  // your formula to count the buildings
    return feature.set("buildingCount",buildingCount) // adds the value to the feature
};

var squareKM_Africa_withBuildingCount = squareKM_Africa.map(countBuildings);

What would happen in the above code, is that it would take your feature collection of the square kms of Africa, and then for each feature it would count the buildings in it, and assign the result as a property of each feature.

The advantage of this is that every feature is done concurrently by the earth engine and you don't need to loop through it in you code.

0

I am trying to do the same.

Wouldn't it be better to convert the buildings to a raster:

var building_area = t.reduceToImage({
  properties: ['area_in_meters'],
  reducer: ee.Reducer.sum()
})

and then perform a reducer to 1000m resolution? or reproject?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.