[gdal-dev] Importing and exporting shapefiles in mySQL with OGR

Frank Warmerdam warmerdam at pobox.com
Mon Jan 17 11:02:12 EST 2011


On 11-01-17 02:25 AM, "Dr. Markus Müller" wrote:
> Dear listers,
>
> I am trying to get shapefiles in and out of a mySQL database using OGR. I found
> some example commands for importing and succeeded in doing this. But getting
> the syntax together to get a spatial dataset out of mySQL db seems to be over
> my head.
>
> Can anybody supply an example command to convert from mySQL to shape? Or is it
> just not possible to export geodata from mySQL into shapefiles using OGR?

Markus,

It could be as simple as:

   ogr2ogr out_dir MYSQL:mydbname

This would dump all spatial tables to shapefiles in a newly created
directory "out_dir" from a MySQL database named "mydbname".

If you want to only extract particular tables, then just list them at the
end.

eg.
   ogr2ogr out_dir MYSQL:mydbname roads intersections

For more options, such as custom queries, spatial restrictions and so forth
see the ogr2ogr docs:

   http://www.gdal.org/ogr2ogr.html

Or perhaps I'm missing the gist of your problem?

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list