[gdal-dev] ogr2ogr - geojson to mapInfo - size of .dat become too big

Maxime Demers burton449geo at gmail.com
Wed Sep 23 05:54:58 PDT 2015


Thank you for your answer.

That works correctly with the correct layer name. However, I wonder where
in the geojson that layer name is stored? It's not written in the file
itself and I can't find it in the metadata of the file neither. The layer
name I found is OGRGeoJSON. Is this a default layer name for geojson? Is it
possible to modify it? I cannot find a place in the geojson specifications
where they mention layer name.


On Wed, Sep 23, 2015 at 8:43 AM, Even Rouault <even.rouault at spatialys.com>
wrote:

> Le mercredi 23 septembre 2015 14:41:53, Maxime Demers a écrit :
> > Hi Even,
> >
> > Thank you for the suggestion. However, it seems I cannot use such a -sql
> > statement on a geojson file. I got the following error with the command
> > below:
> >
> > ogr2ogr -f "MapInfo File" test.tab points.geojson -sql "select cast(id as
> > integer(10)), cast(codecs as character(3)), cast(codeSecteur as
> > character(20)), cast(codeWork as character(20)), cast(codePostal as
> > character(6)) from points"
> >
> > ERROR 1: SELECT from table points failed, no such table/featureclass.
>
> The error message gives a hint of the reason of the error. There's no
> table/layer named "points" in the source file. Do "ogrinfo points.geojson"
> to
> see the name of the layer.
>
> >
> > However, I have no problem to use the same command to convert a MapInfo
> > File to another MapInfo File with the -sql statement. Are you able to
> > confirm if its possible to do a -sql statement on a geojson file and if
> > yes, do you know why I got this error?
> >
> > thank you,
> >
> > Maxime Demers
> >
> > On Tue, Sep 22, 2015 at 2:47 PM, Even Rouault <
> even.rouault at spatialys.com>
> >
> > wrote:
> > > Le mardi 22 septembre 2015 16:07:56, Maxime Demers a écrit :
> > > > Hi,
> > > >
> > > > I have notice something bad when converting a geojson to mapInfo tab
> > > > with ogr2ogr. The .dat which contain the table feature's properties
> is
> > > > getting way too big after conversion.
> > > >
> > > > To test, I have converted a mapInfo tab to geojson using:
> > > >
> > > > ogr2ogr -f "GeoJSON" test.geojson test.tab
> > > >
> > > > and then I converted it back to mapInfo tab using:
> > > >
> > > > ogr2pgr -f "MapInfo File" test2.tab test.geojson
> > > >
> > > > Before convertion, the .dat of the mapInfo file was 8,75 Mo after
> > > > conversion it became 105 Mo.
> > > > I dont know if the problem is only when converting geojson to mapInfo
> > >
> > > tab.
> > >
> > > > What could be the cause of the problem and does a solution exists?
> > >
> > > Maxime,
> > >
> > > The issue is that when converting from GeoJSON to .tab, the source text
> > > fields in GeoJSON have no longer an explicit field width, hence the
> > > mapinfo driver fallbacks to 254 characters.
> > >
> > > You could workaround with a statement like this :
> > >
> > > ogr2ogr  -f "MapInfo File" test2.tab test.geojson -sql "select
> > > cast(field1_name as character(field_width)), cast(field2_name as
> > > character(field2_width)), ... from layername"
> > >
> > > to specify explicit field width.
> > >
> > > It would have been great if ogr2ogr had a mode to automate this (I
> > > thought there was one already, but can't find it)
> > >
> > > Even
> > >
> > > --
> > > Spatialys - Geospatial professional services
> > > http://www.spatialys.com
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
>



-- 
Stack Overflow: http://stackoverflow.com/users/1914034/burton449
GIS Overflow: http://gis.stackexchange.com/users/14426/burton449
LastFm: http://www.lastfm.fr/user/burton449
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20150923/463c4322/attachment.html>


More information about the gdal-dev mailing list