# Getting the percentage area of intersecting polygons [closed]

I have the polygons for census tracts within New York City. I also have the polygons for the parks. What I would like is % of the census tract area, with an added 400 meter buffer, that is park.

I'm not sure if this is possible with Google Earth Engine. If it is, these are the steps that would be necessary.

1. Add a buffer to the census tract polygons
2. Calculate the area of each buffered polygon (A)
3. Calculate that area of park that intersects with each buffered polygon (Ap)
4. Divide Ap/A to calculate the percentage of park area within the buffered tract

Like I said, I'm not even sure if this is possible in GEE. Any pointers?

As requested, the data:

``````var parks = ee.FeatureCollection("users/tomlogan/NYC_parks"),
tracts = ee.FeatureCollection("users/tomlogan/NYC_tracts");
``````

## closed as off-topic by Vince, Erik, Jochen Schwarze, whyzar, xunilkFeb 19 at 17:25

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – Vince, Erik, Jochen Schwarze, whyzar, xunilk
If this question can be reworded to fit the rules in the help center, please edit the question.

• Please provide the part of code how you got the polygons for the parks and census tracts. This seems to be very well doable in the GEE. – Kuik Feb 19 at 8:46
• @Kuik i've shared the data and added the links above – Tom Logan Feb 19 at 14:00

The steps you provided can be calculated as follows:

``````var bufferTracts = tracts.map(function(feat){
var geom = ee.Feature(feat).geometry();
// 1: add a buffer to the tracts polygons
var buffer = geom.buffer(400);
// 2: Calculate the area of each buffered polygon (A)
var A = buffer.area(1); // (in sq meters)
// 3: Calculate that area of park that intersects with each buffered polygon (Ap)
var unionParks = parks.filterBounds(buffer).union().first().geometry();
var Ap = unionParks.intersection(buffer, 1).area(1);
// 4: Divide Ap/A to calculate the percentage of park area within the buffered tract
var perc = Ap.divide(A).multiply(100);
return ee.Feature(feat).setMulti({AreaBuffer: A, AreaPark: Ap, PercentagePark: perc});
});

print('FeatureCollection output', bufferTracts);
``````

For the full collection, I think this will return a time-out when you calculate it, so you'd possibly want to export this collection:

``````Export.table.toAsset(bufferTracts, 'areaTractsParks_NYC', 'areaTractsParks_NYC');
``````

I also noticed that each feature contained some points/lineStrings, which are not part of the polygons defining your tracts and parks and thus harm the buffer you will create. In the link below you will find that I filtered each geometry containing points/linestrings. Also, I added a smaller area of interest so it was possible to print the output. Remove that filter when you are going to export everything.