Dal gruppo pubblico GIS ITALIA di Facebook (ad oggi +1800 utenti):
Signori, Vi propongo un altro eccitante problema, che mi è sorto in ufficio: risolto con l’Autocad Map aziendale, mi chiedo se esista una soluzione analoga, ma con sw gratuito.
Allora, partendo dai soliti 969 punti rilevati sul campo con Gps submetrico, lo scopo è generare un file DXF contenenti soltanto testi (numeri dei picchetti), ognuno posto alla propria quota Z fisica.
Da un lungo confronto (in FB) è emerso che nessuno dei maggiori software OS (QGIS, GRASS, GvSIG) riesce ad esportare il solo testo in DXF e con la propria Z fisica. Neanche da Shell OSGeo4W con ogr2ogr ci si è riuscito (apparentemente!!!!).
In questo articolo propongo una soluzione semplice ma geniale allo stesso tempo, facendo uso del calcolatore di campi di QGIS e di ogr2ogr: soluzione estratta da un articolo letto qui.
Dopo aver caricato lo shapefile puntuale (969 punti) avvio il calcolatore di campi di QGIS e creo un nuovo campo OGR_STYLE (campo testuale, 254 caratteri max) e lo popolo con la seguente stringa: (per dettagli valori vedasi qui)
concat(‘LABEL(f:Arial,s:3000pt,t:’, “PICCHETTO”,’)’)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
concat('LABEL(f:Arial,s:3000pt,t:', "PICCHETTO",')') | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
Tool parameter units | |
Several parameter values can be expressed in different measurement units depending on the file format you are dealing with. For instance, some systems express line width, or text height in points, other in pixels, and others use ground units. In order to accommodate all that, all parameters can be specified in one of the following units systems: | |
g: Map Ground Units (whatever the map coordinate units are) | |
px: Pixels | |
pt: Points (1/72 Inch) | |
mm: Millimeters | |
cm: Centimeters | |
in: Inches |

dove “PICCHETTO” è un campo testuale da esportare in DXF:

Avviamo la shell di OSGeo4W e con ogr2ogr:

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C:\Users\Salvatore\Desktop>ogr2ogr -f DXF C:\Users\Salvatore\Desktop\prova\daidai.dxf C:\Users\Salvatore\Desktop\toto\dad_1.shp |
otterremmo:

come si può vedere, gli errori sono legati alla ‘non creazione’ dei campi, cosa che non ci interessa avere nel DXF.
Apriamo il file DXF con DraftSight 2016 (che supporta il 3D ed è Gratuito):

vista 3D:

facciamo una ulteriore verifica importando il DXF in QGIS:

Come si noterà, la tabella degli attributi del DXF contiene il campo Text.
Note finali: l’articolo trovato sul web dava un’altra procedura attraverso PostGIS, ma la ho adattata al solo uso di QGIS e per fortuna o per semplice caso è andata bene!!!
Per chi ha voglia di provare, ho realizzato una funzione da usare nel calcolatore di campi di QGIS per popolare il campo OGR_STYLE (da creare) che trovate qui.
Per i curiosi ecco i file.