Share your work here ✅

Yes we can. Thresholding, polygonizing, & geo-referencing predicted segments will be the focus of a future notebook.

The short version is that I’m following a Slippy Map tile name convention used by OpenStreetMap and other web maps which enables easy conversion from tiles to lat/lon coordinates and back.

For example:

Each image & corresponding mask in my segmentation dataset has a filename that starts like “grid_001_19_319363_270514_…”:

After “grid_001_”, the numbers correspond to {zoom}_{xtile}_{ytile} information. So in this case, we can use the provided num2deg() conversion function to get the NW corner longitude & latitude for this particular time:

# https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Python

import math
def num2deg(xtile, ytile, zoom):
    n = 2.0 ** zoom
    lon_deg = xtile / n * 360.0 - 180.0
    lat_rad = math.atan(math.sinh(math.pi * (1 - 2 * ytile / n)))
    lat_deg = math.degrees(lat_rad)
    return (lat_deg, lon_deg)

zoom = 19
xtile = 319363
ytile = 270514

lat, lon = num2deg(xtile, ytile, zoom)
lat, lon
(-5.737609279566592, 39.28916931152344)

Putting this into Google Maps or OpenStreetMap will bring you to that tile’s NW corner location at that zoom level: https://www.openstreetmap.org/#map=19/-5.73761/39.28917

Doing this for all 4 corners of the tile gives you the geo bounds of that tile.

To assign lon/lat coordinates to detected buildings, we have to match up the display (x, y) coordinates of predicted pixels relative to the lon/lat bounds of that tile. This would happen during the polygonizing step. Too much detail to go into that here (and it’s not really specific to deep learning) so stay tuned for that notebook.

If there’s interest, I can also start a new wiki thread for us to share know-how, applications, and new ideas on geospatial deep learning. I’m learning too (aka fumbling my way into making things work) and I’m sure there are many sources of experience & wisdom among us to share and build on!

11 Likes