Python for Geosciences: Scatter Plots and PDF reports

Learn how to create scatter plots from satellite imagery and automate a PDF reporting engine with the results

Maurício Cordeiro
Apr 12 · 8 min read

Introduction

Figure 1: Representation of the waterdetect PDF report in a Sentinel 2 scene from Mexico. Image by author.

Step 1- Install PyPDF2

!pip install PyPDF2
from PyPDF2 import PdfFileMerger

Step 2- Create the RGB PDF

Step 3- Create masked RGB PDF files

Code output.

Step 3- Creating Scatter Plots

Original shape: (1021, 1000)
Fixing first dimension as size 2: (2, 510500)
Reshaping it to a vector: (1021000,)
Code output.
Code output.
land = ~(clouds | shadows | water)
groups = ['land', 'clouds', 'shadows', 'water']
masks = [land, clouds, shadows, water]
colors = ['green', 'orange', 'brown', 'blue']
for group, mask, color in zip(groups, masks, colors):
print(f'Group: {group} - Color: {color}')
Results:
Group: land - Color: green
Group: clouds - Color: orange
Group: shadows - Color: brown
Group: water - Color: blue
Code output.

Step 4- Save Scatter Plots

Code output.

Step 5- Create PDF

Figure 2: Example of PDF report. Image by author.

Notebook

Conclusion

Other posts from Python for Geosciences series

References:

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data…

Sign up for Analytics Vidhya News Bytes

By Analytics Vidhya

Latest news from Analytics Vidhya on our Hackathons and some of our best articles! Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Maurício Cordeiro

Written by

Doctorate student @ Université Paul Sabatier (Toulouse). Water Resources Specialist at the Brazilian National Water Agency.

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Maurício Cordeiro

Written by

Doctorate student @ Université Paul Sabatier (Toulouse). Water Resources Specialist at the Brazilian National Water Agency.

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store