X

Oracle Spatial and Graph – technical tips, best practices, and news from the product team

Spatial with Python and GeoPandas, made easy with cx_Oracle

David Lapp
Product Manager

The open source cx_Oracle Python extension makes it easy to interoperate between Python apps and Oracle Spatial. cx_Oracle works with Python version 2.7 and 3.4+, and supports Oracle Client 11.2+ and therefore any database version supported by Oracle Client 11.2+ (i.e. Oracle Database 9i+) . Working with Spatial is streamlined by cx_Oracle's handling of object types (i.e. SDO_GEOMETRY) and LOBS (WKT, WKB).

See details here: https://oracle.github.io/python-cx_Oracle.

We've provided sample code for working with Python and Spatial using cx_Oracle, specifically

- Binding SDO_GEOMETRY to Python objects and loading geometries to the database

- Retrieving the geometries back from Spatial to Python objects for analysis using the popular GeoPandas Python package.

Please find the sample code here: https://github.com/oracle/python-cx_Oracle/blob/master/samples/SpatialToGeoPandas.py

The script returns a geometry in WKT format which you can view by pasting into Wicket:

 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.