resample

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 1 Imported by: 0 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

orb/resample Godoc Reference

Package resample has a couple functions for resampling line geometry into more or less evenly spaces points.

func Resample(ls orb.LineString, df orb.DistanceFunc, totalPoints int) orb.LineString
func ToInterval(ls orb.LineString, df orb.DistanceFunc, dist float64) orb.LineString

For example, resampling a line string so the points are 1 planar unit apart:

ls := resample.ToInterval(ls, planar.Distance, 1.0)

Documentation

Overview

Package resample has a couple functions for resampling line geometry into more or less evenly spaces points.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resample

func Resample(ls orb.LineString, df orb.DistanceFunc, totalPoints int) orb.LineString

Resample converts the line string into totalPoints-1 evenly spaced segments. This function will modify the linestring input.

Example
package main

import (
	"fmt"

	"github.com/paulmach/orb"
	"github.com/paulmach/orb/planar"
	"github.com/paulmach/orb/resample"
)

func main() {
	ls := orb.LineString{
		{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0},
		{5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}, {10, 0},
	}

	// downsample in this case so there are 2.5 units between points
	ls = resample.ToInterval(ls, planar.Distance, 2.5)
	fmt.Println(ls)

}
Output:
[[0 0] [2.5 0] [5 0] [7.5 0] [10 0]]

func ToInterval

func ToInterval(ls orb.LineString, df orb.DistanceFunc, dist float64) orb.LineString

ToInterval coverts the line string into evenly spaced points of about the given distance. This function will modify the linestring input.

Example
package main

import (
	"fmt"

	"github.com/paulmach/orb"
	"github.com/paulmach/orb/planar"
	"github.com/paulmach/orb/resample"
)

func main() {
	ls := orb.LineString{{0, 0}, {10, 0}}

	// upsample so there are 6 total points
	ls = resample.Resample(ls, planar.Distance, 6)
	fmt.Println(ls)

}
Output:
[[0 0] [2 0] [4 0] [6 0] [8 0] [10 0]]

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL