Points from a list of numbers

A list of digits, consisting of 0 and 1, spread out within a 28*28 grid. I want to make a point where ever a “1” exists on the grid to depict a line as in the present picture

import csv file to gh.gh (19.9 KB)

If your data are in “sets” i.e. you get a List of Matrices (or int [ , ] or bool [ , ]) then get an IndexPair List per Matrix, sort by I then by J (to find the start) and then do a classic iterative proximity (or rather better do a recursive prox search [for an adjacent neighbor in fact] directly on that Matrix - general case: any shape like the letter “Y” and the likes) for the “pixelized” polyline. That said the recursive approach does not need any sort and/or the IndexPairs.

If you want an indicative C# example (NO auto translation to P available/possible) provide an internalized test List of Matrices

Welcome @banooazam.gh ,

You should at least provide a data sample (CSV). The grid stuff should be straighforward to help you with.

many thanks for your answer
I thought a conditional statement in python could help me but it didn’t work.

Your screenshot doesn’t show the entire code.

Where is the file?

No that’s going nowhere (for obvious reasons).

Are you familiar with what recursion means? Some people don’t like that thing and claim Memory issues … but for a 28*28 grid … why bother talking?

BTW: in similar cases always define a public bool [ , ] named say sampled and when in the recursive search Method (i,e, a thing that calls itself] test each new candidate neighbor for avoiding dating the same girl twice (and if no new neighbor exists > adios amigos > terminate the recursion].

BTW: all that for getting an ordered collection of points ready for a simple or nested Graph. If you want just a bunch of connections (i.e. a List of Lines) … well that is rather the easiest of things.

1 Like

FOUT2.csv (199.2 KB)

thanks a lot
yeah, you are right.
I changed it this way:
import csv file to gh.gh (19.9 KB)

Do you want result like this?

Yes. thanks for your attention.
I want to do the same operation using points to get a polyline.

can you share the Algorithm?

import csv file to gh.gh (10.2 KB)


Many thanks for your help :+1: :+1: