[postgis-users] OGR2OGR conversion from PostGIS to MapInfo issue

Obe, Regina robe.dnd at cityofboston.gov
Mon Oct 15 07:14:49 PDT 2007


Thanks Mateusz,

I tried using a view and that seemed to work and the fields now have the
right length and I can resave the file in mapinfo.  The only trick was
that I had to manually insert an entry for my view into the
geometry_columns table for it to work.

My final command shell call looks like this

ogr2ogr -f "MapInfo File" -a_srs "EPSG:2249" update PG:"host=zdnd1
dbname=dnddts" "UPDATE" vwupdate -nln "UPDATE"

thanks again,
Regina



-----Original Message-----
From: Obe, Regina 
Sent: Monday, October 15, 2007 9:44 AM
To: gdal
Subject: RE: [postgis-users] OGR2OGR conversion from PostGIS to MapInfo
issue

 Thanks Mateusz,

I'll give it a try to output the table instead.  Do you think a view
would work instead of a table?  My problem is I don't want to output all
the fields in my table since I have excess stuff they don't need.

Now looking back at my shape export - I had thought it output the field
lengths correctly, but it actually defaulted all of them to 80 so that
explains it.

Regina

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Mateusz Loskot
Sent: Monday, October 15, 2007 9:35 AM
To: PostGIS Users Discussion
Cc: gdal; gdal-announce at lists.osgeo.org
Subject: Re: [postgis-users] OGR2OGR conversion from PostGIS to MapInfo
issue

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
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.




More information about the postgis-users mailing list