├── imgs ├── img1.jpg ├── img2.jpg └── header.png ├── README.md ├── main.py └── .gitignore /imgs/img1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salaheldinaz/WigleKML/HEAD/imgs/img1.jpg -------------------------------------------------------------------------------- /imgs/img2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salaheldinaz/WigleKML/HEAD/imgs/img2.jpg -------------------------------------------------------------------------------- /imgs/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salaheldinaz/WigleKML/HEAD/imgs/header.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Header](imgs/header.png) 2 | 3 | # Wigle {json2kml} Tool 4 | Convert Wigle.net json result file to Kml. So it can be used in Google earth. 5 | 6 | ## Prerequisite 7 | - Python 3+ 8 | - Python module: [simplekml](https://pypi.org/project/simplekml/) 9 | 10 | ## To install python required module: 11 | ```shell 12 | pip3 install simplekml 13 | ``` 14 | 15 | ## Usage: 16 | 1. Download the result json file using [wigle.net API](https://api.wigle.net/swagger) 17 | 18 | 2. Place the downloaded json file in the script folder. 19 | 20 | 3. Run the following command: 21 | ```shell 22 | python3 main.py -i -u 23 | ``` 24 | > Change `` to the json file name. 25 | > 26 | > `-u` is optional parameter to change google earth default icon. 27 | 28 | 4. Open kml file on Google Earth 29 | 30 | ![img2](imgs/img2.jpg) 31 | 32 | 33 | ## More: 34 | Read more at my blog : https://salaheldin.online/blog/wigle-to-google-earth/ 35 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import simplekml 3 | import json 4 | import sys 5 | import getopt 6 | 7 | ''' 8 | Author: Salaheldinaz 9 | Description : Convert Wigle.net json result file to Kml. So it can be used in Google earth. 10 | usage: main.py -i -u 11 | ''' 12 | 13 | 14 | def main(argv): 15 | inputfile = '' # .json 16 | iconurl = 'https://www.iconfinder.com/icons/1249982/download/png/512' 17 | outputfile = '' # .kml 18 | try: 19 | opts, args = getopt.getopt(argv, "hi:u:", ["inputfile=", "iconurl="]) 20 | except getopt.GetoptError: 21 | print('wiglej2k.py -i -u ') 22 | sys.exit(2) 23 | 24 | for opt, arg in opts: 25 | if opt == '-h': 26 | print('wiglej2k.py -i -u ') 27 | sys.exit() 28 | elif opt in ("-i", "--inputfile"): 29 | inputfile = arg 30 | outputfile = str(arg).replace('json', 'kml') 31 | elif opt in ("-u", "--iconurl"): 32 | iconurl = arg 33 | 34 | if inputfile: 35 | with open(inputfile) as json_file: 36 | json_data = json.load(json_file) 37 | 38 | # Create KMl file 39 | kml_data = simplekml.Kml() 40 | kml_data.document.name = outputfile.replace('.kml', '') 41 | devices_collection = kml_data.newfolder(name="Devices") 42 | sharedstyle = simplekml.Style() 43 | sharedstyle.iconstyle.icon.href = iconurl 44 | 45 | count = 0 46 | print(f'Parsing Devices:') 47 | for device in json_data["results"]: 48 | name = device['ssid'] 49 | latitude = device["trilat"] 50 | longitude = device["trilong"] 51 | description = '' 52 | for key, value in device.items(): 53 | description += f'{key}: {value}\n' 54 | 55 | print(f'{name} at {longitude}, {latitude}') 56 | 57 | pnt = devices_collection.newpoint(name=name, description=description, coords=[(longitude, latitude)]) 58 | pnt.style = sharedstyle 59 | count += 1 60 | 61 | print(f'Added {count} devices to KML file {outputfile}.') 62 | kml_data.save(outputfile) 63 | else: 64 | print('Please select input file using -i ') 65 | sys.exit() 66 | 67 | 68 | if __name__ == "__main__": 69 | main(sys.argv[1:]) 70 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | .venv/ 131 | .idea/ 132 | Pipfile 133 | Pipfile.lock 134 | --------------------------------------------------------------------------------