Skip to main content

Python package to detect suspicious OpenStreetMap changesets

Project description

osmcha

OSM Changeset Analyser, osmcha, is a Python package to detect suspicious OSM changesets. It was designed to be used with osmcha-django, but also can be used standalone or in other projects.

You can report issues or request new features in the the osmcha-frontend repository.

https://badge.fury.io/py/osmcha.svg https://travis-ci.org/willemarcel/osmcha.svg https://coveralls.io/repos/willemarcel/osmcha/badge.svg

Installation

pip install osmcha

Usage

Python Library

You can read a replication changeset file directly from the web:

c = ChangesetList('https://planet.openstreetmap.org/replication/changesets/002/236/374.osm.gz')

or from your local filesystem.

c = ChangesetList('tests/245.osm.gz')

c.changesets will return a list containing data of all the changesets listed in the file.

You can filter the changesets passing a GeoJSON file with a polygon with your interest area to ChangesetList as the second argument.

Finally, to analyse an especific changeset, do:

ch = Analyse(changeset_id)
ch.full_analysis()

Customizing Detection Rules

You can customize the detection rules by defining your prefered values when initializing the Analyze class. See below the default values.

ch = Analyse(changeset_id, create_threshold=200, modify_threshold=200,
  delete_threshold=30, percentage=0.7, top_threshold=1000,
  suspect_words=[...], illegal_sources=[...], excluded_words=[...])

Command Line Interface

The command line interface can be used to verify an especific changeset directly from the terminal.

Usage: osmcha <changeset_id>

Detection Rules

osmcha works by analysing how many map features the changeset created, modified or deleted, and by verifying the presence of some suspect words in the comment, source and imagery_used fields of the changeset. Furthermore, we also consider if the software editor used allows to import data or to do mass edits. We consider powerfull editors: JOSM, Merkaartor, level0, QGIS and ArcGis.

In the Usage section, you can see how to customize some of these detection rules.

Possible Import

We tag a changeset as a possible import if the number of created elements is greater than 70% of the sum of elements created, modified and deleted and if it creates more than 1000 elements or 200 elements case it used one of the powerfull editors.

Mass Modification

We consider a changeset as a mass modification if the number of modified elements is greater than 70% of the sum of elements created, modified and deleted and if it modifies more than 200 elements.

Mass Deletion

All changesets that delete more than 1000 elements are considered a mass deletion. If the changeset deletes between 200 and 1000 elements and the number of deleted elements is greater than 70% of the sum of elements created, modified and deleted it’s also tagged as a mass deletion.

Suspect words

The suspect words are loaded from a yaml file. You can customize the words by setting another default file with a environment variable:

export SUSPECT_WORDS=<path_to_the_file>

or pass a list of words to the Analyse class, more information on the section Customizing Detection Rules. We use a list of illegal sources to analyse the source and imagery_used fields and another more general list to examine the comment field. We have also a list of excluded words to avoid false positives.

New mapper

Verify if the user has less than 5 edits or less than 5 mapping days.

User has multiple blocks

Changesets created by users that has received more than one block will be flagged.

Unknown iD instance

Verify the changesets created with iD editor to check the host instance. The trusted iD instances are: OSM.org, Strava, ImproveOSM, iDeditor, Hey, Mapcat and iD indoor, Softek and RapiD.

If you deploy an iD instance for an organization, please let us know so we can whitelist it.

Tests

To run the tests on osmcha:

git clone https://github.com/willemarcel/osmcha.git
cd osmcha
pip install -e .[test]
py.test -v

Changelog

Check CHANGELOG for the version history.

License

GPLv3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osmcha-0.7.0.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

osmcha-0.7.0-py2.py3-none-any.whl (22.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file osmcha-0.7.0.tar.gz.

File metadata

  • Download URL: osmcha-0.7.0.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.3

File hashes

Hashes for osmcha-0.7.0.tar.gz
Algorithm Hash digest
SHA256 d9c47047519023ff96d200fd9677a5f995cbca070966c4ef171f3a4748d3199f
MD5 dea4769f83e5c2fd2c3b828d36dd87e3
BLAKE2b-256 b944f46561ed46cb83581dd464a039a6a5369423f43b14ce10592b6deb8fe354

See more details on using hashes here.

File details

Details for the file osmcha-0.7.0-py2.py3-none-any.whl.

File metadata

  • Download URL: osmcha-0.7.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.3

File hashes

Hashes for osmcha-0.7.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d27f652442f8bf838bcdd0a0af0bdb51d9ec8c2eb1fcf496d2178246ba68af4f
MD5 0ce6e1e60e4070feb55bc907eb6a5568
BLAKE2b-256 ffd0b971eb2a9a2a7d7a9b1a34a3652d87e5ee3f84f0eb4c07338bfeedde8d11

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page