Geographic Information Systems Asked by strangecharm on July 10, 2021
I have been given the code below to create 100m buffers around solar panels.
var buff1 = buff130.difference(buff30).set('buffer','100')
generates the error buff130.difference(...).set is not a function
.
The GEE Debugging Guide (https://developers.google.com/earth-engine/guides/debugging) suggests this is a casting error, so I’ve tried var buff1 = ee.Geometry.Polygon(buff130.difference(buff30)).set('buffer','100')
to define the type of variable.
This did not work.
Where am I going wrong?
var addBuffer = function(Solar_panels){
//Create buffers 30m buffer around solar panels
var buff30 = Solar_panels.buffer(30);
//Create buffers at 100m intervals from the 30m buffer
var buff130 = buff30.buffer(100);
var buff230 = buff30.buffer(200);
var buff330 = buff30.buffer(300);
var buff430 = buff30.buffer(400);
var buff530 = buff30.buffer(500);
var buff630 = buff30.buffer(600);
var buff730 = buff30.buffer(700);
var buff830 = buff30.buffer(800);
var buff930 = buff30.buffer(900);
var buff1030 = buff30.buffer(1000);
var buff1130 = buff30.buffer(1100);
var buff1230 = buff30.buffer(1200);
var buff1330 = buff30.buffer(1300);
var buff1430 = buff30.buffer(1400);
var buff1530 = buff30.buffer(1500);
var buff1630 = buff30.buffer(1600);
var buff1730 = buff30.buffer(1700);
var buff1830 = buff30.buffer(1800);
var buff1930 = buff30.buffer(1900);
var buff2030 = buff30.buffer(2000);
// Subtract consecutive buffers so that have actual 100m buffer
// Add property to show which buffer is which
var buff1 = buff130.difference(buff30).set('buffer','100');
var buff2 = buff230.difference(buff130).set('buffer','200');
var buff3 = buff330.difference(buff230).set('buffer','300');
var buff4 = buff430.difference(buff330).set('buffer','400');
var buff5 = buff530.difference(buff430).set('buffer','500');
var buff6 = buff630.difference(buff530).set('buffer','600');
var buff7 = buff730.difference(buff630).set('buffer','700');
var buff8 = buff830.difference(buff730).set('buffer','800');
var buff9 = buff930.difference(buff830).set('buffer','900');
var buff10 = buff1030.difference(buff930).set('buffer','1000');
var buff11 = buff1130.difference(buff1030).set('buffer','1100');
var buff12 = buff1230.difference(buff1130).set('buffer','1200');
var buff13 = buff1330.difference(buff1230).set('buffer','1300');
var buff14 = buff1430.difference(buff1330).set('buffer','1400');
var buff15 = buff1530.difference(buff1430).set('buffer','1500');
var buff16 = buff1630.difference(buff1530).set('buffer','1600');
var buff17 = buff1730.difference(buff1630).set('buffer','1700');
var buff18 = buff1830.difference(buff1730).set('buffer','1800');
var buff19 = buff1930.difference(buff1830).set('buffer','1900');
var buff20 = buff2030.difference(buff1930).set('buffer','2000');
// Combine buffers into single feature collection
return ee.FeatureCollection([buff1,buff2,buff3,buff4,buff5,buff6,buff7,
buff8, buff9, buff10, buff11, buff12, buff13,
buff14, buff15, buff16, buff17, buff18,
buff19, buff20]);
};
ee.Feature
or ee.FeatureCollection
,So try something like:
var buff1 = ee.Feature(buff130.difference(buff30)).set('buffer','100');
Correct answer by user2856 on July 10, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP