map 2d coordinates to 1d index using blender drivers
I don't know if there is a solution to grease pencil related but in a shader node you could use a formular like
Index = Row * GridWith + Column
to get an index from a 2d Point.