Let’s get technical: Using Web Map Tiles in Python (Pt 1)

As part of ongoing education for our customers, we provide a technical blog series to help enlighten those who want to learn how to maximize their use of Vexcel imagery and data. Below is Part I in a series about using web map tiles by our guru of geospatial information, Pat Edwards.

If you wanted to get an image at a particular location on earth for some zoom level, all you need is the x, y and zoom value. The cells below do the math on getting a tile coordinate from a latitude and longitude pair (deg2num) and then the opposite (num2deg).

Choosing a pair of longitude, latitude coordinates, we get the x and y coordinates for a particular tile at zoom level 14:

Now, we have a way to get a map tile at any point on earth, for any zoom level supported by that WMTS. Note many WMTS only support up to zoom 18, but for services providing ultra high image resolutions, zoom 21 and higher are typical.

The point of all of the above is just to demonstrate that web maps – typically using the WMTS – can be generated by simply making requests to some API by telling it the tile coordinates and then displaying the image.

The cell below shows a more common view of a map tiles – as a collection of images that can be panned across and zoomed into. The URL named base_mapbox_satellite_url just gets passed to the TileLayer object. The TileLayer object keeps track of your interactions and then calculates are replaces the {x}{y} and {z} for the xy and z values to fill the map view.

The cell below uses an API that can access just a small portion of the VDP library but is useful for demonstrating the capabilities of the API. As you can see, we’re using essentially the same code but just using a different URL. This is one of the great things about WMTS. It provides a consistent interface to grab remote sensing data like satellite or aerial imagery.

Part I was focused on showing you the basics of how to request and receive geospatial imagery. Understanding the concepts of how we map from a latitude and longitude, to a tile coordinate, to an image will make it easier to follow in Part II where we can detect shapes within satellite images and process those shapes back from pixel coordinates to geospatial features that can be viewed on a map. Look for Part II coming soon!