Skip to main content

PolyBuild

Build spatial shapes from coordinate data by grouping and ordering points into either polygons (closed shapes) or polylines (open lines). Use this gem to convert raw latitude/longitude values into structured spatial geometries for mapping, analysis, or downstream geospatial operations.

  • Polygon: Uses the POLYGON() format to create a closed shape.
  • Polyline: Uses the LINESTRING() format to create an open path.

Input and Output

The PolyBuild gem accepts the following input and output.

PortDescription
in0Input dataset containing pairs of columns with latitude and longitude coordinates, along with fields for grouping and ordering coordinates.
outOutput dataset with one row per group, each containing a generated polygon or polyline in WKT format.

Parameters

Configure the PolyBuild gem using the following parameters.

ParameterDescription
Build MethodSelect the type of spatial geometry to create from your coordinate data:
• Select Sequence Polygon for closed areas, such as boundaries or zones
• Select Sequence Polyline for open paths, such as routes or trails
Longitude Column NameColumn containing longitude values. Must be in decimal degrees (e.g., -122.4194).
Latitude Column NameColumn containing latitude values. Must be in decimal degrees (e.g., 37.7749).
Group FieldColumn used to divide coordinates into distinct shapes.
Example: Use the state_name column to identify polygons for each state border.
Only one column is supported for grouping.
Sequence FieldColumn that defines the drawing order of points within each group.
This column can be any sortable type (e.g., integers, timestamps, strings).
The points will be connected in ascending order.

Example

Assume you have the following routes table for public transportation routes.

route_idstop_schedulelatitudelongitude
bus_21_morning2025-07-16T08:00:00Z37.7749-122.4194
bus_21_morning2025-07-16T08:10:00Z37.7793-122.4192
bus_21_morning2025-07-16T08:20:00Z37.7796-122.4148
tram_5_evening2025-07-16T18:00:00Z34.0522-118.2437
tram_5_evening2025-07-16T18:10:00Z34.0565-118.2470
tram_5_evening2025-07-16T18:20:00Z34.0580-118.2417

To transform each route into a polyline geometry:

  1. Add the PolyBuild gem to your pipeline canvas.
  2. Connect the routes table to the PolyBuild input port.
  3. Open the PolyBuild gem configuration.
  4. For Build Method, select Sequence Polyline.
  5. For Longitude Column Name, select the longitude column.
  6. For Latitude Column Name, select the latitude column.
  7. For Group Field, select the route_id column.
  8. For Sequence Field, select the stop_schedule column.
  9. Save and run the gem.

Result

The PolyBuild gem outputs a table including a polyline for each route.

route_idwkt
bus_21_morningLINESTRING (-122.4194 37.7749, -122.4192 37.7793, -122.4148 37.7796)
tram_5_eveningLINESTRING (-118.2437 34.0522, -118.2470 34.0565, -118.2417 34.0580)