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:
- Create an OGR shapefile to receive the exported data.
- Save the features and their attributes into the shapefile.
- Compress the shapefile into a ZIP archive.
- Delete our temporary files.
- 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 it, let's create the "Export Shapefile" view function. This will call the export_data()
function to do all the work. Edit the shapefiles/views.py
file and add the following new function:
def export_shapefile...