[FWTools] FWTools Digest, Vol 71, Issue 2 - ogr2ogr convert MIF to SHP file that contains Text Object

Richard Greenwood richard.greenwood at gmail.com
Tue Sep 28 21:54:46 EST 2010


David,

Top quoting here, not sure if that's the preferred style for this list...

MapInfo supports 4 types of spatial objects:
  points
  lines (polylines)
  polygons (regions, areas)
  text (annotations)
Shapefiles only support 3 of those types:
  points
  lines
  polygons
Shapefiles allow only one spatial object type in a single shapfile,
but MapInfo allows different spatial types in the same file. So first
you must convert a MapInfo file into separate shapefiles for each
spatial object type that the MapInfo file contains (as you saw,
Universal Translator does this automatically, ogr2ogr does it with the
-where option).

Since the MapInfo text type is not supported in shapefiles you must
work around this problem. I recall (but might be mistaken) that the
MapInfo text objects are being converted to shapefile polygon objects,
but maybe it's point objects, in any case it doesn't matter. Your
problem is that the actual text is not being converted from the
MapInfo file to the shapefile. You need to get the actual text of the
MapInfo text object into an attribute field before you convert it to a
shapefile. After it is converted then you can use that field to label.

In order to get the actual text of the text object into a field you
need to create a text field to hold the text, and then populate the
field with MapInfo's "Update column" menu option. The function:
   objectinfo(obj,3)
"pulls" the text out of a text object. You can do this interactively
or with a MapBasic statement. I think with a little additional work
you can also pull the font face, font size, text angle, etc.

A couple side notes:
1. ogr2ogr can read MapInfo TAB files, so you really don't need to
convert to MID/MIF files.
2. You can script Universal Translator to do the conversion
non-interactively, but in my experience, using ogr2ogr, as you are
doing, is much easier.

Good luck,
Rich


On Tue, Sep 28, 2010 at 11:54 AM, Jiang, David
<JJiang at p2energysolutions.com> wrote:
> Hello, Richard,
>
> Sorry, could you please explain a little bit more on how to use "Update
> column" to assign text to an attribute in MapInfo for this case?
>
> To me, seems that after I run [ogr2ogr.exe -f "ESRI Shapefile" -where
> ogr_geometry='POINT' drawing_layer_#3_point.shp drawing_layer_#3.mif],
> the above command generates 4 files (in the attachment). But
> drawing_layer_PT.dbf doesn't keep the description. How can I update
> description column when I open these files in MapInfo? There are Point
> and Text objects in the MIF file. Should I use a different ogr_geometry
> value for Point object?
>
> In MapInfo Prof, there is this Universal Translator tool. When I use
> Universal Translator to convert drawing_layer_#3.mif to ESRI shape, it
> does generate a separate set of shape files for the text object in MIF
> besides the shape files for lines, regions and points. And I can see the
> description in the dbf file.
>
> What I am trying to do is: from our application, execute DOS command
> calls ogr2ogr.exe to convert MIF file to ESRI Shape. But it seems that
> ogr2ogr.exe cannot handle Text type in MIF file at this point.
>
> Thanks very much!
> David
>
> -----Original Message-----
> From: fwtools-bounces at lists.maptools.org
> [mailto:fwtools-bounces at lists.maptools.org] On Behalf Of
> fwtools-request at lists.maptools.org
> Sent: Saturday, September 18, 2010 11:00 AM
> To: fwtools at lists.maptools.org
> Subject: FWTools Digest, Vol 71, Issue 2
>
> Send FWTools mailing list submissions to
>        fwtools at lists.maptools.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.maptools.org/mailman/listinfo/fwtools
> or, via email, send a message with subject or body 'help' to
>        fwtools-request at lists.maptools.org
>
> You can reach the person managing the list at
>        fwtools-owner at lists.maptools.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of FWTools digest..."
>
>
> Today's Topics:
>
>   1. Re: FW: Ogr2ogr convert MIF to SHP file that contains     Text
>      object (Richard Greenwood)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 18 Sep 2010 06:42:47 -0600
> From: Richard Greenwood <richard.greenwood at gmail.com>
> Subject: Re: [FWTools] FW: Ogr2ogr convert MIF to SHP file that
>        contains        Text object
> To: "Jiang, David" <JJiang at p2energysolutions.com>
> Cc: fwtools at lists.maptools.org
> Message-ID:
>        <AANLkTi=1qSXmx=5Lp6HuRdvu4CNYz8PKgLhKJmnLcRru at mail.gmail.com>
> Content-Type: text/plain; charset=windows-1252
>
> Shape files don't have text objects, so you'd need to assign the
> MapInfo text to an attribute. This can easily be done in MapInfo using
> the "Update column" menu option with the objectinfo(obj,3) function.
>
> HTH,
> Rich
>
>
> On Tue, Sep 14, 2010 at 11:47 AM, Jiang, David
> <JJiang at p2energysolutions.com> wrote:
>> The attached MIF file contains a Text object with the description of
>> ?test\nanother\nline?.
>>
>>
>>
>> Tried the following command: ogr2ogr ?f ?ESRI Shapefile? ?where
>> ogr_geometry=?POINT? drawing_layer_#3_point.shp drawing_layer_#3.mif
>>
>>
>>
>> The result shape file contains 3 point objects but the problem is that
> it
>> doesn?t keep the ?test\nanother\nline? description.
>>
>>
>>
>> What?s the correct syntax to convert a MIF file that contains Text
> Object?
>>
>>
>>
>> Thanks very much!
>>
>>
>>
>> David
>>
>> _______________________________________________
>> FWTools mailing list
>> FWTools at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/fwtools
>> http://fwtools.maptools.org/
>>
>>
>
>
>
> --
> Richard Greenwood
> richard.greenwood at gmail.com
> www.greenwoodmap.com
>
>
> ------------------------------
>
> _______________________________________________
> FWTools mailing list
> FWTools at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/fwtools
>
>
> End of FWTools Digest, Vol 71, Issue 2
> **************************************
>
>



-- 
Richard Greenwood
richard.greenwood at gmail.com
www.greenwoodmap.com


More information about the FWTools mailing list