Skip to main content
WherobotsDB offers a spatial data generator called Spider. It is a data source that generates random spatial data based on the user-specified parameters.

Quick Start

Once you have your SedonaContext object created, you can create a DataFrame with the spider data source.
Now we have three DataFrames with random spatial data. We can show the first three rows of the df_random_points DataFrame to verify the data is generated correctly.
Output:
The generated DataFrame has two columns: id and geometry. The id column is the unique identifier of each record, and the geometry column is the randomly generated spatial data. We can plot all 3 DataFrames using the following code.
Output: Random Spatial Data You can browse the SpiderWeb website to play with the parameters and see how they affect the generated data. Once you are satisfied with the parameters, you can use them in your Spider DataFrame creation code. The following sections will explain the parameters in detail.

Common Parameters

The following parameters are common to all distributions.
The same seed parameter may produce different results with different Java versions or WherobotsDB versions.

Distributions

Spider supports generating random points, boxes and polygons under various distributions. You can explore the capabilities of Spider by visiting the SpiderWeb website. You can specify the distribution type using the distribution parameter. The parameters for each distribution are listed below.

Uniform Distribution

The uniform distribution generates random geometries in the unit square [0, 1] x [0, 1]. This distribution can be selected by setting the distribution parameter to uniform. Example:
Uniform Distribution

Gaussian Distribution

The Gaussian distribution generates random geometries in a Gaussian distribution with mean [0.5, 0.5] and standard deviation [0.1, 0.1]. This distribution can be selected by setting the distribution parameter to gaussian. Example:
Gaussian Distribution

Bit Distribution

The bit distribution generates random geometries in a bit distribution. This distribution can be selected by setting the distribution parameter to bit. Example:
Bit Distribution

Diagonal Distribution

The diagonal distribution generates random geometries on the diagonal line y = x with some dispersion for geometries that are not exactly on the diagonal. This distribution can be selected by setting the distribution parameter to diagonal. Example:
Diagonal Distribution

Sierpinski Distribution

The Sierpinski distribution generates random geometries distributed on a Sierpinski triangle. This distribution can be selected by setting the distribution parameter to sierpinski. Example:
Sierpinski Distribution

Parcel Distribution

This generator produces boxes that resemble parcel areas. It works by recursively splitting the input domain (unit square) along the longest dimension and then randomly dithering each generated box to add some randomness. This generator can only generate boxes. This distribution can be selected by setting the distribution parameter to parcel. Example:
Parcel Distribution
The number of partitions generated by the parcel distribution is always power of 4. This is for guaranteeing the quality of the generated data. If the specified numPartitions is not a power of 4, it will be automatically adjusted to the nearest power of 4 smaller or equal to the specified value.

Affine Transformation

The random spatial data generated by Spider are mostly in the unit square [0, 1] x [0, 1]. If you need to generate random spatial data in a different region, you can specify affine transformation parameters to scale and translate the data to the target region. The following code demonstrates how to generate random spatial data in a different region using affine transformation. The affine transformation parameters are: The affine transformation is applied to the generated data as follows:
Example:
The data is now in the region [0.5, 2.5] x [0.5, 2.5]. Affine Transformation

References