Projection support in libmygis 0.7

I’ve just recently released a new version of libmygis, a library for dealing with various GIS formats. Its main purpose is importing ESRI Shapefile data into MySQL’s GIS, but it is useful for much more.

There are many new small features in libmygis 0.7, but the biggest new feature is projection support (and automatic re-projection) via the PROJ.4 cartographic library. With support for projections and the ability to read Shapefile PRJ files, libmygis is getting much closer to having full support for the Shapefile format.  This means you can easily import Shapefiles in any projection into MySQL and deal with it in pure lat/lon, which is what you’ll need in order to interface with outside tools such as Google Maps API.

6 thoughts on “Projection support in libmygis 0.7

  1. Your libmygis sounds good, but how can I use it. ’cause the download zip file is all source code. Must we build it ?!
    Now I use shp2mysql from and it works well. But I want to find a Windows version instead of this console program ( for more convenience when using ). Do you know where can I find it.

  2. I’ve been playing with libmygis and it seems to work well. It’s really great that it can now transform coordinates to lat-long, which is ideal for working with Google Maps or GPS data.

    As a couple of posters have mentioned above, the author hasn’t really provided documentation about how to build or use libmygis. Here are a few tips from my experience. Yes, it’s provided only as source code; you’ll need to build it yourself. It has a UNIX-style build system using automake and configure. I built it on Mac OS X with no problem.

    To build libmygis *without* its reprojection capability, simply download the source code, then cd to its directory and type “./configure” and then “make”. If all goes well, an executable “mysqlgisimport” will be generated in the tools directory. This is what you want to run to import your shapefile data. As an example, you could type “mysqlgisimport citylines -o foo” to import from shapefile data in citylines.shp and associated files and generate MySQL commands in an output file foo.

    To build libmygis *with* reprojection support, you’ll first need to download, compile and install the PROJ.4 library, found at Now build libgis as described above; when configuring, you *must* type “./configure –with-projection”. If you fail to include the “–with-projection” argument, the configure script will, confusingly, print “Projection support… yes” even though projection support is not actually enabled! (I believe that this is a bug in the configure script.) Check that your configure output includes the line “checking for pj_init in -lproj… yes”; this indicates that the configure script was able to find the PROJ.4 library you installed earlier. Now you can run mysqlgisimport as described above; all import coordinates will automatically be transformed to longitude/latitude.

    There seems to be one bug in the reprojection support: the output coordinates are wrong if the input data is in a coordinate system using units other than meters. This occurs because the PROJ.4 library expects the x_0 and y_0 values to be in meters, but in PRJ files the False_Easting and False_Northing values are in units listed in the UNIT clause (e.g. feet), and libmygis simply copies these values unchanged. I have a hacky patch that fixes this for US feet at least; I’ll send it to the author and hopefully he can incorporate it into the next version in some form.

  3. Hi there

    I’m triyng to compile libmygis 0.7.3 on a ubuntu 6.10, but I’m experiencing some errors.

    I provide the following configure line:

    # ./configure –with-mysql-lib –with-mysql –with-projection
    # make

    on the following part, it broke te compiling:

    Making all in prj
    make[1]: Entrando no diretório `/usr/src/libmygis-0.7.3/prj’
    source=’prj_yacc.c’ object=’prj_yacc.o’ libtool=no
    depfile=’.deps/prj_yacc.Po’ tmpdepfile=’.deps/prj_yacc.TPo’
    depmode=gcc3 /bin/bash ../depcomp
    gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I.. -g -O2 -c `test -f ‘prj_yacc.c’ || echo ‘./’`prj_yacc.c
    prj_yacc.y:15: error: conflicting types for ‘yyparse’
    prj_yacc.c:17: error: previous declaration of ‘yyparse’ was here
    prj_yacc.y: In function ‘yyparse’:
    prj_yacc.y:71: error: ‘projcs’ undeclared (first use in this function)
    prj_yacc.y:71: error: (Each undeclared identifier is reported only once
    prj_yacc.y:71: error: for each function it appears in.)
    make[1]: ** [prj_yacc.o] Erro 1
    make[1]: Saindo do diretório `/usr/src/libmygis-0.7.3/prj’
    make: ** [all-recursive] Erro 1

    I’m using byacc (public domain Berkeley LALR Yacc parser generator)…

    Any ideas?


  4. I’m having the same problem as Fernao :( Tried all sorts of yacc’s but can’t get it to compile. libmygis-0.7.5 with projections (Proj-4.6.0).

What do you think?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s