Passing bounding box coords as parameter to API call
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.
Page 1 / 1
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).