This can be done in a python recipe (with geopandas) for example, or better, if you have a Postgres sql database, the postgis extension is very useful to handle geo data.
I realize I'm a bit late to the game, but I thought I would chime in for others needing similar help doing geospatial queries. Having never used geopandas before I thought I would just add it as a package to a custom code environment. It was not quite that simple. (I realize that this workload would generally be better offloaded to a database if possible, but I am running DSS 7 locally in a docker container - without access to a DB right now).
This will require a custom Python environment. I was unable to do spatial joins (using the "intersects" operation) without geopandas only. First I got some errors relating to missing package "rtree" and then after installing that package got another error related to "libspatialindex_c". Turns out that rtree is a python package that wraps libstpatialindex. libspatial index is a library that allows for robust spatial indexing and spatial querying - but is not installable through pip. So geopandas depends on rtree and rtree on libspatial index (for some things).
How I resolved my issue:
Other Notes: During my googling, it does appear that there are pre-built binaries on Conda Forge for libspatialindex. So you probably wouldn't need to go through the hassle of all the steps above if you create a code-env that is managed by conda - disclaimer: I did not test this.