av, Can you check if ogr2ogr can convert the shapefile to mapinfo?
-- Best regards, Chaitanya Kumar CH On Dec 26, 2013 8:14 AM, "Avenger Maslog" <amamas...@gmail.com> wrote: > Hi Everyone! > > I'm having an issue with creating MapInfo .tab files. I'm trying to > automate the process of creating either .tab or .shp files using the same > set of codes. It works fine when the output specified are shapefiles but > fails with a message: "Failed writing geometry for feature id #" for each > .tab point feature that I was trying to create.The input is dictionary > information and the output comes out as either .shp or .tab depending on > which one was specified. I really hope somebody could point out the reason > why it works with shapefiles but not with tab files. Thanks in advance! > > if fileType == "TAB": > driver = ogr.GetDriverByName('MapInfo File') > > if fileType == "SHP": > driver = ogr.GetDriverByName('ESRI Shapefile') > > featureDataSource = driver.CreateDataSource(fileName) > > layerName = "FeatureList" > featureSpatialRef = osr.SpatialReference() > featureSpatialRef.ImportFromEPSG(4326) > featureLayer = featureDataSource.CreateLayer(layerName, srs = > featureSpatialRef, geom_type=ogr.wkbPoint) > > standardFieldsList = [] > > standardField = "" > > for attrib in attribList: > > if attrib["FLD_KEY"] == "ATTRIB_NAME": > standardField = attrib["FLD_VAL"] > > if attrib["FLD_KEY"] == "DATA_TYPE": > standardField = standardField + "." + attrib["FLD_VAL"] > > if attrib["FLD_KEY"] == "DATA_LEN": > standardField = standardField + "." + > str(attrib["FLD_VAL"]) > > if attrib["FLD_KEY"] == "DEF_VAL": > standardFieldsList.append(standardField) > standardField = "" > > standardFieldsFileCreator = FileCreator() > standardFieldsFileCreator.createStandardFields(standardFieldsList, > featureLayer) > > featureObj = ogr.Feature(featureLayer.GetLayerDefn()) > featurePoint = ogr.Geometry(ogr.wkbPoint) > > for feature in featureList: > for fieldName in feature.keys(): > fieldValue = feature[fieldName] > featureObj.SetField(str(fieldName), str(fieldValue)) > > coords = str(feature["COORDS"]) > coords = coords.strip()[1:-1] > coords = coords.split(", ") > > featurePoint.AddPoint(float(coords[0]),float(coords[1])) > > featureObj.SetGeometry(featurePoint) > > featureLayer.CreateFeature(featureObj) > > featureDataSource.Destroy() > > av > > _______________________________________________ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev >
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev