Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Bringing the pillars of reproducible spatial science together

Open In Colab

In the previous chapters, you learned how to write readable Python, organize larger workflows, code defensively, capture software environments, and document your spatial projects clearly. Each of these practices improves the quality of your code on its own. In this final chapter, we make the scientific connection explicit.

Together, these practices are the building blocks of reproducible research.

In computational spatial analysis, reproducibility is not just an abstract academic ideal; it is a practical, baseline property of a trustworthy workflow. If your repository contains the data, the code, the environment, and enough documentation for another person to recreate your outputs without guessing, your workflow is reproducible. If not, critical parts of your science remain hidden.

This matters immensely because geospatial workflows are complex. A final map or summary statistic is rarely the result of a single operation. It depends on a deep stack of computational choices:

If these intermediate steps cannot be rerun and verified by another researcher, the final result becomes impossible to trust.

This chapter brings the whole lesson together. You will learn what reproducibility means in computational research, how it differs from replicability, why it should be treated as a minimum standard, where it most often breaks down, and what a realistic reproducibility standard looks like for SDS210 projects.


1. What reproducibility means

In computational research, reproducibility has a very specific definition. According to The Turing Way, a foundational handbook for data science, reproducibility means that if someone else takes your exact original data and your exact original code, they should be able to generate your exact original results.

That definition sounds simple, but it is worth taking seriously. A workflow is not reproducible merely because:

A workflow is only reproducible when another person can actually run it again and obtain the exact same outputs.

The four core ingredients

True reproducibility requires sharing the entire computational context. This involves four pillars, which correspond exactly to the themes you have developed across this module:

  1. Code: The analytical steps and defensive checks must be available and readable.

  2. Data: The raw inputs must be available, unmodified, and clearly accessible via relative paths.

  3. Environment: The relevant software setup and package versions must be recorded.

  4. Documentation: The workflow must be understandable enough to rerun without guesswork.

A geospatial example

Suppose you build a notebook that extracts elevation values from a 25 m DEM at various climate station locations, then maps the result.

A reproducible version of that project makes it possible to load the same station layer, load the same DEM, reproject the data in the same way, run the extraction again, and regenerate the exact same map down to the pixel.

If the notebook only works because of a hidden CSV file, an undeclared package installed on your laptop, or manual preprocessing you did in QGIS before opening Python, the workflow is not reproducible. Furthermore, if the script runs but the map looks slightly different because a newer library handled a projection differently, the research is also not reproducible.

This point is critical. Reproducibility is not primarily about archiving code as a static object. It is about recovering the result.

Interactive Explorer: Reproducibility Stress Test.
Select common threats such as absolute paths, manually edited raw data, hidden notebook state, missing environment files, unfixed randomness, or vague documentation to see which pillar breaks and how a reproducible workflow repairs it. For improved visibility of the explorer, follow this link.


2. Reproducibility vs. replicability

The terms reproducibility and replicability are often used interchangeably, but in modern science, they mean two distinct things. Understanding the difference is critical.

A helpful way to think about the distinction is through this simple formula:

A spatial example

Imagine you publish a project showing that proximity to urban parks in Zurich correlates with lower summer land surface temperatures.

Reproducibility asks: “If I download your Zurich data and run your Python notebook, do I get the exact same correlation coefficient?” This tests the integrity of your computational workflow.

Replicability asks: “If I collect new Landsat data for Geneva and apply your overall methodology, do I find the same cooling effect from parks?” This tests the scientific validity of your underlying hypothesis.

The dependency between them

A study can be reproducible without being replicable. For example, the code might run perfectly, but the cooling effect may apply only to Zurich’s specific climate.

However, it is almost impossible to replicate a study if it is not first reproducible. If another researcher cannot figure out exactly how you calculated the temperatures in Zurich, they cannot confidently apply your methods to Geneva.

Why this distinction matters

For your SDS210 projects, reproducibility is the immediate and achievable target. It is the baseline level of scientific reliability that you can directly control within your own repository.

Replicability is the broader goal of science, but it usually requires a larger research design, new data collection, and independent investigation that extends beyond a single semester project.

Concept Check: Reproduce or Replicate?

You share your Zurich urban heat notebook with a classmate. They download the same input files, create the same environment, run the same notebook, and check whether they obtain your exact map and correlation coefficient. Which scientific question are they testing?

A. Reproducibility, because they are using the same data and same code to recover the same result.

B. Replicability, because a different person is running the workflow.

C. Neither, because reproducibility only applies to published journal articles.


3. Why reproducibility is a standard

As outlined in the PLOS Ten Simple Rules for Reproducible Computational Research, reproducibility is not the ultimate goal of science. The ultimate goal is discovering the truth. However, reproducibility is the minimum standard for judging computational work.

In a traditional scientific paper, a reader must trust the author’s written description of the methods. In computational science, the code is the method. Once your method is formalized as a script, there is no good reason for the workflow to remain mysterious or irrecoverable.

What reproducibility makes possible

A reproducible workflow allows collaborators and reviewers to:

Without reproducibility, the final result is much harder to evaluate scientifically.

A geospatial case

Suppose you produce a map of snow cover trends across Switzerland. If the workflow is reproducible, another person can inspect the input raster stack, check how the annual summaries were computed, verify the chosen CRS, rerun the trend calculation, and confirm that the exact same map appears.

If the workflow is not reproducible, the final map becomes much harder to assess. A reviewer cannot check if an outlier was dropped accidentally, or if a CRS reprojection silently distorted the area calculations. The map may still be correct, but the scientific trust in the result is much weaker because the analytical path cannot be fully recovered.

Reproducibility is not perfection

It is important to keep this grounded. Reproducibility does not guarantee that the science is excellent. A workflow can be fully reproducible and still be based on weak assumptions, poor data, or flawed statistical methods.

By making your work reproducible, you are not claiming your science is flawless. You are simply allowing others to verify, trust, and evaluate your computational process.


4. Common threats to reproducibility

Even well-intentioned data scientists often fall into traps that break reproducibility. Most reproducibility failures are not dramatic, catastrophic errors. They are usually ordinary workflow habits that seem harmless in the moment but create invisible problems later.

This section brings together the most common threats you have encountered throughout this module.

Modifying raw data

One of the most fatal habits is performing important preprocessing steps manually, outside of the code. Opening a CSV file in Excel to delete a few “bad” rows, or clipping a layer interactively in QGIS and overwriting the original input file, breaks reproducibility immediately. There is no record of what was changed, making it impossible for anyone else to reproduce your work from the true raw data.

Hidden notebook state

A notebook may only work on your machine because you ran the cells in a specific, hidden order. For example, you may define a variable at the bottom, then scroll up to use it at the top. When someone else opens your file and clicks “Run All”, the notebook immediately crashes.

A strong notebook must pass a simple test: restart the kernel, run all cells from top to bottom, and recover the final outputs without any manual intervention.

Fragile file paths

Using absolute paths guarantees the code will fail on any other computer. As soon as the project is shared or moved, a path like this breaks the workflow:

gpd.read_file("C:/Users/Hendrik/Desktop/SDS210/data/raw/stations.gpkg")

Environment drift

A notebook may run perfectly today because your laptop happens to have the right packages installed. Without an environment.yml or requirements.txt file recording the exact package versions, your software setup remains a hidden assumption. This leads to silent failures when a geospatial library inevitably updates how it handles an algorithm in the future. This problem is called version drift.

Magic numbers and silent assumptions

Some of the most important analytical choices are often hidden inside the code without explanation:

If you hard-code these magic numbers without an inline comment explaining why you chose them, the workflow may still run, but the scientific reasoning becomes impossible to interpret.

Unfixed randomness

Many spatial data science workflows include random processes, such as the stochastic initialization of a machine learning model, train/test data splits, or the random sampling of points. If the random seed is not fixed, the workflow will produce slightly different outputs on every single run.

Fixing the seed makes the randomness controlled and repeatable:

import numpy as np

# Fixing the seed guarantees the exact same "random" numbers every time
np.random.seed(42)
random_values = np.random.rand(5)
print(random_values)

The accumulated fragility of spatial workflows

Consider a project that samples random points inside a study area, extracts land cover classes, and trains a classifier. Reproducibility may fail because the raw raster was manually edited, the file paths are absolute, the environment is undocumented, the random seed is left unfixed, and the notebook only works after a specific hidden cell order.

None of these issues alone is unusual. Together, they make the workflow impossible to trust.


5. Version control as a reproducibility tool

At the beginning of this course, you were introduced to Git as a way to keep track of changes. While Git is often viewed merely as a convenient backup tool or a “never-forget undo button”, it is actually a cornerstone of reproducible science. In fact, The Turing Way puts version control at the very front of reproducible research practice.

Version control is not just about saving files; it is a permanent record of how your spatial analysis evolves over time.

Commits as meaningful research milestones

In spatial data science, projects rarely work perfectly on the first try; they develop through trial and error. Instead of relying on confusing filenames like final_final_v3.ipynb, Git saves your project as a timeline of discrete, recoverable states.

Each of these save points, or commits, requires a short message explaining what changed and why. By writing helpful commit messages, such as “Add NDVI calculation for Landsat 8 imagery”, you turn your Git history into a traceable, readable log of your scientific development.

Tracking code, not large raw data

A common pitfall in spatial projects is trying to version control everything. Git works best when tracking code and documentation, not heavy spatial data. Large datasets like .tif or .csv files should be kept out of your repository’s history.

You can enforce this by creating a .gitignore file and adding your data/ folder to it. This ensures your repository remains a lightweight, shareable record of your methods, rather than becoming bloated with massive raw inputs.

Linking version control to collaboration and transparency

When you link your local Git repository to an online platform like GitHub, it acts as a shared, central copy of your project. This links version control directly to scientific transparency. Anyone reviewing your work can see not just the final map, but the step-by-step evolution of the code that produced it, allowing collaborators to inspect changes and experiment safely on parallel branches without overwriting your work.


6. What you can realistically achieve

In professional data engineering or large-scale academic labs, reproducible research often involves more complex infrastructure: Docker containers, continuous integration and deployment (CI/CD) pipelines, and automated testing suites.

Because your projects are usually manageable in scope, involving a handful of vector and raster inputs, a few notebooks, and a modest number of dependencies, practical reproducibility is entirely within reach.

A strong student project should aim for this lightweight, high-quality standard:

This approach requires only a little extra discipline, but it elevates your work from a fragile script to a robust, trustworthy piece of science.

Honest limits

At the same time, spatial projects are often constrained by real-world limitations. You might face:

Being reproducible does not mean pretending these issues do not exist. It means documenting them honestly. If your raw data is too large (>100 MB) to host in your repository, your README should explicitly state where and how to download it. Make the workflow as rerunnable as possible within your actual constraints.


7. A reproducibility checklist

One of the best ways to turn reproducibility into a realistic habit is to use a checklist. Before submitting your final project, sharing code with a collaborator, or publishing your first scientific paper, run through these practical questions.

If you can answer “yes” to all of these, your project is in excellent shape.

The checklist

Why this helps

A checklist turns a broad scientific principle into specific, actionable steps. You can look at the list and ask, “Which concrete condition is still missing?” That makes improvement much easier and far less intimidating.


8. Exercise

Below is a deliberately weak project scenario. Your task is to evaluate its reproducibility based on the principles discussed throughout this module.

Project scenario

A student submits a geospatial project on urban heat that:

Task

  1. Identify at least four threats to reproducibility in this project.

  2. Suggest a concrete improvement for each one.

  3. Decide whether the project is:

    • reproducible

    • partly reproducible

    • not yet reproducible

  4. Write two short sentences explaining your judgment.

Your workspace

Threat 1:
Improvement:

Threat 2:
Improvement:

Threat 3:
Improvement:

Threat 4:
Improvement:

Overall judgment:
Reasoning:

9. Summary

Reproducible research means that a workflow can be rerun—and the exact results recovered—using the same code, data, and environment.

In this chapter, you learned that:

Most importantly, reproducibility is not a single task added at the very end of a project. It is the cumulative result of many good choices made throughout the workflow.

A conceptual diagram showing the five pillars of reproducible spatial science (clean Python, project organization, defensive coding, environment files, and clear documentation) feeding into a central computational workflow to produce a verified result.

Figure 1:The pillars of reproducible spatial science. A unified view showing how clean code, logical project organization, defensive coding, locked environments, and clear documentation flow together into a computational process to produce verified, reproducible results.


10. Looking back at the lesson

This lesson has taken you on a journey from basic code quality to professional scientific workflow quality.

You learned how to:

  1. Write readable Python: using PEP 8, clear naming conventions, and modular functions.

  2. Organize projects: moving beyond one long, messy notebook to structured directories and separated logic.

  3. Track progress securely: using Git and GitHub to record the evolution of your project safely.

  4. Code defensively: making spatial workflows robust against hidden failures, mismatched CRSs, and invalid geometries.

  5. Record software environments: using environment.yml to lock down complex geospatial dependencies and prevent version drift.

  6. Document workflows: writing strong READMEs, informative docstrings, and self-explanatory scientific figures.

  7. Practice reproducible research: combining all these elements into a workflow that another human being can actually rerun and trust.

These are not just software engineering skills. They are fundamental research skills.

As you move into larger semester projects, your master’s thesis, or collaborative analysis in the professional world, these habits will matter more and more. In many cases, the clarity and reliability of your workflow will matter just as much as the analytical method itself.