Skip to main content
Solved

How to use values ​​in the Search Envelope through a Choice?


chosbacon
Contributor
Forum|alt.badge.img+5

​Hello, Would anyone know if there is a way to use the Search Envelope by updating from a choice parameter? For example, I have these certain polygons that delimit the area I want to analyze:

Every time I want to analyze an area I have to change the values ​​of the X,Y parameter (min and max):

 

 

To solve the problem, I created a choice that shows the area number on the Display but the values ​​read are the bound coordinates.

 

And I created hidden parameters called Xmin, Xmax, Ymin, Ymax, These parameters look at this choice in the following way: @GetWord($(Choice),0)
Attributes read from parameters with the expression above

But even if the combination is a number, FME does not accept using this value in the search envelope, as it tries to read the entire written parameter. 
Below is the error log:

 

Invalid search envelope specified: GEOTIFF_1_SEARCH_ENVELOPE keyword must be followed by four numeric values (minX minY maxX maxY). Got '@GetWord(-42 -20 -40.5 -19 454,0) @GetWord(-42 -20 -40.5 -19 454,1) @GetWord(-42 -20 -40.5 -19 454,2) @GetWord(-42 -20 -40.5 -19 454,3)'

However, I understand that it does not accept this as input data, after all, even though it is a number, it is not a number-type parameter


To solve this problem, I tried another approach:

My data is in PostGis so I decided to read it through SQLCreator
 

But here I think it's not working because (I believe) there's a bug.

I wrote the expression:

 

FME_SQL_DELIMITER ;
-SELECT trecho_drenagem.* FROM bc250_base.hid_trecho_drenagem_l AS trecho_drenagem, (SELECT ST_MakeEnvelope(split_part($(Choice),' ',1), $(Ymin), $(Xmax), $(Ymax), 4674) AS geom) AS envelope WHERE ST_Intersects(trecho_drenagem.geom, envelope.geom);

 

But SQLCreator doesn't compute SQL functions over parameters,

for example:
split_part($(Choice),' ',1),

should result in just the first value, but it returns everything, even the native sql function, resulting in:

split_part($(3 -52.5 2 -51),' ',1),

Even simple functions, e.g.

We create the parameter A= 34 23 12 3

and we enter left($(A),2) the result will still be:

left(34 23 12 3,2) 

when it should be just 32

even left is written at the end, not computing the functions and not calling the correct coordinate.


Can anyone tell me if I'm the one making a mistake? and where.
Or if this doesn't really work in FME when it comes to parameters?

Best answer by chosbacon

geomancer wrote:

To turn a number represented as a string into an actual number you can use @Evaluate().

Does this work?

@Evaluate(@GetWord(-42 -20 -40.5 -19 454,0))

 

 

Yes, I tried that

 

redgeographics wrote:

I've just done that for a project like an hour ago 😄

My solution is to keep an Excel file with the tile numbers and their bounding box coordinates, then select one of those using a TestFilter and then a WorkspaceRunner to call the workspace that does the actual work, using the tile number and coordinates as parameters.

 

This is a good idea, it could be a method of solving my problem.

Thanks

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

geomancer
Evangelist
Forum|alt.badge.img+47
  • Evangelist
  • July 5, 2024

To turn a number represented as a string into an actual number you can use @Evaluate().

Does this work?

@Evaluate(@GetWord(-42 -20 -40.5 -19 454,0))


nielsgerrits
VIP
Forum|alt.badge.img+54

What is the dataformat you are reading? If it is not LAS, it is also possible to use a FeatureReader to get the data with a spatial filter. So if you have another source with the geometries and the id’s, you can select the tile you need if it matched the id of the user parameter, then use that tile to initiate the featurereader.

 

 


redgeographics
Celebrity
Forum|alt.badge.img+49

I've just done that for a project like an hour ago 😄

My solution is to keep an Excel file with the tile numbers and their bounding box coordinates, then select one of those using a TestFilter and then a WorkspaceRunner to call the workspace that does the actual work, using the tile number and coordinates as parameters.

 


thomasmarti
Contributor
Forum|alt.badge.img+8

I got a similar cse to read LiDAR-Data from a large area.

reading all LiDAR-files would exceed the RAM, so I got to read only the affected tiles from that specific region. then I created for each LiDAR-file the BoundingBox (1km x 1km) and added the filename as an attibute. next I made an AreaOnAreaOverlay with the region/perimeter and all LiDAR-BoundingBox to get the affected files. 

with the FeatureReader you can read now only the affected files and saave a lot of RAM.

maybe you can create an silimar approach. 


chosbacon
Contributor
Forum|alt.badge.img+5
  • Contributor
  • July 5, 2024
geomancer wrote:

To turn a number represented as a string into an actual number you can use @Evaluate().

Does this work?

@Evaluate(@GetWord(-42 -20 -40.5 -19 454,0))

 

 

Yes, I tried that

 

redgeographics wrote:

I've just done that for a project like an hour ago 😄

My solution is to keep an Excel file with the tile numbers and their bounding box coordinates, then select one of those using a TestFilter and then a WorkspaceRunner to call the workspace that does the actual work, using the tile number and coordinates as parameters.

 

This is a good idea, it could be a method of solving my problem.

Thanks


chosbacon
Contributor
Forum|alt.badge.img+5
  • Contributor
  • July 5, 2024

I solved it in the following way, instead of calling the data in SQLCreator using the limits as a parameter, I placed an empty Creator, transformed the properly correct parameters as attributes and called my data through SQLExecutor, then it worked.


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