44 attribute table
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# !pip install leafmap
# !pip install leafmap
In [2]:
Copied!
import leafmap
import leafmap
Add vector data to the map and use the GUI to open attribute table.
In [3]:
Copied!
m = leafmap.Map()
url = "https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/countries.geojson"
m.add_geojson(
url,
layer_name="Countries",
fill_colors=['red', 'yellow', 'green', 'orange'],
info_mode=False,
)
in_geojson = 'https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/cable-geo.geojson'
m.add_geojson(in_geojson, layer_name="Cable lines", info_mode=False)
m
m = leafmap.Map()
url = "https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/countries.geojson"
m.add_geojson(
url,
layer_name="Countries",
fill_colors=['red', 'yellow', 'green', 'orange'],
info_mode=False,
)
in_geojson = 'https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/cable-geo.geojson'
m.add_geojson(in_geojson, layer_name="Cable lines", info_mode=False)
m
--------------------------------------------------------------------------- JSONDecodeError Traceback (most recent call last) File ~/.local/lib/python3.9/site-packages/requests/models.py:910, in Response.json(self, **kwargs) 909 try: --> 910 return complexjson.loads(self.text, **kwargs) 911 except JSONDecodeError as e: 912 # Catch JSON-related errors and raise as requests.JSONDecodeError 913 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError File ~/.local/lib/python3.9/site-packages/simplejson/__init__.py:525, in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw) 521 if (cls is None and encoding is None and object_hook is None and 522 parse_int is None and parse_float is None and 523 parse_constant is None and object_pairs_hook is None 524 and not use_decimal and not kw): --> 525 return _default_decoder.decode(s) 526 if cls is None: File ~/.local/lib/python3.9/site-packages/simplejson/decoder.py:373, in JSONDecoder.decode(self, s, _w, _PY3) 372 if end != len(s): --> 373 raise JSONDecodeError("Extra data", s, end, len(s)) 374 return obj JSONDecodeError: Extra data: line 1 column 4 - line 1 column 15 (char 3 - 14) During handling of the above exception, another exception occurred: JSONDecodeError Traceback (most recent call last) File ~/.local/lib/python3.9/site-packages/leafmap/foliumap.py:1089, in Map.add_geojson(self, in_geojson, layer_name, **kwargs) 1088 if in_geojson.startswith("http"): -> 1089 data = requests.get(in_geojson).json() 1090 else: File ~/.local/lib/python3.9/site-packages/requests/models.py:917, in Response.json(self, **kwargs) 916 else: --> 917 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) JSONDecodeError: [Errno Extra data] 404: Not Found: 3 During handling of the above exception, another exception occurred: Exception Traceback (most recent call last) Input In [3], in <cell line: 12>() 4 m.add_geojson( 5 url, 6 layer_name="Countries", 7 fill_colors=['red', 'yellow', 'green', 'orange'], 8 info_mode=False, 9 ) 11 in_geojson = 'https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/cable-geo.geojson' ---> 12 m.add_geojson(in_geojson, layer_name="Cable lines", info_mode=False) 14 m File ~/.local/lib/python3.9/site-packages/leafmap/foliumap.py:1104, in Map.add_geojson(self, in_geojson, layer_name, **kwargs) 1102 raise TypeError("The input geojson must be a type of str or dict.") 1103 except Exception as e: -> 1104 raise Exception(e) 1106 # interchangeable parameters between ipyleaflet and folium. 1107 if "style" in kwargs: Exception: [Errno Extra data] 404: Not Found: 3
Last update:
2022-03-14