2

I have a ORACLE database 10g(Oracle Database 10g Enterprise Edition Release 10.2.0.3.0) with a SDE.ST_Geometry field and i want to make a program in python so i can create several shapefiles based on this ST_Geometry field and use other fields as well so i can fill my shapes with attributes. I only have database access and i have no idea which arcgis is related.

How can i do this? Is there any suggestion?

  • Please update the question to specify the exact Oracle release and the version of ArcGIS which created the ST_GEOMETRY. Has the listener been correctly configured to permit SDE.ST_AsText invocation from SQL*Plus? Do you have the rest of ArcGIS available? What Python libraries for shapefile manipulation do you have available? – Vince Sep 30 '14 at 11:25
  • @Vince i'm not using nothing, im starting from scratch. I have no idea how to do this so i'm asking for suggestion how to start this. Where to look at.. At this moment i'm looking for GDAL libs.However i follow your advice by updating my question. – ePascoal Sep 30 '14 at 11:47
  • There's likely scores of shapefile and/or GML access libraries, dozens of them written in Python. As it stands, your question is very broad, and not particularly answerable. – Vince Sep 30 '14 at 12:18
  • @Vince, my question is pretty simple if you have some experience on my issue, which is how to export/create a shapefile from a oracle database base on the field sde.st_geommetry, to shapefile or gml, please help me. If you know dozens of libs that allows me to do this, i just want to know at least one example of that dozens libs that you've experience, so i can investigate? I just need suggestions to start with. – ePascoal Sep 30 '14 at 13:36
2

If you have the same issue GDAL can be a good aproach..

Please take a look on

http://www.gdal.org/ogr2ogr.html

http://www.gdal.org/ogr/drv_oci.html

import cx_Oracle
# Import osgeo
    try:
        from osgeo import ogr, osr, gdal
        print "Import success!"
    except:
        sys.exit('ERROR: cannot find GDAL/OGR modules')

# To connect to oracle database you will need:
     Connection_String = 'username/pwd@ (DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = xx.xxx.xxx.xx)(PORT = xxxx))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = name.service)))'   
    cx_Oracle.connect(Connection_String)


    cur = db.cursor()
    cur.execute("select shape.minx, shape.miny, somefield from mydbase.table")

# "shape" is the name of your SDE.ST_Geometry field.

finally you just have to follow this link:

http://www.digital-geography.com/create-and-edit-shapefiles-with-python-only/#.VDPnvPldU31

and problem solved.. If you have this same issue and find this question useful, please vote.

  • Could you add the final lines with SDO driver? – jlSta May 30 '17 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.