Demo#
Be sure to install the python packages as described in the Command Line Tools section.
Also, for this demo specifically, also install ipyleaflet with
pip install ipyleaflet
jupyter nbextension enable --py widgetsnbextension
The following tutorial can be run in an ipython notebook or in an ipython shell.
We will start with the necessary imports
import os
import json
import requests
import pkg_resources
from ipyleaflet import Map, GeoJSON
from gmpacket.scan import scan_gmp
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 6
3 import requests
4 import pkg_resources
----> 6 from ipyleaflet import Map, GeoJSON
7 from gmpacket.scan import scan_gmp
ModuleNotFoundError: No module named 'ipyleaflet'
Now we will read in the example data that is in the data directory of the gmpacket package
datapath = os.path.join('data', 'examples', 'sps-100-200-example.json') #
data_file = pkg_resources.resource_filename('gmpacket', datapath)
with open(data_file, 'r') as f:
data = json.load(f)
geo_json = GeoJSON(data=data)
There is only one feature, so we will grab it to set the center of the map
lon, lat, depth = geo_json.data['features'][0]['geometry']['coordinates']
m = Map(center=(lat, lon), zoom=7)
m.add_layer(geo_json)
m
Now we can use the scan_gmp
function to print a summary of the example data
scan_gmp(data_file, print_what='summary')
We can also change the print_what
argument to also include the metrics
scan_gmp(data_file, print_what='all')