Python bindings and utilities for GeoJSON

Overview

geojson

GitHub Actions Codecov Jazzband

This Python library contains:

Table of Contents

Installation

geojson is compatible with Python 3.6 - 3.9. The recommended way to install is via pip:

pip install geojson

GeoJSON Objects

This library implements all the GeoJSON Objects described in The GeoJSON Format Specification.

All object keys can also be used as attributes.

The objects contained in GeometryCollection and FeatureCollection can be indexed directly.

Point

>>> from geojson import Point

>>> Point((-115.81, 37.24))  # doctest: +ELLIPSIS
{"coordinates": [-115.8..., 37.2...], "type": "Point"}

Visualize the result of the example above here. General information about Point can be found in Section 3.1.2 and Appendix A: Points within The GeoJSON Format Specification.

MultiPoint

>>> from geojson import MultiPoint

>>> MultiPoint([(-155.52, 19.61), (-156.22, 20.74), (-157.97, 21.46)])  # doctest: +ELLIPSIS
{"coordinates": [[-155.5..., 19.6...], [-156.2..., 20.7...], [-157.9..., 21.4...]], "type": "MultiPoint"}

Visualize the result of the example above here. General information about MultiPoint can be found in Section 3.1.3 and Appendix A: MultiPoints within The GeoJSON Format Specification.

LineString

>>> from geojson import LineString

>>> LineString([(8.919, 44.4074), (8.923, 44.4075)])  # doctest: +ELLIPSIS
{"coordinates": [[8.91..., 44.407...], [8.92..., 44.407...]], "type": "LineString"}

Visualize the result of the example above here. General information about LineString can be found in Section 3.1.4 and Appendix A: LineStrings within The GeoJSON Format Specification.

MultiLineString

>>> from geojson import MultiLineString

>>> MultiLineString([
...     [(3.75, 9.25), (-130.95, 1.52)],
...     [(23.15, -34.25), (-1.35, -4.65), (3.45, 77.95)]
... ])  # doctest: +ELLIPSIS
{"coordinates": [[[3.7..., 9.2...], [-130.9..., 1.52...]], [[23.1..., -34.2...], [-1.3..., -4.6...], [3.4..., 77.9...]]], "type": "MultiLineString"}

Visualize the result of the example above here. General information about MultiLineString can be found in Section 3.1.5 and Appendix A: MultiLineStrings within The GeoJSON Format Specification.

Polygon

>>> from geojson import Polygon

>>> # no hole within polygon
>>> Polygon([[(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)]])  # doctest: +ELLIPSIS
{"coordinates": [[[2.3..., 57.32...], [23.19..., -20.2...], [-120.4..., 19.1...]]], "type": "Polygon"}

>>> # hole within polygon
>>> Polygon([
...     [(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)],
...     [(-5.21, 23.51), (15.21, -10.81), (-20.51, 1.51), (-5.21, 23.51)]
... ])  # doctest: +ELLIPSIS
{"coordinates": [[[2.3..., 57.32...], [23.19..., -20.2...], [-120.4..., 19.1...]], [[-5.2..., 23.5...], [15.2..., -10.8...], [-20.5..., 1.5...], [-5.2..., 23.5...]]], "type": "Polygon"}

Visualize the results of the example above here. General information about Polygon can be found in Section 3.1.6 and Appendix A: Polygons within The GeoJSON Format Specification.

MultiPolygon

>>> from geojson import MultiPolygon

>>> MultiPolygon([
...     ([(3.78, 9.28), (-130.91, 1.52), (35.12, 72.234), (3.78, 9.28)],),
...     ([(23.18, -34.29), (-1.31, -4.61), (3.41, 77.91), (23.18, -34.29)],)
... ])  # doctest: +ELLIPSIS
{"coordinates": [[[[3.7..., 9.2...], [-130.9..., 1.5...], [35.1..., 72.23...]]], [[[23.1..., -34.2...], [-1.3..., -4.6...], [3.4..., 77.9...]]]], "type": "MultiPolygon"}

Visualize the result of the example above here. General information about MultiPolygon can be found in Section 3.1.7 and Appendix A: MultiPolygons within The GeoJSON Format Specification.

GeometryCollection

>>> from geojson import GeometryCollection, Point, LineString

>>> my_point = Point((23.532, -63.12))

>>> my_line = LineString([(-152.62, 51.21), (5.21, 10.69)])

>>> geo_collection = GeometryCollection([my_point, my_line])

>>> geo_collection  # doctest: +ELLIPSIS
{"geometries": [{"coordinates": [23.53..., -63.1...], "type": "Point"}, {"coordinates": [[-152.6..., 51.2...], [5.2..., 10.6...]], "type": "LineString"}], "type": "GeometryCollection"}

>>> geo_collection[1]
{"coordinates": [[-152.62, 51.21], [5.21, 10.69]], "type": "LineString"}

>>> geo_collection[0] == geo_collection.geometries[0]
True

Visualize the result of the example above here. General information about GeometryCollection can be found in Section 3.1.8 and Appendix A: GeometryCollections within The GeoJSON Format Specification.

Feature

>>> from geojson import Feature, Point

>>> my_point = Point((-3.68, 40.41))

>>> Feature(geometry=my_point)  # doctest: +ELLIPSIS
{"geometry": {"coordinates": [-3.68..., 40.4...], "type": "Point"}, "properties": {}, "type": "Feature"}

>>> Feature(geometry=my_point, properties={"country": "Spain"})  # doctest: +ELLIPSIS
{"geometry": {"coordinates": [-3.68..., 40.4...], "type": "Point"}, "properties": {"country": "Spain"}, "type": "Feature"}

>>> Feature(geometry=my_point, id=27)  # doctest: +ELLIPSIS
{"geometry": {"coordinates": [-3.68..., 40.4...], "type": "Point"}, "id": 27, "properties": {}, "type": "Feature"}

Visualize the results of the examples above here. General information about Feature can be found in Section 3.2 within The GeoJSON Format Specification.

FeatureCollection

>>> from geojson import Feature, Point, FeatureCollection

>>> my_feature = Feature(geometry=Point((1.6432, -19.123)))

>>> my_other_feature = Feature(geometry=Point((-80.234, -22.532)))

>>> feature_collection = FeatureCollection([my_feature, my_other_feature])

>>> feature_collection # doctest: +ELLIPSIS
{"features": [{"geometry": {"coordinates": [1.643..., -19.12...], "type": "Point"}, "properties": {}, "type": "Feature"}, {"geometry": {"coordinates": [-80.23..., -22.53...], "type": "Point"}, "properties": {}, "type": "Feature"}], "type": "FeatureCollection"}

>>> feature_collection.errors()
[]

>>> (feature_collection[0] == feature_collection['features'][0], feature_collection[1] == my_other_feature)
(True, True)

Visualize the result of the example above here. General information about FeatureCollection can be found in Section 3.3 within The GeoJSON Format Specification.

GeoJSON encoding/decoding

All of the GeoJSON Objects implemented in this library can be encoded and decoded into raw GeoJSON with the geojson.dump, geojson.dumps, geojson.load, and geojson.loads functions. Note that each of these functions is a wrapper around the core json function with the same name, and will pass through any additional arguments. This allows you to control the JSON formatting or parsing behavior with the underlying core json functions.

>>> import geojson

>>> my_point = geojson.Point((43.24, -1.532))

>>> my_point  # doctest: +ELLIPSIS
{"coordinates": [43.2..., -1.53...], "type": "Point"}

>>> dump = geojson.dumps(my_point, sort_keys=True)

>>> dump  # doctest: +ELLIPSIS
'{"coordinates": [43.2..., -1.53...], "type": "Point"}'

>>> geojson.loads(dump)  # doctest: +ELLIPSIS
{"coordinates": [43.2..., -1.53...], "type": "Point"}

Custom classes

This encoding/decoding functionality shown in the previous can be extended to custom classes using the interface described by the __geo_interface__ Specification.

>>> import geojson

>>> class MyPoint():
...     def __init__(self, x, y):
...         self.x = x
...         self.y = y
...
...     @property
...     def __geo_interface__(self):
...         return {'type': 'Point', 'coordinates': (self.x, self.y)}

>>> point_instance = MyPoint(52.235, -19.234)

>>> geojson.dumps(point_instance, sort_keys=True)  # doctest: +ELLIPSIS
'{"coordinates": [52.23..., -19.23...], "type": "Point"}'

Default and custom precision

GeoJSON Object-based classes in this package have an additional precision attribute which rounds off coordinates to 6 decimal places (roughly 0.1 meters) by default and can be customized per object instance.

>>> from geojson import Point

>>> Point((-115.123412341234, 37.123412341234))  # rounded to 6 decimal places by default
{"coordinates": [-115.123412, 37.123412], "type": "Point"}

>>> Point((-115.12341234, 37.12341234), precision=8)  # rounded to 8 decimal places
{"coordinates": [-115.12341234, 37.12341234], "type": "Point"}

Helpful utilities

coords

geojson.utils.coords yields all coordinate tuples from a geometry or feature object.

>>> import geojson

>>> my_line = LineString([(-152.62, 51.21), (5.21, 10.69)])

>>> my_feature = geojson.Feature(geometry=my_line)

>>> list(geojson.utils.coords(my_feature))  # doctest: +ELLIPSIS
[(-152.62..., 51.21...), (5.21..., 10.69...)]

map_coords

geojson.utils.map_coords maps a function over all coordinate values and returns a geometry of the same type. Useful for scaling a geometry.

>>> import geojson

>>> new_point = geojson.utils.map_coords(lambda x: x/2, geojson.Point((-115.81, 37.24)))

>>> geojson.dumps(new_point, sort_keys=True)  # doctest: +ELLIPSIS
'{"coordinates": [-57.905..., 18.62...], "type": "Point"}'

map_tuples

geojson.utils.map_tuples maps a function over all coordinates and returns a geometry of the same type. Useful for changing coordinate order or applying coordinate transforms.

>>> import geojson

>>> new_point = geojson.utils.map_tuples(lambda c: (c[1], c[0]), geojson.Point((-115.81, 37.24)))

>>> geojson.dumps(new_point, sort_keys=True)  # doctest: +ELLIPSIS
'{"coordinates": [37.24..., -115.81], "type": "Point"}'

map_geometries

geojson.utils.map_geometries maps a function over each geometry in the input.

>>> import geojson

>>> new_point = geojson.utils.map_geometries(lambda g: geojson.MultiPoint([g["coordinates"]]), geojson.GeometryCollection([geojson.Point((-115.81, 37.24))]))

>>> geojson.dumps(new_point, sort_keys=True)
'{"geometries": [{"coordinates": [[-115.81, 37.24]], "type": "MultiPoint"}], "type": "GeometryCollection"}'

validation

is_valid property provides simple validation of GeoJSON objects.

>>> import geojson

>>> obj = geojson.Point((-3.68,40.41,25.14,10.34))
>>> obj.is_valid
False

errors method provides collection of errors when validation GeoJSON objects.

>>> import geojson

>>> obj = geojson.Point((-3.68,40.41,25.14,10.34))
>>> obj.errors()
'a position must have exactly 2 or 3 values'

generate_random

geojson.utils.generate_random yields a geometry type with random data

>>> import geojson

>>> geojson.utils.generate_random("LineString")  # doctest: +ELLIPSIS
{"coordinates": [...], "type": "LineString"}

>>> geojson.utils.generate_random("Polygon")  # doctest: +ELLIPSIS
{"coordinates": [...], "type": "Polygon"}

Development

To build this project, run python setup.py build. To run the unit tests, run python setup.py test. To run the style checks, run flake8 (install flake8 if needed).

Credits

Comments
  • Default Precision Issues

    Default Precision Issues

    I understand the rationale with the default precision in v2.5 for those that want smaller geojson files, but I'm curious why the default isn't to behave as in previous versions? This change isn't backwards compatible in the sense that data read/written with 2.4 will come in different in 2.5, so at a minimum I suppose the version should have bumped to v3.

    Is there opposition to changing the default precision to be backwards compatible and those that want it truncated can opt in?

    opened by youngpm 23
  • Add option to allow specifying floating point precision on geojson.dump/geojson.dumps

    Add option to allow specifying floating point precision on geojson.dump/geojson.dumps

    Just received an email with this request:

    I would like to suggest that you provide a means to specify the precision of floats that the module outputs, perhaps a format string as an argument to dump()/dumps().

    A typical coordinate coming from geojson looks like: [-74.4995503571598, 39.42247551734061]. That's 14 decimal places in the fraction, far, far more than I'll ever need considering that 8 places gives 1.1mm precision. I would like to reduce the file size by limiting the precision to a sensible value.

    enhancement 
    opened by frewsxcv 10
  • Improve the documentation

    Improve the documentation

    Right now the documentation is relatively unorganized and not entirely informative. Possible suggestions for improvement include conversion to markdown (for use on GitHub) or rst (for use on readthedocs). Additionally, a complete page documenting the API would greatly benefit new users. As per this comment I'd be willing to take this task

    opened by frewsxcv 10
  • Fix map_geometries() loss of feature IDs

    Fix map_geometries() loss of feature IDs

    opened by bryik 8
  • Point with 3 coordinates or more does not pass validation while valid as per the GeoJSON specs

    Point with 3 coordinates or more does not pass validation while valid as per the GeoJSON specs

    Please excuse me if I'm mistaken, but as I was reading the GeoJSON specs, I came accross a paragraph mentioning positions with more than two elements:

    A position is represented by an array of numbers. There must be at least two elements, and may be more. The order of elements must follow x, y, z order (easting, northing, altitude for coordinates in a projected coordinate reference system, or longitude, latitude, altitude for coordinates in a geographic coordinate reference system). Any number of additional elements are allowed -- interpretation and meaning of additional elements is beyond the scope of this specification.

    In python-geojson's validator, this is explicitly forbidden:

    code:

        if isinstance(obj, geojson.Point):
            if len(obj['coordinates']) != 2:
                return output('the "coordinates" member must be a single position')
    

    tests:

        def test_invalid_point(self):
            point = geojson.Point((10, 20, 30))
            self.assertEqual(is_valid(point)['valid'], NO)
    

    If my understanding is correct, the validator should allow any number of elements greater than of equal to two.

    The same change was made in MongoDB:

    • https://jira.mongodb.org/browse/SERVER-9220
    • https://github.com/mongodb/mongo/commit/bd489b1c2c76a7ee84105db758839c4d47ffcbcb
    bug 
    opened by lafrech 8
  • Generate random geojson

    Generate random geojson

    Hey everyone,

    Thanks for a great python library. Just wondering if you'd be interested in extending it to support generating random features? eg create me a linestring.

    >>> from geojson import LineString
    
    >>> Random_LineString() 
    {"coordinates": [[8.91..., 44.407...], [8.92..., 44.407...]], "type": "LineString"}
    

    I'd be happy to attempt to make a start even though I dont entriely know what Im getting myself in for!

    Cheers, Rowan

    opened by rowanwins 8
  • add validation for geojson objects

    add validation for geojson objects

    Hi! I notice what allows to construct object even if is not valid by specification and i created module for checking validation for objects. Now is something like a "concept"(or very restricted version), because i don't know about needs this for you. No tests and no documentation, but contains two objects LineString and MultiLineString. How it works:

    >>> from geojson import LineString, MultiLineString, IsValid
    >>> IsValid(LineString([(8.919, 44.4074), (8.923, 44.4075)]))
    {'valid': 'yes', 'message': ''}
    >>> IsValid(LineString([(8.919, 44.4074)]))
    {'valid': 'no', 'message': 'the "coordinates" member must be an array of two or more positions'}
    >>> IsValid(MultiLineString([[(10,5), (4,3)]]))
    {'message': '', 'valid': 'yes'}
    >>> IsValid(MultiLineString([[(10,5)]]))
    {'message': 'the "coordinates" member must be an array of LineString coordinate arrays', 'valid': 'no'}
    

    The messages is just a copy-paste from specification What do you think about this?

    opened by saromanov 8
  • Test Python 3.10 release candidate

    Test Python 3.10 release candidate

    Python 3.10.0 final is due for release in October:

    • https://www.python.org/dev/peps/pep-0619/

    The first release candidate is now out and the Python release team has issued a call to action for community members:

    We strongly encourage maintainers of third-party Python projects to prepare their projects for 3.10 compatibilities during this phase. As always, report any issues to the Python bug tracker.

    https://discuss.python.org/t/python-3-10-0rc1-is-now-available/9982?u=hugovk

    So let's also test 3.10 on the CI. The good news is everything passes.


    I didn't yet add 3.10 to python_requires, classifiers or README.rst, that can wait until 3.10 is released and officially supported, but could be updated now if you wish.

    opened by hugovk 7
  • Circular reference on module import

    Circular reference on module import

    Hello there,

    I'm experiencing an endless sequence of Import Errors because there's several circular references between base.py, codec.py, factory.py and mapping.py.

    I'm at the end of my tether trying to make them work as they are so I reckon I'll just merge those files into one.

    I'd recommend for you to rearrange the classes in a way that prevent this from happening.

    Anyway, thanks for making available this library! :-)

    Cheers, Rodrigo Gambra

    opened by tiktaalik-dev 7
  • rewrite of validation mechanism

    rewrite of validation mechanism

    There was a conceptual problem with validation function, since it assumes "valid" for all unknown instances. This in turn generates valid status for some otherwise false imputs (false positives). This implementation instead assumes "not implemented" unless "errors" method is implemented on all subitems.

    This change introduces small incompatibility with previous version.

    • is_valid function is removed
    • obj.is_valid property is introduced instead
    • obj.errors() method is introduced to get error details

    Test cases and README file is changed to reflect the change.

    I have only small set of geojson data available. I suggest to run validation tests on bigger dataset if you have it available.

    opened by zoranbosnjak 6
  • Polygon Encoding issue

    Polygon Encoding issue

    Hi Geojson Team, thanks for this great library.

    I'm having an issue when putting Polygon Features together into a FeatureCollection. Here's an example.

    import geojson
    from geojson import Point, Polygon, Feature, FeatureCollection
    
    a = Polygon([(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15)])
    b = Polygon( [(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15)])
    c = Feature(geometry=a)
    d = Feature(geometry=b)
    e = FeatureCollection([c,d])
    print geojson.dumps(e)
    
    {"type": "FeatureCollection", "features": [{"geometry": {"type": "Polygon", "coordinates": [[2.38, 57.322], [23.194, -20.28], [-120.43, 19.15]]}, "type": "Feature", "id": null, "properties": {}}, {"geometry": {"type": "Polygon", "coordinates": [[2.38, 57.322], [23.194, -20.28], [-120.43, 19.15]]}, "type": "Feature", "id": null, "properties": {}}]}'
    

    Notice in the output that there are two brackets in the polygon coordinates. The GeoJson spec for Polygon has three brackets whether the Polyogn has holes or not where the expected output would be as follows:

    {"type": "FeatureCollection", "features": [{"geometry": {"type": "Polygon", "coordinates": [[[2.38, 57.322], [23.194, -20.28], [-120.43, 19.15]]]}, "type": "Feature", "id": null, "properties": {}}, {"geometry": {"type": "Polygon", "coordinates": [][2.38, 57.322], [23.194, -20.28], [-120.43, 19.15][]}, "type": "Feature", "id": null, "properties": {}}]}'
    
    bug 
    opened by zachcp 6
  • Next release?

    Next release?

    This project has undergone breaking changes, including the discontinuation of Python2 and support for the latest Python since its last release three years ago. I know we can try the latest version of geojson with:

    pip install git+https://github.com/jazzband/geojson
    

    But I would like to see geojson's new release on PyPI...

    opened by eggplants 1
  • README renovation

    README renovation

    This project's README is currently written in reStructuredText format, which provides for additional functionality that is lacking from Markdown. The main additional functionality used in this project is the ability to introspect code snippets and run unit tests on them (to help ensure valid code examples in documentation).

    However, the README contains several links to map visualizations which are sadly no longer active and which we are unable to fix for reasons.

    The good news is that GitHub has recently announced native support for GeoJSON map visualizations in GitHub Flavored Markdown (GFM). So, this is the shortest path to adding map visualizations back to the README. Here's an example native GeoJSON Point visualization showing the location of the East River Amphitheater Park in NYC.

    {"coordinates": [-73.9778, 40.7111], "type": "Point"}
    
    {"coordinates": [-73.9778, 40.7111], "type": "Point"}
    

    This new feature is only available for GFM though, not reStructuredText. So, we can have beautiful map visualizations along with each example in the README, or we can introspect and unit test the code snippets for each example in the README, but not both.

    Furthermore, from a packaging perspective, GFM has been natively supported by the PyPi renderer just like reStructuredText since 2019, so that is no longer a reason to avoid GFM.

    My inclination would be to convert the README to GFM and leverage the map visualization feature, as I feel it would make the documentation more accessible, but I want a sense of community support for this.

    If you think sacrificing unit-tested code snippets for built-in GeoJSON map visualizations in the README is a good idea, please give this issue a thumbs up. If you disagree, thumbs down. And of course, comment with any pertinent thoughts.

    Thank you!

    opened by rayrrr 1
  • Implement tox-gh-actions for CI

    Implement tox-gh-actions for CI

    Implement tox-gh-actions for more robust CI testing as per recommendations at https://jazzband.co/about/releases#continuous-integration

    • also bump unit test pypy version to 3.9
    opened by rayrrr 1
  • renaming `master` branch to `main`

    renaming `master` branch to `main`

    opened by rayrrr 0
  • Failing test test_features.FeaturesTest

    Failing test test_features.FeaturesTest

    Hi, I'm porting the package to GNU Guix. One of the tests test_features.FeaturesTest is failing.

    Any suggestion on how to fix it?

    $ python3 --version
    Python 3.9.6
    
    starting phase `check'
    running "python setup.py" with command "test" and parameters ()
    running test
    WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
    running egg_info
    writing geojson.egg-info/PKG-INFO
    writing dependency_links to geojson.egg-info/dependency_links.txt
    writing top-level names to geojson.egg-info/top_level.txt
    adding license file 'LICENSE.rst' (matched pattern 'LICEN[CS]E*')
    reading manifest file 'geojson.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.txt' under directory 'tests'
    writing manifest file 'geojson.egg-info/SOURCES.txt'
    running build_ext
    running test
    WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
    running egg_info
    writing geojson.egg-info/PKG-INFO
    writing dependency_links to geojson.egg-info/dependency_links.txt
    writing top-level names to geojson.egg-info/top_level.txt
    adding license file 'LICENSE.rst' (matched pattern 'LICEN[CS]E*')
    reading manifest file 'geojson.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.txt' under directory 'tests'
    writing manifest file 'geojson.egg-info/SOURCES.txt'
    running build_ext
    test_errors (test_base.BaseTestCase) ... ok
    test_to_instance (test_base.BaseTestCase) ... ok
    test_delattr (test_base.OperatorOverloadingTestCase) ... ok
    test_getattr (test_base.OperatorOverloadingTestCase) ... ok
    test_setattr (test_base.OperatorOverloadingTestCase) ... ok
    test_type_property (test_base.TypePropertyTestCase) ... ok
    test_copy_construction (test_constructor.TestGeoJSONConstructor) ... ok
    test_nested_constructors (test_constructor.TestGeoJSONConstructor) ... ok
    test_dict (test_coords.CoordsTestCase) ... ok
    test_featurecollection (test_coords.CoordsTestCase) ... ok
    test_map_feature (test_coords.CoordsTestCase) ... ok
    test_map_invalid (test_coords.CoordsTestCase) ... ok
    test_map_linestring (test_coords.CoordsTestCase) ... ok
    test_map_multipolygon (test_coords.CoordsTestCase) ... ok
    test_map_point (test_coords.CoordsTestCase) ... ok
    test_map_polygon (test_coords.CoordsTestCase) ... ok
    test_multipolygon (test_coords.CoordsTestCase) ... ok
    test_point (test_coords.CoordsTestCase) ... ok
    test_point_feature (test_coords.CoordsTestCase) ... ok
    test_point_rounding (test_coords.CoordsTestCase) ... ok
    test_feature_class (test_features.FeaturesTest)
    Test the Feature class ... ERROR
    test_geo_interface (test_features.FeaturesTest) ... ok
    test_protocol (test_features.FeaturesTest)
    A dictionary can satisfy the protocol ... ok
    test_unicode_properties (test_features.FeaturesTest) ... ok
    test_GeoJSON (test_geo_interface.EncodingDecodingTest) ... ok
    test_decode (test_geo_interface.EncodingDecodingTest)
    Ensure a GeoJSON string can be decoded into GeoJSON objects ... ok
    test_decode_nested (test_geo_interface.EncodingDecodingTest)
    Ensure a GeoJSON string can be decoded into nested GeoJSON objects ... ok
    test_encode (test_geo_interface.EncodingDecodingTest)
    Ensure objects that implement __geo_interface__ can be encoded into ... ok
    test_encode_nested (test_geo_interface.EncodingDecodingTest)
    Ensure nested objects that implement __geo_interface__ can be encoded ... ok
    test_invalid (test_geo_interface.EncodingDecodingTest) ... ok
    test_mapping (test_geo_interface.EncodingDecodingTest) ... ok
    test_null_geometry_explicit (test_null_geometries.NullGeometriesTest) ... ok
    test_null_geometry_implicit (test_null_geometries.NullGeometriesTest) ... ok
    test_decode_inf (test_strict_json.StrictJsonTest)
    Ensure Error is raised when decoding Infinity or -Infinity ... ok
    test_decode_nan (test_strict_json.StrictJsonTest)
    Ensure Error is raised when decoding NaN ... ok
    test_encode_inf (test_strict_json.StrictJsonTest)
    Ensure Error is raised when encoding inf or -inf ... ok
    test_encode_nan (test_strict_json.StrictJsonTest)
    Ensure Error is raised when encoding nan ... ok
    test_valid_jsonobject (test_validation.TestValidationGeoJSONObject) ... ok
    test_invalid_geometry_with_validate (test_validation.TestValidationGeometry) ... ok
    test_invalid_geometry_without_validate (test_validation.TestValidationGeometry) ... ok
    test_not_number (test_validation.TestValidationGeometry) ... ok
    test_not_sequence (test_validation.TestValidationGeometry) ... ok
    test_valid_geometry (test_validation.TestValidationGeometry) ... ok
    test_valid_geometry_with_elevation (test_validation.TestValidationGeometry) ... ok
    test_invalid_geometrycollection (test_validation.TestValidationGeometryCollection) ... ok
    test_valid_geometrycollection (test_validation.TestValidationGeometryCollection) ... ok
    test_invalid_linestring (test_validation.TestValidationLineString) ... ok
    test_valid_linestring (test_validation.TestValidationLineString) ... ok
    test_invalid_multilinestring (test_validation.TestValidationMultiLineString) ... ok
    test_valid_multilinestring (test_validation.TestValidationMultiLineString) ... ok
    test_invalid_multipolygon (test_validation.TestValidationMultiPolygon) ... ok
    test_valid_multipolygon (test_validation.TestValidationMultiPolygon) ... ok
    test_invalid_multipoint (test_validation.TestValidationMultipoint) ... ok
    test_valid_multipoint (test_validation.TestValidationMultipoint) ... ok
    test_valid_multipoint_with_elevation (test_validation.TestValidationMultipoint) ... ok
    test_invalid_point (test_validation.TestValidationPoint) ... ok
    test_valid_point (test_validation.TestValidationPoint) ... ok
    test_valid_point_with_elevation (test_validation.TestValidationPoint) ... ok
    test_invalid_polygon (test_validation.TestValidationPolygon) ... ok
    test_valid_polygon (test_validation.TestValidationPolygon) ... ok
    /tmp/guix-build-python-geojson-2.5.0.drv-0/geojson-2.5.0/README.rst
    Doctest: README.rst ... ok
    
    ======================================================================
    ERROR: test_feature_class (test_features.FeaturesTest)
    Test the Feature class
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/tmp/guix-build-python-geojson-2.5.0.drv-0/geojson-2.5.0/tests/test_features.py", line 85, in test_feature_class
        feature = geojson.loads(json, object_hook=factory, encoding="utf-8")
      File "/tmp/guix-build-python-geojson-2.5.0.drv-0/geojson-2.5.0/geojson/codec.py", line 51, in loads
        return json.loads(s,
      File "/gnu/store/p5fgysbcnnp8b1d91mrvjvababmczga0-python-3.9.6/lib/python3.9/json/__init__.py", line 359, in loads
        return cls(**kw).decode(s)
    TypeError: __init__() got an unexpected keyword argument 'encoding'
    
    ----------------------------------------------------------------------
    Ran 61 tests in 0.012s
    
    FAILED (errors=1)
    Test failed: <unittest.runner.TextTestResult run=61 errors=1 failures=0>
    error: Test failed: <unittest.runner.TextTestResult run=61 errors=1 failures=0>
    error: in phase 'check': uncaught exception:
    %exception #<&invoke-error program: "python" arguments: ("-c" "import setuptools, tokenize;__file__='setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))" "test") exit-status: 1 term-signal: #f stop-signal: #f>
    phase `check' failed after 0.3 seconds
    command "python" "-c" "import setuptools, tokenize;__file__='setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))" "test" failed with status 1
    builder for `/gnu/store/jnzsz15kp7ykzrs72xyavigazm8hv8fl-python-geojson-2.5.0.drv' failed with exit code 1
    build of /gnu/store/jnzsz15kp7ykzrs72xyavigazm8hv8fl-python-geojson-2.5.0.drv failed
    View build log at '/var/log/guix/drvs/jn/zsz15kp7ykzrs72xyavigazm8hv8fl-python-geojson-2.5.0.drv.bz2'.
    cannot build derivation `/gnu/store/iv9f0v2dpfxpmcikzbbnkja741mzar0v-wfetch-.drv': 1 dependencies couldn't be built
    guix build: error: build of `/gnu/store/iv9f0v2dpfxpmcikzbbnkja741mzar0v-wfetch-.drv' failed
    
    opened by phodina 1
Calculate the area inside of any GeoJSON geometry. This is a port of Mapbox's geojson-area for Python

geojson-area Calculate the area inside of any GeoJSON geometry. This is a port of Mapbox's geojson-area for Python. Installation $ pip install area U

Alireza 87 Dec 14, 2022
Open GeoJSON data on geojson.io

geojsonio.py Open GeoJSON data on geojson.io from Python. geojsonio.py also contains a command line utility that is a Python port of geojsonio-cli. Us

Jacob Wasserman 114 Dec 21, 2022
A bot that tweets info and location map for new bicycle parking added to OpenStreetMap within a GeoJSON boundary.

Bike parking tweepy bot app A twitter bot app that searches for bicycle parking added to OpenStreetMap. Relies on AWS Lambda/S3, Python3, Tweepy, Flas

Angelo Trivisonno 1 Dec 19, 2021
gjf: A tool for fixing invalid GeoJSON objects

gjf: A tool for fixing invalid GeoJSON objects The goal of this tool is to make it as easy as possible to fix invalid GeoJSON objects through Python o

Yazeed Almuqwishi 91 Dec 6, 2022
Python bindings to libpostal for fast international address parsing/normalization

pypostal These are the official Python bindings to https://github.com/openvenues/libpostal, a fast statistical parser/normalizer for street addresses

openvenues 651 Dec 16, 2022
WIP: extracting Geometry utilities from datacube-core

odc.geo This is still work in progress. This repository contains geometry related code extracted from Open Datacube. For details and motivation see OD

Open Data Cube 34 Jan 9, 2023
This is a simple python code to get IP address and its location using python

IP address & Location finder @DEV/ED : Pavan Ananth Sharma Dependencies: ip2geotools Note: use pip install ip2geotools to install this in your termin

Pavan Ananth Sharma 2 Jul 5, 2022
OSMnx: Python for street networks. Retrieve, model, analyze, and visualize street networks and other spatial data from OpenStreetMap.

OSMnx OSMnx is a Python package that lets you download geospatial data from OpenStreetMap and model, project, visualize, and analyze real-world street

Geoff Boeing 4k Jan 8, 2023
Python interface to PROJ (cartographic projections and coordinate transformations library)

pyproj Python interface to PROJ (cartographic projections and coordinate transformations library). Documentation Stable: http://pyproj4.github.io/pypr

null 832 Dec 31, 2022
Documentation and samples for ArcGIS API for Python

ArcGIS API for Python ArcGIS API for Python is a Python library for working with maps and geospatial data, powered by web GIS. It provides simple and

Esri 1.4k Dec 30, 2022
python toolbox for visualizing geographical data and making maps

geoplotlib is a python toolbox for visualizing geographical data and making maps data = read_csv('data/bus.csv') geoplotlib.dot(data) geoplotlib.show(

Andrea Cuttone 976 Dec 11, 2022
geemap - A Python package for interactive mapping with Google Earth Engine, ipyleaflet, and ipywidgets.

A Python package for interactive mapping with Google Earth Engine, ipyleaflet, and folium

Qiusheng Wu 2.4k Dec 30, 2022
Python interface to PROJ (cartographic projections and coordinate transformations library)

pyproj Python interface to PROJ (cartographic projections and coordinate transformations library). Documentation Stable: http://pyproj4.github.io/pypr

null 832 Dec 31, 2022
Pure Python NetCDF file reader and writer

Pyncf Pure Python NetCDF file reading and writing. Introduction Inspired by the pyshp library, which provides simple pythonic and dependency free data

Karim Bahgat 14 Sep 30, 2022
Download and process satellite imagery in Python using Sentinel Hub services.

Description The sentinelhub Python package allows users to make OGC (WMS and WCS) web requests to download and process satellite images within your Py

Sentinel Hub 659 Dec 23, 2022
leafmap - A Python package for geospatial analysis and interactive mapping in a Jupyter environment.

A Python package for geospatial analysis and interactive mapping with minimal coding in a Jupyter environment

Qiusheng Wu 1.4k Jan 2, 2023
A Python interface between Earth Engine and xarray

eexarray A Python interface between Earth Engine and xarray Description eexarray was built to make processing gridded, mesoscale time series data quic

Aaron Zuspan 159 Dec 23, 2022
A simple python script that, given a location and a date, uses the Nasa Earth API to show a photo taken by the Landsat 8 satellite. The script must be executed on the command-line.

What does it do? Given a location and a date, it uses the Nasa Earth API to show a photo taken by the Landsat 8 satellite. The script must be executed

Caio 42 Nov 26, 2022
An API built to format given addresses using Python and Flask.

An API built to format given addresses using Python and Flask. About The API returns properly formatted data, i.e. removing duplicate fields, distingu

null 1 Feb 27, 2022