Exactly how did you go about looking for information?
I entered what seemed like an obvious set of keywords to google:
mac os spaces terminal command
In the search results, this was the 4th hit:
I confirmed the information by enabling & disabling Spaces, and reading the plist file with Property List Editor.
To discover the values associated with Spaces row and column count, change the default using System Preferences, then re-read the plist file. Same procedure for discovering which space is occupied by which apps.
I chose the search keywords to include
spaces for the obvious reason, and
terminal command because I thought it's more likely an answer is going to involve a Terminal command, rather than an actual AppleScript scripting element or a GUI app. Why? Because who but a programmer would even want this capability, and the first tool most programmers think of making is a command-line tool.