Skip to main content

Dear altruist, I have a datasets of soil moisture values in array system. So, for each grid cell, I have values for each day for certain years (image 1 shows the structure of array). However, for some cells we have consistently a constant value ( e.g. 1). For these cells I have to recalculate the soil moisture based on the average of neighboring cells as per the formula in the second image. I have tried with Attribute manager and conditional statement in setting values, which is not sufficient to do this job. Can anyone kindly suggest and explain how conveniently it can be done in FME?

 

Image 1 image 2

I would probably convert the csv to a raster grid and use focal analysis to replace the bad cells.

 

Staying in vector, you could use a vertexCreator to turn the CSV into points and then a neighborfinder in Candidates only mode with the Neighbors to Find set to 4 or 8 depending on how many neighbours you want to average and generate a list.

Then you can average the values in by using the ListSummer and ListElementCounter and dividing one by the other.


I would probably convert the csv to a raster grid and use focal analysis to replace the bad cells.

 

Staying in vector, you could use a vertexCreator to turn the CSV into points and then a neighborfinder in Candidates only mode with the Neighbors to Find set to 4 or 8 depending on how many neighbours you want to average and generate a list.

Then you can average the values in by using the ListSummer and ListElementCounter and dividing one by the other.

Thanks @jdh​ for the reply. As the data is already georeferenced and displayed in point, do you think I still need VertexCreator? Also, by using neighborfinder, I would need to specify the number of neighbors. But in my case, I need to specify the neighboring cells for each cells in interest because sometimes neighbring cells also have constant values which I do not want to include in calculating the average.


Thanks @jdh​ for the reply. As the data is already georeferenced and displayed in point, do you think I still need VertexCreator? Also, by using neighborfinder, I would need to specify the number of neighbors. But in my case, I need to specify the neighboring cells for each cells in interest because sometimes neighbring cells also have constant values which I do not want to include in calculating the average.

No, if your data is already point, you don't need the vertexCreator, in the image you posted it was a csv table with lat/long attributes so I made an assumption.

For the neighborfinder, you could include more neighbours and then validate the entries in the list and ignore the constant values.

 

A better solution, now that i'm thinking about it, is to send all your "bad" points to the base port and all your valid points to the candidate port. That way only good values would be in the list. You would still want to specify the number of neighbours at 4, 8, and possibly a max distance as well, to constrain the "focal window".

 


Thanks @jdh​ for the reply. As the data is already georeferenced and displayed in point, do you think I still need VertexCreator? Also, by using neighborfinder, I would need to specify the number of neighbors. But in my case, I need to specify the neighboring cells for each cells in interest because sometimes neighbring cells also have constant values which I do not want to include in calculating the average.

Hi @jdh​, thank you again for giving hints towards a solution. I have first divided data that got SM==1 data and sent them to base port. As I need to find neighboring cells that have at least one arm common, I have used distance parameter and put the value of half of the length of an arm. Unfortunately now not sure how to proceed further. Wondering is it possible to have your email address just to share some data so that you might develop a workspace for me.

 

ConstantgridCellsIssue3


Thanks @jdh​ for the reply. As the data is already georeferenced and displayed in point, do you think I still need VertexCreator? Also, by using neighborfinder, I would need to specify the number of neighbors. But in my case, I need to specify the neighboring cells for each cells in interest because sometimes neighbring cells also have constant values which I do not want to include in calculating the average.

Unfortunately I will not be able to create a workspace for you.

If you restrict the number of neighbours to 1, then you will only get 1 result, and not say the 4 surrounding points to average.

In either case, the attribute of the neighboring points will be in ngbrCells{} list. ex ngbrCells{0}.SM.

 

With just one neighbour you could simply use an attributeCreator/Manager to set SM to ngbrCells{0}.SM.

If you want to average multiple neighbours use a ListSummer to get the total value as an attribute (_sumSM) and the ListElementCounter to get the number of neighbours (_element_count) and then an attributeCreator/Manager to set SM to _sumSM/_element_count.

 

 


I think jdh's first answer in which they also suggest changing the data to a raster format might be a lot quicker/ easier. You can use the NumericEasterizer to convert and then use a RasterConvolver with the following settings: Settings for RasterConvolverThen you can use the RasterCellCoercer to convert back into points.


Reply