Skip to main content

No project description provided

Project description

GeoJSON Former

Library that creates valid *.geojson files from shapely shapes.

Dependancies

This component depends on two external python libraries:

  • numpy
  • shapely

Supported shapely types

Currently out of all the available shapely types supported ones are:

  • Point
  • LineString
  • Polygon

Examples of usage

Adding points

Simple addition of points.

from geojsonformer.geojsonformer import GeoJSON
from shapely.geometry import Point

point1 = Point([22.8515625, 55.3791104480105])
point2 = Point([12.3046875, 51.17934297928927])

# Simply append points to object
gj = GeoJSON()
gj.add_point(point=point1)
gj.add_point(point2)

Adding LineString objects

Addition of LineString which is constructed from multiple points.

from geojsonformer.geojsonformer import GeoJSON
from shapely.geometry import Point, LineString

point1 = Point([22.8515625, 55.3791104480105])
point2 = Point([12.3046875, 51.17934297928927])
linestring = LineString([point1, point2])

# Append linestring to object
gj = GeoJSON()
gj.add_linestring(line_string=linestring)

Adding polygon objects

Constructing a Polygon object and then adding it to object.

from geojsonformer.geojsonformer import GeoJSON
from shapely.geometry.polygon import Polygon

polygon = Polygon([
            [
              24.0765380859375,
              55.22589019607769
            ],
            [
              25.3509521484375,
              55.22589019607769
            ],
            [
              25.3509521484375,
              55.71164005362048
            ],
            [
              24.0765380859375,
              55.71164005362048
            ],
            [
              24.0765380859375,
              55.22589019607769
            ]
          ])
gj = GeoJSON()
gj.add_polygon(polygon=polygon)

Add multiple shapes and write to file

GeoJSON supports adding multiple different shapely objects and then writing them all to a single .geojson file. Correctness of files can be tested on http://geojson.io.

from geojsonformer.geojsonformer import GeoJSON
from shapely.geometry import Point, LineString
from shapely.geometry.polygon import Polygon

point1 = Point([22.8515625, 55.3791104480105])
point2 = Point([12.3046875, 51.17934297928927])
point3 = Point([12.3046875, 51.17934297928927])
polygon = Polygon([
        [
            24.0765380859375,
            55.22589019607769
        ],
        [
            25.3509521484375,
            55.22589019607769
        ],
        [
            25.3509521484375,
            55.71164005362048
        ],
        [
            24.0765380859375,
            55.71164005362048
        ],
        [
            24.0765380859375,
            55.22589019607769
        ]
        ])
gj = GeoJSON()
gj.add_point(point=point1)
gj.add_point(point2)
gj.add_point(point3)
gj.add_polygon(polygon=polygon)
gj.add_linestring(line_string=LineString([point1, point2, point3]))
gj.write_to_file(file_path='points.geojson')

Compatability

Compatability is currently restricted to >= python3.10.

Author

Project is created and maintained by Arminas Šidlauskas.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geojsonformer-0.1.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geojsonformer-0.1.3-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file geojsonformer-0.1.3.tar.gz.

File metadata

  • Download URL: geojsonformer-0.1.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for geojsonformer-0.1.3.tar.gz
Algorithm Hash digest
SHA256 dc468542e6dbf3cb69c18d04b7ca10713b3901fef8951c79a0458b0bf804cd5d
MD5 cf5d1c8f169288f07a7113deb515b431
BLAKE2b-256 ffcb678f6df9adda8d0ed1d316978493d8ec40663fa62d2c325782f276e685c7

See more details on using hashes here.

File details

Details for the file geojsonformer-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: geojsonformer-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for geojsonformer-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e6e011f7691df1ba1a292b9ed247d77bcad8b76e48e9910e2924e4b1e8bd0157
MD5 647b7a47a401ae7a78a9c071bab5e451
BLAKE2b-256 f60b979e02f5def5adaacf669d437cd4824b8efdb59bc8fe8fa90bc09eb0a964

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page