Solved

KML remove data outside of bounding box

  • 30 July 2019
  • 3 replies
  • 29 views

New user here so be patient!

 

I would like to remove from a KML all the geometry (point, lines and areas) that are outside of an arbitrary bounding box (let's say a square defined by the corner coordinates).

 

I tried using a Tester but I can't seem to get the numerical values of the of the placemark. With the following parameter I get always "passed" even if the points coordinates don't respect the condition:

Moreover this approach will be problematic for lines and areas. I tried multiple transformers but with no success.

 

So does anyone have a suggestion on what will be the best approach for filtering this data?

 

Thanks!

icon

Best answer by chrisatsafe 1 August 2019, 19:15

View original

3 replies

Badge +2

Hii @mitch753,

Welcome to the FME Community!

You have a couple of different options here:

  1. You can use a Search Envelope in the Reader to filter data out - this will prevent it from being read into the workspace in general. You can do this when you add the KML reader to the workspace by clicking the Parameters > select Use Search Envelope and specifying the Min/Max X/Y coordinates. You can choose for features to be clipped to the bounding box as well!

     

    Note: if you have already added the reader to the workspace or if you want to modify the search envelope coordinates, you can adjust the search envelope parameters in the Navigator pane under the reader parameters:

     

     

  2. Option 2, if you have a polygon that makes up the bounding box, you can use a Clipper transformer to clip all of the features to that area. If you are interested in this approach, be sure to check out the Example using the Clipper Transformer article. Note: if you don't have an existing polygon, you can always create one using a Creator, setting the geometry object to box/polygon and specifying the coordinates.

I have attached a sample workspace that shows both methods. The original dataset has 194 points but is filtered down to 4.

Hope this helps!

Search_Envelope.fmwt

Hii @mitch753,

Welcome to the FME Community!

You have a couple of different options here:

  1. You can use a Search Envelope in the Reader to filter data out - this will prevent it from being read into the workspace in general. You can do this when you add the KML reader to the workspace by clicking the Parameters > select Use Search Envelope and specifying the Min/Max X/Y coordinates. You can choose for features to be clipped to the bounding box as well!

     

    Note: if you have already added the reader to the workspace or if you want to modify the search envelope coordinates, you can adjust the search envelope parameters in the Navigator pane under the reader parameters:

     

     

  2. Option 2, if you have a polygon that makes up the bounding box, you can use a Clipper transformer to clip all of the features to that area. If you are interested in this approach, be sure to check out the Example using the Clipper Transformer article. Note: if you don't have an existing polygon, you can always create one using a Creator, setting the geometry object to box/polygon and specifying the coordinates.

I have attached a sample workspace that shows both methods. The original dataset has 194 points but is filtered down to 4.

Hope this helps!

Search_Envelope.fmwt

I had managed to solve the issue with a spatial filter, but for the filter I had to build a polygon in google earth, so it wasn't easy to just change the bounding box.

But your solution is much better and it was exactly what I was searching. So thanks a lot really appreciated!

Badge +2
I had managed to solve the issue with a spatial filter, but for the filter I had to build a polygon in google earth, so it wasn't easy to just change the bounding box.

But your solution is much better and it was exactly what I was searching. So thanks a lot really appreciated!

Great to hear @mitch753!

If you are planning on changing the bounding box often, you may want to look into using published parameters so it is easy to change set the values at runtime (as done in the example I provided). If you are interested in learning about published parameters, definitely check out the section on Advanced Parameter Use in the FME Desktop Advanced Training.

Reply