Skip to main content
Solved

I'm looking on how to add attributes to a raster of points, based on their neighbors


4ntoine
Contributor
Forum|alt.badge.img+3

Hello

 

I'm currently transforming a GeoTiff in a point raster using centerpointreplacer. I have a grid of points every 100m.

The next step is to add 8 attributes for the 8 neighbours (or less if the point is on a border) and in each attribute set the slope from this point to the neighbor [in %].

I have z values for each point, I don't know how to get the distance between 2 points and how to add the attributes according to the neighbors.

Maximum distance for neighbors: @sqrt($(Resolution)^2 + $(Resolution)^2) * 1.1

 

20231212_110110 

Thanks,

Antoine

Best answer by joepk

I'm not entirely sure if I understand your question correctly but I think you could use the NeighborFinder for this. Set it to Candidates Only mode.

 

You could set maximum distance to 100m (or 101, not sure) and generate a list attribute on each point, in which you gather the attributes of interest of the 8 (or less) surrounding points.

 

You can explode the list attribute using the ListExploder for further analysis/ease of visualisation.

 

Hope this helps.

View original
Did this help you find an answer to your question?

7 replies

joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • Best Answer
  • December 12, 2023

I'm not entirely sure if I understand your question correctly but I think you could use the NeighborFinder for this. Set it to Candidates Only mode.

 

You could set maximum distance to 100m (or 101, not sure) and generate a list attribute on each point, in which you gather the attributes of interest of the 8 (or less) surrounding points.

 

You can explode the list attribute using the ListExploder for further analysis/ease of visualisation.

 

Hope this helps.


geomancer
Evangelist
Forum|alt.badge.img+47
  • Evangelist
  • December 12, 2023

It may be easier to do your calculations on the original raster. Have you looked at the Raster transformers?


4ntoine
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • December 12, 2023
geomancer wrote:

It may be easier to do your calculations on the original raster. Have you looked at the Raster transformers?

Thank you for your reply. I have looked on how to do this with raster transformers, like the RasterSlopeCalculator, but it "only" gives the maximum rate of change in z in the cell, and I need to hav the slope for all 8 directions

 


4ntoine
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • December 12, 2023
joepk wrote:

I'm not entirely sure if I understand your question correctly but I think you could use the NeighborFinder for this. Set it to Candidates Only mode.

 

You could set maximum distance to 100m (or 101, not sure) and generate a list attribute on each point, in which you gather the attributes of interest of the 8 (or less) surrounding points.

 

You can explode the list attribute using the ListExploder for further analysis/ease of visualisation.

 

Hope this helps.

Thank you fot your reply.

I'm not very familiar with lists. I know the values are like stored and can be called with {} but I don't really know how to retrieve them.

I had already tried the NeighborFinder (Candidates Only mode somhow only returns unmatched elements) but it's not very clear to me what happens


4ntoine
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • December 12, 2023
joepk wrote:

I'm not entirely sure if I understand your question correctly but I think you could use the NeighborFinder for this. Set it to Candidates Only mode.

 

You could set maximum distance to 100m (or 101, not sure) and generate a list attribute on each point, in which you gather the attributes of interest of the 8 (or less) surrounding points.

 

You can explode the list attribute using the ListExploder for further analysis/ease of visualisation.

 

Hope this helps.

It now seems to work, thank you. I had an error in my formula @sqrt($(Resolution)^2 + $(Resolution)^2) * 1.1, as FME Arimthmetic Editor doesn't understand ^ as power, I have to write @sqrt(@pow($(Resolution),2) + @pow($(Resolution),2)) * 1.1 and everything works fine


joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • December 12, 2023
4ntoine wrote:

Thank you fot your reply.

I'm not very familiar with lists. I know the values are like stored and can be called with {} but I don't really know how to retrieve them.

I had already tried the NeighborFinder (Candidates Only mode somhow only returns unmatched elements) but it's not very clear to me what happens

Glad to see the NeighborFinder approach works for you. Below is some more explanation about the lists.

 

This is my dummy workspace:

imageThese are the settings of my NeighborFinder:

imageAs you can see under Attribute Accumulation, I collect all values from the Z attribute to the list called _NeighborList.

You can explode the list with the ListExploder, which results in this:imageimageThe ListExploder basically multiplies your input features with the amount of list elements. I have prefixed the neighbor attributes with nb_ to avoid confusion. 'Z' and 'ID' are from the original point and 'nb_Z' and 'nb_ID' are from the neighboring points.

As you can see, ID 1 has three neighbors, so three points are generated. These points have the attributes of ID 1 (Z = 3.9) and of the neighbor points ID 2, ID 11, ID 12 (nb_Z = 2.6, nb_Z = 3.2 and nb_Z = 1.3).

 

You can do further calculations with these exploded features and e.g. merge it back together based on the original ID.

 

Have fun!


4ntoine
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • December 13, 2023
4ntoine wrote:

Thank you fot your reply.

I'm not very familiar with lists. I know the values are like stored and can be called with {} but I don't really know how to retrieve them.

I had already tried the NeighborFinder (Candidates Only mode somhow only returns unmatched elements) but it's not very clear to me what happens

Worked perfectly for me, thanks!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings