Search code examples
pythonpython-imaging-libraryfoliumpyproj

Folium - Extracting an nxn image of mxm meters


I am using Folium on Python to extract maps. Given a coordinate, I want to extract an image of the mxm meters square around that coordinate. So, using pyproj, I project UTM to regular meters, create the mxm square and project back to UTM to get the coordinates of the bounding boxs corners.

Then, I've used fit_bounds with those corners to get my nxn picture. However, the output is still a rectangle. Sure, I can use Pillow to crop the image after the fact, but I need more control over how many meters that image is... And, right now I am not sure what I am actually getting.

What is the best way to extract a square image using Folium? Lets say I want to extract a map that gets the 100x100 meters area with coordinates (48.8584,2.2945) in the center.

What is the best approach to get this map?


Solution

  • I figured out how to control

    OpenStreetMap has this wiki link with information regarding the different zoom levels.

    To figure out how much of the real world is covered by a single pixel, formulas are provided. It is a function of the zoom level and the latitude at which the map is extracted.

    s_pixel = C*cos(latitude)/(2**(zoomlevel + 8))