0

I would like to create an ee.Geometry.Rectangle centered at a specific coordinate point and with specific width and height values in pixels. ee.Geometry.Rectangle accepts the coordinate points for the minimum and maximum corners of the rectangle; however, I want don't want to pass these but instead do something similar to the folium library

folium.Map(location=[lon,lat], zoom_start=19, width=256, height=256)

Is there any way to export the bounds from folium.map as coordinate points or perhaps a way to use the ee API directly? The reason why I want to do this is because I will be using the images centered at specific coordinate points and would like to test the effect image size on the classification accuracy of my algorithm.

user6360
  • 21
  • 5

2 Answers2

1

Giving number of pixels as a measure of distance is not common to GEE. I have a solution assuming projected Coordinates systems and using meters.

    var makeRectangle = function(point, xDistance, yDistance, proj){
          var geometry = 
                ee.Geometry.Rectangle(
                      [point[0] - xDistance, 
                       point[1] - yDistance,
                       point[0] + xDistance, 
                       point[1] + yDistance], proj, false);

          return geometry
}

var point = [50000,5500000]
var xDistance = 100000
var yDistance = 100000

Map.addLayer(makeRectangle(point, xDistance, yDistance,'EPSG:32632'))
Djaner Emin
  • 35
  • 1
  • 6
  • I did do this, however I used geometric coordinates. This seems like a great to work around it. Thanks – user6360 Apr 03 '20 at 16:22
0

found the FromLatLngToPixel(self, lat_lng, zoom) and CalculateBoundsZoomLevel(self, bounds, view_size) functions in a python reference from the old Google Maps API here if anyone is still looking for the answer

user6360
  • 21
  • 5