All Projects → geomet → Geomet

geomet / Geomet

Licence: apache-2.0
GeoMet - Convert GeoJSON to WKT/WKB, and vice versa

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Geomet

polylabel cmd
A command-line utility for generating optimum polygon label coordinates from GeoJSON
Stars: ✭ 12 (-90.24%)
Mutual labels:  geojson, gis
Go Geom
Package geom implements efficient geometry types for geospatial applications.
Stars: ✭ 456 (+270.73%)
Mutual labels:  gis, geojson
GeoJSON.jl
Utilities for working with GeoJSON data in Julia
Stars: ✭ 46 (-62.6%)
Mutual labels:  geojson, gis
django-graphql-geojson
GeoJSON support for Graphene Django
Stars: ✭ 61 (-50.41%)
Mutual labels:  geojson, gis
Leaflet Geoman
🍂🗺️ The most powerful leaflet plugin for drawing and editing geometry layers
Stars: ✭ 1,088 (+784.55%)
Mutual labels:  gis, geojson
pygeoif
Basic implementation of the __geo_interface__
Stars: ✭ 44 (-64.23%)
Mutual labels:  geojson, gis
Orb
Types and utilities for working with 2d geometry in Golang
Stars: ✭ 378 (+207.32%)
Mutual labels:  gis, geojson
geojson-to-wfs-t-2
A lightweight javascript module to format WFS-T-2 statements from GeoJSON features
Stars: ✭ 21 (-82.93%)
Mutual labels:  geojson, gis
Django Rest Framework Gis
Geographic add-ons for Django REST Framework. Maintained by the OpenWISP Project.
Stars: ✭ 830 (+574.8%)
Mutual labels:  gis, geojson
Turf
A modular geospatial engine written in JavaScript
Stars: ✭ 6,659 (+5313.82%)
Mutual labels:  gis, geojson
turf-go
A Go language port of Turf.js
Stars: ✭ 41 (-66.67%)
Mutual labels:  geojson, gis
Featureserver
An open source Geoservices Implementation
Stars: ✭ 66 (-46.34%)
Mutual labels:  gis, geojson
open-geo-data-education
Open Geospatial Datasets for GIS Education: This is a repository of open geospatial datasets to be used in an educational context. I created these files over years of teaching Geographic Data Science and GIS. All original datasets are freely available online with open data licenses (see the dataset attribution for details). All the datasets in t…
Stars: ✭ 52 (-57.72%)
Mutual labels:  geojson, gis
nl
geojson and topojson for common dutch areas
Stars: ✭ 30 (-75.61%)
Mutual labels:  geojson, gis
pyturf
A modular geospatial engine written in python
Stars: ✭ 15 (-87.8%)
Mutual labels:  geojson, gis
GeoConvert
Converting between Geojson and GIS file formats
Stars: ✭ 32 (-73.98%)
Mutual labels:  geojson, gis
de9im
DE-9IM spatial predicate library implemented in Javascript.
Stars: ✭ 22 (-82.11%)
Mutual labels:  geojson, gis
geojson-to-sqlite
CLI tool for converting GeoJSON files to SQLite (with SpatiaLite)
Stars: ✭ 41 (-66.67%)
Mutual labels:  geojson, gis
Koop
🔮 Transform, query, and download geospatial data on the web.
Stars: ✭ 505 (+310.57%)
Mutual labels:  gis, geojson
Geotools
Official GeoTools repository
Stars: ✭ 1,109 (+801.63%)
Mutual labels:  gis, geojson

GeoMet Build Status

Convert GeoJSON to WKT/WKB (Well-Known Text/Binary) or GeoPackage Binary, and vice versa. Extended WKB/WKT are also supported. Conversion functions are exposed through idiomatic load/loads/dump/dumps interfaces.

The name "GeoMet" was inspired by "met", the German word for mead. It is also a shortened version of the word "geometry".

GeoMet is intended to cover all common use cases for dealing with 2D, 3D, and 4D geometries (including 'Z', 'M', and 'ZM').

The following conversion functions are supported.

WKT/EWKT <--> GeoJSON:

  • Point
  • LineString
  • Polygon
  • MultiPoint
  • MultiLineString
  • MultiPolygon
  • GeometryCollection

WKB/EWKB <--> GeoJSON:

  • Point
  • LineString
  • Polygon
  • MultiPoint
  • MultiLineString
  • MultiPolygon
  • GeometryCollection

Note: Reading and writing empty WKB geometries is not currently supported.

GeoPackage Binary <--> GeoJSON:

  • Point
  • LineString
  • Polygon
  • MultiPoint
  • MultiLineString
  • MultiPolygon
  • GeometryCollection

Note: Reading and writing empty GeoPackage geometries is not currently supported.

Installation

Install from PyPI (easiest method):

$ pip install geomet

Clone the source code from git and run:

$ python setup.py install

You can also install directly from the git repo using pip:

$ pip install git+git://github.com/geomet/geomet.git

Example usage

Coverting a 'Point' GeoJSON object to WKT:

>>> from geomet import wkt
>>> point = {'type': 'Point', 'coordinates': [116.4, 45.2, 11.1]}
>>> wkt.dumps(point, decimals=4)
'POINT (116.4000 45.2000 11.1000)'

Converting a 'Point' GeoJSON object to WKB:

>>> from geomet import wkb
>>> wkb.dumps(point)
b'\x00\x00\x00\x10\[email protected]]\x19\x99\x99\x99\x99\[email protected]\x99\x99\x99\x99\x99\[email protected]&333333'
>>> wkb.dumps(point, big_endian=False)
b'\x01\x01\x10\x00\x00\x9a\x99\x99\x99\x99\x19]@\x9a\x99\x99\x99\x99\[email protected]&@'

Converting a 'Point' GeoJSON object to GeoPackage Binary:

>>> from geomet import geopackage
>>> geopackage.dumps(point)
b'GP\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\[email protected]]\x19\x99\x99\x99\x99\[email protected]\x99\x99\x99\x99\x99\[email protected]&333333'
>>> geopackage.dumps(point, big_endian=False)
b'GP\x00\x01\x00\x00\x00\x00\x01\xe9\x03\x00\x00\x9a\x99\x99\x99\x99\x19]@\x9a\x99\x99\x99\x99\[email protected]&@'

Converting a 'LineString' GeoJSON object to WKT:

>>> linestring = {'type':'LineString',
...               'coordinates': [[0.0, 0.0, 10.0], [2.0, 1.0, 20.0],
...                               [4.0, 2.0, 30.0], [5.0, 4.0, 40.0]]}
>>> wkt.dumps(linestring, decimals=0)
'LINESTRING (0 0 10, 2 1 20, 4 2 30, 5 4 40)'

Converting a 'LineString' GeoJSON object to WKB:

>>> wkb.dumps(linestring)
b'\x00\x00\x00\x10\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\[email protected]$\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\x00?\xf0\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\[email protected]\x10\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\[email protected]>\x00\x00\x00\x00\x00\[email protected]\x14\x00\x00\x00\x00\x00\[email protected]\x10\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00'
>>> wkb.dumps(linestring, big_endian=False)
b'\x01\x02\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\xf0?\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00>@\x00\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\[email protected]'

Converting a 'LineString' GeoJSON object to GeoPackage Binary:

>>> geopackage.dumps(linestring)
b'GP\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\[email protected]$\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\x00?\xf0\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\[email protected]\x10\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\[email protected]>\x00\x00\x00\x00\x00\[email protected]\x14\x00\x00\x00\x00\x00\[email protected]\x10\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00'
>>> geopackage.dumps(linestring, big_endian=False)
b'GP\x00\x01\x00\x00\x00\x00\x01\x02\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\xf0?\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00>@\x00\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\[email protected]'

Converting 'Point' WKT to GeoJSON:

>>> wkt.loads('POINT(10 20)')
{'type': 'Point', 'coordinates': [10.0, 20.0]}

Coverting 'GeometryCollection' WKT to GeoJSON:

>>> wkt.loads('GEOMETRYCOLLECTION(POINT(10 20),POLYGON(((0 0), (10 30), (30 10), (0 0)))')
{'type': 'GeometryCollection', 'geometries': [{'type': 'Point', 'coordinates': [10.0, 20.0]}, {'type': 'Polygon', 'coordinates': [[[0.0, 0.0]], [[10.0, 30.0]], [[30.0, 10.0]], [[0.0, 0.0]]]}]}

EWKT/EWKB are also supported for all geometry types. This uses a custom extension to the GeoJSON standard in order to preserve SRID information through conversions. For example:

>>> wkt.loads('SRID=4326;POINT(10 20)')
{'type': 'Point', 'coordinates': [10.0, 20.0], 'meta': {'srid': '4326'}}
>>> wkt.dumps({'type': 'Point', 'coordinates': [10.0, 20.0], 'meta': {'srid': '4326'}, 'crs': {'properties': {'name': 'EPSG4326'}, 'type': 'name'}})
'SRID=4326;POINT (10.0000000000000000 20.0000000000000000)'
>>> wkb.loads('\x00 \x00\x00\x01\x00\x00\x10\[email protected]$\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00')
{'meta': {'srid': '4326'}, 'type': 'Point', 'coordinates': [10.0, 20.0]}
>>> wkb.dumps({'type': 'Point', 'coordinates': [10.0, 20.0], 'meta': {'srid': '4326'}, 'crs': {'properties': {'name': 'EPSG4326'}, 'type': 'name'}})
'\x00 \x00\x00\x01\x00\x00\x10\[email protected]$\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00'

GeoPackage binary supports encoding of SRID and envelope information. If your geopackage has an envelope specified, then it will be added into the resulting GeoJSON in a key called 'bbox':

>>> gpkg = b'GP\x00\x03\x00\x00\x00\x00\xf0\x9e\xa0\xa7\x05;#@hZ\xbd\x93\[email protected]\x01\x01\x00\x00\x00\xf0\x9e\xa0\xa7\x05;#@hZ\xbd\x93\[email protected]'
>>> geopackage.loads(gpkg)
>>> {'type': 'Point', 'coordinates': [9.615277517659223, 38.55870291467437], 'bbox': (9.615277517659223, 38.55870291467437, 9.615277517659223, 38.55870291467437)}

In the same way, if a 'bbox' key is present on a dumps-ed geometry, it will be added to the header of the GeoPackage geometry:

>>> polygon = {'type': 'Polygon', 'coordinates': [[[20.0, 20.0], [34.0, 124.0], [70.0, 140.0], [130.0, 130.0], [70.0, 100.0], [110.0, 70.0], [170.0, 20.0], [90.0, 10.0], [20.0, 20.0]]], 'bbox': (20.0, 170.0, 10.0, 140.0)}
>>> geopackage.dumps(polygon)
b'GP\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\[email protected]@\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x03\x00\x00\x00\x01\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\[email protected]_\x00\x00\x00\x00\x00\[email protected]\x80\x00\x00\x00\x00\[email protected]\x80\x00\x00\x00\x00\[email protected]`@\x00\x00\x00\x00\[email protected]`@\x00\x00\x00\x00\[email protected]\x80\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\[email protected][\x80\x00\x00\x00\x00\[email protected]\x80\x00\x00\x00\x00\[email protected]@\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\[email protected]\x80\x00\x00\x00\x00\[email protected]$\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\[email protected]\x00\x00\x00\x00\x00\x00'

If an integer SRID identifier is present in a 'meta' key (like 'meta': {'srid': 4326}), then the SRID will be included in the GeoPackage header.

See Also

  • wellknown: A similar package for Node.js.
  • geo: A nearly-identical package for Elixir.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].