[Gdal-dev] Re: [postgis-users] OGR2OGR conversion from PostGIS to MapInfo issue

Mateusz Loskot mateusz at loskot.net
Mon Oct 15 09:34:58 EDT 2007


Obe, Regina wrote:
> I apologize for this cross-posting, but wasn't quite sure which list
> would be best.

Regina,

I believe the best list is the official mailing list of GDAL project:
gdal-dev at lists.maptools.org

> I converted a query from PostGIS to MapInfo for one of our GIS
> specialists here, and apparently all the fields came out as varchar(254)
> and when they try to resave the file in MapInfo - it doesn't allow them
> to (I forget the error).  Aside from that, reading the file seems fine
> and you can see the features.  If I do the same but to shape format,
> then the fields have the correct field sizes and everything.
>  
> Is there something I am doing wrong here or is this just a limitation of
> the Ogr Mapinfo driver?

varchar(256) is a default width of string field in MapInfo format,
if not specified explicitly (http://www.gdal.org/ogr/drv_mitab.html)

I made a short test and it shows that columns are differently
recognized for layer based on SQL query than layer based on a table:

1. Reading point table as a layer determines wiedth of columns:

mloskot at dog:~/dev/gdal/_svn/trunk/gdal$ ogr/ogrinfo -ro PG:dbname=test
point -so
INFO: Open of `PG:dbname=test'
      using driver `PostgreSQL' successful.

Layer name: point
Geometry: Point
Feature Count: 53
Extent: (11.660233, 48.320915) - (21.675484, 53.763435)
Layer SRS WKT:
(unknown)
Geometry Column = the_geom
altitude: String (6.0)
gid: Integer (0.0)
lat: String (12.0)
lon: String (12.0)
longname: String (17.0)
name: String (17.0)
recnum: String (6.0)


2. If layer is based on SQL query, no details about columns width is given:

mloskot at dog:~/dev/gdal/_svn/trunk/gdal$ ogr/ogrinfo -ro PG:dbname=test
-sql "SELECT gid,name,recnum FROM point" -so
INFO: Open of `PG:dbname=test'
      using driver `PostgreSQL' successful.

Layer name: sql_statement
Geometry: Unknown (any)
Feature Count: 53
Layer SRS WKT:
(unknown)
gid: Integer (0.0)
name: String (0.0)
recnum: String (0.0)
mloskot at dog:~/dev/gdal/_svn/trunk/gdal$


In case 2., default value (254) is used, that's why you get varchar(254).

I'd recognize it as correct and expected behavior of OGR,
although a little strange or even surprising :-)


p.s. I added gdal-dev at lists.maptools.org to CC

Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the Gdal-dev mailing list