Table of Contents for
Python Geospatial Development - Third Edition

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition Python Geospatial Development - Third Edition by Erik Westra Published by Packt Publishing, 2016
  1. Cover
  2. Table of Contents
  3. Python Geospatial Development Third Edition
  4. Python Geospatial Development Third Edition
  5. Credits
  6. About the Author
  7. About the Reviewer
  8. www.PacktPub.com
  9. Preface
  10. What you need for this book
  11. Who this book is for
  12. Conventions
  13. Reader feedback
  14. Customer support
  15. 1. Geospatial Development Using Python
  16. Geospatial development
  17. Applications of geospatial development
  18. Recent developments
  19. Summary
  20. 2. GIS
  21. GIS data formats
  22. Working with GIS data manually
  23. Summary
  24. 3. Python Libraries for Geospatial Development
  25. Dealing with projections
  26. Analyzing and manipulating Geospatial data
  27. Visualizing geospatial data
  28. Summary
  29. 4. Sources of Geospatial Data
  30. Sources of geospatial data in raster format
  31. Sources of other types of geospatial data
  32. Choosing your geospatial data source
  33. Summary
  34. 5. Working with Geospatial Data in Python
  35. Working with geospatial data
  36. Changing datums and projections
  37. Performing geospatial calculations
  38. Converting and standardizing units of geometry and distance
  39. Exercises
  40. Summary
  41. 6. Spatial Databases
  42. Spatial indexes
  43. Introducing PostGIS
  44. Setting up a database
  45. Using PostGIS
  46. Recommended best practices
  47. Summary
  48. 7. Using Python and Mapnik to Generate Maps
  49. Creating an example map
  50. Mapnik concepts
  51. Summary
  52. 8. Working with Spatial Data
  53. Designing and building the database
  54. Downloading and importing the data
  55. Implementing the DISTAL application
  56. Using DISTAL
  57. Summary
  58. 9. Improving the DISTAL Application
  59. Dealing with the scale problem
  60. Performance
  61. Summary
  62. 10. Tools for Web-based Geospatial Development
  63. A closer look at three specific tools and techniques
  64. Summary
  65. 11. Putting It All Together – a Complete Mapping System
  66. Designing the ShapeEditor
  67. Prerequisites
  68. Setting up the database
  69. Setting up the ShapeEditor project
  70. Defining the ShapeEditor's applications
  71. Creating the shared application
  72. Defining the data models
  73. Playing with the admin system
  74. Summary
  75. 12. ShapeEditor – Importing and Exporting Shapefiles
  76. Importing shapefiles
  77. Exporting shapefiles
  78. Summary
  79. 13. ShapeEditor – Selecting and Editing Features
  80. Editing features
  81. Adding features
  82. Deleting features
  83. Deleting shapefiles
  84. Using the ShapeEditor
  85. Further improvements and enhancements
  86. Summary
  87. Index

Creating the shared application

The shapeEditor.shared application will hold the core database tables and Python modules we use throughout the system. Let's go ahead and create this application now. Use the cd command to change the current directory to the top-level shapeEditor directory and type the following:

python manage.py startapp shared

This will create a new Python package named shared that will hold the contents of the shared app. Note that, by default, a new application is placed in the topmost shapeEditor directory. This means you can import this application into your Python program like this:

import shared

Django's conventions say that applications in the topmost directory (or anywhere else in your Python path) are intended to be reusable—that is, you can take that application and use it in a different project. The applications we're defining here aren't like that; they can only work as part of the shapeEditor project, and we would like to be able to import them like this:

import shapeEditor.shared

To allow this, you have to move the newly-created shared package directory inside the shapeEditor project's subdirectory. Doing this from the command line is easy; simply cd into the outermost shapeEditor directory and type the following command:

mv shared shapeEditor

Alternatively, if you are running MS Windows, you should use the following command:

move shared shapeEditor

Note

Unfortunately, Django doesn't currently make it easy for you to create non-reusable applications. You have to create the application first and then move the directory into the project directory to make it non-reusable.

Inside the shapeEditor.shared package directory will be a number of files:

File

Description

__init__.py

This is a standard Python package initialization file

admin.py

This module defines the admin interface for the shapeEditor.shared application

migrations

This directory will hold the various database migrations used by this application

models.py

This Python module holds the shapeEditor.shared application's database models

tests.py

This module can be used to hold the application's unit tests

views.py

This module is normally used to hold the application's view functions

Go ahead and delete the tests.py and views.py modules, as we won't be using them for this application. You should end up with the following directory structure:

Creating the shared application

Since we have created the application itself, let's add it to our project. Edit the settings.py file again, and add the following entry to the INSTALLED_APPS list:

'shapeEditor.shared',

Now that we have our shapeEditor.shared application, let's start to put some useful things into it.