### Navigation

- index
- modules
- next
- previous
- Home »
- Contents »
- InaSAFE’s API documentation »
- Package::safe »
- Package::safe.storage »

# Module: safe.storage.core

IO module for reading and writing of files

This module provides functionality to read and write raster and vector layers from numerical data.

`safe.storage.core.``bboxlist2string`(bbox, decimals=6)

  Convert bounding box list to comma separated string

  Args:
    - bbox: List of coordinates of the form [W, S, E, N]
  Returns:
    - bbox_string: Format ‘W,S,E,N’ - each will have 6 decimal points

`safe.storage.core.``bboxstring2list`(bbox_string)

  Convert bounding box string to list

  Args:
    - bbox_string: String of bounding box coordinates of the form ‘W,S,E,N’
  Returns:
    - bbox: List of floating point numbers with format [W, S, E, N]

`safe.storage.core.``check_bbox_string`(bbox_string)

  Check that bbox string is valid

`safe.storage.core.``get_bounding_box`(filename)

  Get bounding box for specified raster or vector file

  Args:
    - filename
  Returns:
    - bounding box as python list of numbers [West, South, East, North]

`safe.storage.core.``get_bounding_box_string`(filename)

  Get bounding box for specified raster or vector file

  Args:
    - filename
  Returns:
    - bounding box as python string ‘West, South, East, North’

`safe.storage.core.``read_layer`(filename)

  Read spatial layer from file. This can be either raster or vector data.

`safe.storage.core.``write_raster_data`(data, projection, geotransform, filename, keywords=None)

  Write array to raster file with specified metadata and one data layer

  Args:

    - data: Numpy array containing grid data

    - projection: WKT projection information

    - geotransform: 6 digit vector
        (top left x, w-e pixel resolution, rotation,

          top left y, rotation, n-s pixel resolution). See e.g. http://www.gdal.org/gdal_tutorial.html

    - filename: Output filename

    - keywords: Optional dictionary

  Note:
    The only format implemented is GTiff and the extension must be .tif

`safe.storage.core.``write_vector_data`(data, projection, geometry, filename, keywords=None)

  Write point data and any associated attributes to vector file

  Args:
    - data: List of N dictionaries each with M fields where

        M is the number of attributes. A value of None is acceptable.

    - projection: WKT projection information

    - geometry: List of points or polygons.

    - filename: Output filename

    - keywords: Optional dictionary

  Note
    The only format implemented is GML and SHP so the extension must be either .gml or .shp

  # FIXME (Ole): When the GML driver is used, # the spatial reference is not stored. # I suspect this is a bug in OGR.

  Background:
    - http://www.gdal.org/ogr/ogr_apitut.html (last example)
    - http://invisibleroads.com/tutorials/gdal-shapefile-points-save.html

This module forms part of the InaSAFE tool.

### Navigation

- index
- modules
- next
- previous
- Home »
- Contents »
- InaSAFE’s API documentation »
- Package::safe »
- Package::safe.storage »