0

We have a lot of our data stored in a PostGIS database and I need to create some styled MapInfo TAB file. So I have added an MI_STYLE column (varchar254) that contains a simple brush fill

BRUSH(fc:#0000FF);PEN(c:#000000)

I then export to TAB using ogr2ogr and open in MapInfo and I see polygons with the default black line but it should be a blue polygon with a black line.

Having read this similar question it seems I should be using OGR_STYLE as I am doing styling per row. So I changed my PostGIS database column name and did the export again. Unfortunately I still get the same result as above.

Can anyone help with an example?

What column name is MapInfo expecting?

And what is the correct ogr2ogr export?

closed as too broad by PolyGeo May 20 '18 at 9:14

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

It should work as you did with the OGR_STYLE field but I do not have MapInfo available for testing. Here is one polygon in OpenJUMP JML format.

<?xml version='1.0' encoding='UTF-8'?>
<JCSDataFile xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" >
<JCSGMLInputTemplate>
<CollectionElement>featureCollection</CollectionElement>
<FeatureElement>feature</FeatureElement>
<GeometryElement>geometry</GeometryElement>
<CRSElement>boundedBy</CRSElement>
<ColumnDefinitions>
     <column>
          <name>OGR_STYLE</name>
          <type>STRING</type>
          <valueElement elementName="property" attributeName="name" attributeValue="OGR_STYLE"/>
          <valueLocation position="body"/>
     </column>
</ColumnDefinitions>
</JCSGMLInputTemplate>

<featureCollection>
  <gml:boundedBy>
    <gml:Box>
      <gml:coordinates decimal="." cs="," ts=" ">-156156.64,7229908.00 185812.64,7521587.68</gml:coordinates>
    </gml:Box>
  </gml:boundedBy>
  <feature>
    <geometry>
      <gml:Polygon>
        <gml:outerBoundaryIs>
        <gml:LinearRing>
          <gml:coordinates>
            -156156.64000000007,7504824.48 
            185812.63999999996,7521587.68 
            16504.31999999993,7229908.0 
            -156156.64000000007,7504824.48 
          </gml:coordinates>
        </gml:LinearRing>
        </gml:outerBoundaryIs>
      </gml:Polygon>
    </geometry>
    <property name="OGR_STYLE">BRUSH(fc:#0000FF);PEN(c:#000000)</property>
  </feature>
</featureCollection>
</JCSDataFile>

Ogrinfo:

ogrinfo mi_styletest.jml -al
INFO: Open of `mi_styletest.jml'
      using driver `JML' successful.

Layer name: mi_styletest
Geometry: Unknown (any)
Feature Count: 1
Extent: (-156156.640000, 7229908.000000) - (185812.640000, 7521587.680000)
Layer SRS WKT:
(unknown)
OGR_STYLE: String (0.0)
OGRFeature(mi_styletest):0
  OGR_STYLE (String) = BRUSH(fc:#0000FF);PEN(c:#000000)
  Style = BRUSH(fc:#0000FF);PEN(c:#000000)
  POLYGON ((-156156.64 7504824.48,185812.64 7521587.68,16504.32 7229908.0,-156156.64 7504824.48))

Conversion into MapInfo MID/MIF:

ogr2ogr -f "MapInfo file" mi_styletest.mif mi_styletest.jml

Now ogrinfo finds these styled from the mif:

  Style = BRUSH(fc:#0000ff,id:"mapinfo-brush-1,ogr-brush-1");PEN(w:1px,c:#000000,id:"mapinfo-pen-2,ogr-pen-0")

I do not know the MID/MIF format but the styles seem to be converted into the mif part this way:

Pen (1,2,0)
Brush (1,255)

Copy-paste and save the JML into a file, run the ogr2ogr command and try how MapInfo shows the MID/MIF data.

EDIT

By the document https://web.archive.org/web/20060909054240/http://resource.mapinfo.com/static/files/document/1074660800077/interchange_file.pdf the Brush does not get converted right.

Pattern number 1 is “no fill,” and pattern number 2 is a solid fill

Edit the MIF file to use Brush (2,255) and see again if you can get your blue fill. If you can consider to create a GDAL issue into https://github.com/OSGeo/gdal.

Not the answer you're looking for? Browse other questions tagged or ask your own question.