diff --git a/CHANGES.txt b/CHANGES.txt new file mode 100644 index 0000000..d3d5d59 --- /dev/null +++ b/CHANGES.txt @@ -0,0 +1,6 @@ + +## Changes + +### 0.1.2 (2015-08-05) + +- First official release diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..044b01e --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,22 @@ + +The MIT License (MIT) + +Copyright (c) 2015 Karim Bahgat + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/PyCRS.egg-info/PKG-INFO b/PyCRS.egg-info/PKG-INFO new file mode 100644 index 0000000..a778c65 --- /dev/null +++ b/PyCRS.egg-info/PKG-INFO @@ -0,0 +1,209 @@ +Metadata-Version: 1.1 +Name: PyCRS +Version: 0.1.2 +Summary: GIS package for reading, writing, and converting between CRS formats. +Home-page: http://github.com/karimbahgat/PyCRS +Author: Karim Bahgat +Author-email: karim.bahgat.norway@gmail.com +License: MIT +Description: PyCRS + ===== + + PyCRS is a pure Python GIS package for reading, writing, and converting + between various common coordinate reference system (CRS) string and data + source formats. + + Introduction + ------------ + + Python should have a standalone GIS library focused solely on coordinate + reference system metadata. That is, a library focused on the various + formats used to store and represent crs definitions, including OGC WKT, + ESRI WKT, Proj4, and various short-codes defined by organizations like + EPSG, ESRI, and SR-ORG. Correctly parsing and converting between these + formats is essential in many types of GIS work. For instance when trying + to use PyProj to transform coordinates from a non-proj4 crs format. Or + when wanting to convert the crs from a GeoJSON file to a .prj file. Or + when simply adding a crs definition to a file that was previously + missing one. + + When I created PyCRS, the only way to read and convert between crs + formats was to use the extensive Python GDAL suite and its srs + submodule, but the requirements of some applications might exclude the + use of GDAL. There have also been some online websites/services, but + these only allow partial lookups or one-way conversion from one format + to another. I therefore hope that PyCRS will make it easier for + lightweight applications to read a broader range of data files and + correctly interpret and possibly transform their crs definitions. + Written entirely in Python I also hope it will help clarify the + differences between the various formats, and make it easier for more + people to help keep it up-to-date and bug-free. + + Status + ------ + + Currently, the supported formats are OGC WKT (v1), ESRI WKT, Proj4, and + any EPSG, ESRI, or SR-ORG code available from spatialreference.org. In + the future I hope to add support for OGC URN identifier strings, and + GeoTIFF file tags. + + The package is still in alpha version, so it will not perfectly parse or + convert between all crs, and it is likely to have several (hopefully + minor) differences from the results of other parsers like GDAL. In the + source repository there is a tester.py script, which uses a barrage of + commonly used crs as listed on + http://www.remotesensing.org/geotiff/proj\_list/. Currently, the overall + success rate for loading as well as converting between the three main + formats is 70-90%, and visual inspections of rendering the world with + each crs generally look correct. However, whether the converted crs + strings are logically equivalent to each other from a mathematical + standpoint is something that needs a more detailed quality check. + + Platforms + --------- + + So far only tested on Python version 2.x, but should also be compatible + with 3.x. + + Dependencies + ------------ + + Pure Python, no dependencies. + + Installing it + ------------- + + PyCRS is installed with pip from the commandline: + + :: + + pip install pycrs + + It also works to just place the "pycrs" package folder in an importable + location like "PythonXX/Lib/site-packages". + + Example Usage + ------------- + + Begin by importing the pycrs module: + + :: + + import pycrs + + Reading + ~~~~~~~ + + The first point of action when dealing with a data source's crs is that + you should be able to parse it correctly. In most situations this will + mean reading the ESRI .prj file that accomponies a shapefile or some + other file. PyCRS has a convenience function for doing that: + + :: + + fromcrs = pycrs.loader.from_file("path/to/shapefilename.prj") + + The same function also supports reading the crs from GeoJSON files: + + :: + + fromcrs = pycrs.loader.from_file("path/to/geojsonfile.json") + + If your crs is not defined in a file there are also functions for that. + For instance if you know the url where the crs is defined you can do: + + :: + + fromcrs = pycrs.loader.from_url("www.somesite.com/someproj") + + Or if you are provided with the actual string representation of the crs, + given by a web service for instance, you can load it using the + appropriate function from the parser module or let PyCRS autodetect and + load the crs type for you: + + :: + + fromcrs = pycrs.parser.from_unknown_text(somecrs_string) + + Converting + ~~~~~~~~~~ + + Once you have read the crs of the original data source, you may want to + convert it to some other crs format. A common reason for wanting this + for instance, is if you want to reproject the coordinates of your + spatial data. In Python this is typically done with the PyProj module + which only takes proj4 strings, so you would have to convert your + datasource's crs to proj4: + + :: + + fromcrs_proj4 = fromcrs.to_proj4() + + You can then use PyCRS to define your target projection in the string + format of your choice, before converting it to the proj4 format that + PyProj expects: + + :: + + tocrs = pycrs.parser.from_esri_code(54030) # Robinson projection from esri code + tocrs_proj4 = tocrs.to_proj4() + + With the source and target projections defined in the proj4 crs format, + you are ready to transform your data coordinates with PyProj, which is + not covered here. + + Writing + ~~~~~~~ + + After you transform your data coordinates you may also wish to save the + data back to file along with the new crs. With PyCRS you can do this in + a variety of crs format. For instance: + + :: + + with open("shapefile.prj", "w") as writer: + writer.write(tocrs.to_esri_wkt()) + + PyCRS also gives access to each crs element and parameter that make up a + crs in the "elements" subpackage, so you could potentially also build a + crs from scratch and then save it to a format of your choice. Inspect + the parser submodule source code for inspiration on how to go about + this. + + More Information: + ----------------- + + This tutorial only covered some basic examples. For the full list of + functions and supported crs formats, check out the API Documentation. + + - `Home Page `__ + - `API Documentation `__ + + License: + -------- + + This code is free to share, use, reuse, and modify according to the MIT + license, see license.txt + + Credits: + -------- + + Karim Bahgat (2015) + + Changes + ------- + + 0.1.2 (2015-08-05) + ~~~~~~~~~~~~~~~~~~ + + - First official release + +Keywords: GIS spatial CRS coordinates format +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 diff --git a/PyCRS.egg-info/SOURCES.txt b/PyCRS.egg-info/SOURCES.txt new file mode 100644 index 0000000..3a5dbb1 --- /dev/null +++ b/PyCRS.egg-info/SOURCES.txt @@ -0,0 +1,19 @@ +README.rst +setup.cfg +setup.py +PyCRS.egg-info/PKG-INFO +PyCRS.egg-info/SOURCES.txt +PyCRS.egg-info/dependency_links.txt +PyCRS.egg-info/top_level.txt +pycrs/__init__.py +pycrs/loader.py +pycrs/parser.py +pycrs/utils.py +pycrs/elements/__init__.py +pycrs/elements/containers.py +pycrs/elements/datums.py +pycrs/elements/directions.py +pycrs/elements/ellipsoids.py +pycrs/elements/parameters.py +pycrs/elements/projections.py +pycrs/elements/units.py \ No newline at end of file diff --git a/PyCRS.egg-info/dependency_links.txt b/PyCRS.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/PyCRS.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/PyCRS.egg-info/top_level.txt b/PyCRS.egg-info/top_level.txt new file mode 100644 index 0000000..e240f7e --- /dev/null +++ b/PyCRS.egg-info/top_level.txt @@ -0,0 +1,2 @@ +pycrs +pycrs\elements diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..1abf04f --- /dev/null +++ b/README.rst @@ -0,0 +1,191 @@ +PyCRS +===== + +PyCRS is a pure Python GIS package for reading, writing, and converting +between various common coordinate reference system (CRS) string and data +source formats. + +Introduction +------------ + +Python should have a standalone GIS library focused solely on coordinate +reference system metadata. That is, a library focused on the various +formats used to store and represent crs definitions, including OGC WKT, +ESRI WKT, Proj4, and various short-codes defined by organizations like +EPSG, ESRI, and SR-ORG. Correctly parsing and converting between these +formats is essential in many types of GIS work. For instance when trying +to use PyProj to transform coordinates from a non-proj4 crs format. Or +when wanting to convert the crs from a GeoJSON file to a .prj file. Or +when simply adding a crs definition to a file that was previously +missing one. + +When I created PyCRS, the only way to read and convert between crs +formats was to use the extensive Python GDAL suite and its srs +submodule, but the requirements of some applications might exclude the +use of GDAL. There have also been some online websites/services, but +these only allow partial lookups or one-way conversion from one format +to another. I therefore hope that PyCRS will make it easier for +lightweight applications to read a broader range of data files and +correctly interpret and possibly transform their crs definitions. +Written entirely in Python I also hope it will help clarify the +differences between the various formats, and make it easier for more +people to help keep it up-to-date and bug-free. + +Status +------ + +Currently, the supported formats are OGC WKT (v1), ESRI WKT, Proj4, and +any EPSG, ESRI, or SR-ORG code available from spatialreference.org. In +the future I hope to add support for OGC URN identifier strings, and +GeoTIFF file tags. + +The package is still in alpha version, so it will not perfectly parse or +convert between all crs, and it is likely to have several (hopefully +minor) differences from the results of other parsers like GDAL. In the +source repository there is a tester.py script, which uses a barrage of +commonly used crs as listed on +http://www.remotesensing.org/geotiff/proj\_list/. Currently, the overall +success rate for loading as well as converting between the three main +formats is 70-90%, and visual inspections of rendering the world with +each crs generally look correct. However, whether the converted crs +strings are logically equivalent to each other from a mathematical +standpoint is something that needs a more detailed quality check. + +Platforms +--------- + +So far only tested on Python version 2.x, but should also be compatible +with 3.x. + +Dependencies +------------ + +Pure Python, no dependencies. + +Installing it +------------- + +PyCRS is installed with pip from the commandline: + +:: + + pip install pycrs + +It also works to just place the "pycrs" package folder in an importable +location like "PythonXX/Lib/site-packages". + +Example Usage +------------- + +Begin by importing the pycrs module: + +:: + + import pycrs + +Reading +~~~~~~~ + +The first point of action when dealing with a data source's crs is that +you should be able to parse it correctly. In most situations this will +mean reading the ESRI .prj file that accomponies a shapefile or some +other file. PyCRS has a convenience function for doing that: + +:: + + fromcrs = pycrs.loader.from_file("path/to/shapefilename.prj") + +The same function also supports reading the crs from GeoJSON files: + +:: + + fromcrs = pycrs.loader.from_file("path/to/geojsonfile.json") + +If your crs is not defined in a file there are also functions for that. +For instance if you know the url where the crs is defined you can do: + +:: + + fromcrs = pycrs.loader.from_url("www.somesite.com/someproj") + +Or if you are provided with the actual string representation of the crs, +given by a web service for instance, you can load it using the +appropriate function from the parser module or let PyCRS autodetect and +load the crs type for you: + +:: + + fromcrs = pycrs.parser.from_unknown_text(somecrs_string) + +Converting +~~~~~~~~~~ + +Once you have read the crs of the original data source, you may want to +convert it to some other crs format. A common reason for wanting this +for instance, is if you want to reproject the coordinates of your +spatial data. In Python this is typically done with the PyProj module +which only takes proj4 strings, so you would have to convert your +datasource's crs to proj4: + +:: + + fromcrs_proj4 = fromcrs.to_proj4() + +You can then use PyCRS to define your target projection in the string +format of your choice, before converting it to the proj4 format that +PyProj expects: + +:: + + tocrs = pycrs.parser.from_esri_code(54030) # Robinson projection from esri code + tocrs_proj4 = tocrs.to_proj4() + +With the source and target projections defined in the proj4 crs format, +you are ready to transform your data coordinates with PyProj, which is +not covered here. + +Writing +~~~~~~~ + +After you transform your data coordinates you may also wish to save the +data back to file along with the new crs. With PyCRS you can do this in +a variety of crs format. For instance: + +:: + + with open("shapefile.prj", "w") as writer: + writer.write(tocrs.to_esri_wkt()) + +PyCRS also gives access to each crs element and parameter that make up a +crs in the "elements" subpackage, so you could potentially also build a +crs from scratch and then save it to a format of your choice. Inspect +the parser submodule source code for inspiration on how to go about +this. + +More Information: +----------------- + +This tutorial only covered some basic examples. For the full list of +functions and supported crs formats, check out the API Documentation. + +- `Home Page `__ +- `API Documentation `__ + +License: +-------- + +This code is free to share, use, reuse, and modify according to the MIT +license, see license.txt + +Credits: +-------- + +Karim Bahgat (2015) + +Changes +------- + +0.1.2 (2015-08-05) +~~~~~~~~~~~~~~~~~~ + +- First official release diff --git a/build/doc/elements/containers.m.html b/build/doc/elements/containers.m.html new file mode 100644 index 0000000..13909a5 --- /dev/null +++ b/build/doc/elements/containers.m.html @@ -0,0 +1,1640 @@ + + + + + + pycrs.elements.containers API documentation + + + + + + + + + + + + + + + +Top + +
+ + + + +
+ + + + + + +
+

pycrs.elements.containers module

+ + + +
+ +
+ + +

Classes

+ +
+

class CRS

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, toplevel)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class Datum

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, name, ellipsoid, datumshift=None)

+
+ + + + +

Arguments:

+
    +
  • name: Specific datum name instance.
  • +
  • ellipsoid: Ellipsoid parameter instance.
  • +
+
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_geotiff(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class Ellipsoid

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, name, semimaj_ax=None, inv_flat=None)

+
+ + + + +

Arguments:

+
    +
  • name: Specific ellipsoid name instance.
  • +
+
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_geotiff(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class GeogCS

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, name, datum, prime_mer, angunit, twin_ax=None)

+
+ + + + +

Arguments:

+
    +
  • name: Arbitrary name.
  • +
+
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class ProjCS

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, name, geogcs, proj, params, unit, twin_ax=None)

+
+ + + + +

Arguments:

+
    +
  • name: Arbitrary name.
  • +
+
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class Projection

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/build/doc/elements/datums.m.html b/build/doc/elements/datums.m.html new file mode 100644 index 0000000..f65b227 --- /dev/null +++ b/build/doc/elements/datums.m.html @@ -0,0 +1,1225 @@ + + + + + + pycrs.elements.datums API documentation + + + + + + + + + + + + + + + +Top + +
+ + + + +
+ + + + + + +
+

pycrs.elements.datums module

+ + + +
+ +
+ +

Functions

+ +
+
+

def find(

datumname, crstype, strict=False)

+
+ + + + +
+
+ +
+ + +

Classes

+ +
+

class NAD27

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class NAD83

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class SphereArcInfo

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Unknown

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class WGS72_BE

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class WGS84

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/build/doc/elements/directions.m.html b/build/doc/elements/directions.m.html new file mode 100644 index 0000000..aa5fd1d --- /dev/null +++ b/build/doc/elements/directions.m.html @@ -0,0 +1,1203 @@ + + + + + + pycrs.elements.directions API documentation + + + + + + + + + + + + + + + +Top + +
+ + + + +
+ + + + + + +
+

pycrs.elements.directions module

+ + + +
+ +
+ + +

Classes

+ +
+

class Down

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class East

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class North

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class South

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Up

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class West

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/build/doc/elements/ellipsoids.m.html b/build/doc/elements/ellipsoids.m.html new file mode 100644 index 0000000..2d235e5 --- /dev/null +++ b/build/doc/elements/ellipsoids.m.html @@ -0,0 +1,1305 @@ + + + + + + pycrs.elements.ellipsoids API documentation + + + + + + + + + + + + + + + +Top + +
+ + + + +
+ + + + + + +
+

pycrs.elements.ellipsoids module

+ + + +
+ +
+ +

Functions

+ +
+
+

def find(

ellipsname, crstype, strict=False)

+
+ + + + +
+
+ +
+ + +

Classes

+ +
+

class Airy1830

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Bessel1841

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Clarke1866

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class GRS80

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class International

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Krassowsky1940

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class SphereArcInfo

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Unknown

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class WGS72

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class WGS84

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/build/doc/elements/index.html b/build/doc/elements/index.html new file mode 100644 index 0000000..14c2a26 --- /dev/null +++ b/build/doc/elements/index.html @@ -0,0 +1,1132 @@ + + + + + + pycrs.elements API documentation + + + + + + + + + + + + + + + +Top + +
+ + + + + +
+ +
+ + \ No newline at end of file diff --git a/build/doc/elements/parameters.m.html b/build/doc/elements/parameters.m.html new file mode 100644 index 0000000..08a35d7 --- /dev/null +++ b/build/doc/elements/parameters.m.html @@ -0,0 +1,2733 @@ + + + + + + pycrs.elements.parameters API documentation + + + + + + + + + + + + + + + +Top + +
+ + + + +
+ + + + + + +
+

pycrs.elements.parameters module

+ + + +
+ +
+ +

Functions

+ +
+
+

def find(

paramname, crstype, strict=False)

+
+ + + + +
+
+ +
+ + +

Classes

+ +
+

class AngularUnit

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, unittype, metermultiplier)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class Azimuth

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class CentralMeridian

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_geotiff(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class DatumShift

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class FalseEasting

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class FalseNorthing

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class LatitudeFirstStndParallel

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_geotiff(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class LatitudeOrigin

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_geotiff(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class LatitudeSecondStndParallel

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_geotiff(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class LatitudeTrueScale

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_geotiff(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class LongitudeCenter

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class MeterMultiplier

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class PrimeMeridian

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +

Arguments:

+
    +
  • value: Longitude value relative to Greenwich.
  • +
+
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class SatelliteHeight

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class ScalingFactor

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_geotiff(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class TiltAngle

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class Unit

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, unittype, metermultiplier)

+
+ + + + +
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+

class UnitType

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +

Methods

+ +
+
+

def __init__(

self, value)

+
+ + + + +

Arguments:

+
    +
  • value: A specific unit type instance, eg Meter().
  • +
+
+
+ +
+ + +
+
+

def to_esri_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_ogc_wkt(

self)

+
+ + + + +
+
+ +
+ + +
+
+

def to_proj4(

self)

+
+ + + + +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/build/doc/elements/projections.m.html b/build/doc/elements/projections.m.html new file mode 100644 index 0000000..2f246bd --- /dev/null +++ b/build/doc/elements/projections.m.html @@ -0,0 +1,1785 @@ + + + + + + pycrs.elements.projections API documentation + + + + + + + + + + + + + + + +Top + +
+ + + + +
+ + + + + + +
+

pycrs.elements.projections module

+ + + +
+ +
+ +

Functions

+ +
+
+

def find(

projname, crstype, strict=False)

+
+ + + + +
+
+ +
+ + +

Classes

+ +
+

class AlbersEqualArea

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class AzimuthalEquidistant

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class CylindricalEqualArea

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class EckertIV

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class EckertVI

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class EquiDistantConic

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class EquiDistantCylindrical

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class EquiRectangular

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class GallStereographic

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class GeostationarySatellite

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Gnomonic

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class InteruptedGoodeHomolosine

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Krovak

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class LamberEqualAreaConic

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class LambertAzimuthalEqualArea

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class LambertConformalConic

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Larrivee

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Mercator

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class MillerCylindrical

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Mollweide

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class NearSidedPerspective

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class ObliqueCylindricalEqualArea

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class ObliqueMercator

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class ObliqueStereographic

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Orthographic

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class PolarStereographic

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Polyconic

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Robinson

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Sinusoidal

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Stereographic

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class TiltedPerspective

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class TransverseMercator

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class UTM

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class VanDerGrinten

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/build/doc/elements/units.m.html b/build/doc/elements/units.m.html new file mode 100644 index 0000000..0595ddb --- /dev/null +++ b/build/doc/elements/units.m.html @@ -0,0 +1,1185 @@ + + + + + + pycrs.elements.units API documentation + + + + + + + + + + + + + + + +Top + +
+ + + + +
+ + + + + + +
+

pycrs.elements.units module

+ + + +
+ +
+ +

Functions

+ +
+
+

def find(

unitname, crstype, strict=False)

+
+ + + + +
+
+ +
+ + +

Classes

+ +
+

class Degree

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Feet

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Meter

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+

class Unknown

+ + +
+
+ + +
+

Ancestors (in MRO)

+ +
+
+ +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/build/doc/index.html b/build/doc/index.html new file mode 100644 index 0000000..fff88db --- /dev/null +++ b/build/doc/index.html @@ -0,0 +1,1115 @@ + + + + + + pycrs API documentation + + + + + + + + + + + + + + + +Top + +
+ + + + +
+ + + + + + +
+

pycrs module

+

API Documentation

+ + +
+ +
+ + + +

Sub-modules

+
+

pycrs.elements

+ + +

Access to the various construct and parameter classes needed to build a CRS object.

+ +
+
+

pycrs.loader

+ + +

Convenience functions for loading from different sources.

+ +
+
+

pycrs.parser

+ + +

The main module containing functions for parsing text strings into crs objects.

+ +
+
+

pycrs.utils

+ + +

Misc utility functions related to crs formats and online services.

+ +
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/build/doc/loader.m.html b/build/doc/loader.m.html new file mode 100644 index 0000000..1d514c0 --- /dev/null +++ b/build/doc/loader.m.html @@ -0,0 +1,1131 @@ + + + + + + pycrs.loader API documentation + + + + + + + + + + + + + + + +Top + +
+ + + + +
+ + + + + + +
+

pycrs.loader module

+

Convenience functions for loading from different sources.

+ + +
+ +
+ +

Functions

+ +
+
+

def from_file(

filepath)

+
+ + + + +

Returns the crs object from a file, with the format determined from the filename extension.

+

Arguments:

+
    +
  • filepath: filepath to be loaded, including extension.
  • +
+
+
+ +
+ + +
+
+

def from_url(

url, format=None)

+
+ + + + +

Returns the crs object from a string interpreted as a specified format, located at a given url site.

+

Arguments:

+
    +
  • url: The url where the crs string is to be read from.
  • +
  • format (optional): Which format to parse the crs string as. One of "ogc wkt", "esri wkt", or "proj4". + If None, tries to autodetect the format for you (default).
  • +
+

Returns:

+
    +
  • CRS object.
  • +
+
+
+ +
+ + + +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/build/doc/parser.m.html b/build/doc/parser.m.html new file mode 100644 index 0000000..51ff9b6 --- /dev/null +++ b/build/doc/parser.m.html @@ -0,0 +1,1288 @@ + + + + + + pycrs.parser API documentation + + + + + + + + + + + + + + + +Top + +
+ + + + +
+ + + + + + +
+

pycrs.parser module

+

The main module containing functions for parsing text strings into crs objects.

+ + +
+ +
+ +

Functions

+ +
+
+

def from_epsg_code(

code)

+
+ + + + +

Load crs object from epsg code, via spatialreference.org. +Parses based on the proj4 representation.

+

Arguments:

+
    +
  • code: The EPSG code as an integer.
  • +
+

Returns:

+
    +
  • CRS object.
  • +
+
+
+ +
+ + +
+
+

def from_esri_code(

code)

+
+ + + + +

Load crs object from esri code, via spatialreference.org. +Parses based on the proj4 representation.

+

Arguments:

+
    +
  • code: The ESRI code as an integer.
  • +
+

Returns:

+
    +
  • CRS object.
  • +
+
+
+ +
+ + +
+
+

def from_esri_wkt(

string, strict=False)

+
+ + + + +

Parse crs as esri wkt formatted string and return the resulting crs object.

+

Arguments:

+
    +
  • string: The ESRI WKT representation as a string.
  • +
  • strict (optional): When True, the parser is strict about names having to match + exactly with upper and lowercases. Default is not strict (False).
  • +
+

Returns:

+
    +
  • CRS object.
  • +
+
+
+ +
+ + +
+
+

def from_ogc_wkt(

string, strict=False)

+
+ + + + +

Parse crs as ogc wkt formatted string and return the resulting crs object.

+

Arguments:

+
    +
  • string: The OGC WKT representation as a string.
  • +
  • strict (optional): When True, the parser is strict about names having to match + exactly with upper and lowercases. Default is not strict (False).
  • +
+

Returns:

+
    +
  • CRS object.
  • +
+
+
+ +
+ + +
+
+

def from_proj4(

string, strict=False)

+
+ + + + +

Parse crs as proj4 formatted string and return the resulting crs object.

+

Arguments:

+
    +
  • string: The proj4 representation as a string.
  • +
  • strict (optional): When True, the parser is strict about names having to match + exactly with upper and lowercases. Default is not strict (False).
  • +
+

Returns:

+
    +
  • CRS object.
  • +
+
+
+ +
+ + +
+
+

def from_sr_code(

code)

+
+ + + + +

Load crs object from sr-org code, via spatialreference.org. +Parses based on the proj4 representation.

+

Arguments:

+
    +
  • code: The SR-ORG code as an integer.
  • +
+

Returns:

+
    +
  • CRS object.
  • +
+
+
+ +
+ + +
+
+

def from_unknown_text(

text, strict=False)

+
+ + + + +

Detect crs string format and parse into crs object with appropriate function.

+

Arguments:

+
    +
  • string: The crs text representation of unknown type.
  • +
  • strict (optional): When True, the parser is strict about names having to match + exactly with upper and lowercases. Default is not strict (False).
  • +
+

Returns:

+
    +
  • CRS object.
  • +
+
+
+ +
+ + +
+
+

def from_unknown_wkt(

string, strict=False)

+
+ + + + +

Given an unknown wkt string, detect if uses ogc or esri flavor, and parse the crs accordingly.

+

Arguments:

+
    +
  • string: The unknown WKT representation as a string.
  • +
  • strict (optional): When True, the parser is strict about names having to match + exactly with upper and lowercases. Default is not strict (False).
  • +
+

Returns: +- CRS object.

+
+
+ +
+ + + +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/build/doc/utils.m.html b/build/doc/utils.m.html new file mode 100644 index 0000000..49f118f --- /dev/null +++ b/build/doc/utils.m.html @@ -0,0 +1,1133 @@ + + + + + + pycrs.utils API documentation + + + + + + + + + + + + + + + +Top + +
+ + + + +
+ + + + + + +
+

pycrs.utils module

+

Misc utility functions related to crs formats and online services.

+ + +
+ +
+ +

Functions

+ +
+
+

def build_crs_table(

savepath)

+
+ + + + +

Build crs table of all equivalent format variations by scraping spatialreference.org. +Saves table as tab-delimited text file. +NOTE: Might take a while.

+

Arguments:

+
    +
  • savepath: The absolute or relative filepath to which to save the crs table, including the ".txt" extension.
  • +
+
+
+ +
+ + +
+
+

def crscode_to_string(

codetype, code, format)

+
+ + + + +

Lookup crscode on spatialreference.org and return in specified format.

+

Arguments:

+
    +
  • codetype: "epsg", "esri", or "sr-org".
  • +
  • code: The code.
  • +
  • format: The crs format of the returned string. One of "ogcwkt", "esriwkt", or "proj4", but also several others...
  • +
+

Returns:

+
    +
  • Crs string in the specified format.
  • +
+
+
+ +
+ + + +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/dist/PyCRS-0.1.0.zip b/dist/PyCRS-0.1.0.zip new file mode 100644 index 0000000..e68203c Binary files /dev/null and b/dist/PyCRS-0.1.0.zip differ diff --git a/dist/PyCRS-0.1.1.zip b/dist/PyCRS-0.1.1.zip new file mode 100644 index 0000000..69bbf22 Binary files /dev/null and b/dist/PyCRS-0.1.1.zip differ diff --git a/dist/PyCRS-0.1.2.zip b/dist/PyCRS-0.1.2.zip new file mode 100644 index 0000000..4d7bbb7 Binary files /dev/null and b/dist/PyCRS-0.1.2.zip differ diff --git a/pycrs/__init__.py b/pycrs/__init__.py index 3f200d7..54aa7b4 100644 --- a/pycrs/__init__.py +++ b/pycrs/__init__.py @@ -1,12 +1,153 @@ """ -PyCRS -Karim Bahgat, 2015 +# PyCRS + +PyCRS is a pure Python GIS package for reading, writing, and converting between various +common coordinate reference system (CRS) string and data source formats. + + +## Introduction + +Python should have a standalone GIS library focused solely on coordinate reference system metadata. +That is, a library focused on the various formats used to store and represent crs definitions, including +OGC WKT, ESRI WKT, Proj4, and various short-codes defined by organizations like EPSG, ESRI, and SR-ORG. +Correctly parsing and converting between these formats is essential in many types of GIS work. +For instance when trying to use PyProj to transform coordinates from a non-proj4 crs format. Or +when wanting to convert the crs from a GeoJSON file to a .prj file. Or when simply adding a crs definition +to a file that was previously missing one. + +When I created PyCRS, the only way to read and convert between crs formats was to use the extensive Python +GDAL suite and its srs submodule, but the requirements of some applications might exclude the use of +GDAL. There have also been some online websites/services, but these only allow partial lookups or +one-way conversion from one format to another. I therefore hope that PyCRS will make it easier for +lightweight applications to read a broader range of data files and correctly interpret and possibly transform +their crs definitions. Written entirely in Python I also hope it will help clarify the differences +between the various formats, and make it easier for more people to help keep it up-to-date and bug-free. + + +## Status + +Currently, the supported formats are OGC WKT (v1), ESRI WKT, Proj4, and any EPSG, ESRI, or SR-ORG code +available from spatialreference.org. In the future I hope to add support for OGC URN identifier strings, +and GeoTIFF file tags. + +The package is still in alpha version, so it will not perfectly parse or convert between all crs, +and it is likely to have several (hopefully minor) differences from the results of other parsers like GDAL. +In the source repository there is a tester.py script, which uses a barrage of commonly +used crs as listed on http://www.remotesensing.org/geotiff/proj_list/. Currently, the overall success rate +for loading as well as converting between the three main formats is 70-90%, and visual inspections of +rendering the world with each crs generally look correct. However, whether the converted crs strings +are logically equivalent to each other from a mathematical standpoint is something that needs a more detailed +quality check. + + +## Platforms + +So far only tested on Python version 2.x, but should also be compatible with 3.x. + + +## Dependencies + +Pure Python, no dependencies. + + +## Installing it + +PyCRS is installed with pip from the commandline: + + pip install pycrs + +It also works to just place the "pycrs" package folder in an importable location like +"PythonXX/Lib/site-packages". + + +## Example Usage + +Begin by importing the pycrs module: + + import pycrs + +### Reading + +The first point of action when dealing with a data source's crs is that you should be able to +parse it correctly. In most situations this will mean reading the ESRI .prj file that accomponies +a shapefile or some other file. PyCRS has a convenience function for doing that: + + fromcrs = pycrs.loader.from_file("path/to/shapefilename.prj") + +The same function also supports reading the crs from GeoJSON files: + + fromcrs = pycrs.loader.from_file("path/to/geojsonfile.json") + +If your crs is not defined in a file there are also functions for that. For instance if you know the url +where the crs is defined you can do: + + fromcrs = pycrs.loader.from_url("www.somesite.com/someproj") + +Or if you are provided with the actual string representation of the crs, given by a web service for +instance, you can load it using the appropriate function from the parser module or let PyCRS autodetect +and load the crs type for you: + + fromcrs = pycrs.parser.from_unknown_text(somecrs_string) + +### Converting + +Once you have read the crs of the original data source, you may want to convert it to some other crs format. +A common reason for wanting this for instance, is if you want to reproject the coordinates of your spatial +data. In Python this is typically done with the PyProj module which only takes proj4 strings, so you would +have to convert your datasource's crs to proj4: + + fromcrs_proj4 = fromcrs.to_proj4() + +You can then use PyCRS to define your target projection in the string format of your choice, before converting +it to the proj4 format that PyProj expects: + + tocrs = pycrs.parser.from_esri_code(54030) # Robinson projection from esri code + tocrs_proj4 = tocrs.to_proj4() + +With the source and target projections defined in the proj4 crs format, you are ready to transform your +data coordinates with PyProj, which is not covered here. + +### Writing + +After you transform your data coordinates you may also wish to save the data back to file along with the new +crs. With PyCRS you can do this in a variety of crs format. For instance: + + with open("shapefile.prj", "w") as writer: + writer.write(tocrs.to_esri_wkt()) + +PyCRS also gives access to each crs element and parameter that make up a crs in the "elements" subpackage, +so you could potentially also build a crs from scratch and then save it to a format of your choice. +Inspect the parser submodule source code for inspiration on how to go about this. + + +## More Information: + +This tutorial only covered some basic examples. For the full list of functions and supported crs formats, +check out the API Documentation. + +- [Home Page](http://github.com/karimbahgat/PyCRS) +- [API Documentation](http://pythonhosted.org/PyCRS) + + +## License: + +This code is free to share, use, reuse, +and modify according to the MIT license, see license.txt + + +## Credits: + +Karim Bahgat (2015) -Intro... """ +__version__ = "0.1.2" + from . import loader from . import parser from . import utils + + + diff --git a/pycrs/__init__.pyc b/pycrs/__init__.pyc index ee49d64..f185006 100644 Binary files a/pycrs/__init__.pyc and b/pycrs/__init__.pyc differ diff --git a/pycrs/elements/__init__.py b/pycrs/elements/__init__.py index a17b4e7..ad372e7 100644 --- a/pycrs/elements/__init__.py +++ b/pycrs/elements/__init__.py @@ -1,3 +1,7 @@ +""" +Access to the various construct and parameter classes needed to build a CRS object. +""" + from . import datums from . import ellipsoids from . import projections diff --git a/pycrs/elements/__init__.pyc b/pycrs/elements/__init__.pyc index 28e8a4a..c63ad39 100644 Binary files a/pycrs/elements/__init__.pyc and b/pycrs/elements/__init__.pyc differ diff --git a/pycrs/loader.py b/pycrs/loader.py index 88103c8..127480c 100644 --- a/pycrs/loader.py +++ b/pycrs/loader.py @@ -16,10 +16,13 @@ def from_url(url, format=None): Returns the crs object from a string interpreted as a specified format, located at a given url site. Arguments: + - *url*: The url where the crs string is to be read from. - - *format*: Which format to parse the crs string as. One of "ogc wkt", "esri wkt", or "proj4". + - *format* (optional): Which format to parse the crs string as. One of "ogc wkt", "esri wkt", or "proj4". + If None, tries to autodetect the format for you (default). Returns: + - CRS object. """ # first get string from url @@ -41,6 +44,10 @@ def from_url(url, format=None): def from_file(filepath): """ Returns the crs object from a file, with the format determined from the filename extension. + + Arguments: + + - *filepath*: filepath to be loaded, including extension. """ if filepath.endswith(".prj"): string = open(filepath, "r").read() diff --git a/pycrs/loader.pyc b/pycrs/loader.pyc index 3b408f5..8b2231f 100644 Binary files a/pycrs/loader.pyc and b/pycrs/loader.pyc differ diff --git a/pycrs/parser.py b/pycrs/parser.py index c3d88e5..92f20de 100644 --- a/pycrs/parser.py +++ b/pycrs/parser.py @@ -22,9 +22,11 @@ def from_epsg_code(code): Parses based on the proj4 representation. Arguments: + - *code*: The EPSG code as an integer. Returns: + - CRS object. """ # must go online (or look up local table) to get crs details @@ -39,9 +41,11 @@ def from_esri_code(code): Parses based on the proj4 representation. Arguments: + - *code*: The ESRI code as an integer. Returns: + - CRS object. """ # must go online (or look up local table) to get crs details @@ -56,9 +60,11 @@ def from_sr_code(code): Parses based on the proj4 representation. Arguments: + - *code*: The SR-ORG code as an integer. Returns: + - CRS object. """ # must go online (or look up local table) to get crs details @@ -72,11 +78,13 @@ def from_ogc_wkt(string, strict=False): Parse crs as ogc wkt formatted string and return the resulting crs object. Arguments: + - *string*: The OGC WKT representation as a string. - *strict* (optional): When True, the parser is strict about names having to match exactly with upper and lowercases. Default is not strict (False). Returns: + - CRS object. """ # parse arguments into components @@ -88,11 +96,13 @@ def from_esri_wkt(string, strict=False): Parse crs as esri wkt formatted string and return the resulting crs object. Arguments: + - *string*: The ESRI WKT representation as a string. - *strict* (optional): When True, the parser is strict about names having to match exactly with upper and lowercases. Default is not strict (False). Returns: + - CRS object. """ # parse arguments into components @@ -104,6 +114,7 @@ def from_unknown_wkt(string, strict=False): Given an unknown wkt string, detect if uses ogc or esri flavor, and parse the crs accordingly. Arguments: + - *string*: The unknown WKT representation as a string. - *strict* (optional): When True, the parser is strict about names having to match exactly with upper and lowercases. Default is not strict (False). @@ -120,12 +131,14 @@ def _from_wkt(string, wkttype, strict=False): Internal method for parsing wkt, with minor differences depending on ogc or esri style. Arguments: + - *string*: The OGC or ESRI WKT representation as a string. - *wkttype* (optional): How to parse the WKT string, as either 'ogc', 'esri', or None. If None, tries to autodetect the wkt type before parsing (default). - *strict* (optional): When True, the parser is strict about names having to match exactly with upper and lowercases. Default is not strict (False). Returns: + - CRS object. """ # TODO @@ -399,11 +412,13 @@ def from_proj4(string, strict=False): Parse crs as proj4 formatted string and return the resulting crs object. Arguments: + - *string*: The proj4 representation as a string. - *strict* (optional): When True, the parser is strict about names having to match exactly with upper and lowercases. Default is not strict (False). Returns: + - CRS object. """ # parse arguments into components @@ -713,11 +728,13 @@ def from_unknown_text(text, strict=False): Detect crs string format and parse into crs object with appropriate function. Arguments: + - *string*: The crs text representation of unknown type. - *strict* (optional): When True, the parser is strict about names having to match exactly with upper and lowercases. Default is not strict (False). Returns: + - CRS object. """ diff --git a/pycrs/parser.pyc b/pycrs/parser.pyc index 2ff73ef..524beda 100644 Binary files a/pycrs/parser.pyc and b/pycrs/parser.pyc differ diff --git a/pycrs/utils.py b/pycrs/utils.py index d77ba6d..b6a13c2 100644 --- a/pycrs/utils.py +++ b/pycrs/utils.py @@ -12,6 +12,7 @@ def build_crs_table(savepath): NOTE: Might take a while. Arguments: + - *savepath*: The absolute or relative filepath to which to save the crs table, including the ".txt" extension. """ # create table @@ -70,11 +71,13 @@ def crscode_to_string(codetype, code, format): Lookup crscode on spatialreference.org and return in specified format. Arguments: + - *codetype*: "epsg", "esri", or "sr-org". - *code*: The code. - *format*: The crs format of the returned string. One of "ogcwkt", "esriwkt", or "proj4", but also several others... Returns: + - Crs string in the specified format. """ link = 'http://spatialreference.org/ref/%s/%s/%s/' %(codetype,code,format) diff --git a/pycrs/utils.pyc b/pycrs/utils.pyc index 497b144..3725715 100644 Binary files a/pycrs/utils.pyc and b/pycrs/utils.pyc differ diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..988c5d6 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ + +[metadata] +description-file = README.rst diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..095976f --- /dev/null +++ b/setup.py @@ -0,0 +1,15 @@ +try: from setuptools import setup +except: from distutils.core import setup + +setup( long_description=open("README.rst").read(), + name="""PyCRS""", + license="""MIT""", + author="""Karim Bahgat""", + author_email="""karim.bahgat.norway@gmail.com""", + url="""http://github.com/karimbahgat/PyCRS""", + version="""0.1.2""", + keywords="""GIS spatial CRS coordinates format""", + packages=['pycrs', 'pycrs\\elements'], + classifiers=['License :: OSI Approved', 'Programming Language :: Python', 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', 'Intended Audience :: End Users/Desktop', 'Topic :: Scientific/Engineering :: GIS'], + description="""GIS package for reading, writing, and converting between CRS formats.""", + ) diff --git a/testrenders/Thumbs.db b/testrenders/Thumbs.db index 2a7623b..f4b12e5 100644 Binary files a/testrenders/Thumbs.db and b/testrenders/Thumbs.db differ diff --git a/upload.py b/upload.py new file mode 100644 index 0000000..ae3008c --- /dev/null +++ b/upload.py @@ -0,0 +1,25 @@ +import pypi + +packpath = "pycrs" +pypi.define_upload(packpath, + author="Karim Bahgat", + author_email="karim.bahgat.norway@gmail.com", + license="MIT", + name="PyCRS", + changes=["First official release"], + description="GIS package for reading, writing, and converting between CRS formats.", + url="http://github.com/karimbahgat/PyCRS", + keywords="GIS spatial CRS coordinates format", + classifiers=["License :: OSI Approved", + "Programming Language :: Python", + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + 'Intended Audience :: End Users/Desktop', + "Topic :: Scientific/Engineering :: GIS"], + ) + +pypi.generate_docs(packpath) +#pypi.upload_test(packpath) +#pypi.upload(packpath) +