Do you still get blown away by the beauty of geospatial data visualization? I know I do.
Welcome to all of the post Data Day Texas new subscribers!
Data Day Texas launched my return to conference travel.
You simply can’t ZOOM a presentation in the same way as being live with attendees and friends. Networking with many of you and having conversations about my book, Python for Geospatial Analysis — there was an O’Reilly showcase featured at the conference — made me think about topics for our conversations here.
I will revisit and update case studies from the book but most fun for me will be to share new visualizations and tools.
Whitebox Geospatial is certainly not new but it is valuable for analytics both within QGIS and notebooks as demonstrated below.
Where to find raster data
Earth Explorer is a fairly straightforward portal for downloading raster data. A detailed video will follow below the paid subscriber line (or a free 7-day trial) but if you are already familiar or have your own raster layer feel free to continue to follow along. Your area of interest can be anywhere in the world. I selected Lakarna, Pakistan.
Once you download the data products (you will need to create a free account) you can upload them to your colab files. For the example in the notebook we are using bands B1-B5. There are many different file types listed here — put a pin in them as we will revisit them in another post.
!pip install whitebox-workflows
import whitebox_workflows as wbw
wbe = wbw.WbEnvironment()
import math
wbe.verbose = True
wbe.max_procs = -1
This code block is run in your colab or jupyter notebook. If you are interested in a video on how to use a notebook for your python code please leave a comment. In fact, my Python book has a free accompanying notebook that provides workable examples.
As a quick aside, notebooks are also great for reading in raster files to find out quick information:
sp_tif = wbe.read_raster(‘youruploadedfile.tif')
print(f'Rows: {dem.configs.rows}')
print(f'Columns: {dem.configs.columns}')
print(f'Resolution (x direction): {dem.configs.resolution_x}')
print(f'Resolution (y direction): {dem.configs.resolution_y}')
print(f'North: {dem.configs.north}')
print(f'South: {dem.configs.south}')
print(f'East: {dem.configs.east}')
print(f'West: {dem.configs.west}')
print(f'Min value: {dem.configs.minimum}')
print(f'Max value: {dem.configs.maximum}')
print(f'EPSG code: {dem.configs.epsg_code}') # 0 if not set
print(f'Nodata value: {dem.configs.nodata}')
Output:
Rows: 1689 Columns: 1265 Resolution (x direction): 26.19778450592886 Resolution (y direction): 25.763999999999832 North: 3067246.119 South: 3023756.487 East: 444748.74521549407 West: 411634.7456 Min value: 0.0 Max value: 1.0 EPSG code: 24312 Nodata value: -32768.0
Okay, back to the Whitebox example — User Manual (with data from earth explorer):
band2, band3, band4, band5 = wbe.read_rasters('band2.TIF', 'band3.TIF', 'band4.TIF', 'band5.TIF')
dds = wbe.direct_decorrelation_stretch(bce, achromatic_factor=0.3)
wbe.write_raster(dds, 'final_false_cc.tif', True)
Your files will be listed in the Files in colab—simply click and they will appear in the dashboard.
Following many of my talks I update this playlist on YouTube. It is unlisted because I prefer to point people to the resource intentionally but you are free to share.
Free Resources and Tools:
Geospatial Presentations on YouTube
As promised, there are a few extra perks for subscribing or pledging in any amount
Books (not free):
Python for Geospatial Data Analysis: Theory, Tools, and Practice for Location Intelligence
Geospatial Analysis with SQL: A hands-on guide to performing geospatial analysis by unlocking the syntax of spatial SQL
Keep reading with a 7-day free trial
Subscribe to Open-Source Solutions for Geospatial Analysis to keep reading this post and get 7 days of free access to the full post archives.