Skip to main content

Hi I’m calling an Ordnance Survey API using a bounding box of a 25km grid square to just get the building outline features I need.  I’m doing a spatial filter and buffer then to further reduce the number of features I want.  I’m doing this manually i.e. putting the new bounding box values into the API call parameters then running the workbench again.  I want to be able to do this dynamically via a parameter, from a list of bounding box coordinates from another file, so I can effectively loop through and spit out out a file for each grid square (I’ll append these back together later).

Is this possible?  Any help gratefully received.

A few transformers that might help

BoundsExtractor - Extracts a feature’s minimum and maximum coordinate values into attributes

CoordinatesExtractor - (points) use with Specify Coordinate mode to write out _x _y _z attributes

GeometryExtractor - (polygon) extracts the geometry of a feature according to the setting of the geometry encoding parameter.  In your case the API you’re using might accept GeoJson encoding or WKT

GeometryReplacer - Replaces the geometry of a feature according to the setting of the geometry encoding parameter. This transformer is typically used to restore geometry previously extracted into an attribute by the GeometryExtractor

BoundingBoxAccumulator - Useful after bufferer, this creates a rectangular polygon that spans the extents of all input features.


Thank you ​@j.botterill - I’m familiar with the transformers for extracting bounds / geometry - its the parameterisation / automation passing the bounds to the API I really need a solution to 


What exactly are you having problems with? The whole process is quite easy. Let’s say I have a geopackage with a few polygons in there, and those polygons should be used to get the data from the API. Then that would, in its most simple form, work as follows:

  • read Geopackage
  • get MBR for each polygon
  • create Json from MBR
  • Post Json to API
  • Receive result
  • process result

I’m not familiar with the OS API’s, but usually one needs to use the HTTPCaller to POST a json-body to the API in these sorts of requests, so I am assuming that is the case here as well. The GeometryExtractor allows you to extract geometry from a feature in (Geo-)Json format, but with an MBR it’s also not that difficult to generate it yourself usually.

So which part of the above process do you have a problem with, and what have you tried?


Thanks ​@s.jager I guess if it was easy I wouldn’t be posting.  Does the graphic below help in terms of what I’m trying to achieve?

 


Ah. You are using a reader. That does make this scenario a bit more complicated (not impossible).

I would use the HTTPCaller instead. Because then you can use the values of attributes in creating your URL query parameters, which means you can just read your list of bounding boxes and request the data one at a time (provided that API is not limited: public API’s are frequently limited both in number of requests and amount of data they return - that’s something you’ll need to check).

 

 

 

Edit:  just found this tutorial and this article. Might be helpful for you.


Or change the classic reader to a FeatureReader, you can then use the geometry of the initiating feature as Spatial Filter.


Or change the classic reader to a FeatureReader, you can then use the geometry of the initiating feature as Spatial Filter.

Thanks - will this iterate through all the bounding boxes in the list or just do the first one?


No list, just a feature with a geometry. One feature is one request.


No list, just a feature with a geometry. One feature is one request.

Ok thanks


No list, just a feature with a geometry. One feature is one request.

Ok thanks

If you need a sample workspace let me know.


No list, just a feature with a geometry. One feature is one request.

Ok thanks

If you need a sample workspace let me know.

Thank you yes that would be great to see a sample workspace and compare to what I have so far


Reply