Skip to main content
Question

ASCII Grid to multiple XYZ attribute CSV file

  • 4 February 2013
  • 1 reply
  • 18 views

Hi,

 

 

I'm trying to convert mulitple ASCII grids to a single CSV file in the following format:

 

 

X, Y, Z, Z, Z, Z....etc.... where the Z is rainfall data over time.

 

 

I can capture the XYZ info, but I don't know how to write out multiple Z value attributes while keeping the XY as a constant into a single CSV file.

 

 

Any ideas on how to solve this are welcome.

 

 

Thanks

 

Ricky (newbie!) 
I've processed wind speed data in text format that was very similar to this structure with:

 

 

X,Y,Z,Z,Z

 

 

where Z = wind speed and typically there were 100 Z values each one representing a 1km easterly offset from the X,Y value. So your structure appears identical. It was a bit tricky to process but it can be achieved. I did the following:

 

  • Read source as Text
  • Exposed the attribute text_line_number
  • Split my data on the delimiter, in my case ; but perhaps , for you.
  • Used the ListExploder to then turn all attributes into features... in this case feature 1 is X, feature 2 is Y, feature 3 is Z, feature 4 is also a Z.
The trick to this type of process is understanding what order your features are flowing in. You'll now have X, Y, Z, Z, Z, Z, X, Y, Z, Z, Z, Z, X, Y, Z, Z, Z, Z etc

 

 

You now need to put a StringSearcher or a Tester in the way of your features and test for the X and Y and send them off in one direction and all the rainfall values go out of the other port.

 

 

The X and Y values should go to 2 x VariableSetters, the two variables get set and then elsewhere in the workspace where the Z values are arriving you use VariableRetrievers to retrieve those values, you may also need to use an ExpressionEvaluator to apply the relevant X or Y shift for each Z value. In your workspace features flow like this:

 

 

X, Y, Z, Z, Z, Z

 

 

then

 

 

X,Y go in one direction

 

Z, Z, Z, Z go in the other

 

 

Variable are fetched and retrieved and you end up with

 

 

X,Y,Z

 

X,Y,Z

 

X,Y,Z

 

X,Y,Z

 

 

When the next X and Y values arrive, they change the variables to the new values and the following Z values get the new position information tagged onto them, and so on.

 

 

You can now plot the points and create your grid.

 

 

Best of luck

 

 


Reply