GIS to CAD using ogr2ogr – Part 3 – Point Annotation to Text in CAD

GIS to CAD using ogr2ogr – Part 1 – Shp to DXF with Contour Data
GIS to CAD using ogr2ogr – Part 2 – GML to DXF with OS MasterMap

MasterMap Topo Sample Data:

https://www.ordnancesurvey.co.uk/business-and-government/licensing/sample-data/discover-data.html

OS MasterMap has an annotation layer, which is simple to symbolise in a GIS program. But becomes more difficult in CAD software.

With ogr2org, when writing a DXF file, if you have an input point geometry, which has an OGR_STYLE attribute, it will be written as a text geometry when opened in CAD.

So for our MasterMap data we have one layer we want to convert to text:
CartographicText

So for this we are primarily interested in “textString” and potentially “orientation”.

Lets see the layer as points first as a baseline:

Screenshot[10]

Zoomed in:

Screenshot[11]

But lets try that as text. We will keep this simple and only take into account orientation and to a small extent height. Lets look at orientation:

Orientation – The orientation of text or symbol features for cartographic placement. This is measured in tenths of a degree anticlockwise from due east (0–3599).

So conversion to degree will be simple. Orientation/10

We can also take into consideration height as a multiplier.

And “textString” stores the text itself.

The command:

Full extent:

Screenshot[12]

Zoomed in:

Screenshot[13]

Explained:

Since this is run in windows, through the regular console, the escape character for quotes is two quotes “”‘. So a combination on ‘ ” and “”‘ we can accommodate all the required quotes.

f:””Arial””,s:””‘||(height*800)||'””,t:””‘||textString||'””,a:””‘||(orientation/10)||'””,p:5

f:””Arial””
Font: Arial

s:””‘||(height*800)||'””
Size: Multiplier of the height field, I am not sure what the units are, comments appreciated.

t:””‘||textString||'””
Text: textString column

a:””‘||(orientation/10)||'””
Align: In degrees

p:5
Position: the OS position and the ogr2ogr style position are slightly different, so better placement could be achieved with some pre-processing

3 thoughts on “GIS to CAD using ogr2ogr – Part 3 – Point Annotation to Text in CAD

  1. Pingback: GIS to CAD using ogr2ogr – Part 3 – Point Annotation to Text in CAD | GeoNe.ws

  2. Pingback: GIS to CAD using ogr2ogr – Part 2 – GML to DXF with OS MasterMap | GIS for Thought

  3. BoKai

    Hallo,

    i followed your description of getting Annotation/Labeling from some file to DXF. At the time beeing i am trying to run the command as recommended:
    ogr2ogr.exe -f DXF Hausnummern.dxf Lage_mit_Hausnummer_clip.shp Lage_mit_Hausnummer_clip -sql “SELECT ‘LABEL(f:””Arial””,s:””‘||(TXTHOH*1)||'””,t:””‘||TXT||'””,a:””‘||(DWI_MATH*1)||'””,p:5)’ AS OGR_STYLE, * FROM Lage_mit_Hausnummer_clip” -dialect SQLITE
    But i get an Error because of quotes problem and about || sign.

    I didn’t wanted to change anything of your code thats why i also used the brackets with math operations as multiplication with 1. The orientation of my Text lables is ok and need no transformation.

    The only big difference is that i used a shp as input file

    Do you have any hints or solutions for the problem?

    Thank you in advance!

    Best,

    Bo

    Reply

Leave a Reply

Your email address will not be published.