{"id":21602991,"url":"https://github.com/rbhatia46/spatio-temporal-dbscan","last_synced_at":"2025-06-16T21:37:55.090Z","repository":{"id":112799413,"uuid":"288983682","full_name":"rbhatia46/Spatio-Temporal-DBSCAN","owner":"rbhatia46","description":"Spatio Temporal DBSCAN algorithm in Python. Useful to cluster spatio-temporal data with irregular time intervals, a prominent example could be GPS trajectories collected using mobile devices.","archived":false,"fork":false,"pushed_at":"2020-08-20T11:38:43.000Z","size":192,"stargazers_count":34,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T00:06:12.145Z","etag":null,"topics":["clustering","dbscan","spatio-temporal-analysis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rbhatia46.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-20T11:06:22.000Z","updated_at":"2025-03-24T01:46:18.000Z","dependencies_parsed_at":"2023-09-15T09:46:35.273Z","dependency_job_id":null,"html_url":"https://github.com/rbhatia46/Spatio-Temporal-DBSCAN","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbhatia46%2FSpatio-Temporal-DBSCAN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbhatia46%2FSpatio-Temporal-DBSCAN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbhatia46%2FSpatio-Temporal-DBSCAN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbhatia46%2FSpatio-Temporal-DBSCAN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rbhatia46","download_url":"https://codeload.github.com/rbhatia46/Spatio-Temporal-DBSCAN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248330084,"owners_count":21085651,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clustering","dbscan","spatio-temporal-analysis"],"created_at":"2024-11-24T19:14:51.522Z","updated_at":"2025-04-11T02:35:23.150Z","avatar_url":"https://github.com/rbhatia46.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Spatio-temporal DBSCAN algorithm implemented using Python.\n\n##  Working of the algorithm\n\nAlgorithm is quite similar to the usual DBSCAN algorithm, with an addition to incorporate the temporal information, if any.\n\nThere are primarily 3 parameters in this implementation - \n\n* eps1/spatial threshold - This is similar to epsilon in DBSCAN\n* eps2/temporal threshold\n* min_neighbors - This is similar to MinPts in DBSCAN.\n\nIf the time difference between successive points is within eps2 AND the distance between successive points is less than eps1, they belong to same cluster.\n\nThere are no defined rules for choosing the values of these parameters, selection of these depend entirely on specific application and use-case.\n\n**Notice I have used AND in above statement, i.e. both conditions must be followed, for points to belong to the same cluster.**\n\nAn intuitive explanation can be understood by the image below - \n\n\n\n![](./static/working.png)\n\nIf you need some more clariications, here are some [slides](http://www.bios.unc.edu/~dzeng/BIOS740/Qin_Bios740.pdf) by Department of Statistics and Operations Research, The University of North Carolina\n\n## An Important Note before usage - \nIf you are using this for GPS data, ensure that you convert the CRS of latitude, longitude to UTM.(you can use this [library](https://pypi.org/project/utm/) to do that), that is because this algorithm needs to calculate multiple distances between points, it optimizes by assuming latitude and longitude columns in UTM projection(since Euclidean distance is simpler and faster to calculate than haversine).\n\n## Usage\n\n```python\nimport st_dbscan\nst_dbscan = st_dbscan.STDBSCAN(spatial_threshold=50, temporal_threshold=700,\n                         min_neighbors=2)\nst_dbscan.fit_transform(data,col_lat='latitude',col_lon='longitude',col_time='ts')\n```\n* As mentioned, above assumes your latitude and longitude are in UTM Projection.\n* Invoking .fit_transform() returns a Pandas Series with cluster labels\n\n\nFor detailed explanation, you can refer the following paper - \n```\nBirant, D. and Kut, A. (2007). St-dbscan: An algorithm for clustering \nspatial–temporal data. Data \u0026 Knowledge Engineering, 60(1):208 – 221. \nIntelligent Data Mining.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbhatia46%2Fspatio-temporal-dbscan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frbhatia46%2Fspatio-temporal-dbscan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbhatia46%2Fspatio-temporal-dbscan/lists"}