O'Reilly logo

Python Geospatial Development - Third Edition by Erik Westra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exporting shapefiles

We next need to implement the ability to export a shapefile. The process of exporting a shapefile is basically the reverse of the importing logic, and involves the following steps:

  1. Create an OGR shapefile to receive the exported data.
  2. Save the features and their attributes into the shapefile.
  3. Compress the shapefile into a ZIP archive.
  4. Delete our temporary files.
  5. Send the ZIP file back to the user's web browser.

All this work will take place in the shapefileIO.py module, with help from some utils.py functions. Before we begin, let's define the export_data() function so that we have somewhere to place our code. Edit shapefileIO.py, and add the following new function:

def export_data(shapefile):
    return "More to come..."

While we're at ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required