xyzspaces.iml.layer module¶
This module defines interactive map layer.
- class xyzspaces.iml.layer.HexbinClustering(clustering_type='hexbin', absolute_resolution=None, resolution=None, relative_resolution=None, property=None, pointmode=None)[source]¶
Bases:
object
This class defines attributes for
hexbin
clustering algorithm.- Parameters
clustering_type (str) –
absolute_resolution (Optional[int]) –
resolution (Optional[int]) –
relative_resolution (Optional[int]) –
property (Optional[str]) –
pointmode (Optional[bool]) –
- Return type
None
- clustering_type: str = 'hexbin'¶
- absolute_resolution: Optional[int] = None¶
- resolution: Optional[int] = None¶
- relative_resolution: Optional[int] = None¶
- property: Optional[str] = None¶
- pointmode: Optional[bool] = None¶
- __annotations__ = {'absolute_resolution': typing.Union[int, NoneType], 'clustering_type': <class 'str'>, 'pointmode': typing.Union[bool, NoneType], 'property': typing.Union[str, NoneType], 'relative_resolution': typing.Union[int, NoneType], 'resolution': typing.Union[int, NoneType]}¶
- __dataclass_fields__ = {'absolute_resolution': Field(name='absolute_resolution',type=typing.Union[int, NoneType],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'clustering_type': Field(name='clustering_type',type=<class 'str'>,default='hexbin',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'pointmode': Field(name='pointmode',type=typing.Union[bool, NoneType],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'property': Field(name='property',type=typing.Union[str, NoneType],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'relative_resolution': Field(name='relative_resolution',type=typing.Union[int, NoneType],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'resolution': Field(name='resolution',type=typing.Union[int, NoneType],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)¶
- __eq__(other)¶
Return self==value.
- __hash__ = None¶
- __init__(clustering_type='hexbin', absolute_resolution=None, resolution=None, relative_resolution=None, property=None, pointmode=None)¶
- Parameters
clustering_type (str) –
absolute_resolution (Optional[int]) –
resolution (Optional[int]) –
relative_resolution (Optional[int]) –
property (Optional[str]) –
pointmode (Optional[bool]) –
- Return type
None
- __repr__()¶
Return repr(self).
- class xyzspaces.iml.layer.QuadbinClustering(clustering_type='quadbin', no_buffer=False, relative_resolution=None, resolution=None, countmode=None)[source]¶
Bases:
object
This class defines attributes for
quadbin
clustering algorithm.- Parameters
clustering_type (str) –
no_buffer (bool) –
relative_resolution (Optional[int]) –
resolution (Optional[int]) –
countmode (Optional[str]) –
- Return type
None
- clustering_type: str = 'quadbin'¶
- no_buffer: bool = False¶
- relative_resolution: Optional[int] = None¶
- resolution: Optional[int] = None¶
- countmode: Optional[str] = None¶
- __annotations__ = {'clustering_type': <class 'str'>, 'countmode': typing.Union[str, NoneType], 'no_buffer': <class 'bool'>, 'relative_resolution': typing.Union[int, NoneType], 'resolution': typing.Union[int, NoneType]}¶
- __dataclass_fields__ = {'clustering_type': Field(name='clustering_type',type=<class 'str'>,default='quadbin',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'countmode': Field(name='countmode',type=typing.Union[str, NoneType],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'no_buffer': Field(name='no_buffer',type=<class 'bool'>,default=False,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'relative_resolution': Field(name='relative_resolution',type=typing.Union[int, NoneType],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'resolution': Field(name='resolution',type=typing.Union[int, NoneType],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)¶
- __eq__(other)¶
Return self==value.
- __hash__ = None¶
- __init__(clustering_type='quadbin', no_buffer=False, relative_resolution=None, resolution=None, countmode=None)¶
- Parameters
clustering_type (str) –
no_buffer (bool) –
relative_resolution (Optional[int]) –
resolution (Optional[int]) –
countmode (Optional[str]) –
- Return type
None
- __repr__()¶
Return repr(self).
- class xyzspaces.iml.layer.InteractiveMapApiResponse(resp)[source]¶
Bases:
object
This class defines response returned from Interactive Map APIs.
- class xyzspaces.iml.layer.InteractiveMapLayer(layer_id, catalog)[source]¶
Bases:
object
This class provides access to data stored in Interactive Map layers.
- Parameters
layer_id (str) –
catalog (Catalog) –
- __init__(layer_id, catalog)[source]¶
Initialize layer instance.
- Parameters
layer_id (str) – a string with the layer ID of this layer
catalog (xyzspaces.iml.catalog.Catalog) – the instance of the Catalog this layer belongs to
- property statistics: dict¶
The statistical information of the layer.
- get_feature(feature_id, selection=None, force_2d=False)[source]¶
Return GeoJSON feature for the provided
feature_id
.- Parameters
feature_id (str) – Feature id which is to fetched.
selection (Optional[List[str]]) – A list, only these properties will be present in returned feature.
force_2d (bool) – If set to
True
then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.
- Returns
Feature
object.- Return type
- get_features(feature_ids, selection=None, force_2d=False)[source]¶
Return GeoJSON FeatureCollection for the provided feature_ids.
- Parameters
feature_ids (List[str]) – A list of feature identifiers to fetch.
selection (Optional[List[str]]) – A list, only these properties will be present in returned features.
force_2d (bool) – If set to
True
then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.
- Returns
FeatureCollection
object.- Raises
ValueError – If
feature_ids
is empty list.- Return type
- search_features(limit=30000, params=None, selection=None, skip_cache=False, force_2d=False)[source]¶
Search for features in the layer based on the properties.
- Parameters
limit (int) – A maximum number of features to return in the result. Default is 30000. Hard limit is 100000.
params (Optional[Dict[str, Union[str, list, tuple]]]) –
A dict to represent additional filters on features to be searched.
Examples:
params={"name": "foo"}
returns all features with a value of propertyname
equal tofoo
.params={"name!": "foo"}
returns all features with a value of propertyname
not equal tofoo
.params={"count=gte": "10"}
returns all features with a value of propertycount
greater than or equal to10
.params={"count=lte": "10"}
returns all features with a value of propertycount
less than or equal to10
.params={"count=gt": "10"}
returns all features with a value of propertycount
greater than10
.params={"count=lt": "10"}
returns all features with a value of propertycount
less than10
.params={"name=cs": "bar"}
returns all features with a value of propertyname
which contains``bar``.
selection (Optional[List[str]]) – A list, only these properties will be present in returned features.
skip_cache (bool) – If set to
True
the response is not returned from cache. Default isFalse
.force_2d (bool) – If set to
True
then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.
- Returns
FeatureCollection
object.- Return type
- iter_features(chunk_size=30000, selection=None, skip_cache=False, force_2d=False)[source]¶
Return all the features in a Layer as Generator.
- Parameters
chunk_size (int) – A number of features to return in single iteration.
selection (Optional[List[str]]) – A list, only these properties will be present in returned features.
skip_cache (bool) – If set to
True
the response is not returned from cache. Default isFalse
.force_2d (bool) – If set to
True
then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.
- Yields
A
Feature
object.- Return type
Iterator[geojson.feature.Feature]
- get_features_in_bounding_box(bounds, clip=False, limit=30000, params=None, selection=None, skip_cache=False, clustering=None, force_2d=False)[source]¶
Return the features which are inside a bounding box stipulated by
bounds
parameter.- Parameters
bounds (Tuple[float, float, float, float]) – A tuple of four numbers representing the West, South, East and North margins, respectively, of the bounding box.
clip (bool) – A Boolean indicating if the result should be clipped (default: False)
limit (int) – A maximum number of features to return in the result. Default is 30000. Hard limit is 100000.
params (Optional[Dict[str, Union[str, list, tuple]]]) –
A dict to represent additional filters on features to be searched.
Examples:
params={"name": "foo"}
returns all features with a value of propertyname
equal tofoo
.params={"name!": "foo"}
returns all features with a value of propertyname
not equal tofoo
.params={"count=gte": "10"}
returns all features with a value of propertycount
greater than or equal to10
.params={"count=lte": "10"}
returns all features with a value of propertycount
less than or equal to10
.params={"count=gt": "10"}
returns all features with a value of propertycount
greater than10
.params={"count=lt": "10"}
returns all features with a value of propertycount
less than10
.params={"name=cs": "bar"}
returns all features with a value of propertyname
which contains``bar``.
selection (Optional[List[str]]) – A list, only these properties will be present in returned features.
skip_cache (bool) – If set to
True
the response is not returned from cache. Default isFalse
.clustering (Optional[Union[xyzspaces.iml.layer.HexbinClustering, xyzspaces.iml.layer.QuadbinClustering]]) – An object of either
HexbinClustering
orQuadbinClustering
.force_2d (bool) – If set to
True
then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.
- Returns
FeatureCollection
object.- Return type
- spatial_search(lng, lat, radius, limit=30000, params=None, selection=None, skip_cache=False, force_2d=False)[source]¶
Return the features which are inside the specified radius.
- Parameters
lng (float) – The longitude in WGS’84 decimal degree (-180 to +180) of the center Point.
lat (float) – The latitude in WGS’84 decimal degree (-90 to +90) of the center Point.
radius (int) – Radius in meter which defines the diameter of the search request.
limit (int) – The maximum number of features in the response. Default is 30000. Hard limit is 100000.
params (Optional[Dict[str, Union[str, list, tuple]]]) –
A dict to represent additional filters on features to be searched.
Examples:
params={"name": "foo"}
returns all features with a value of propertyname
equal tofoo
.params={"name!": "foo"}
returns all features with a value of propertyname
not equal tofoo
.params={"count=gte": "10"}
returns all features with a value of propertycount
greater than or equal to10
.params={"count=lte": "10"}
returns all features with a value of propertycount
less than or equal to10
.params={"count=gt": "10"}
returns all features with a value of propertycount
greater than10
.params={"count=lt": "10"}
returns all features with a value of propertycount
less than10
.params={"name=cs": "bar"}
returns all features with a value of propertyname
which contains``bar``.
selection (Optional[List[str]]) – A list, only these properties will be present in returned features.
skip_cache (bool) – If set to
True
the response is not returned from cache. Default isFalse
.force_2d (bool) – If set to
True
then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.
- Returns
FeatureCollection
object.- Return type
- spatial_search_geometry(geometry, radius=None, limit=30000, params=None, selection=None, skip_cache=False, force_2d=False)[source]¶
Return the features which are inside the specified radius and geometry.
The origin point is calculated based on the provided geometry.
- Parameters
geometry (Union[geojson.feature.Feature, geojson.geometry.Geometry, dict, Any]) – Geometry which will be used in intersection.
radius (Optional[int]) – Radius in meter which defines the diameter of the search request.
limit (int) – The maximum number of features in the response. Default is 30000. Hard limit is 100000.
params (Optional[Dict[str, Union[str, list, tuple]]]) –
A dict to represent additional filters on features to be searched.
Examples:
params={"name": "foo"}
returns all features with a value of propertyname
equal tofoo
.params={"name!": "foo"}
returns all features with a value of propertyname
not equal tofoo
.params={"count=gte": "10"}
returns all features with a value of propertycount
greater than or equal to10
.params={"count=lte": "10"}
returns all features with a value of propertycount
less than or equal to10
.params={"count=gt": "10"}
returns all features with a value of propertycount
greater than10
.params={"count=lt": "10"}
returns all features with a value of propertycount
less than10
.params={"name=cs": "bar"}
returns all features with a value of propertyname
which contains``bar``.
selection (Optional[List[str]]) – A list, only these properties will be present in returned features.
skip_cache (bool) – If set to
True
the response is not returned from cache. Default isFalse
.force_2d (bool) – If set to
True
then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.
- Type
a GeoJSON Feature of Geometry or any object that supports the
__geo_interface__
.- Returns
FeatureCollection
object.- Return type
- write_feature(feature_id, data)[source]¶
Write GeoJSON feature to Layer.
- Parameters
feature_id (str) – Identifier for the feature.
data (Union[geojson.feature.Feature, dict]) – GeoJSON feature which is written to layer.
- Return type
None
- update_feature(feature_id, data)[source]¶
Update the GeoJSON feature in the Layer.
- Parameters
feature_id (str) – A feature_id to be updated.
data (Union[geojson.feature.Feature, dict]) – A GeoJSON Feature object to update.
- Return type
None
- delete_feature(feature_id)[source]¶
Delete feature from the layer.
- Parameters
feature_id (str) – A feature_id to be deleted.
- Return type
None
- write_features(features=None, from_file=None, feature_count=2000)[source]¶
Write GeoJSON FeatureCollection to layer.
As API has a limitation on the size of features, features are divided into groups, and each group has number of features based on
feature_count
.- Parameters
features (Optional[Union[geojson.feature.FeatureCollection, dict, Iterator[geojson.feature.Feature], List[geojson.feature.Feature]]]) – Features represented by
FeatureCollection
, Dict,Iterator
or list of features.from_file (Optional[Union[str, pathlib.Path]]) – Path of GeoJSON file.
feature_count (int) – An int representing a number of features to upload at a time.
- Return type
None
- _upload_features(feature_groups)[source]¶
- Parameters
feature_groups (Iterator[Union[geojson.feature.Feature, Dict]]) –
- Return type
None