geopyspark.geotrellis.tms module¶
-
class
geopyspark.geotrellis.tms.
TileRender
(render_function)¶ A Python implementation of the Scala geopyspark.geotrellis.tms.TileRender interface. Permits a callback from Scala to Python to allow for custom rendering functions.
Parameters: render_function (Tile => PIL.Image.Image) – A function to convert geopyspark.geotrellis.Tile to a PIL Image. -
render_function
¶ Tile => PIL.Image.Image – A function to convert geopyspark.geotrellis.Tile to a PIL Image.
-
renderEncoded
(scala_array)¶ A function to convert an array to an image.
Parameters: scala_array – A linear array of bytes representing the protobuf-encoded contents of a tile Returns: bytes representing an image
-
-
class
geopyspark.geotrellis.tms.
TMS
(server)¶ Provides a TMS server for raster data.
In order to display raster data on a variety of different map interfaces (e.g., leaflet maps, geojson.io, GeoNotebook, and others), we provide the TMS class.
Parameters: server (JavaObject) – The Java TMSServer instance -
pysc
¶ pyspark.SparkContext – The
SparkContext
being used this session.
-
server
¶ JavaObject – The Java TMSServer instance
-
host
¶ str – The IP address of the host, if bound, else None
-
port
¶ int – The port number of the TMS server, if bound, else None
-
url_pattern
¶ string – The URI pattern for the current TMS service, with {z}, {x}, {y} tokens. Can be copied directly to services such as geojson.io.
-
bind
(host=None, requested_port=None)¶ Starts up a TMS server.
Parameters: - host (str, optional) – The target host. Typically “localhost”, “127.0.0.1”, or “0.0.0.0”. The latter will make the TMS service accessible from the world. If omitted, defaults to localhost.
- requested_port (optional, int) – A port number to bind the service to. If omitted, use a random available port.
-
classmethod
build
(source, display, allow_overzooming=True)¶ Builds a TMS server from one or more layers.
This function takes a SparkContext, a source or list of sources, and a display method and creates a TMS server to display the desired content. The display method is supplied as a ColorMap (only available when there is a single source), or a callable object which takes either a single tile input (when there is a single source) or a list of tiles (for multiple sources) and returns the bytes representing an image file for that tile.
Parameters: - source (tuple or orlist or
Pyramid
) – The tile sources to render. Tuple inputs are (str, str) pairs where the first component is the URI of a catalog and the second is the layer name. A list input may be any combination of tuples andPyramid
s. - display (ColorMap, callable) – Method for mapping tiles to images. ColorMap may only be applied to single input source. Callable will take a single numpy array for a single source, or a list of numpy arrays for multiple sources. In the case of multiple inputs, resampling may be required if the tile sources have different tile sizes. Returns bytes representing the resulting image.
- allow_overzooming (bool) – If set, viewing at zoom levels above the highest available zoom level will produce tiles that are resampled from the highest zoom level present in the data set.
- source (tuple or orlist or
-
host
Returns the IP string of the server’s host if bound, else None.
Returns: (str)
-
port
Returns the port number for the current TMS server if bound, else None.
Returns: (int)
-
unbind
()¶ Shuts down the TMS service, freeing the assigned port.
-
url_pattern
Returns the URI for the tiles served by the present server. Contains {z}, {x}, and {y} tokens to be substituted for the desired zoom and x/y tile position.
Returns: (str)
-