
This course covers agentic coding workflows specializing in geospatial data science. You will get hands-on experience setting up your agent and understand how to use Skills and MCP servers to augment domain-specific capabilities. We cover best practices for using coding agents to rapidly solve complex problems - grounded in established science and human-in-the-loop validation. We cover hands-on examples using Claude Code - including crime hotspot mapping, route optimization, and object detection from aerial imagery. You will also learn how to use agents to manage a personal knowledge base and create a website that automatically updates with new information.
Visit GitHub.com and create a free account. If you already have an account, skip this step.
Follow our Git and GitHub CLI Installation Guide install and configure Git and GitHub CLI.
We will use conda to install the required Python packages and manage local development environment.
Follow our step-by-step Conda Installation Guide to install Miniconda for your operating system.
conda-forge.Your local development environment is now ready.
We recommend Visual Studio Code (VS Code) editor for this workshop.
Follow our step-by-step Visual Studio Code Installation Guide to install and configure VS Code on your system.
Follow our step-by-step Claude Code Installation Guide to install and configure Claude Code on your system.
OpenRouteService (ORS) provides a free API for routing, distance matrix, geocoding, route optimization etc. using OpenStreetMap data. We will use the Optimization API in this course.
We will obtain a key from OpenRouteService so we can use their API. The API is maintained by HeiGIT (Heidelberg Institute for Geoinformation Technology). Visit HeiGIT Sign Up page and create an account. Once your account is activated, you can visit the Dashboard and copy the long string displayed under Basic Key.
The code examples and reference materials used in this workshop are
supplied to you in the claude_code_geospatial.zip file.
Unzip this file to a directory - preferably to the
<home folder>/Desktop/claude_code_geospatial/
folder.
Download claude_code_geospatial.zip.
Note: Certification and Support are only available for participants in our paid instructor-led classes.
A good practice is to always setup a CLAUDE.md file for
your project. This file contains instructions and rules to be followed
when working inside the project directory. If you already have a
directory with some code or have cloned a Git repository, Claude Code
can automatically create the CLAUDE.md file using the
/init command. Here we are starting with a blank project,
so we will create a new CLAUDE.md file with
instructions.
<home folder>/Desktop/claude_code_geospatial/ where
you have unzipped the data package.

CLAUDE.md. Note
that the filename is case sensitive and needs to have the
.md extension.
# CLAUDE.md
## Geospatial Stack Preferences
- Prefer Python-based approaches
- Use existing packages instead of building solutions from scratch
- My preference for geospatial packages are below
- Pandas for tabular data
- GeoPandas for vector geospatial data
- XArray ecosystem (rioxarray, xarray-spatial etc) for raster geospatial data
- Scikit-learn for Machine Learning
- GeoAI (geoai-py) for Deep Learning
- Web Apps
- Streamlit for data driven apps
- Leaflet for interactive mapping apps
- Self contained HTML for small apps
## Other Preferences
- Write code that is simple to understand and explain
- Always install python packages in a conda environment. Never install anything in the base environment. Ask to change or create a new environment before installing.
- Do not use emojis

cd command to change the
current working directory to the project directory.Windows
Mac/Linux


/help to see all available
commands. Let’s run a few commands. First enable Plan
Mode by entering the /plan command. Next choose the
model using the /model command. The default model choice is
good for now, and you can change the model at any time.
Now we are ready to use Claude Code for our first data analysis task.
We will now use Claude Code to do some data exploration, cleaning and analysis. This will give you a feel of how agents work and how to guide them. We will take the Police.uk data on street-level crime for the City of London Police and identify crime hotspots.
I would like to do an exploratory data analysis of crime data in the folder london_crime_2024.
* Give me a summary of the rows, columns and any missing data.
* Flag any data quality issues.
* Create charts showing different types of crime and monthly patterns.

CLAUSE.md states, all the work
needs to be done in a conda virtual envrionment. Claude will prompt you
to choose an environment. Choose the
claude_code_workshop environment created for this class
and press Enter.

Depending on your operating system, Claude Code version, and selected model, you may see a slightly different set of questions.




output/ subfolder.
Now that we have a good understanding of the data structure, we can ask Claude to help us with analyzing the data. In this section, we will go through the workflow of identifying hotspots off thefts. Starting with data cleaning, we will iteratively improve our analysis and learn how we can use existing references (research papers, manuals etc.) to ground the behavior of the model.
I want to analyze thefts data. Suggest which categories should be merged.




Filter to data to only for the 7 theft-family categories and
write a single merged CSV with those records.
Remove missing data and unnecessary fields.


I want to map the theft hotspots.
Suggest what would be the best technique for the analysis.


Create a static visualiztion using matplotlib using gaussian_kde.



I have some reference material for crime mapping in documents/hotspots.pdf.
Incorporate suggestions from that and give me an updated plan.



Save the updated script and chart with the _v2 suffix.



Use the criteria "Greater than 5x mean" to extract hotspots and convert then to polygons.
Save the results as a GeoJSON london_theft_hotspots.geojson.



It’s a good practice to keep an eye on your token usage and costs. You can use the following command to know the utilization in the current session and how much quota is left in your plan.
/usage

In this section, we will learn how to use Claude Code to build Jupyter notebooks for data analysis and interactively guide the agent to reach the desired solution and validate the results. We will be implementing a real-world scenario of optimizing delivery routes based on a route optimization algorithm.
In your data package, you will find the following files in the
data/route_optimization/ folder.
Delivery_Locations.geojson: A set of 100 addresses in
Washington DC area representing delivery locations.Grocery_Store_Locations.geojson: A set of 14 grocery
store locations which needs to fulfill the delivery to these
locations.We will use Claude Code to build a Jupyter Notebook that builds an end-to-end workflow that loadis the data, finds optimal delivery routes and writes PDF manifests with delivery schedule for each store.
Let’s install the Claude Code for VS Code extension.



Now that we have Claude Code running inside VS Code, we can prompt it to build a Jupyter notebook for us.
claude_code_geospatial is
open in VS Code. Enter the following prompt.I want to build a notebook to find optimal delivery routes.
Create a new notebook scripts/route_optimization.ipynb
Read the .geojson files in data/route_optimization/ folder and
display the data on an interactive map.

CLAUDE.md already has preferences listed for how to setup
the environment and what packages to use. Claude Code will start
creating the notebook and will pause periodically for confirmation. You
can choose Yes to proceed.
route_optimization.ipynb will be created in the
scripts/ folder as instructed.

Now, let’s build the core of our data analysis to find the optimal delivery routes. This is a complex problem that requires a lot more context and direction. We will use the Plan mode and guide Claude Code towards building the code that solves the problem.
route_optimization.ipynb is
open. Open Claude Code from the Toggle Chat button.

I want to use OpenRouteService API.
Give me options on different approaches to plan for the most optimal delivery routes from each store.
Here are the constrants:
- A single trip will consist of 10 deliveries at maximum.
- The delivery will originate at a grocery store and end at the same delivery store.
- All stores are capable of fulfilling the order but can do a maximum of 5 delivery trips each day.
I want to know the most optimal route to minimize the distance traveled along with a schedule of the trips.


<your-api-key> with your actual API key. If you do
have your key handy, you can login to your HeiGIT Account and copy
the long string displayed under Basic Key.Yes, I have a key. Save the API key in a separate cell in the notebook.
ORS_API_KEY='<your-api-key>'

claude_code_workshop conda environment that we have setup.
You can then click Submit answers.



openrouteservice Python package. We can instead ask it to
use the API directly instead of a client library by adding a comment
like below.Instead, use the REST API directly.






When building with AI - you need to spend most of your time validating the results and guiding the model. Let’s learn some techniques for validation.
I see that some stores are not assigned any deliveries even if they are quite close to an address.
The assignment tries to assign 10 deliveries in each route -
making some of them quite long while nearby stores end up without any deliveries.
Update the plan to address this problem.



Save the routes as a single GeoJSON file in the outputs/route_optimization/
folder so I can validate the results.

routes.geojson will be created. Locate it in
the VS Code Explorer. Right-click and select Reveal in File
Explorer to open the folder on your computer.
routes.geojson, along with the source data
Delivery_Locations.geojson and
Grocery_Store_Locations.geojson and verify the
results.
Generate PDF manifests in the outputs/route_optimization/ folder containing
delivery order and addresses for each trip.
1 manifest per store.



This course material is licensed under a Creative Commons Attribution 4.0 International (CC BY 4.0). You are free to re-use and adapt the material but are required to give appropriate credit to the original author as below:
Agentic Coding for Geospatial course by Ujaval Gandhi www.spatialthoughts.com
© 2026 Spatial Thoughts www.spatialthoughts.com
If you want to report any issues with this page, please comment below.