In this paper, we propose an OBDA approach for accessing geospatial data stored in relational databases using the R2RML mappings and OGC standard GeoSPARQL. On the theoretical side, we provide a formalization of GeoSPARQL in terms of SPARQL entailment regime. For a practical query answering algorithm, we introduce an extension to the existing SPARQL-to-SQL translation method to support GeoSPARQL features. Our approach has been implemented in the system Ontop-spatial, an extension of the OBDA system Ontop for creating virtual geospatial RDF graphs on top of geospatial relational databases. We present an experimental evaluation of our system using and extending a state-of-the-art benchmark. To measure the performance of our system, we compare it to two state-of-the-art geospatial RDF stores –a free and open-source one, and a commercial one– and confirm its efficiency.