Metadata-Version: 1.1
Name: PyGeoj
Version: 0.2
Summary: A simple Python GeoJSON file reader and writer.
Home-page: http://github.com/karimbahgat/PyGeoj
Author: Karim Bahgat
Author-email: karim.bahgat.norway@gmail.com
License: MIT
Description: PyGeoj
        ======
        
        PyGeoj is a simple Python GeoJSON file reader and writer intended for
        end-users. It exposees dictionary structures as high level objects with
        convenience methods, so the user does not have to get caught up in the
        details of the format specification.
        
        Platforms
        ---------
        
        So far only tested on Python version 2.x.
        
        Dependencies
        ------------
        
        Pure Python, no dependencies.
        
        Installing it
        -------------
        
        PyGeoj is installed with pip from the commandline:
        
        ::
        
            pip install pygeoj
        
        It also works to just place the "pygeoj" package folder in an importable
        location like "C:/PythonXX/Lib/site-packages".
        
        Example Usage
        -------------
        
        Begin by importing the pygeoj module:
        
        ::
        
            import pygeoj
        
        Reading
        ~~~~~~~
        
        Reading geojson formatted GIS files is a simple one-liner (requires the
        geojson file to be a "FeatureCollection"):
        
        ::
        
            testfile = pygeoj.load(filepath="testfile.geojson")
        
        Basic information about the geojson file can then be extracted, such as:
        
        ::
        
            len(testfile) # the number of features
            testfile.bbox # the bounding box region of the entire file
            testfile.crs # the coordinate reference system
            testfile.common_attributes # retrieves which field attributes are common to all features
        
        Individual features can be accessed either by their index in the
        features list:
        
        ::
        
            testfile.getfeature(3)
        
        Or by iterating through all of them:
        
        ::
        
            for feature in testfile: 
                # do something
        
        A feature can be inspected in various ways:
        
        ::
        
            feature.properties
            feature.geometry.coordinates
            feature.geometry.bbox
        
        Editing
        ~~~~~~~
        
        The standard Python list operations can be used to edit and swap around
        the features in a geojson instance, and then saving to a new geojson
        file:
        
        ::
        
            testfile[3] = testfile[8]
            testfile.pop_feature(8)
            testfile.save("test_edit.geojson")
        
        An existing feature can also be tweaked by using simple
        attribute-setting:
        
        ::
        
            # set your own properties
            feature.properties = {"newfield1":"newvalue1", "newfield2":"newvalue2"}
        
            # borrow the geometry of the 16th feature
            feature.geometry = testfile[16].geometry
        
        Constructing
        ~~~~~~~~~~~~
        
        Creating a new geojson file from scratch is also easy:
        
        ::
        
            newfile = pygeoj.new()
        
            # The data coordinate system defaults to long/lat WGS84 or can be manually defined:
            newfile.define_crs(type="link", link="http://spatialreference.org/ref/epsg/26912/esriwkt/", link_type="esriwkt")
        
        The new file can then be populated with new features:
        
        ::
        
            newfile.add_feature(properties={"country":"Norway"},
                                geometry=pygeoj.Geometry(type="Polygon", coordinates=[[(21,3),(33,11),(44,22)]]))
            newfile.add_feature(properties={"country":"USA"},
                                geometry=pygeoj.Geometry(type="Polygon", coordinates=[[(11,23),(14,5),(66,31)]]))
        
        Finally, some useful additional information can be added to top off the
        geojson file before saving it to file:
        
        ::
        
            newfile.add_all_bboxes()
            newfile.add_unique_id()
            newfile.save("test_construct.geojson")
        
        More Information:
        -----------------
        
        -  `Home Page <http://github.com/karimbahgat/PyGeoj>`__
        -  `API Documentation <http://pythonhosted.org/PyGeoj>`__
        
        License:
        --------
        
        This code is free to share, use, reuse, and modify according to the MIT
        license, see license.txt
        
        Credits:
        --------
        
        Karim Bahgat (2015)
        
Keywords: GIS spatial file format GeoJSON
Platform: UNKNOWN
Classifier: License :: OSI Approved
Classifier: Programming Language :: Python
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: End Users/Desktop
Classifier: Topic :: Scientific/Engineering :: GIS
