Book Image

Geospatial Development By Example with Python

By : Pablo Carreira
5 (1)
Book Image

Geospatial Development By Example with Python

5 (1)
By: Pablo Carreira

Overview of this book

From Python programming good practices to the advanced use of analysis packages, this book teaches you how to write applications that will perform complex geoprocessing tasks that can be replicated and reused. Much more than simple scripts, you will write functions to import data, create Python classes that represent your features, and learn how to combine and filter them. With pluggable mechanisms, you will learn how to visualize data and the results of analysis in beautiful maps that can be batch-generated and embedded into documents or web pages. Finally, you will learn how to consume and process an enormous amount of data very efficiently by using advanced tools and modern computers’ parallel processing capabilities.
Table of Contents (17 chapters)
Geospatial Development By Example with Python
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Exporting geo objects


Before we continue, as part of the workaround for windows users we will need to export our geo objects as files.

We will use the GeoJSON file format. It's a good choice of format for exporting geographic data because:

  • It's human-readable

  • It's an open standard

  • It's easy to make code that exports GeoJSON

  • Mapnik can import it

  • The properties/attributes can have multiple levels

Here you can see the same example of a GeoJSON file that we saw in Chapter 3, Combining Multiple Data Sources – How Geographic Data is Represented. You don't need to type it, we are just going to use it as a reference to write our export code:

{"type": "FeatureCollection",
 "features": [
    {"type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [102.0, 0.5]},
      "properties": {"prop0": "value0"}
    },
    {"type": "Feature",
      "geometry": {
        "type": "LineString",
        "coordinates": [[102.0, 0.0], [103.0, 1.0], [104.0, 0.0]]
      },
      "properties":...