mirror of
https://github.com/bellingcat/geoclustering.git
synced 2026-06-10 20:48:29 +03:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3cc3c30e03 | ||
|
|
c9d36c6bf3 | ||
|
|
62da0806c7 |
@@ -8,10 +8,6 @@ import geoclustering.encoding as encoding
|
||||
import geoclustering.io as io
|
||||
|
||||
|
||||
def print_debug(s):
|
||||
click.secho(s, fg="bright_black")
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Tool to cluster geolocations. A cluster is created when a certain number of points (--size) each are within a given distance (--distance) of at least one other point in the cluster. Input is supplied as a csv file. At a minimum, each row needs to have a 'lat' and a 'lon' column. Other rows are reflected to the output."
|
||||
)
|
||||
@@ -54,19 +50,19 @@ def print_debug(s):
|
||||
@click.option("--debug", is_flag=True, help="Print debug output.")
|
||||
@click.argument("filename", type=click.Path(exists=True))
|
||||
def main(distance, size, output, filename, algorithm, open, debug):
|
||||
if debug:
|
||||
print_debug(f"Reading input from {Path(filename).absolute()}")
|
||||
def print_debug(s):
|
||||
if debug:
|
||||
click.secho(s, fg="bright_black")
|
||||
|
||||
df = io.read_csv_file(filename)
|
||||
if debug:
|
||||
print_debug(f"Read {len(df)} valid coordinates")
|
||||
print_debug(f"Read {len(df)} valid coordinates from {Path(filename).absolute()}")
|
||||
|
||||
clusters = clustering.cluster_locations(
|
||||
df=df, algorithm=algorithm, radius_km=distance, min_cluster_size=size
|
||||
)
|
||||
|
||||
if not bool(clusters):
|
||||
click.echo("Did not find clusters matching input parameters.")
|
||||
click.secho("Did not find clusters matching input parameters.", fg="yellow")
|
||||
return
|
||||
|
||||
print_debug(f"Found {len(clusters)} valid clusters using {algorithm}")
|
||||
@@ -83,6 +79,8 @@ def main(distance, size, output, filename, algorithm, open, debug):
|
||||
print_debug(f"Opening visualization in default browser")
|
||||
webbrowser.open_new_tab("file://" + str(vis.absolute()))
|
||||
|
||||
click.secho("Clustering completed.", fg="green")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -2,7 +2,7 @@ _MAJOR = "0"
|
||||
_MINOR = "2"
|
||||
# On main and in a nightly release the patch should be one ahead of the last
|
||||
# released build.
|
||||
_PATCH = "0"
|
||||
_PATCH = "1"
|
||||
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
|
||||
# https://semver.org/#is-v123-a-semantic-version for the semantics.
|
||||
_SUFFIX = ""
|
||||
|
||||
Reference in New Issue
Block a user