I have an ontology and data that includes WGS84 lat/lon coordinates, and I have previously used Stardog and Jena with Geosparql to run queries to find data points within a given distance of each other. I am trying to get those same queries to work in python via owlready2, if that is at all possible. I've looked at trying to replicate the haversine formula for distance between latlon points using SWRL rules, but that seems like it won't work since SWRL doesn't seem to have atan2 or sqrt functions. I know there isn't a geosparql implementation for owlready2 (that I'm aware of), but there is one for RDFLib (https://github.com/RDFLib/geosparql-dggs). This one might work if I can figure out how to convert coordinates. Are there any other potential approaches to this problem out there that I'm overlooking?
I'm sorry, geospatial ontologies is very far from my domain of specialty... Using RDFlib can be an option. If you need to call Python function from SPARQL in the Owlready native SPARQL engine, this is possible (I still need to add a proper API for that, but would not be difficult).