September 2019
Beginner
456 pages
10h 53m
English
All of the following functions, except the functions related to time, have been used in previous chapters in some form. Let's see how to use utility functions in our example:
def ll2m(lat, lon): """Lat/lon to meters""" x = lon * 20037508.34 / 180.0 y = math.log(math.tan((90.0 + lat) * math.pi / 360.0)) / (math.pi / 180.0) y = y * 20037508.34 / 180 return (x, y)
def world2pixel(x, y, w, h, bbox): """Converts world coordinates to image pixel coordinates""" # Bounding box of the map minx, miny, maxx, maxy = bbox # world x distance xdist ...