I have some geometry which can be perceived as regions within a country and wish to create a shapefile which contains all the regions along with some attributes (e.g. name, population, area code, etc.)

I have the geometry from the regions in x,y WGS84 lat lon (not polygons so cannot be sure they are closed loops which is priority) currently stored in mySQL.

I wish to be able to create a single shp (with associated dbf and shx files) to contain this data.

Any pointers on command line tools and methods to do this would be gratefully received.

  • So I have the boundarys of many 'zones' along with the attributes for those zones, I just want to put it all together in a nice tidy shape file :) – JSz Nov 4 '13 at 13:58

Try with ogr2ogr using something like:

ogr2ogr output.shp MYSQL:dbname,user=userid,password=password,host=host,port=3306 tablename
  • 1
    never had great success with ogr2ogr and mySQL, the program becomes very unstable and documentation is particularly poor. – JSz Nov 4 '13 at 15:20
  • Take a look at this thread: osgeo-org.1560.x6.nabble.com/… – Antonio Falciano Nov 4 '13 at 15:29

Here it worked with:

ogr2ogr -f "ESRI Shapefile"  C:/......./pms/pms.shp MySQL:dbgeom,host=webgis.bla.intern,user=bla,password=bla tablename -lco engine=MYISAM

If you can read the mySQL file in QGIS, then just right-click and save as a shapefile


Take look at this example: http://docs.geotools.org/latest/userguide/tutorial/feature/csv2shp.html

It's easy to go from CSV to MySQL in Java.

  • all the data is currently in mySQL so its just a matter of taking my data ( an array of lat lons ) then add a few attributes to this arrany... and then finally mosaic it all together – JSz Nov 4 '13 at 13:59
  • This appears to be addressing a question other than the MySQL to shapefile conversion that is being asked about. Also, your last paragraph links to a deleted question and so I have deleted that paragraph. – PolyGeo Sep 10 '14 at 0:20

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.