Add shapefile
In [1]:
Copied!
import geodemora
import os
import geodemora
import os
In [2]:
Copied!
m = geodemora.Map()
m
m = geodemora.Map()
m
In [3]:
Copied!
style = {
"stroke": True,
"color": "#ff0000",
"weight": 2,
"opacity": 1,
"fill": True,
"fillColor": "#000000",
"fillOpacity": 0.4,
}
style = {
"stroke": True,
"color": "#ff0000",
"weight": 2,
"opacity": 1,
"fill": True,
"fillColor": "#000000",
"fillOpacity": 0.4,
}
In [4]:
Copied!
in_shp = "./data/countries.shp"
in_shp = "./data/countries.shp"
In [5]:
Copied!
m.add_shapefile(in_shp, style = style, layer_name="Shapefile")
m.add_shapefile(in_shp, style = style, layer_name="Shapefile")
--------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) Input In [5], in <cell line: 1>() ----> 1 m.add_shapefile(in_shp, style = style, layer_name="Shapefile") File ~/.local/lib/python3.9/site-packages/geodemora/geodemora.py:118, in Map.add_shapefile(self, in_shp, style, layer_name) 109 def add_shapefile(self, in_shp, style=None, layer_name="Untitled"): 110 """Add a shapefile to ipyleaflet map object. 111 112 Args: (...) 115 layer_name (str, optional): The layer name for the GeoJSON layer. Defaults to "Untitled". 116 """ --> 118 geojson = shp_to_geojson(in_shp) 119 self.add_geojson(geojson, style = style, layer_name = layer_name) File ~/.local/lib/python3.9/site-packages/geodemora/geodemora.py:155, in shp_to_geojson(in_shp, out_geojson) 152 in_shp = os.path.abspath(in_shp) 154 if not os.path.exists(in_shp): --> 155 raise FileNotFoundError("The provided shapefile could not be found.") 157 sf = shapefile.Reader(in_shp) 158 geojson = sf.__geo_interface__ FileNotFoundError: The provided shapefile could not be found.
In [6]:
Copied!
in_geojson = "./data/countries.json"
in_geojson = "./data/countries.json"
In [7]:
Copied!
m.add_geojson(in_geojson, layer_name="GeoJSON")
m.add_geojson(in_geojson, layer_name="GeoJSON")
--------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) Input In [7], in <cell line: 1>() ----> 1 m.add_geojson(in_geojson, layer_name="GeoJSON") File ~/.local/lib/python3.9/site-packages/geodemora/geodemora.py:84, in Map.add_geojson(self, in_geojson, style, layer_name) 81 if isinstance(in_geojson, str): 83 if not os.path.exists(in_geojson): ---> 84 raise FileNotFoundError("The provided GeoJSON file could not be found.") 86 with open(in_geojson) as f: 87 data = json.load(f) FileNotFoundError: The provided GeoJSON file could not be found.
In [ ]:
Copied!
Last update:
2022-06-06