1

I have a Fusion table having shape-files of various districts of India and I am using this fusion table in Earth Engine code.

var district = ee.FeatureCollection('ft:1PA2zwArj8EsplrX9eMxJ2H_TICyyx855KPnbJhC1','geometry')
    .filter(ee.Filter.eq('name','Begusarai'));

var district_image = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
    .filterBounds(district)
    .filterDate('2018-03-01','2018-05-01')
    .filter(ee.Filter.lt('CLOUD_COVER',5))
    .sort('CLOUD_COVER')
    .map(maskClouds)
    .median();

Then I perform some classification on the given image and export the classified image to my drive 'input' variable is having that classified image..

Export.image.toDrive({
  image: input.clip(district),
  description: 'begusarai2018',
  scale: 30,
  region: district
});

I now want to get the maximum and minimum coordinates (Latitude and Longitude) of these districts. How can I achieve this?

0

I have got the answer for my question today as:

var district = ee.FeatureCollection('ft:1PA2zwArj8EsplrX9eMxJ2H_TICyyx855KPnbJhC1','geometry')
    .filter(ee.Filter.eq('name','Begusarai'));

var boundbox = district.geometry().bounds();
Map.centerObject(bbox); Map.addLayer(bbox); Map.addLayer(geometry, {color: 'red'});
print(district);

// return the list of coordinates
var listCoords = ee.Array.cat(boundbox.coordinates(), 1); 

// get the X and Y -coordinates
var xCoords = listCoords.slice(1, 0, 1);
var yCoords = listCoords.slice(1, 1, 2);

// reduce the arrays to find the max (or min) value
var xMin = xCoords.reduce('min', [0]).get([0,0]); print('xMin',xMin);
var xMax = xCoords.reduce('max', [0]).get([0,0]); print('xMax',xMax);
var yMin = yCoords.reduce('min', [0]).get([0,0]); print('yMin',yMin);
var yMax = yCoords.reduce('max', [0]).get([0,0]); print('yMax',yMax);

and it works well for my problem

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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