Skip to content
Study / Practical
Python for GIS: scripting, GDAL and spatial statistics
Twenty parts, written for beginners. Parts 1 to 16 build their own small sample data, so every example runs on any computer with no downloads. Parts 17 to 20 are intermediate and use real Bengaluru data: PyQGIS, spatial statistics, a Landsat 8 scene, and a final project that brings pandas, GeoPandas and GDAL together.
22 partsPython 3pandasGeoPandasGDALrasterioSQLFree software
Python basics
6 parts- 01Python basics: variables, numbers and textInstall Python, run your first lines, and learn variables, data types and string cleaning by describing a city the way a GIS attribute table does.
- 02Python collections: lists, tuples, sets, dictionariesStore many cities, coordinates and road classes at once. Learn when to use a list, tuple, set or dictionary, with GIS records as the examples.
- 03Python decisions and loopsClassify cities by population, validate coordinates and process many records with if, for, while and list comprehensions.
- 04Python functions and errorsWrite reusable functions for distance and classification, handle bad values with try and except, and test your code with assert.
- 05Python files, CSV, JSON, dates and modulesRead and write text, CSV and JSON files, build file paths with pathlib, work with dates, and put reusable code in your own module.
- 06Python mini project: city data cleanerCombine everything from Python basics into one script that cleans a messy list of city records, validates coordinates, logs rejected rows and writes CSV and JSON output ready for pandas and GeoPandas.
Pandas
3 parts- 07Pandas first steps: read, filter, sortLoad a cities table into a pandas DataFrame, inspect it, find missing values, filter with conditions and sort. Every step is explained for a beginner.
- 08Pandas groupby, merge, reshape, classes and datesSummarise a table by group, join two tables on a key, reshape wide and long data, classify values into bins, and convert text to dates and numbers.
- 09Pandas text cleaning with .str methodsClean place names, road codes and addresses with pandas .str methods: strip, replace, split, contains, match, extract and findall, with a gentle introduction to regular expressions.
GeoPandas
2 parts- 10GeoPandas: points, CRS, measuring and mapsTurn a table of latitude and longitude into a GeoDataFrame, set and change the CRS, measure distance and area correctly, draw a map and save the layer.
- 11GeoPandas: spatial join, buffer, overlay, dissolveCount points in polygons, find what lies near a road, measure how much of each district is flooded and merge districts into zones, using a small invented dataset you can run anywhere.
GDAL
2 parts- 12GDAL rasters: inspect, reproject, clip, mosaic, calculateUse the GDAL Python bindings to read raster metadata, handle NoData, convert, reproject, clip, mosaic and run a raster calculation on a small terrain raster built in the first step.
- 13GDAL/OGR vectors: convert, filter, rasterize, polygonizeUse the OGR side of GDAL to inspect vector files, convert between formats, reproject, filter by attribute, turn polygons into a raster and a raster back into polygons. Each step comes with its command line twin.
SQL
2 parts- 14SQL basics for GIS data (PostgreSQL)Learn SQL on a small cities table in PostgreSQL, using pgAdmin's Query Tool: create tables, select, filter, sort, classify, handle missing values, join and summarise. Copy each query and run it.
- 15Spatial SQL with PostGISAdd geometry to SQL with PostGIS. Store points and polygons, measure distances correctly, find what is within a distance, join by location, buffer, intersect and dissolve, and read the results into GeoPandas.
Rasterio
1 part- 16Rasterio: read, clip, reproject, calculateUse rasterio to open a raster, read its metadata and cells, handle NoData, clip it with a polygon, reproject it, calculate NDVI from two bands, take zonal statistics per district, and write new GeoTIFF files.
Python and GDAL
2 parts- 17Python for GIS: PyQGIS, GeoPandas and GDALAutomate QGIS from the Python console, run Processing tools from a script, and use GeoPandas and GDAL for vector and raster work outside the QGIS interface.
- 18Spatial statistics and simulationTest whether a pattern is clustered, measure how similar nearby values are, fit a variogram, and run a small urban growth simulation with a few lines of Python.
Rasterio
1 part- 19Rasterio on real data: Landsat NDVI and zonal statisticsOpen real Landsat 8 bands in rasterio, convert them to reflectance, mask clouds with the quality band, calculate NDVI, take zonal statistics for Bengaluru's five city corporations, and compare them with the share of parks and lakes.
Final project
1 part- 20Final project: a corporation scorecardBring pandas, GeoPandas and GDAL together in one real project: count hospitals, measure parks, lakes and roads, take zonal NDVI with GDAL, join everything into one scorecard, check it, and save it as a CSV, a GeoPackage, a GeoJSON and a map.
Image classification
1 part- 21LULC with Python: K-means and Random ForestTurn a six-band Sentinel-2 image of Bengaluru into a land cover map with Python. Group pixels with K-means, train a Random Forest on labelled samples, check the result against independent reference points, and measure the area of each class.
Time series
1 part- 22Raster time series with PythonStack twelve monthly NDVI rasters into one array, read the seasonal curve of a field and a town, handle a month with missing cells, and map when each place is greenest. A gentle first project with satellite time series, using NumPy, pandas and rasterio.

