Tuesday 10 September 2019

convert - How to read MapInfo .tab files in ArcPy?


I want to use arcpy (the ESRI install of python 2.65) to analyse MapInfo TAB files...can this be done directly or do I need to convert them to shp files...if so would it be possible to do something like


tabs=glob.glob('*.tab') and then

for tab in tabs
some function to convert tab to shp tab_shp1.shp


(maybe ogr2ogr -f "ESRI Shapefile" mydata.shp mydata.tab) not sure how to call an external command line.



 shpObj=arcpy.Describe(tab_shp1)
etc

I know there is functionality in FWTOOLS via OGR but can I access this via the ESRI python 2.65 install?



We have both tab and shp data and I am trying to create a master spatial index of all the datasets we have. I have written the code for ESRI formats but want to include the tab's if possible.



Answer



If you have OGR installed you should be able to use OGR in python.


import ogr
ds = ogr.Open("Path")

There is some explains of usinig Python OGR on here http://www.gdal.org/ogr/ogr_apitut.html


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...