diff --git a/previews/PR159/background/history/index.html b/previews/PR159/background/history/index.html index 96c466e..de02229 100644 --- a/previews/PR159/background/history/index.html +++ b/previews/PR159/background/history/index.html @@ -5,4 +5,4 @@ properties # for Geometries -coordinates

However, the position type is gone and merged with PointTrait.

+coordinates

However, the position type is gone and merged with PointTrait.

diff --git a/previews/PR159/background/sf/index.html b/previews/PR159/background/sf/index.html index 9b05938..f399c40 100644 --- a/previews/PR159/background/sf/index.html +++ b/previews/PR159/background/sf/index.html @@ -10,4 +10,4 @@ spatialDimension locateAlong -locateBetween +locateBetween diff --git a/previews/PR159/guides/defaults/index.html b/previews/PR159/guides/defaults/index.html index 160b7ca..dc28a3e 100644 --- a/previews/PR159/guides/defaults/index.html +++ b/previews/PR159/guides/defaults/index.html @@ -14,4 +14,4 @@ GeoInterface.y(b) == 2 c = (;X=1, Y=2, Z=3) -GeoInterface.z(c) == 3

Wrapper types

It is common that a package does not implement all objects supported by GeoInterface.jl, and may lack the ability to define features. It is useful to define generic objects that can be used in testing and for scripting where geometries need to be constructed from components. Using generic wrappers means this is backend agnostic: the same code will work if geometries come from GeoJSON.jl, Shapefile.jl, LibGEOS.jl, or other packages defining GeoInterface.jl traits.

Wrapper types are provided for constructing geometries out of any lower-level components that implement GeoInterface.jl traits. These wrappers can wrap objects of the same trait (possibly to add extent data), vectors of child objects, or nested vectors of lower level children, such as points.

As an example, we can construct a polygon from any GeoInterface.jl compatible geometries that return LinearRingTrait from GeoInterface.geomtrait:

poly = Polygon([interior, hole1, hole2])

See the API documentation for each wrapper for more details.

Wrappers for Triangle, Hexagon and some other geometries are yet to be implemented. Please make a GitHub issue if you need them.

Feature and FeatureCollection wrappers are also provided, to add properties, crs and extents to any GeoInterface.jl compatible geometries.

Wrappers are not exported by default because they are very common names used by other packages. To use them directly, run using GeoInterface.Wrappers.

+GeoInterface.z(c) == 3

Wrapper types

It is common that a package does not implement all objects supported by GeoInterface.jl, and may lack the ability to define features. It is useful to define generic objects that can be used in testing and for scripting where geometries need to be constructed from components. Using generic wrappers means this is backend agnostic: the same code will work if geometries come from GeoJSON.jl, Shapefile.jl, LibGEOS.jl, or other packages defining GeoInterface.jl traits.

Wrapper types are provided for constructing geometries out of any lower-level components that implement GeoInterface.jl traits. These wrappers can wrap objects of the same trait (possibly to add extent data), vectors of child objects, or nested vectors of lower level children, such as points.

As an example, we can construct a polygon from any GeoInterface.jl compatible geometries that return LinearRingTrait from GeoInterface.geomtrait:

poly = Polygon([interior, hole1, hole2])

See the API documentation for each wrapper for more details.

Wrappers for Triangle, Hexagon and some other geometries are yet to be implemented. Please make a GitHub issue if you need them.

Feature and FeatureCollection wrappers are also provided, to add properties, crs and extents to any GeoInterface.jl compatible geometries.

Wrappers are not exported by default because they are very common names used by other packages. To use them directly, run using GeoInterface.Wrappers.

diff --git a/previews/PR159/guides/developer/index.html b/previews/PR159/guides/developer/index.html index 067607e..d3dc7cc 100644 --- a/previews/PR159/guides/developer/index.html +++ b/previews/PR159/guides/developer/index.html @@ -77,4 +77,4 @@ # These alias for npolygon and getpolygon GeoInterface.ngeom(::MultiPolygonTrait, geom::customgeom)::Integer -GeoInterface.getgeom(::MultiPolygonTrait, geom::customgeom, i)::"PolygonTrait" +GeoInterface.getgeom(::MultiPolygonTrait, geom::customgeom, i)::"PolygonTrait" diff --git a/previews/PR159/index.html b/previews/PR159/index.html index 28625cb..b3d6220 100644 --- a/previews/PR159/index.html +++ b/previews/PR159/index.html @@ -1,2 +1,2 @@ -Home · GeoInterface.jl

GeoInterface

Stable Dev Build Status

An interface for geospatial vector data in Julia

This Package describe a set of traits based on the Simple Features standard (SF) for geospatial vector data, including the SQL/MM extension with support for circular geometry. By using these traits, it should be easy to parse, serialize and use different custom geometries in the Julia ecosystem, without knowing the specifics of each individual package. In that regard it is similar to Tables.jl, but for geometries instead of tables.

Packages which support the GeoInterface.jl interface can be found in Packages.

For usage see Traits interface, while if you look to implement GeoInterface in your own package, check out Implementing GeoInterface. For background about the interface and Simple Features, see Changes with respect to SF.

Compat

This traits interface is new and is a major departure from previous pre-1.0 releases. See History for more information. Feel free to ask questions on Github.

+Home · GeoInterface.jl

GeoInterface

Stable Dev Build Status

An interface for geospatial vector data in Julia

This Package describe a set of traits based on the Simple Features standard (SF) for geospatial vector data, including the SQL/MM extension with support for circular geometry. By using these traits, it should be easy to parse, serialize and use different custom geometries in the Julia ecosystem, without knowing the specifics of each individual package. In that regard it is similar to Tables.jl, but for geometries instead of tables.

Packages which support the GeoInterface.jl interface can be found in Packages.

For usage see Traits interface, while if you look to implement GeoInterface in your own package, check out Implementing GeoInterface. For background about the interface and Simple Features, see Changes with respect to SF.

Compat

This traits interface is new and is a major departure from previous pre-1.0 releases. See History for more information. Feel free to ask questions on Github.

diff --git a/previews/PR159/reference/api/index.html b/previews/PR159/reference/api/index.html index c07b77c..45f9a33 100644 --- a/previews/PR159/reference/api/index.html +++ b/previews/PR159/reference/api/index.html @@ -1,10 +1,10 @@ -API · GeoInterface.jl

API

Functions

GeoInterface.asbinaryMethod
asbinary(geom) -> WKB

Convert geom into Well Known Binary (WKB) representation, such as 000000000140000000000000004010000000000000.

source
GeoInterface.astextMethod
astext(geom) -> WKT

Convert geom into Well Known Text (WKT) representation, such as POINT (30 10).

source
GeoInterface.bboxMethod
bbox(geom) -> T <: Extents.Extent

Alias for extent, for compatibility with GeoJSON and the Python geointerface. Ensures backwards compatibility with GeoInterface version 0.

source
GeoInterface.boundingpolygonsMethod
boundingpolygons(geom, i) -> AbstractMultiPolygon

Returns the collection of polygons in this surface that bounds the ith patch in the given geom.

source
GeoInterface.bufferMethod
buffer(geom, distance) -> AbstractGeometry

Returns a geometric object that represents a buffer of the given geom with distance.

source
GeoInterface.containsMethod
contains(a, b) -> Bool

Returns whether a contains b. The order of arguments is important. Equivalent to within with reversed arguments.

source
GeoInterface.convertMethod
convert(type::CustomGeom, geom)
-convert(module::Module, geom)

Create a CustomGeom from any geom that implements the GeoInterface.

Can also convert to a Module, which finds the corresponding geom type for the trait using the modules geointerface_traittype method.

convert(T::Type) or convert(m::Module) return curried versions of that function, just like ==.

source
GeoInterface.convexhullMethod
convexhull(geom) -> AbstractCurve

Returns a geometric object that represents the convex hull of the given geom.

source
GeoInterface.coordinatesMethod
coordinates(geom) -> Vector

Return (an iterator of) point coordinates. Ensures backwards compatibility with GeoInterface version 0.

source
GeoInterface.coordnamesMethod
coordnames(geom) -> Tuple{Symbol}

Return the names of coordinate dimensions (such for (:X,:Y,:Z)) for the geometry.

source
GeoInterface.crsMethod
crs(geom) -> T <: GeoFormatTypes.CoordinateReferenceSystemFormat

Retrieve Coordinate Reference System for given geom. In SF this is defined as SRID.

source
GeoInterface.crstraitMethod
crstrait(geom) -> AbstractCRSTrait

Retrieves the type of the Coordinate Reference System for the given geom. Defaults to retrieving from crs(geom) and to UnknownTrait if not implemented.

source
GeoInterface.differenceMethod
difference(a, b) -> AbstractGeometry

Returns a geometric object that represents the Point set difference of a with b

source
GeoInterface.extentMethod
extent(obj; fallback=true) -> T <: Extents.Extent

Retrieve the extent (bounding box) for given geom or feature. In SF this is defined as envelope.

Extents.extent(obj) will be called if extent(trait(obj), obj), is not defined so it may be preferable to define Extents.extent directly.

When fallback is true, and the obj does not have an extent, an extent is calculated from the coordinates of all geometries in obj.

source
GeoInterface.geometryMethod
GeoInterface.geometry(feat) => geom

Retrieve the geometry of feat. It is expected that isgeometry(geom) === true. Ensures backwards compatibility with GeoInterface version 0.

source
GeoInterface.geometrycolumnsMethod
GeoInterface.geometrycolumns(featurecollection) => (:geometry,)

Retrieve the geometrycolumn(s) of featurecollection; the fields (or columns in a table) which contain geometries that support GeoInterface.

source
GeoInterface.getfeatureMethod
GeoInterface.getfeature(collection) => [feature, ...]

Retrieve the features of collection as some iterable of features. It is expected that isfeature(feature) === true.

source
GeoInterface.intersectionMethod
intersection(a, b) -> AbstractGeometry

Returns a geometric object that represents the Point set intersection of a with b

source
GeoInterface.isfeatureMethod
GeoInterface.isfeature(x) => Bool

Check if an object x is a feature and thus implicitly supports some GeoInterface methods. A feature is a combination of a geometry and properties, not unlike a row in a table. It is recommended that for users implementing MyType, they define only isfeature(::Type{MyType}). isfeature(::MyType) will then automatically delegate to this method.

Ensures backwards compatibility with GeoInterface version 0.

source
GeoInterface.isfeaturecollectionMethod
GeoInterface.isfeaturecollection(x) => Bool

Check if an object x is a collection of features and thus implicitly supports some GeoInterface methods. A feature collection is a collection of features, and may also contain metatdata for the whole collection, like an Extent.

It is recommended that for users implementing MyType, they define only isfeaturecollection(::Type{MyType}). isfeaturecollection(::MyType) will then automatically delegate to this method.

source
GeoInterface.isgeometryMethod
GeoInterface.isgeometry(x) => Bool

Check if an object x is a geometry and thus implicitly supports GeoInterface methods. It is recommended that for users implementing MyType, they define only isgeometry(::Type{MyType}). isgeometry(::MyType) will then automatically delegate to this method.

source
GeoInterface.israsterMethod
GeoInterface.israster(x) => Bool

Check if an object x is a raster and thus implicitly supports some GeoInterface methods. A raster requires the crs and extent methods to be defined.

It is recommended that for users implementing MyType, they define only israster(::Type{MyType}). israster(::MyType) will then automatically delegate to this method.

source
GeoInterface.issimpleMethod
issimple(geom) -> Bool

Return true when the geometry is simple, i.e. doesn't cross or touch itself.

source
GeoInterface.mMethod
m(geom) -> Number

Return the :M (measured) coordinate of the given geom. Note that this is only valid for AbstractPointTraits.

For length 4 Tuple and Vector points, the fourth value is returned.

Length 3 Tuple and Vector points can not represent measured points, and will throw an ArgumentError.

source
GeoInterface.ncoordMethod
ncoord(geom) -> Integer

Return the number of coordinate dimensions (such as 3 for X,Y,Z) for the geometry. Note that SF distinguishes between dimensions, spatial dimensions and topological dimensions, which we do not.

source
GeoInterface.propertiesMethod
GeoInterface.properties(feat) => properties

Retrieve the properties of feat. This can be any Iterable that behaves like an AbstractRow. Ensures backwards compatibility with GeoInterface version 0.

source
GeoInterface.relateMethod
relate(a, b, relationmatrix::String) -> Bool

Returns whether a and b relate, based on the provided relation matrix.

source
GeoInterface.subtraitMethod
subtrait(t::AbstractGeometryTrait)

Gets the expected, possible abstract, (sub)trait for subgeometries (retrieved with getgeom) of trait t. This follows the Type hierarchy of Simple Features.

Examples

julia> GeoInterface.subtrait(LineStringTrait())
+API · GeoInterface.jl

API

Functions

GeoInterface.asbinaryMethod
asbinary(geom) -> WKB

Convert geom into Well Known Binary (WKB) representation, such as 000000000140000000000000004010000000000000.

source
GeoInterface.astextMethod
astext(geom) -> WKT

Convert geom into Well Known Text (WKT) representation, such as POINT (30 10).

source
GeoInterface.bboxMethod
bbox(geom) -> T <: Extents.Extent

Alias for extent, for compatibility with GeoJSON and the Python geointerface. Ensures backwards compatibility with GeoInterface version 0.

source
GeoInterface.boundingpolygonsMethod
boundingpolygons(geom, i) -> AbstractMultiPolygon

Returns the collection of polygons in this surface that bounds the ith patch in the given geom.

source
GeoInterface.bufferMethod
buffer(geom, distance) -> AbstractGeometry

Returns a geometric object that represents a buffer of the given geom with distance.

source
GeoInterface.containsMethod
contains(a, b) -> Bool

Returns whether a contains b. The order of arguments is important. Equivalent to within with reversed arguments.

source
GeoInterface.convertMethod
convert(type::CustomGeom, geom)
+convert(module::Module, geom)

Create a CustomGeom from any geom that implements the GeoInterface.

Can also convert to a Module, which finds the corresponding geom type for the trait using the modules geointerface_traittype method.

convert(T::Type) or convert(m::Module) return curried versions of that function, just like ==.

source
GeoInterface.convexhullMethod
convexhull(geom) -> AbstractCurve

Returns a geometric object that represents the convex hull of the given geom.

source
GeoInterface.coordinatesMethod
coordinates(geom) -> Vector

Return (an iterator of) point coordinates. Ensures backwards compatibility with GeoInterface version 0.

source
GeoInterface.coordnamesMethod
coordnames(geom) -> Tuple{Symbol}

Return the names of coordinate dimensions (such for (:X,:Y,:Z)) for the geometry.

source
GeoInterface.crsMethod
crs(geom) -> T <: GeoFormatTypes.CoordinateReferenceSystemFormat

Retrieve Coordinate Reference System for given geom. In SF this is defined as SRID.

source
GeoInterface.crstraitMethod
crstrait(geom) -> AbstractCRSTrait

Retrieves the type of the Coordinate Reference System for the given geom. Defaults to retrieving from crs(geom) and to UnknownTrait if not implemented.

source
GeoInterface.differenceMethod
difference(a, b) -> AbstractGeometry

Returns a geometric object that represents the Point set difference of a with b

source
GeoInterface.extentMethod
extent(obj; fallback=true) -> T <: Extents.Extent

Retrieve the extent (bounding box) for given geom or feature. In SF this is defined as envelope.

Extents.extent(obj) will be called if extent(trait(obj), obj), is not defined so it may be preferable to define Extents.extent directly.

When fallback is true, and the obj does not have an extent, an extent is calculated from the coordinates of all geometries in obj.

source
GeoInterface.geometryMethod
GeoInterface.geometry(feat) => geom

Retrieve the geometry of feat. It is expected that isgeometry(geom) === true. Ensures backwards compatibility with GeoInterface version 0.

source
GeoInterface.geometrycolumnsMethod
GeoInterface.geometrycolumns(featurecollection) => (:geometry,)

Retrieve the geometrycolumn(s) of featurecollection; the fields (or columns in a table) which contain geometries that support GeoInterface.

source
GeoInterface.getfeatureMethod
GeoInterface.getfeature(collection) => [feature, ...]

Retrieve the features of collection as some iterable of features. It is expected that isfeature(feature) === true.

source
GeoInterface.intersectionMethod
intersection(a, b) -> AbstractGeometry

Returns a geometric object that represents the Point set intersection of a with b

source
GeoInterface.isfeatureMethod
GeoInterface.isfeature(x) => Bool

Check if an object x is a feature and thus implicitly supports some GeoInterface methods. A feature is a combination of a geometry and properties, not unlike a row in a table. It is recommended that for users implementing MyType, they define only isfeature(::Type{MyType}). isfeature(::MyType) will then automatically delegate to this method.

Ensures backwards compatibility with GeoInterface version 0.

source
GeoInterface.isfeaturecollectionMethod
GeoInterface.isfeaturecollection(x) => Bool

Check if an object x is a collection of features and thus implicitly supports some GeoInterface methods. A feature collection is a collection of features, and may also contain metatdata for the whole collection, like an Extent.

It is recommended that for users implementing MyType, they define only isfeaturecollection(::Type{MyType}). isfeaturecollection(::MyType) will then automatically delegate to this method.

source
GeoInterface.isgeometryMethod
GeoInterface.isgeometry(x) => Bool

Check if an object x is a geometry and thus implicitly supports GeoInterface methods. It is recommended that for users implementing MyType, they define only isgeometry(::Type{MyType}). isgeometry(::MyType) will then automatically delegate to this method.

source
GeoInterface.israsterMethod
GeoInterface.israster(x) => Bool

Check if an object x is a raster and thus implicitly supports some GeoInterface methods. A raster requires the crs and extent methods to be defined.

It is recommended that for users implementing MyType, they define only israster(::Type{MyType}). israster(::MyType) will then automatically delegate to this method.

source
GeoInterface.issimpleMethod
issimple(geom) -> Bool

Return true when the geometry is simple, i.e. doesn't cross or touch itself.

source
GeoInterface.mMethod
m(geom) -> Number

Return the :M (measured) coordinate of the given geom. Note that this is only valid for AbstractPointTraits.

For length 4 Tuple and Vector points, the fourth value is returned.

Length 3 Tuple and Vector points can not represent measured points, and will throw an ArgumentError.

source
GeoInterface.ncoordMethod
ncoord(geom) -> Integer

Return the number of coordinate dimensions (such as 3 for X,Y,Z) for the geometry. Note that SF distinguishes between dimensions, spatial dimensions and topological dimensions, which we do not.

source
GeoInterface.propertiesMethod
GeoInterface.properties(feat) => properties

Retrieve the properties of feat. This can be any Iterable that behaves like an AbstractRow. Ensures backwards compatibility with GeoInterface version 0.

source
GeoInterface.relateMethod
relate(a, b, relationmatrix::String) -> Bool

Returns whether a and b relate, based on the provided relation matrix.

source
GeoInterface.subtraitMethod
subtrait(t::AbstractGeometryTrait)

Gets the expected, possible abstract, (sub)trait for subgeometries (retrieved with getgeom) of trait t. This follows the Type hierarchy of Simple Features.

Examples

julia> GeoInterface.subtrait(LineStringTrait())
 AbstractPointTrait
 julia> GeoInterface.subtrait(PolygonTrait())  # Any of LineStringTrait, LineTrait, LinearRingTrait
 AbstractLineStringTrait
# `nothing` is returned when there's no subtrait or when it's not known beforehand
 julia> isnothing(GeoInterface.subtrait(PointTrait()))
 true
 julia> isnothing(GeoInterface.subtrait(GeometryCollectionTrait()))
-true
source
GeoInterface.symdifferenceMethod
symdifference(a, b) -> AbstractGeometry

Returns a geometric object that represents the Point set symmetric difference of a with b.

source
GeoInterface.unionMethod
union(a, b) -> AbstractGeometry

Returns a geometric object that represents the Point set union of a with b

source
GeoInterface.withinMethod
within(a, b) -> Bool

Returns whether a is within b. The order of arguments is important. Equivalent to contains with reversed arguments.

source
GeoInterface.xMethod
x(geom) -> Number

Return the :X coordinate of the given geom. Note that this is only valid for AbstractPointTraits.

For Tuple and Vector points, the first value is returned.

source
GeoInterface.yMethod
y(geom) -> Number

Return the :Y coordinate of the given geom. Note that this is only valid for AbstractPointTraits.

For Tuple and Vector points, the second value is returned.

source
GeoInterface.zMethod
z(geom) -> Number

Return the :Z coordinate of the given geom. Note that this is only valid for AbstractPointTraits.

For length 3 Tuple and Vector points, the third value is returned.

source

Types

GeoInterface.CircularStringTraitType

A CircularStringTrait is a curve, with an odd number of points. A single segment consists of three points, where the first and last are the beginning and end, while the second is halfway the curve.

source

Index

+true
source
GeoInterface.symdifferenceMethod
symdifference(a, b) -> AbstractGeometry

Returns a geometric object that represents the Point set symmetric difference of a with b.

source
GeoInterface.unionMethod
union(a, b) -> AbstractGeometry

Returns a geometric object that represents the Point set union of a with b

source
GeoInterface.withinMethod
within(a, b) -> Bool

Returns whether a is within b. The order of arguments is important. Equivalent to contains with reversed arguments.

source
GeoInterface.xMethod
x(geom) -> Number

Return the :X coordinate of the given geom. Note that this is only valid for AbstractPointTraits.

For Tuple and Vector points, the first value is returned.

source
GeoInterface.yMethod
y(geom) -> Number

Return the :Y coordinate of the given geom. Note that this is only valid for AbstractPointTraits.

For Tuple and Vector points, the second value is returned.

source
GeoInterface.zMethod
z(geom) -> Number

Return the :Z coordinate of the given geom. Note that this is only valid for AbstractPointTraits.

For length 3 Tuple and Vector points, the third value is returned.

source

Types

GeoInterface.CircularStringTraitType

A CircularStringTrait is a curve, with an odd number of points. A single segment consists of three points, where the first and last are the beginning and end, while the second is halfway the curve.

source

Index

diff --git a/previews/PR159/reference/integrations/index.html b/previews/PR159/reference/integrations/index.html index aacb0ce..d094ab0 100644 --- a/previews/PR159/reference/integrations/index.html +++ b/previews/PR159/reference/integrations/index.html @@ -1,2 +1,2 @@ -Implementations · GeoInterface.jl
+Implementations · GeoInterface.jl
diff --git a/previews/PR159/search/index.html b/previews/PR159/search/index.html index c6bfe4c..ba2dc85 100644 --- a/previews/PR159/search/index.html +++ b/previews/PR159/search/index.html @@ -1,2 +1,2 @@ -Search · GeoInterface.jl

Loading search...

    +Search · GeoInterface.jl

    Loading search...

      diff --git a/previews/PR159/tutorials/installation/index.html b/previews/PR159/tutorials/installation/index.html index 4c1d67d..2b145ae 100644 --- a/previews/PR159/tutorials/installation/index.html +++ b/previews/PR159/tutorials/installation/index.html @@ -1,2 +1,2 @@ -Installation · GeoInterface.jl
      +Installation · GeoInterface.jl
      diff --git a/previews/PR159/tutorials/usage/index.html b/previews/PR159/tutorials/usage/index.html index f9825a4..c57faae 100644 --- a/previews/PR159/tutorials/usage/index.html +++ b/previews/PR159/tutorials/usage/index.html @@ -22,4 +22,4 @@ julia> getcoords.(getpoint.(Ref(ext), 1:npoint(ext))) [[1.,2.],[2.,3.],[1.,2.]] julia> coordinates(geom) # fallback based on ngeom & npoint above - +