Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve quadrant splitting #36

Open
davidoesch opened this issue Dec 21, 2023 · 0 comments
Open

improve quadrant splitting #36

davidoesch opened this issue Dec 21, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@davidoesch
Copy link
Collaborator

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

@davidoesch davidoesch added the enhancement New feature or request label Dec 21, 2023
@davidoesch davidoesch self-assigned this Dec 21, 2023
@davidoesch davidoesch added this to the v1.0.0 milestone Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant