I am trying to import my ESRI-shapefile with OGR2OGR to an existing mysql table. This works fine but unfortunately only the featureID and the geometry data is exported. How do I add the labels of the different polygons? These are stored in the .dbf-File if I am not mistaken. I am using the following command:

ogr2ogr -f MySQL MYSQL:Polygons,host=localhost,user=user,password=user,port=3306 -nln route -a_srs EPSG:4326 -append /home/Fields3.shp

if using ogrinfo on the file it tells me:

INFO: Open of `Fields3.shp'
      using driver `ESRI Shapefile' successful.
1: Fields3 (Polygon)

How can I get the addition information into Mysql? The Shapefile is created using Qgis 2.0 with standard settings.

  • Since you are appending the MySql table, the dbf fields should exist in the Mysql table. – klewis Jan 17 '14 at 13:34
  • It doesn't look like there are any attributes associated with the features in this Shapefile. Can you show us the attribute table of the Shapefile in QGIS? – underdark Jan 18 '14 at 11:26
  • The schema of shapefile can be read with ogrinfo as ogrinfo file.shp -al -so where -al means "all layers" and -so "summary only". This is documented in gdal.org/ogrinfo.html. Your original command lists only the name of the layer that GDAL finds from the shapefile. – user30184 May 29 '14 at 5:57

Your Answer

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

Browse other questions tagged or ask your own question.