<div dir="ltr"><div><div>Thank you for your answer. <br><br></div>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.<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 23, 2015 at 8:43 AM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Le mercredi 23 septembre 2015 14:41:53, Maxime Demers a écrit :<br>
> Hi Even,<br>
><br>
> Thank you for the suggestion. However, it seems I cannot use such a -sql<br>
> statement on a geojson file. I got the following error with the command<br>
> below:<br>
><br>
> ogr2ogr -f "MapInfo File" test.tab points.geojson -sql "select cast(id as<br>
> integer(10)), cast(codecs as character(3)), cast(codeSecteur as<br>
> character(20)), cast(codeWork as character(20)), cast(codePostal as<br>
> character(6)) from points"<br>
><br>
> ERROR 1: SELECT from table points failed, no such table/featureclass.<br>
<br>
</span>The error message gives a hint of the reason of the error. There's no<br>
table/layer named "points" in the source file. Do "ogrinfo points.geojson" to<br>
see the name of the layer.<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> However, I have no problem to use the same command to convert a MapInfo<br>
> File to another MapInfo File with the -sql statement. Are you able to<br>
> confirm if its possible to do a -sql statement on a geojson file and if<br>
> yes, do you know why I got this error?<br>
><br>
> thank you,<br>
><br>
> Maxime Demers<br>
><br>
> On Tue, Sep 22, 2015 at 2:47 PM, Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>><br>
><br>
> wrote:<br>
> > Le mardi 22 septembre 2015 16:07:56, Maxime Demers a écrit :<br>
> > > Hi,<br>
> > ><br>
> > > I have notice something bad when converting a geojson to mapInfo tab<br>
> > > with ogr2ogr. The .dat which contain the table feature's properties is<br>
> > > getting way too big after conversion.<br>
> > ><br>
> > > To test, I have converted a mapInfo tab to geojson using:<br>
> > ><br>
> > > ogr2ogr -f "GeoJSON" test.geojson test.tab<br>
> > ><br>
> > > and then I converted it back to mapInfo tab using:<br>
> > ><br>
> > > ogr2pgr -f "MapInfo File" test2.tab test.geojson<br>
> > ><br>
> > > Before convertion, the .dat of the mapInfo file was 8,75 Mo after<br>
> > > conversion it became 105 Mo.<br>
> > > I dont know if the problem is only when converting geojson to mapInfo<br>
> ><br>
> > tab.<br>
> ><br>
> > > What could be the cause of the problem and does a solution exists?<br>
> ><br>
> > Maxime,<br>
> ><br>
> > The issue is that when converting from GeoJSON to .tab, the source text<br>
> > fields in GeoJSON have no longer an explicit field width, hence the<br>
> > mapinfo driver fallbacks to 254 characters.<br>
> ><br>
> > You could workaround with a statement like this :<br>
> ><br>
> > ogr2ogr  -f "MapInfo File" test2.tab test.geojson -sql "select<br>
> > cast(field1_name as character(field_width)), cast(field2_name as<br>
> > character(field2_width)), ... from layername"<br>
> ><br>
> > to specify explicit field width.<br>
> ><br>
> > It would have been great if ogr2ogr had a mode to automate this (I<br>
> > thought there was one already, but can't find it)<br>
> ><br>
> > Even<br>
> ><br>
> > --<br>
> > Spatialys - Geospatial professional services<br>
> > <a href="http://www.spatialys.com" rel="noreferrer" target="_blank">http://www.spatialys.com</a><br>
<br>
--<br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com" rel="noreferrer" target="_blank">http://www.spatialys.com</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div><div>Stack Overflow: <a href="http://stackoverflow.com/users/1914034/burton449" target="_blank">http://stackoverflow.com/users/1914034/burton449</a><br></div></div>GIS Overflow: <a href="http://gis.stackexchange.com/users/14426/burton449" target="_blank">http://gis.stackexchange.com/users/14426/burton449</a><br></div>LastFm: <a href="http://www.lastfm.fr/user/burton449" target="_blank">http://www.lastfm.fr/user/burton449</a><br></div></div>
</div>