Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3963810
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:15:34+00:00 2026-05-20T03:15:34+00:00

I have a need to take a 2D graph of n points and reduce

  • 0

I have a need to take a 2D graph of n points and reduce it the r points (where r is a specific number less than n). For example, I may have two datasets with slightly different number of total points, say 1021 and 1001 and I’d like to force both datasets to have 1000 points. I am aware of a couple of simplification algorithms: Lang Simplification and Douglas-Peucker. I have used Lang in a previous project with slightly different requirements.

The specific properties of the algorithm I am looking for is:

1) must preserve the shape of the line

2) must allow me reduce dataset to a specific number of points

3) is relatively fast

This post is a discussion of the merits of the different algorithms. I will post a second message for advice on implementations in Java or Groovy (why reinvent the wheel).

I am concerned about requirement 2 above. I am not an expert enough in these algorithms to know whether I can dictate the exact number of output points. The implementation of Lang that I’ve used took lookAhead, tolerance and the array of Points as input, so I don’t see how to dictate the number of points in the output. This is a critical requirement of my current needs. Perhaps this is due to the specific implementation of Lang we had used, but I have not seen a lot of information on Lang on the web. Alternatively we could use Douglas-Peucker but again I am not sure if the number of points in the output can be specified.

I should add I am not an expert on these types of algorithms or any kind of math wiz, so I am looking for mere mortal type advice 🙂 How do I satisfy requirements 1 and 2 above? I would sacrifice performance for the right solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:15:34+00:00Added an answer on May 20, 2026 at 3:15 am

    You can find my C++ implementation and article on Douglas-Peucker simplification here and here. I also provide a modified version of the Douglas-Peucker simplification that allows you to specify the number of points of the resulting simplified line. It uses a priority queue as mentioned by ‘Peter Taylor’. Its a lot slower though, so I don’t know if it would satisfy the ‘is relatively fast‘ requirement.

    I’m planning on providing an implementation for Lang simplification (and several others). Currently I don’t see any easy way how to adjust Lang to reduce to a fixed point count. If you
    could live with a less strict requirement: ‘must allow me reduce dataset to an approximate number of points‘, then you could use an iterative approach. Guess an initial value for lookahead: point count / desired point count. Then slowly increase the lookahead until you approximately hit the desired point count.

    I hope this helps.

    p.s.: I just remembered something, you could also try the Visvalingam-Whyatt algorithm. In short:
    -compute the triangle area for each point with its direct neighbors
    -sort these areas
    -remove the point with the smallest area
    -update the area of its neighbors
    -resort
    -continue until n points remain

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Synopsis: I have a need to take two generic C# objects, and if they
I have a phonegap application which will need to take a zip archive of
I have a homework assignment where I need to take input from a file
I need to take a url, /ServiceSearch/r.php?n=blahblah, and have it go to /search/blahblah/ so
I have an int[] array. I need to take an int and append it
I have a task to do, I need to take data that has been
I have a user control with several buttons, which need to take different actions
This is my first post here. I have a problem. I need to take
I have a task I need to perform, do_stuff(opts) , that will take ~1s
I have data with a best fit line draw. I need to draw two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.