# geo > Encodes and decodes WKB, WKT, and GeoJSON formats. ## Docs ### Geo (module) A collection of GIS functions. ### Geo.endian/0 (type) Endianess (byte-order) of the WKB/EWKB representation. * `:ndr` - little-endian * `:xdr` - big-endian ### Geo.geometry/0 (type) ### Geo.GeometryCollection (module) Defines the GeometryCollection struct. ### Geo.GeometryCollection.t/0 (type) ### Geo.JSON (module) Converts Geo structs to and from a map representing GeoJSON. You are responsible to encoding and decoding of JSON. This is so that you can use any JSON parser you want as well as making it so that you can use the resulting GeoJSON structure as a property in larger JSON structures. Note that, per [the GeoJSON spec](https://tools.ietf.org/html/rfc7946#section-4), all geometries are assumed to use the WGS 84 datum (SRID 4326) by default. ### Examples - Geo.JSON (module) # Using Jason as the JSON parser for these examples iex> json = "{ \"type\": \"Point\", \"coordinates\": [100.0, 0.0] }" ...> json |> Jason.decode!() |> Geo.JSON.decode!() %Geo.Point{coordinates: {100.0, 0.0}, srid: 4326} iex> geom = %Geo.Point{coordinates: {100.0, 0.0}, srid: nil} ...> Jason.encode!(geom) "{\"coordinates\":[100.0,0.0],\"type\":\"Point\"}" iex> geom = %Geo.Point{coordinates: {100.0, 0.0}, srid: nil} ...> Geo.JSON.encode!(geom) %{"type" => "Point", "coordinates" => [100.0, 0.0]} ### Geo.JSON.decode/1 (function) Takes a map representing GeoJSON and returns a Geometry. ### Geo.JSON.decode!/1 (function) Takes a map representing GeoJSON and returns a Geometry. ### Geo.JSON.encode/1 (function) Takes a Geometry and returns a map representing the GeoJSON. ### Geo.JSON.encode/2 (function) ### Geo.JSON.encode!/1 (function) Takes a Geometry and returns a map representing the GeoJSON. ### Geo.JSON.encode!/2 (function) ### Geo.LineString (module) Defines the LineString struct. ### Geo.LineString.t/0 (type) ### Geo.LineStringZ (module) Defines the LineStringZ struct. ### Geo.LineStringZ.t/0 (type) ### Geo.LineStringZM (module) Defines the LineStringZM struct. ### Geo.LineStringZM.t/0 (type) ### Geo.MultiLineString (module) Defines the MultiLineString struct. ### Geo.MultiLineString.t/0 (type) ### Geo.MultiLineStringZ (module) Defines the MultiLineStringZ struct. ### Geo.MultiLineStringZ.t/0 (type) ### Geo.MultiPoint (module) Defines the MultiPoint struct. ### Geo.MultiPoint.t/0 (type) ### Geo.MultiPointZ (module) Defines the MultiPointZ struct. ### Geo.MultiPointZ.t/0 (type) ### Geo.MultiPolygon (module) Defines the MultiPolygon struct. ### Geo.MultiPolygon.t/0 (type) ### Geo.MultiPolygonZ (module) Defines the MultiPolygonZ struct. ### Geo.MultiPolygonZ.t/0 (type) ### Geo.Point (module) Defines the Point struct. ### Geo.Point.latitude/0 (type) ### Geo.Point.longitude/0 (type) ### Geo.Point.t/0 (type) ### Geo.PointM (module) Defines the PointM struct. ### Geo.PointM.t/0 (type) ### Geo.PointZ (module) Defines the PointZ struct. ### Geo.PointZ.t/0 (type) ### Geo.PointZM (module) Defines the PointZM struct. ### Geo.PointZM.t/0 (type) ### Geo.Polygon (module) Defines the Polygon struct. ### Geo.Polygon.t/0 (type) ### Geo.PolygonZ (module) Defines the PolygonZ struct. ### Geo.PolygonZ.t/0 (type) ### Geo.WKB (module) Converts to and from WKB and EWKB. It supports WKB both as base-16 encoded strings or as binaries. ### Examples - Geo.WKB (module) iex> {:ok, point} = Geo.WKB.decode("0101000000000000000000F03F000000000000F03F") Geo.Point[coordinates: {1, 1}, srid: nil] iex> Geo.WKT.encode!(point) "POINT(1 1)" iex> point = Geo.WKB.decode!("0101000020E61000009EFB613A637B4240CF2C0950D3735EC0") Geo.Point[coordinates: {36.9639657, -121.8097725}, srid: 4326] ### Geo.WKB.decode/1 (function) Takes a WKB, either as a base-16 encoded string or a binary, and returns a Geometry. ### Geo.WKB.decode!/1 (function) Takes a WKB, either as a base-16 encoded string or a binary, and returns a Geometry. ### Geo.WKB.encode/2 (function) Takes a Geometry and returns a base-16 encoded WKB string. The endian decides what the byte order will be. ### Geo.WKB.encode!/2 (function) Takes a Geometry and returns a base-16 encoded WKB string. The endian decides what the byte order will be. ### Geo.WKB.encode_to_iodata/2 (function) Takes a Geometry and returns WKB as iodata (a sequence of bytes). The endian decides what the byte order will be. ### Geo.WKT (module) Converts to and from WKT and EWKT ### Examples - Geo.WKT (module) iex> {:ok, point} = Geo.WKT.decode("POINT(30 -90)") Geo.Point[coordinates: {30, -90}, srid: nil] iex> Geo.WKT.encode!(point) "POINT(30 -90)" iex> point = Geo.WKT.decode!("SRID=4326;POINT(30 -90)") Geo.Point[coordinates: {30, -90}, srid: 4326] ### Geo.WKT.decode/1 (function) Takes a WKT string and returns a Geo.geometry struct or list of Geo.geometry. ### Geo.WKT.decode!/1 (function) Takes a WKT string and returns a Geo.geometry struct or list of Geo.geometry. ### Geo.WKT.encode/1 (function) Takes a Geometry and returns a WKT string. ### Geo.WKT.encode!/1 (function) Takes a Geometry and returns a WKT string. ### Geo.JSON.Decoder.DecodeError.t/0 (type) ### Geo.JSON.Encoder.EncodeError.t/0 (type) ## Links - [Online documentation](https://hexdocs.pm/geo)