I am trying to go through the following notebook. https://developer.ibm.com/tutorials/working-with-geospatial-vector-data-in-python
It is written really well but at the end, I am getting an error message. Been trying to understand what I am doing wrong. This is the block of code that is, I think, causing it:
# define the helper function
def download_file_to_local(project_filename, local_file_destination=None, project=None):
"""
Uses project-lib to get a bytearray and then downloads this file to local.
Requires a valid `project` object.
Args:
project_filename str: the filename to be passed to get_file
local_file_destination: the filename for the local file if different
Returns:
0 if everything worked
"""
project = project
# get the file
print("Attempting to get file {}".format(project_filename))
_bytes = project.get_file(project_filename).read()
# check for new file name, download the file
print("Downloading...")
if local_file_destination==None: local_file_destination = project_filename
with open(local_file_destination, 'wb') as f:
f.write(bytearray(_bytes))
print("Completed writing to {}".format(local_file_destination))
return 0
The Second code block:
download_file_to_local('london_pois.zip', project=project)
zipfile = "zip://./london_pois.zip!london_pois/london_pois.dbf"
pois = gpd.read_file(zipfile)
This is the error message:
Attempting to get file london_pois.zip
2020-04-26 12:16:21,947 - __PROJECT_LIB__ - ERROR - Project___get_file_name_from_asset_metadata(): asset name [london_pois.zip] can not be found!
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-228-b1f651d5708a> in <module>
----> 1 download_file_to_local('london_pois.zip', project=project)
2 zipfile = "zip://./london_pois.zip!london_pois/london_pois.dbf"
3 pois = gpd.read_file(zipfile)
<ipython-input-227-bcdb30c6cafe> in download_file_to_local(project_filename, local_file_destination, project)
17 # get the file
18 print("Attempting to get file {}".format(project_filename))
---> 19 _bytes = project.get_file(project_filename).read()
20
21 # check for new file name, download the file
/opt/conda/envs/Python36/lib/python3.6/site-packages/project_lib/project.py in get_file(self, file_name, direct_storage, direct_os_retrieval)
214 final_file_name = [file_name]
215 if (not direct):
--> 216 final_file_name = self._get_file_name_from_asset_metadata(file_name)
217
218 if (final_file_name is None):
/opt/conda/envs/Python36/lib/python3.6/site-packages/project_lib/project.py in _get_file_name_from_asset_metadata(self, asset_name)
522 asset_id = self._core.get_asset_id_from_asset_name(asset_name)
523 if (not asset_id):
--> 524 logger.log_and_throw("Project___get_file_name_from_asset_metadata(): asset name [{}] can not be found!".format(asset_name))
525
526 # fetch data object keys
/opt/conda/envs/Python36/lib/python3.6/site-packages/project_lib/utils/logger.py in log_and_throw(self, err_msg)
50 # see https://github.ibm.com/ax/planning/issues/4946
51 self.logger.error(err_msg)
---> 52 raise RuntimeError(err_msg)
53
54 def log_and_throw_response(self, method_name, res_status_code, res_text):
RuntimeError: Project___get_file_name_from_asset_metadata(): asset name [london_pois.zip] can not be found!
------------------------------
naveen ganpat
------------------------------
#GlobalAIandDataScience#GlobalDataScience