safe.utilities.osm_downloader module

InaSAFE Disaster risk assessment tool developed by AusAid - Import Dialog.

Contact :


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version., output_base_path, extent, progress_dialog=None)[source]

Download shapefiles from Kartoza server.

New in version 3.2.

  • feature_type (str) – What kind of features should be downloaded. Currently ‘buildings’, ‘building-points’ or ‘roads’ are supported.
  • output_base_path (str) – The base path of the shape file.
  • extent – A list in the form [xmin, ymin, xmax, ymax] where all

coordinates provided are in Geographic / EPSG:4326. :type extent: list

Parameters:progress_dialog (QProgressDialog) – A progress dialog.
Raises:ImportDialogError, CanceledImportDialogError
safe.utilities.osm_downloader.extract_zip(zip_path, destination_base_path)[source]

Extract different extensions to the destination base path.

Example : contains a.shp, a.dbf, a.prj and destination_base_path = ‘/tmp/CT-buildings Expected result :

  • /tmp/CT-buildings.shp
  • /tmp/CT-buildings.dbf
  • /tmp/CT-buildings.prj

If two files in the zip with the same extension, only one will be copied.

New in version 3.2.

  • zip_path (str) – The path of the .zip file
  • destination_base_path (str) – The destination base path where the shp will be written to.

IOError - when not able to open path or output_dir does not exist.

safe.utilities.osm_downloader.fetch_zip(url, output_path, feature_type, progress_dialog=None)[source]

Download zip containing shp file and write to output_path.

New in version 3.2.

  • url (str) – URL of the zip bundle.
  • output_path (str) – Path of output file,
  • feature_type (str) – What kind of features should be downloaded. Currently ‘buildings’, ‘building-points’ or ‘roads’ are supported.
  • progress_dialog (QProgressDialog) – A progress dialog.

ImportDialogError - when network error occurred