Skip to main content
Became Hot Network Question
added 26 characters in body
Source Link
Joe.M
  • 67
  • 7

Here is a code snippet for creating a sectoral geometry with customized parameters in Google Earth Engine.

// random center point for sector var center = ee.Geometry.Point([-73, 0]); var coords=ee.List(center.coordinates()); var longitude=ee.Number(coords.get(0)); var latitude=ee.Number(coords.get(1)); // Parameters var radius = 5000; var startAngle = 45; var endAngle = 90; // Convert degrees to radians var startRad = ee.Number(startAngle).multiply(Math.PI/180); var endRad = ee.Number(endAngle).multiply(Math.PI/180); var radDiff = startRad.subtract(endRad); // Distance in meter of 1 degree longitude/latitude radian var loninMeter=111320; var latRad=latitude.multiply(Math.PI/180); var latinMeter=ee.Number(ee.Number(latRad).cos()).multiply(111320); // Define the number of points for the arc var numPoints = 10; // Function to calculate points for the arc var arcPoints = function(radius) { var points = ee.List.sequence(1, numPoints).map(function(i) { var percentage = ee.Number(i).divide(numPoints); var currentRad = startRad.add(radDiff.multiply(percentage)); var x = longitude.add(ee.Number(currentRad).cos().multiply(radius).divide(loninMeter)); var y = latitude.add(ee.Number(currentRad).sin().multiply(radius).divide(latinMeter)); return ee.Geometry.Point([x, y]); }); return points; }; var arcPoints = arcPoints(radius).add(center); // close the shape var sector=ee.Geometry.Polygon(innerArcPoints.add(center)arcPoints); Map.addLayer(sector,{color:'red'},'sectoral'); 

If startAngle and endAngle are set to 45 and 90, respectively, one radius of the sector will extends horizontally and forms a 45 degree angle with the other radius, which is strange already as arcPints are created based on coordinates of center, radius should be horizontal when startAngle is 0. Furthermore, if I set them to 45 and 75, angle between radii are 30 degree but none of the radius extends horizontally. It looks like the direction of sector is random. Why is this happening? direction of the sector when startAngle and endAngle are 45 and 75, respectively.

Here is a code snippet for creating a sectoral geometry with customized parameters in Google Earth Engine.

// random center point for sector var center = ee.Geometry.Point([-73, 0]); var coords=ee.List(center.coordinates()); var longitude=ee.Number(coords.get(0)); var latitude=ee.Number(coords.get(1)); // Parameters var radius = 5000; var startAngle = 45; var endAngle = 90; // Convert degrees to radians var startRad = ee.Number(startAngle).multiply(Math.PI/180); var endRad = ee.Number(endAngle).multiply(Math.PI/180); var radDiff = startRad.subtract(endRad); // Distance in meter of 1 degree longitude/latitude radian var loninMeter=111320; var latRad=latitude.multiply(Math.PI/180); var latinMeter=ee.Number(ee.Number(latRad).cos()).multiply(111320); // Define the number of points for the arc var numPoints = 10; // Function to calculate points for the arc var arcPoints = function(radius) { var points = ee.List.sequence(1, numPoints).map(function(i) { var percentage = ee.Number(i).divide(numPoints); var currentRad = startRad.add(radDiff.multiply(percentage)); var x = longitude.add(ee.Number(currentRad).cos().multiply(radius).divide(loninMeter)); var y = latitude.add(ee.Number(currentRad).sin().multiply(radius).divide(latinMeter)); return ee.Geometry.Point([x, y]); }); return points; }; var arcPoints = arcPoints(radius); var sector=ee.Geometry.Polygon(innerArcPoints.add(center)); Map.addLayer(sector,{color:'red'},'sectoral'); 

If startAngle and endAngle are set to 45 and 90, respectively, one radius of the sector will extends horizontally and forms a 45 degree angle with the other radius, which is strange already as arcPints are created based on coordinates of center, radius should be horizontal when startAngle is 0. Furthermore, if I set them to 45 and 75, angle between radii are 30 degree but none of the radius extends horizontally. It looks like the direction of sector is random. Why is this happening? direction of the sector when startAngle and endAngle are 45 and 75, respectively.

Here is a code snippet for creating a sectoral geometry with customized parameters in Google Earth Engine.

// random center point for sector var center = ee.Geometry.Point([-73, 0]); var coords=ee.List(center.coordinates()); var longitude=ee.Number(coords.get(0)); var latitude=ee.Number(coords.get(1)); // Parameters var radius = 5000; var startAngle = 45; var endAngle = 90; // Convert degrees to radians var startRad = ee.Number(startAngle).multiply(Math.PI/180); var endRad = ee.Number(endAngle).multiply(Math.PI/180); var radDiff = startRad.subtract(endRad); // Distance in meter of 1 degree longitude/latitude radian var loninMeter=111320; var latRad=latitude.multiply(Math.PI/180); var latinMeter=ee.Number(ee.Number(latRad).cos()).multiply(111320); // Define the number of points for the arc var numPoints = 10; // Function to calculate points for the arc var arcPoints = function(radius) { var points = ee.List.sequence(1, numPoints).map(function(i) { var percentage = ee.Number(i).divide(numPoints); var currentRad = startRad.add(radDiff.multiply(percentage)); var x = longitude.add(ee.Number(currentRad).cos().multiply(radius).divide(loninMeter)); var y = latitude.add(ee.Number(currentRad).sin().multiply(radius).divide(latinMeter)); return ee.Geometry.Point([x, y]); }); return points; }; var arcPoints = arcPoints(radius).add(center); // close the shape var sector=ee.Geometry.Polygon(arcPoints); Map.addLayer(sector,{color:'red'},'sectoral'); 

If startAngle and endAngle are set to 45 and 90, respectively, one radius of the sector will extends horizontally and forms a 45 degree angle with the other radius, which is strange already as arcPints are created based on coordinates of center, radius should be horizontal when startAngle is 0. Furthermore, if I set them to 45 and 75, angle between radii are 30 degree but none of the radius extends horizontally. It looks like the direction of sector is random. Why is this happening? direction of the sector when startAngle and endAngle are 45 and 75, respectively.

added 7 characters in body
Source Link
Joe.M
  • 67
  • 7

Here is a code snippet for creating a sectoral geometry with customized parameters in Google Earth Engine.

// random center point for sector var center = ee.Geometry.Point([-73, 0]); var coords=ee.List(center.coordinates()); var longitude=ee.Number(coords.get(0)); var latitude=ee.Number(coords.get(1)); // Parameters var radius = 5000; var startAngle = 45; var endAngle = 90; // Convert degrees to radians var startRad = ee.Number(startAngle).multiply(Math.PI/180); var endRad = ee.Number(endAngle).multiply(Math.PI/180); var radDiff = startRad.subtract(endRad); // Distance in meter of 1 degree longitude/latitude radian var loninMeter=111320; var latRad=latitude.multiply(Math.PI/180); var latinMeter=ee.Number(ee.Number(latRad).cos()).multiply(111320); // Define the number of points for the arc var numPoints = 10; // Function to calculate points for the arc var arcPoints = function(radius) { var points = ee.List.sequence(1, numPoints).map(function(i) { var percentage = ee.Number(i).divide(numPoints); var currentRad = startRad.add(radDiff.multiply(percentage)); var x = longitude.add(ee.Number(currentRad).cos().multiply(radius).divide(loninMeter)); var y = latitude.add(ee.Number(currentRad).sin().multiply(radius).divide(latinMeter)); return ee.Geometry.Point([x, y]); }); return points; }; var arcPoints = arcPoints(radius); var sector=ee.Geometry.Polygon(innerArcPoints.add(center)); Map.addLayer(sector,{color:'red'},'sectoral'); 

If startAngle and endAngle are set to 45 and 90, respectively, one radius of the sector will extends horizontally and the other radius will haveforms a 45 degree angle with itthe other radius, which is strange already as arcPints are created based on coordinates of center, radius should be horizontal when startAngle is 0. Furthermore, if I set them to 45 and 75, angle between radii are 30 degree but none of the radius will be horizontalextends horizontally. It looks like the direction of sector is random. Why is this happening? direction of the sector when startAngle and endAngle are 45 and 75, respectively.

Here is a code snippet for creating a sectoral geometry with customized parameters in Google Earth Engine.

// random center point for sector var center = ee.Geometry.Point([-73, 0]); var coords=ee.List(center.coordinates()); var longitude=ee.Number(coords.get(0)); var latitude=ee.Number(coords.get(1)); // Parameters var radius = 5000; var startAngle = 45; var endAngle = 90; // Convert degrees to radians var startRad = ee.Number(startAngle).multiply(Math.PI/180); var endRad = ee.Number(endAngle).multiply(Math.PI/180); var radDiff = startRad.subtract(endRad); // Distance in meter of 1 degree longitude/latitude radian var loninMeter=111320; var latRad=latitude.multiply(Math.PI/180); var latinMeter=ee.Number(ee.Number(latRad).cos()).multiply(111320); // Define the number of points for the arc var numPoints = 10; // Function to calculate points for the arc var arcPoints = function(radius) { var points = ee.List.sequence(1, numPoints).map(function(i) { var percentage = ee.Number(i).divide(numPoints); var currentRad = startRad.add(radDiff.multiply(percentage)); var x = longitude.add(ee.Number(currentRad).cos().multiply(radius).divide(loninMeter)); var y = latitude.add(ee.Number(currentRad).sin().multiply(radius).divide(latinMeter)); return ee.Geometry.Point([x, y]); }); return points; }; var arcPoints = arcPoints(radius); var sector=ee.Geometry.Polygon(innerArcPoints.add(center)); Map.addLayer(sector,{color:'red'},'sectoral'); 

If startAngle and endAngle are set to 45 and 90, respectively, one radius of the sector will extends horizontally and the other radius will have a 45 degree with it, which is strange already as arcPints are created based on coordinates of center, radius should be horizontal when startAngle is 0. Furthermore, if I set them to 45 and 75, angle between radii are 30 but none of the radius will be horizontal. It looks like the direction of sector is random. Why is this happening? direction of the sector when startAngle and endAngle are 45 and 75, respectively.

Here is a code snippet for creating a sectoral geometry with customized parameters in Google Earth Engine.

// random center point for sector var center = ee.Geometry.Point([-73, 0]); var coords=ee.List(center.coordinates()); var longitude=ee.Number(coords.get(0)); var latitude=ee.Number(coords.get(1)); // Parameters var radius = 5000; var startAngle = 45; var endAngle = 90; // Convert degrees to radians var startRad = ee.Number(startAngle).multiply(Math.PI/180); var endRad = ee.Number(endAngle).multiply(Math.PI/180); var radDiff = startRad.subtract(endRad); // Distance in meter of 1 degree longitude/latitude radian var loninMeter=111320; var latRad=latitude.multiply(Math.PI/180); var latinMeter=ee.Number(ee.Number(latRad).cos()).multiply(111320); // Define the number of points for the arc var numPoints = 10; // Function to calculate points for the arc var arcPoints = function(radius) { var points = ee.List.sequence(1, numPoints).map(function(i) { var percentage = ee.Number(i).divide(numPoints); var currentRad = startRad.add(radDiff.multiply(percentage)); var x = longitude.add(ee.Number(currentRad).cos().multiply(radius).divide(loninMeter)); var y = latitude.add(ee.Number(currentRad).sin().multiply(radius).divide(latinMeter)); return ee.Geometry.Point([x, y]); }); return points; }; var arcPoints = arcPoints(radius); var sector=ee.Geometry.Polygon(innerArcPoints.add(center)); Map.addLayer(sector,{color:'red'},'sectoral'); 

If startAngle and endAngle are set to 45 and 90, respectively, one radius of the sector will extends horizontally and forms a 45 degree angle with the other radius, which is strange already as arcPints are created based on coordinates of center, radius should be horizontal when startAngle is 0. Furthermore, if I set them to 45 and 75, angle between radii are 30 degree but none of the radius extends horizontally. It looks like the direction of sector is random. Why is this happening? direction of the sector when startAngle and endAngle are 45 and 75, respectively.

Source Link
Joe.M
  • 67
  • 7

How to control the direction of customized sector geometry in GEE

Here is a code snippet for creating a sectoral geometry with customized parameters in Google Earth Engine.

// random center point for sector var center = ee.Geometry.Point([-73, 0]); var coords=ee.List(center.coordinates()); var longitude=ee.Number(coords.get(0)); var latitude=ee.Number(coords.get(1)); // Parameters var radius = 5000; var startAngle = 45; var endAngle = 90; // Convert degrees to radians var startRad = ee.Number(startAngle).multiply(Math.PI/180); var endRad = ee.Number(endAngle).multiply(Math.PI/180); var radDiff = startRad.subtract(endRad); // Distance in meter of 1 degree longitude/latitude radian var loninMeter=111320; var latRad=latitude.multiply(Math.PI/180); var latinMeter=ee.Number(ee.Number(latRad).cos()).multiply(111320); // Define the number of points for the arc var numPoints = 10; // Function to calculate points for the arc var arcPoints = function(radius) { var points = ee.List.sequence(1, numPoints).map(function(i) { var percentage = ee.Number(i).divide(numPoints); var currentRad = startRad.add(radDiff.multiply(percentage)); var x = longitude.add(ee.Number(currentRad).cos().multiply(radius).divide(loninMeter)); var y = latitude.add(ee.Number(currentRad).sin().multiply(radius).divide(latinMeter)); return ee.Geometry.Point([x, y]); }); return points; }; var arcPoints = arcPoints(radius); var sector=ee.Geometry.Polygon(innerArcPoints.add(center)); Map.addLayer(sector,{color:'red'},'sectoral'); 

If startAngle and endAngle are set to 45 and 90, respectively, one radius of the sector will extends horizontally and the other radius will have a 45 degree with it, which is strange already as arcPints are created based on coordinates of center, radius should be horizontal when startAngle is 0. Furthermore, if I set them to 45 and 75, angle between radii are 30 but none of the radius will be horizontal. It looks like the direction of sector is random. Why is this happening? direction of the sector when startAngle and endAngle are 45 and 75, respectively.