Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2025 May 9;24(1):12.
doi: 10.1186/s12942-025-00399-6.

MaskMyPy: python tools for performing and analyzing geographic masks

Affiliations

MaskMyPy: python tools for performing and analyzing geographic masks

David Swanlund et al. Int J Health Geogr. .

Abstract

Background: Geographic masking is an important but under-utilized technique for protecting and disseminating sensitive geospatial health data. Geographic masks work by displacing static point locations such that the people those locations describe cannot be identified, while at the same time preserving important spatial patterns for analysis. Unfortunately, there is a lack of available tooling surrounding geographic masks which we believe creates an unnecessary barrier towards the adoption of these techniques. As such, this article presents a set of tools for performing, evaluating, and developing geographic masks, called MaskMyPy.

Results: MaskMyPy is an open-source Python package that includes functions for performing geographic masks, including donut, street, location swapping, and Voronoi masks. It also includes a range of tools for evaluating the results of these masks, both with regard to privacy and information loss. Finally, it includes a special class called the 'Atlas' that aims to dramatically streamline mask execution and evaluation. We conducted a short case study to illustrate the power of MaskMyPy in geographic masking research, and in doing so showed that mask performance can range widely due solely to randomization. As such, we recommend that masking researchers test their masks repeatedly across a variety of test datasets.

Conclusion: MaskMyPy makes it easy to apply a variety of geographic masks to a set of sensitive points and then measure which mask provided the most privacy while suffering the least information loss. We believe this style of tooling is important to not only make geographic masks accessible to non-experts, but to enable expert users to better interrogate the masks they develop, and in doing so drive the geographic masking discipline forward.

Keywords: Anonymization; Geographic masking; Geomasking; Geoprivacy; Privacy; Python; Tools.

PubMed Disclaimer

Conflict of interest statement

Declarations. Ethics approval and consent to participate: Not applicable. Consent for publication: Not applicable. Competing interests: The authors declare no competing interests.

Figures

Fig. 1
Fig. 1
an illustration of how points are displaced by (1) donut masking, (2) location swapping, (3) voronoi masking, and 4) street masking. Donut masking (1) displaces points randomly between a minimum and maximum distance. Location swapping (2) displaces points to random nearby addresses (yellow circles) within a minimum to maximum distance. Voronoi masking (3) constructs voronoi polygons around each point, and snaps sensitive points to the closest edge (grey lines). Street masking (4) displaces points along the surrounding street network (grey lines) based on its relative density. Sensitive points are colored red, masked points are colored blue
Fig. 2
Fig. 2
an automatically generated map depicting how each point was displaced from their original, sensitive locations (red) to the masked location (blue). Note that no actual sensitive locations were used in this example, as the data was synthetically generated
Fig. 3
Fig. 3
Box-plots depicting the range of k-satisfaction across 50 iterations of donut masking
Fig. 4
Fig. 4
Box-plots depicting the range of k-satisfaction across 50 iterations of location swapping
Fig. 5
Fig. 5
Box-plots depicting the range of k-satisfaction across 50 iterations of street masking

References

    1. Haley DF, Matthews SA, Cooper HLF, Haardörfer R, Adimora AA, Wingood GM, et al. Confidentiality considerations for use of social-spatial data on the social determinants of health: Sexual and reproductive health case study. Soc Sci Med. 2016;166:49–56. - PMC - PubMed
    1. Kounadi O, Leitner M. Why does geoprivacy matter? The scientific publication of confidential data presented on maps. J Empir Res Hum Res Ethics. 2014;9:34–45. 10.1177/1556264614544103. - PubMed
    1. Armstrong MP, Rushton G, Zimmerman DL. Geographically masking health data to preserve confidentiality. Stat Med. 1999;18:497–525. - PubMed
    1. Hampton KH, Fitch MK, Allshouse WB, Doherty IA, Gesink DC, Leone PA, et al. Mapping health data: improved privacy protection with donut method geomasking. Am J Epidemiol. 2010;172:1062–9. - PMC - PubMed
    1. Kounadi O, Leitner M. Adaptive areal elimination (AAE): a transparent way of disclosing protected spatial datasets. Comput Environ Urban Syst. 2016;57:59–67.

Publication types

LinkOut - more resources