Is it possible to have the python shell from either qgis or argis to load (import) both qgis.core and arcpy?
I am developing a metadata creation tool and have completed the core functionality using arcpy for formats that arcgis reads but want it to handle .tab files as well without having to convert the files to shp and then analyse them as in this post How to read MapInfo .tab files in ArcPy?
=== Thanks to RK I got some of this working (see code below)
BUT I can't figure out how to get the projection and other important info...http://www.gis.usu.edu/~chrisg/python/2009/docs/ogr.pdf includes a GetSpatialReference, GetGeometryType( self ) and GetGeometryName( self ):but how do you use them?
import osgeo, os
from osgeo import ogr
os.chdir(r'L:\\Data_Admin\\QA\\Metadata_python_toolset\\test\\Local_Govt\\TRC\\TAB')
os.getcwd()
driver = ogr.GetDriverByName('MapInfo File')
fn='trc_boundary.tab'
dataSource=driver.Open(fn,0)
layer = dataSource.GetLayer(0)
feature = layer.GetFeature(0)
extent=layer.GetExtent()
numFeatures=layer.GetFeatureCount()
#id = feature.GetFieldAsString('id') # this didn't work
geometry = feature.GetGeometryRef()
x=geometry.GetX()
#delete datasets from memory
#feature.Destroy()
#dataSource.Destroy()
And is there a tool similar to arcpy.ListFeatureClasses() if not I guess we can use glob as anyway for ogr the driver has to be specified.
No comments:
Post a Comment