O'Reilly logo

Python Geospatial Development - Second 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

Next, we need to implement the ability to export a shapefile. The process of exporting a shapefile is basically the reverse of the "import" logic, and involves the following steps:

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

All this work will take place in the shapefileIO application, with help from some utils.py functions. Before we begin, let's create an exporter module to handle the exporting process. Go to the shapefileIO directory, and create a new module named exporter.py. Initially, we're just going to add a dummy function ...

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