Skip to Main Content
Learning Geospatial Analysis with Python - Third Edition
book

Learning Geospatial Analysis with Python - Third Edition

by Joel Lawhead
September 2019
Beginner content levelBeginner
456 pages
10h 53m
English
Packt Publishing
Content preview from Learning Geospatial Analysis with Python - Third Edition

Working with utility functions

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:

  1. First, the ll2m() function converts latitude and longitude to meters:
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)
  1. The world2pixel() function converts geospatial coordinates to pixel coordinates on our output map image:
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Geospatial Analysis with Python

Mastering Geospatial Analysis with Python

Silas Toms, Eric van Rees, Paul Crickard

Publisher Resources

ISBN: 9781789959277Supplemental Content