Last active
January 14, 2025 06:59
-
Star
(144)
You must be signed in to star a gist -
Fork
(17)
You must be signed in to fork a gist
-
-
Save sgillies/2217756 to your computer and use it in GitHub Desktop.
Revisions
-
sgillies renamed this gist
Mar 22, 2017 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -135,9 +135,9 @@ References ========== .. [1] http://docs.scipy.org/doc/numpy/reference/arrays.interface.html .. [2] https://tools.ietf.org/html/rfc7946 .. [3] https://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/asshape.htm .. [4] https://bitbucket.org/sgillies/descartes/src/f97e54f3b8d4/descartes/patch.py#cl-14 .. [5] http://pypi.python.org/pypi/geojson/ .. [6] https://pysal.readthedocs.io/en/latest/users/tutorials/shapely.html .. [7] https://github.com/Toblerity/Shapely -
sgillies revised this gist
Mar 28, 2012 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,10 @@ Author: Sean Gillies Version: 1.0 Abstract ======== This document describes a GeoJSON-like protocol for geo-spatial (GIS) vector data. Introduction ============ @@ -12,7 +13,7 @@ Python has a number of built-in protocols (descriptors, iterators, etc). A very simple and familiar one involves string representations of objects. The built-in ``str()`` function calls the ``__str__()`` method of its single argument. By implementing ``__str__()``, instances of any class can be printed by any other Python program. :: >>> class A(object): @@ -25,7 +26,7 @@ by anyother Python program. >>> "%s" % a 'Eh!' What if we could do something like this for geo-spatial objects? It might, for example, let any object be analyzed using any other hypothetical software package like this:: @@ -53,7 +54,7 @@ type (required) a geometry type: "Point", "LineString", "Polygon", etc. bbox (optional) A tuple of floats that describes the geo-spatial bounds of the object: (left, bottom, right, top) or (west, south, east, north). properties (optional) -
sgillies revised this gist
Mar 28, 2012 . 1 changed file with 25 additions and 16 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,9 +8,12 @@ This document describes a GeoJSON-like protocol for geospatial vector data. Introduction ============ Python has a number of built-in protocols (descriptors, iterators, etc). A very simple and familiar one involves string representations of objects. The built-in ``str()`` function calls the ``__str__()`` method of its single argument. By implementing ``__str__()``, instances of any class can be printed by anyother Python program. :: >>> class A(object): ... def __str__(self): @@ -22,18 +25,17 @@ function calls the ``__str__()`` method of its single argument. Example:: >>> "%s" % a 'Eh!' What if we could do something like this for geospatial (GIS) objects? It might, for example, let any object be analyzed using any other hypothetical software package like this:: >>> from some_analytic_module import as_geometry >>> as_geometry(obj).buffer(1.0).area # obj is a "point" of some kind 3.1365484905459389 The hypothetical ``as_geometry()`` function of the hypothetical `some_analytic_module` module would access relevant data of its single argument using an agreed upon method or attribute. __geo_interface__ ================= @@ -92,14 +94,18 @@ Next, a toy class with a feature representation:: Implementations =============== Python programs and packages that you have heard of – and made be a frequent user of – already implement this protocol: * ArcPy [3]_ * descartes [4]_ * geojson [5]_ * PySAL [6]_ Shapely ------- Shapely [7]_ provides a ``shape()`` function that makes Shapely geometries from objects that provide ``__geo_interface__`` and a ``mapping()`` function that writes geometries out as dictionaries:: @@ -129,5 +135,8 @@ References .. [1] http://docs.scipy.org/doc/numpy/reference/arrays.interface.html .. [2] http://geojson.org .. [3] http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000153000000 .. [4] https://bitbucket.org/sgillies/descartes/src/f97e54f3b8d4/descartes/patch.py#cl-14 .. [5] http://pypi.python.org/pypi/geojson/ .. [6] http://pysal.geodacenter.org/1.3/users/tutorials/shapely.html .. [7] https://github.com/Toblerity/Shapely -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 1 addition and 116 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,4 @@ Author: Sean Gillies Abstract ======== @@ -137,112 +131,3 @@ References .. [2] http://geojson.org .. [3] https://github.com/Toblerity/Shapely -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 133 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,9 +3,142 @@ Abstract This document describes a GeoJSON-like protocol for geospatial vector data. Introduction ============Author: Sean Gillies Abstract ======== This document describes a GeoJSON-like protocol for geospatial vector data. Introduction ============ Python has a number of built-in protocols (descriptor, iterator, etc). A very simple one involves string representations of objects. The built-in ``str()`` function calls the ``__str__()`` method of its single argument. Example:: >>> class A(object): ... def __str__(self): ... return "Eh!" ... >>> a = A() >>> str(a) 'Eh!' >>> "%s" % a 'Eh!' By implementing ``__str__()``, instances of any class can be printed by any other Python program. What if we could do something like this for geospatial (GIS) objects? It might, for example, let any object be analyzed using any other hypothetical software package like this:: >>> from some_analytic_module import as_geometry >>> as_geometry(obj).buffer(1.0).area # obj is a "point" of some kind 3.1365484905459389 The hypothetical ``as_geometry()`` function of the hypothetical module would access relevant data of its single argument using an agreed upon method or attribute. __geo_interface__ ================= Following the lead of numpy's Array Interface [1]_, let's agree on a ``__geo_interface__`` property. To avoid creating even more protocols, let's make the value of this attribute a Python mapping. To further minimize invention, let's borrow from the GeoJSON format [2]_ for the structure of this mapping. The keys are: type (required) A string indicating the geospatial type. Possible values are "Feature" or a geometry type: "Point", "LineString", "Polygon", etc. bbox (optional) A tuple of floats that describes the geospatial bounds of the object: (left, bottom, right, top) or (west, south, east, north). properties (optional) A mapping of feature properties (labels, populations ... you name it. Dependent on the data). Valid for "Feature" types only. geometry (optional) The geometric object of a "Feature" type, also as a mapping. coordinates (required) Valid only for geometry types. This is an ``(x, y)`` or ``(longitude, latitude)`` tuple in the case of a "Point", a list of such tuples in the "LineString" case, or a list of lists in the "Polygon" case. See the GeoJSON spec for details. Examples ======== First, a toy class with a point representation:: >>> class Pointy(object): ... __geo_interface__ = {'type': 'Point', 'coordinates': (0.0, 0.0)} ... >>> as_geometry(Pointy()).buffer(1.0).area 3.1365484905459389 Next, a toy class with a feature representation:: >>> class Placemark(object): ... __geo_interface__ = { ... 'type': 'Feature', ... 'properties': {'name': 'Phoo'}, ... 'geometry': Pointy.__geo_interface__ } >>> from my_analytic_module import as_feature >>> as_feature(Placemark())['properties']['name'] 'Phoo' Implementations =============== * `ArcPy <http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000153000000>`__ * `descartes <https://bitbucket.org/sgillies/descartes/src/f97e54f3b8d4/descartes/patch.py#cl-14>`__ * `PySAL <http://pysal.geodacenter.org/1.3/users/tutorials/shapely.html>`__ Shapely ------- Shapely [3]_ provides a ``shape()`` function that makes Shapely geometries from objects that provide ``__geo_interface__`` and a ``mapping()`` function that writes geometries out as dictionaries:: >>> from shapely.geometry import Point >>> from shapely.geometry import mapping, shape >>> Point(0.0, 0.0).__geo_interface__ {'type': 'Point', 'coordinates': (0.0, 0.0)} >>> shape(Point(0.0, 0.0)) <shapely.geometry.point.Point object at 0x...> >>> mapping(Point(0.0, 0.0)) {'type': 'Point', 'coordinates': (0.0, 0.0)} The Shapely version of the example in the introduction is:: >>> from shapely.geometry import shape >>> shape(obj).buffer(1.0).area 3.1365484905459389 where ``obj`` could be a geometry object from ArcPy or PySAL, or even a mapping directly:: >>> shape({'type': 'Point', 'coordinates': (0.0, 0.0)}).buffer(1.0).area 3.1365484905459389 References ========== .. [1] http://docs.scipy.org/doc/numpy/reference/arrays.interface.html .. [2] http://geojson.org .. [3] https://github.com/Toblerity/Shapely Python has a number of built-in protocols (descriptor, iterator, etc). A very simple one involves string representations of objects. The built-in ``str()`` function calls the ``__str__()`` method of its single argument. Example:: >>> class A(object): -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,7 @@ The hypothetical ``as_geometry()`` function of the hypothetical module would acc __geo_interface__ ================= Following the lead of numpy's Array Interface [1]_, let's agree on a ``__geo_interface__`` property. To avoid creating even more protocols, let's make the value of this attribute a Python mapping. To further minimize invention, let's borrow from the GeoJSON format [2]_ for the structure of this mapping. -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 14 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ This document describes a GeoJSON-like protocol for geospatial vector data. Introduction ============ Python has a number of built-in protocols (descriptor, iterator, etc). A very simple one involves string representations of objects. The built-in ``str()`` function calls the ``__str__()`` method of its single argument. Example:: >>> class A(object): ... def __str__(self): @@ -18,8 +18,8 @@ Python has a number of built-in protocols (descriptor, iterator, etc). A very si >>> "%s" % a 'Eh!' By implementing ``__str__()``, instances of any class can be printed by any other Python program. What if we could do something like this for geospatial (GIS) objects? It might, for example, let any object be analyzed using any other hypothetical software package like this:: >>> from some_analytic_module import as_geometry >>> as_geometry(obj).buffer(1.0).area # obj is a "point" of some kind @@ -96,6 +96,17 @@ out as dictionaries:: >>> mapping(Point(0.0, 0.0)) {'type': 'Point', 'coordinates': (0.0, 0.0)} The Shapely version of the example in the introduction is:: >>> from shapely.geometry import shape >>> shape(obj).buffer(1.0).area 3.1365484905459389 where ``obj`` could be a geometry object from ArcPy or PySAL, or even a mapping directly:: >>> shape({'type': 'Point', 'coordinates': (0.0, 0.0)}).buffer(1.0).area 3.1365484905459389 References ========== -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -76,9 +76,9 @@ Next, a toy class with a feature representation:: Implementations =============== * `ArcPy <http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000153000000>`__ * `descartes <https://bitbucket.org/sgillies/descartes/src/f97e54f3b8d4/descartes/patch.py#cl-14>`__ * `PySAL <http://pysal.geodacenter.org/1.3/users/tutorials/shapely.html>`__ Shapely ------- -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 22 additions and 10 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,21 +30,18 @@ The hypothetical ``as_geometry()`` function of the hypothetical module would acc __geo_interface__ ================= Following the lead of numpy's Array Interface [1]_, let's agree on a ``__geo_interface__`` attribute. To avoid creating even more protocols, let's make the value of this attribute a Python mapping. To further minimize invention, let's borrow from the GeoJSON format [2]_ for the structure of this mapping. The keys are: type (required) A string indicating the geospatial type. Possible values are "Feature" or a geometry type: "Point", "LineString", "Polygon", etc. bbox (optional) A tuple of floats that describes the geospatial bounds of the object: (left, bottom, right, top) or (west, south, east, north). properties (optional) A mapping of feature properties (labels, populations ... you name it. Dependent on the data). Valid for "Feature" types only. @@ -82,11 +79,26 @@ Implementations * ArcPy * descartes * PySAL Shapely ------- Shapely [3]_ provides a ``shape()`` function that makes Shapely geometries from objects that provide ``__geo_interface__`` and a ``mapping()`` function that writes geometries out as dictionaries:: >>> from shapely.geometry import Point >>> from shapely.geometry import mapping, shape >>> Point(0.0, 0.0).__geo_interface__ {'type': 'Point', 'coordinates': (0.0, 0.0)} >>> shape(Point(0.0, 0.0)) <shapely.geometry.point.Point object at 0x...> >>> mapping(Point(0.0, 0.0)) {'type': 'Point', 'coordinates': (0.0, 0.0)} References ========== .. [1] http://docs.scipy.org/doc/numpy/reference/arrays.interface.html .. [2] http://geojson.org .. [3] https://github.com/Toblerity/Shapely -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 16 additions and 5 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,11 +21,11 @@ Python has a number of built-in protocols (descriptor, iterator, etc). A very si By implementing ``__str__()``, instances of any class can be printed by any other Python program. What if we could do something like this for geospatial (GIS) objects? It might, for example, let any object be analyzed using another hypothetical software package like this:: >>> from some_analytic_module import as_geometry >>> as_geometry(obj).buffer(1.0).area # obj is a "point" of some kind 3.1365484905459389 The hypothetical ``as_geometry()`` function of the hypothetical module would access relevant data of its single argument using an agreed upon method or attribute. __geo_interface__ ================= @@ -57,14 +57,25 @@ coordinates (required) Examples ======== First, a toy class with a point representation:: >>> class Pointy(object): ... __geo_interface__ = {'type': 'Point', 'coordinates': (0.0, 0.0)} ... >>> as_geometry(Pointy()).buffer(1.0).area 3.1365484905459389 Next, a toy class with a feature representation:: >>> class Placemark(object): ... __geo_interface__ = { ... 'type': 'Feature', ... 'properties': {'name': 'Phoo'}, ... 'geometry': Pointy.__geo_interface__ } >>> from my_analytic_module import as_feature >>> as_feature(Placemark())['properties']['name'] 'Phoo' Implementations =============== -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,14 +18,14 @@ Python has a number of built-in protocols (descriptor, iterator, etc). A very si >>> "%s" % a 'Eh!' By implementing ``__str__()``, instances of any class can be printed by any other Python program. What if we could do something like this for geospatial (GIS) objects? It might, for example, let any object be analyzed using another hypothetical software package like this:: >>> from some_analytic_module import shape >>> shape(obj).buffer(1.0).area # obj is a "point" of some kind 3.1365484905459389 The ``shape()`` function of the hypothetical module would access relevant data of its single argument using an agreed upon method or attribute. __geo_interface__ ================= -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -65,6 +65,14 @@ Here's a toy class with a point representation:: >>> shape(Pointy()).buffer(1.0).area 3.1365484905459389 Implementations =============== * ArcPy * descartes * PySAL * Shapely References ========== -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -57,7 +57,13 @@ coordinates (required) Examples ======== Here's a toy class with a point representation:: >>> class Pointy(object): ... __geo_interface__ = {'type': 'Point', 'coordinates': (0.0, 0.0)} ... >>> shape(Pointy()).buffer(1.0).area 3.1365484905459389 References ========== -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 15 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,7 +43,21 @@ bbox (optional) A tuple of floats that describes the geospatial bounds of the object: (left, bottom, right, top) or (west, south, east, north). features (optional) An iterator (including lists and other sequences) over "Feature" type mappings. Valid for "FeatureCollection" types only. properties (optional) A mapping of feature properties (labels, populations ... you name it. Dependent on the data). Valid for "Feature" types only. geometry (optional) The geometric object of a "Feature" type, also as a mapping. coordinates (required) Valid only for geometry types. This is an ``(x, y)`` or ``(longitude, latitude)`` tuple in the case of a "Point", a list of such tuples in the "LineString" case, or a list of lists in the "Polygon" case. See the GeoJSON spec for details. Examples ======== A class References ========== -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,8 +36,14 @@ borrow from the GeoJSON format [3]_ for the structure of this mapping. The keys are: type (required) A string indicating the geospatial type. Possible values are "FeatureCollection", "Feature", or a geometry type: "Point", "LineString", "Polygon", etc. bbox (optional) A tuple of floats that describes the geospatial bounds of the object: (left, bottom, right, top) or (west, south, east, north). features (optional) A list of "Feature" type mappings. Valid only "FeatureCollection" types only. References ========== -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 11 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,6 +34,14 @@ Following the lead of numpy's Array Interface [2]_, let's agree on a ``__geo_int even more protocols, let's make the value of this attribute a Python mapping. To further minimize invention, let's borrow from the GeoJSON format [3]_ for the structure of this mapping. The keys are: type (string) "FeatureCollection", "Feature", or a geometry type: "Point", "LineString", "Polygon", etc. References ========== .. [1] https://github.com/Toblerity/Shapely .. [2] http://docs.scipy.org/doc/numpy/reference/arrays.interface.html .. [3] http://geojson.org -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,6 +34,6 @@ Following the lead of numpy's Array Interface [2]_, let's agree on a ``__geo_int even more protocols, let's make the value of this attribute a Python mapping. To further minimize invention, let's borrow from the GeoJSON format [3]_ for the structure of this mapping. [1] https://github.com/Toblerity/Shapely [2] http://docs.scipy.org/doc/numpy/reference/arrays.interface.html [3] http://geojson.org -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 8 additions and 4 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,8 +18,8 @@ Python has a number of built-in protocols (descriptor, iterator, etc). A very si >>> "%s" % a 'Eh!' By implementing ``__str__()``, instances of any class can be printed by any other Python program. What if we could do something like this for geospatial (GIS) objects? It might, for example, let any object be analyzed using Shapely [1]_ as simply as:: >>> from shapely.geometry import shape >>> shape(obj).buffer(1.0).area # obj is a "point" of some kind @@ -30,6 +30,10 @@ Shapely's ``shape()`` function would access relevant data of its single argument __geo_interface__ ================= Following the lead of numpy's Array Interface [2]_, let's agree on a ``__geo_interface__`` attribute. To avoid creating even more protocols, let's make the value of this attribute a Python mapping. To further minimize invention, let's borrow from the GeoJSON format [3]_ for the structure of this mapping. .. [1] https://github.com/Toblerity/Shapely .. [2] http://docs.scipy.org/doc/numpy/reference/arrays.interface.html .. [3] http://geojson.org -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,6 +30,6 @@ Shapely's ``shape()`` function would access relevant data of its single argument __geo_interface__ ================= Following the lead of numpy's Array Interface [1]_, let's agree on a ``__geo_interface__`` attribute. .. [1] http://docs.scipy.org/doc/numpy/reference/arrays.interface.html -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,9 +25,11 @@ simply as:: >>> shape(obj).buffer(1.0).area # obj is a "point" of some kind 3.1365484905459389 Shapely's ``shape()`` function would access relevant data of its single argument using an agreed upon method or attribute. __geo_interface__ ================= Following the lead of numpy's Array Interface [1], let's agree on a ``__geo_interface__`` attribute. [1] http://docs.scipy.org/doc/numpy/reference/arrays.interface.html -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 25 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,31 @@ Abstract ======== This document describes a GeoJSON-like protocol for geospatial vector data. Introduction ============ Python has a number of built-in protocols (descriptor, iterator, etc). A very simple one involves string representations of objects. The built-in ``str()`` function delegates to the ``__str__()`` method of its single argument. Example:: >>> class A(object): ... def __str__(self): ... return "Eh!" ... >>> a = A() >>> str(a) 'Eh!' >>> "%s" % a 'Eh!' By implementing ``__str__()``, instances of any class can be printed by any other Python program. What if we could do something like this for geospatial (GIS) objects? It might, for example, let any object be analyzed using Shapely as simply as:: >>> from shapely.geometry import shape >>> shape(obj).buffer(1.0).area # obj is a "point" of some kind 3.1365484905459389 Shapely's ``shape()`` function would access some data of its single argument using an agreed upon method or attribute. __geo_interface__ ================= -
sgillies revised this gist
Mar 27, 2012 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,9 @@ Introduction ============ Blah, blah. __geo_interface__ ================= A mapping with a type key. -
sgillies created this gist
Mar 27, 2012 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ __geo_interface__ A mapping with a type key.