Skip to content

improve quadrant splitting #36

@davidoesch

Description

@davidoesch

Is your feature request related to a problem? Please describe.
the use of bbox = bounds.coordinates().getInfo()[0] in

def get_quadrants(roi):
is not best practice ( Hendrik)

Describe the solution you'd like
replace

def get_quadrants(roi):

with

`// Calculate the bounding box of the region
var bounds = aoi_exp.bounds();

// Extract the coordinates of the bounding box
var coords = ee.List(ee.Geometry(bounds).coordinates().get(0));

// get the corner coordinates
var topLeft = ee.Geometry.Point(coords.get(3));
var topRight = ee.Geometry.Point(coords.get(2));
var bottomLeft = ee.Geometry.Point(coords.get(0));
var bottomRight = ee.Geometry.Point(coords.get(1));

// get the midpoints
var midLeft = ee.Geometry.LineString([topLeft, bottomLeft],'EPSG:4326', false).centroid(1)
var midTop = ee.Geometry.LineString([topLeft, topRight],'EPSG:4326', false).centroid(1)
var midRight = ee.Geometry.LineString([bottomRight, topRight],'EPSG:4326', false).centroid(1)
var midBottom = ee.Geometry.LineString([bottomRight, bottomLeft],'EPSG:4326', false).centroid(1)

// get the center point
var midVertical = ee.Geometry.LineString([midTop, midBottom],'EPSG:4326', false).centroid(1)
var midHorizontal = ee.Geometry.LineString([midLeft, midRight],'EPSG:4326', false).centroid(1)
var center = ee.Geometry.LineString([midVertical, midHorizontal],'EPSG:4326', false).centroid(1)

// Create quadrants
var quadrant1 = ee.Geometry.Rectangle([midLeft, midTop], 'EPSG:4326', false).buffer(2000);
var quadrant2 = ee.Geometry.Rectangle([center, topRight], 'EPSG:4326', false).buffer(2000);
var quadrant3 = ee.Geometry.Rectangle([midBottom, midRight], 'EPSG:4326', false).buffer(2000);
var quadrant4 = ee.Geometry.Rectangle([bottomLeft, center], 'EPSG:4326', false).buffer(2000);

// Create a list of quadrants
var quadrants = ee.List([quadrant1, quadrant2, quadrant3, quadrant4]);`

Additional context
As used in https://code.earthengine.google.com/d017c023cda8ee526a38b03155750b91

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions