[Qgis-tr] huge string to translate
Raymond Nijssen
r.nijssen at terglobo.nl
Tue Oct 28 22:40:41 PDT 2014
How come this huuuuuge string has suddenly appeared in QGIS application
(and in transifex for translation) so shortly for the 2.6 release???
Raymond
<h3>Delimited Text File Layer</h3>⏎
Loads and displays delimited text files⏎
<p>⏎
<a href="#re">Overview</a><br/>⏎
<a href="#creating">Creating a delimited text layer</a><br/>⏎
<a href="#csv">How the delimiter, quote, and escape characters
work</a><br />⏎
<a href="#regexp">How regular expression delimiters work</a><br />⏎
<a href="#wkt">How WKT text is interpreted</a><br />⏎
<a href="#attributes">Attributes in delimited text files</a><br />⏎
<a href="#example">Example of a text file with X,Y point
coordinates</a><br/>⏎
<a href="#wkt_example">Example of a text file with WKT geometries</a><br/>⏎
<a href="#python">Using delimited text layers in Python</a><br/>⏎
</p>⏎
⏎
<h4><a name="re">Overview</a></h4>⏎
<p>A "delimited text file" contains data in which each record
starts on a new line, and ⏎
is split into fields by a delimiter such as a comma. ⏎
This type of file is commonly exported from spreadsheets (for example
CSV files) or databases. ⏎
Typically the first line of a delimited text file contains the names of
the fields. ⏎
</p>⏎
<p>⏎
Delimited text files can be loaded into QGIS as a layer. ⏎
The records can be displayed spatially either as a point⏎
defined by X and Y coordinates, or using a Well Known Text (WKT)
definition of a geometry which may⏎
describe points, lines, and polygons of arbitrary complexity. The file
can also be loaded as an attribute⏎
only table, which can then be joined to other tables in QGIS.⏎
</p>⏎
<p>⏎
In addition to the geometry definition the file can contain text,
integer, and real number fields. By default ⏎
QGIS will choose the type of field based on its the non blank values of
the field. If all can be interpreted⏎
as integer then the type will be integer, if all can be interpreted as
real numbers then the type will⏎
be double, otherwise the type will be text.⏎
</p>⏎
<p>⏎
QGIS can also read the types from an OGR CSV driver compatible
"csvt" file. ⏎
This is a file alongside the data file, but with a "t"
appended to the file name. ⏎
The file should just contain one line which lists the type of each field. ⏎
Valid types are "integer", "real",
"string", "date", "time", and
"datetime". The date, time, and datetime types are treated as
strings in QGIS.⏎
Each type may be followed by a width and precision, for example
"real(10.4)".⏎
The list of types are separated by commas, regardless of the delimiter
used in the data file. An⏎
example of a valid format file would be:⏎
</p>⏎
⏎
<pre>⏎
"integer","string","string(20)","real(20.4)"⏎
</pre>⏎
⏎
<h4><a name="creating">Creating a delimited text layer</a></h4>⏎
<p>Creating a delimited text layer involves choosing the data file,
defining the format (how each record is to⏎
be split into fields), and defining the geometry is represented. ⏎
This is managed with the delimited text dialog as detailed below. ⏎
The dialog box displays a sample from the beginning of the file which
shows how the format⏎
options have been applied.⏎
</p>⏎
<h5>Choosing the data file</h5>⏎
<p>Use the "Browse..." button to select the data file. Once
the file is selected the⏎
layer name will automatically be populated based on the file name. The
layer name is used to represent⏎
the data in the QGIS legend. ⏎
</p>⏎
<p>⏎
By default files are assumed to be encoded as UTF-8. However other file⏎
encodings can be selected. For example "System" uses the
default encoding for the operating system. ⏎
It is safer to use an explicit coding if the QGIS project needs to be
portable.⏎
</p>⏎
<h5>Specifying the file format</h5>⏎
<p>The file format can be one of⏎
<ul>⏎
<li>CSV file format. This is a format commonly used by spreadsheets, in
which fields are delimited⏎
by a comma character, and quoted using a "(quote) character. Within
quoted fields, a quote⏎
mark is entered as "".</li>⏎
<li>Selected delimiters. Each record is split into fields using one or
more delimiter character.⏎
Quote characters are used for fields which may contain delimiters.
Escape characters may be used ⏎
to treat the following character as a normal character (ie to include
delimiter, quote, and ⏎
new line characters in text fields). The use of delimiter, quote, and
escape characters is detailed <a href="#csv">below</a>.⏎
<li>Regular expression. Each line is split into fields using a
"regular expression" delimiter.⏎
The use of regular expressions is details <a href="#regexp">below</a>.⏎
</ul>⏎
<h5>Record and field options</h5>⏎
<p>The following options affect the selection of records and fields from
the data file</p>⏎
<ul>⏎
<li>Number of header lines to discard: used to ignore header lines at
the beginning of the text file</li>⏎
<li>First record has fields names: if selected then the first record in
the file (after the discarded lines) is interpreted as names of fields,
rather than as a data record.</li>⏎
<li>Trim fields: if selected then leading and trailing whitespace
characters will be removed from each field (except quoted fields). </li>⏎
<li>Discard empty fields: if selected then empty fields (after trimming)
will be discard. This ⏎
affects the alignment of data into fields and is equivalent to treating
consecutive delimiters as a ⏎
single delimiter. Quoted fields are never discarded.</li>⏎
<li>Decimal separator is comma: if selected then commas instead of
points are used as the decimal separator in real numbers. For⏎
example <tt>-51,354</tt> is equivalent to -51.354.⏎
</li>⏎
</ul>⏎
<h5>Geometry definition</h5>⏎
<p>The geometry is can be define as one of</p>⏎
<ul>⏎
<li>Point coordinates: each feature is represented as a point defined by
X and Y coordinates.</li>⏎
<li>Well known text (WKT) geometry: each feature is represented as a
well known text string, for example⏎
<tt>POINT(1.525622 51.20836)</tt>. See details of the <a
href="#wkt">well known text</a> format.⏎
<li>No geometry (attribute only table): records will not be displayed on
the map, but can be viewed⏎
in the attribute table and joined to other layers in QGIS</li>⏎
</ul>⏎
<p>For point coordinates the following options apply:</p>⏎
<ul>⏎
<li>X field: specifies the field containing the X coordinate</li>⏎
<li>Y field: specifies the field containing the Y coordinate</li>⏎
<li>DMS angles: if selected coordinates are represented as
degrees/minutes/seconds⏎
or degrees/minutes. QGIS is quite permissive in its interpretation of
degrees/minutes/seconds.⏎
A valid DMS coordinate will contain three numeric fields with an
optional hemisphere prefix or suffix⏎
(N, E, or + are positive, S, W, or - are negative). Additional non
numeric characters are ⏎
generally discarded. For example <tt>N41d54'01.54"</tt> is a valid
coordinate.⏎
</li>⏎
</ul>⏎
<p>For well known text geometry the following options apply:</p>⏎
<ul>⏎
<li>Geometry field: the field containing the well known text
definition.</li>⏎
<li>Geometry type: one of "Detect" (detect),
"Point", "Line", or "Polygon".⏎
QGIS layers can only display one type of geometry feature (point, line,
or polygon). This option selects⏎
which geometry type is displayed in text files containing multiple
geometry types. Records containing⏎
other geometry types are discarded. ⏎
If "Detect" is selected then the type of the first geometry in
the file will be used.⏎
"Point" includes POINT and MULTIPOINT WKT types,
"Line" includes LINESTRING and⏎
MULTLINESTRING WKT types, and "Polygon" includes POLYGON and
MULTIPOLYGON WKT types.⏎
</ul>⏎
<h5>Layer settings</h5>⏎
<p>Layer settings control the way the layer is managed in QGIS. The
options available are:</p>⏎
<ul>⏎
<li>Use spatial index. Create a spatial index to improve the performance
of displaying and selecting spatial objects.⏎
This option may be useful for files larger than a few megabytes in
size.</li>⏎
<li>Use subset index. Create an index if a subset of records is being
used (either by explicitly setting a subset string ⏎
from the layer properties dialog, or an implicit subset of features for
which the geometry is valid in files⏎
for which all not geometries are valid). The index will only be created
when a subset is defined.</li>⏎
<li>Watch file. If this options is selected QGIS will watch the file for
changes by other applications, and ⏎
reload the file when it is changed. The map will not be updated until
refreshed by the user, but indexes and⏎
extents will be reloaded. This option should be selected if indexes are
used and it is likely that another⏎
application will change the file. </li>⏎
</ul>⏎
⏎
<h4><a name="csv">How the delimiter, quote, and escape characters
work</a></h4>⏎
<p>Records are split into fields using three character sets: ⏎
delimiter characters, quote characters, and escape characters. ⏎
Other characters in the record are considered as data, split into⏎
fields by delimiter characters. ⏎
Quote characters occur in pairs and cause the text between them to be
treated as a data. Escape characters cause the character following them
to be treated as data. ⏎
</p>⏎
<p>⏎
Quote and escape characters cannot be the same as delimiter characters -
they⏎
will be ignored if they are. Escape characters can be the same as quote
characters, but behave differently⏎
if they are.</p>⏎
<p>The delimiter characters are used to mark the end of each field. If
more than one delimiter character⏎
is defined then any one of the characters can mark the end of a field.
The quote and escape characters ⏎
can override the delimiter character, so that it is treated as a normal
data character.</p>⏎
<p>Quote characters may be used to mark the beginning and end of quoted
fields. Quoted fields can ⏎
contain delimiters and may span multiple lines in the text file. If a
field is quoted then it must⏎
start and end with the same quote character. Quote characters cannot
occur within a field unless they⏎
are escaped.</p>⏎
<p>Escape characters which are not quote characters force the following
character to be treated as data. ⏎
(that is, to stop it being treated as a new line, delimiter, or quote
character). ⏎
</p>⏎
<p>Escape characters that are also quote characters have much more
limited effect. They only apply within quotes and only escape
themselves. For example, if ⏎
<tt>'</tt> is a quote and escape character, then the string⏎
<tt>'Smith''s Creek'</tt> will represent the value Smith's Creek.⏎
</p>⏎
⏎
⏎
<h4><a name="regexp">How regular expression delimiters work</a></h4>⏎
<p>Regular expressions are mini-language used to represent character
patterns. There are many variations⏎
of regular expression syntax - QGIS uses the syntax provided by the <a
href="http://qt-project.org/doc/qt-4.8/qregexp.html">QRegExp</a> class
of the <a href="http://qt.digia.com">Qt</a> framework.</p>⏎
<p>In a regular expression delimited file each line is treated as a
record. Each match of the regular expression in the line is treated as
the end of a field. ⏎
If the regular expression contains capture groups (eg <tt>(cat|dog)</tt>)⏎
then these are extracted as fields. ⏎
If this is not desired then use non-capturing groups (eg
<tt>(?:cat|dog)</tt>).⏎
</p>⏎
<p>The regular expression is treated differently if it is anchored to
the start of the line (that is, the pattern starts with <tt>^</tt>).⏎
In this case the regular expression is matched against each line. If the
line does not match it is discarded⏎
as an invalid record. Each capture group in the expression is treated as
a field. The regular expression⏎
is invalid if it does not have capture groups. As an example this can be
used as a (somewhat ⏎
unintuitive) means of loading data with fixed width fields. For example
the ⏎
expression⏎
<pre>⏎
^(.{5})(.{10})(.{20})(.{20})⏎
</pre>⏎
<p>will extract four fields of widths 5, 10, 20, and 20 characters from
each line. ⏎
Lines less than 55 characters long will be discarded.⏎
</p>⏎
⏎
⏎
<h4><a name="wkt">How WKT text is interpreted</a></h4>⏎
<p>⏎
The delimited text layer recognizes the following ⏎
<a href="http://en.wikipedia.org/wiki/Well-known_text">well known
text</a> types - ⏎
<tt>POINT</tt>, <tt>MULTIPOINT</tt>, <tt>LINESTRING</tt>,
<tt>MULTILINESTRING</tt>, <tt>POLYGON</tt>, and <tt>MULTIPOLYGON</tt>. ⏎
It will accept geometries with⏎
a Z coordinate (eg <tt>POINT Z</tt>), a measure
(<tt>POINT M</tt>), or both (<tt>POINT ZM</tt>).⏎
</p>⏎
<p>⏎
It can also handle the PostGIS EWKT variation, in which the geometry is
preceded by an spatial reference ⏎
system id (eg <tt>SRID=4326;POINT(175.3 41.2)</tt>), and a variant
used by Informix in which the WKT is ⏎
preceded by an integer spatial reference id (eg <tt>1
POINT(175.3 41.2)</tt>).⏎
In both cases the SRID is ignored.⏎
</p>⏎
⏎
⏎
⏎
<h4><a name="attributes">Attributes in delimited text files</a></h4> ⏎
<p>Each record in the delimited text file is split into fields representing⏎
attributes of the record. Usually the attribute names are taken from the
first⏎
data record in the file. However if this does not contain attribute
names, then they will be named <tt>field_1</tt>, <tt>field_2</tt>, and
so on. ⏎
Also if records have more fields than are defined in the header record
then these⏎
will be named <tt>field_#</tt>, where # is the field number (note that
empty fields at the end of a record are ignored).⏎
QGIS may override ⏎
the names in the text file if they are numbers, or have names like
<tt>field_#</tt>,⏎
or are duplicated.⏎
</p>⏎
<p>⏎
In addition to the attributes explicitly in the data file QGIS assigns a
unique ⏎
feature id to each record which is the line number in the source file on
which⏎
the record starts. ⏎
</p>⏎
<p>⏎
Each attribute also has a data type, one of string (text), integer, or
real number.⏎
The data type is inferred from the content of the fields - if every non
blank value⏎
is a valid integer then the type is integer, otherwise if it is a valid
real⏎
number then the type is real, otherwise the type is string. Note that
this is⏎
based on the content of the fields - quoting fields does not change the
way they⏎
are interpreted.⏎
</p>⏎
⏎
⏎
<h4><a name="example">Example of a text file with X,Y point
coordinates</a></h4> ⏎
<pre>⏎
X;Y;ELEV⏎
-300120;7689960;13⏎
-654360;7562040;52⏎
1640;7512840;3⏎
</pre>⏎
<p>This file:</p>⏎
<ul>⏎
<li> Uses <b>;</b> as delimiter. Any character can be used to delimit
the fields.</li>⏎
<li>The first row is the header row. It contains the field names X, Y
and ELEV.</li>⏎
<li>The x coordinates are contained in the X field.</li>⏎
<li>The y coordinates are contained in the Y field.</li>⏎
</ul>⏎
<h4><a name="wkt_example">Example of a text file with WKT
geometries</a></h4>⏎
<pre>⏎
id|wkt⏎
1|POINT(172.0702250 -43.6031036)⏎
2|POINT(172.0702250 -43.6031036)⏎
3|POINT(172.1543206 -43.5731302)⏎
4|POINT(171.9282585 -43.5493308)⏎
5|POINT(171.8827359 -43.5875983)⏎
</pre>⏎
<p>This file:</p>⏎
<ul>⏎
<li>Has two fields defined in the header row: id and wkt.⏎
<li>Uses <b>|</b> as a delimiter.</li>⏎
<li>Specifies each point using the WKT notation⏎
</ul>⏎
⏎
<h4><a name="python">Using delimited text layers in Python</a></h4>⏎
<p>Delimited text data sources can be creating from Python in a similar
way to other vector layers.⏎
The pattern is:⏎
</p>⏎
<pre>⏎
from PyQt4.QtCore import QUrl, QString⏎
from qgis.core import QgsVectorLayer, QgsMapLayerRegistry⏎
⏎
# Define the data source⏎
filename="test.csv"⏎
uri=QUrl.fromLocalFile(filename)⏎
uri.addQueryItem("type","csv")⏎
uri.addQueryItem("delimiter","|")⏎
uri.addQueryItem("wktField","wkt")⏎
# ... other delimited text parameters⏎
layer=QgsVectorLayer(QString(uri.toEncoded()),"Test CSV
layer","delimitedtext")⏎
# Add the layer to the map⏎
if layer.isValid():⏎
QgsMapLayerRegistry.instance().addMapLayer( layer )⏎
</pre>⏎
<p>This could be used to load the second example file above.</p>⏎
<p>The configuration of the delimited text layer is defined by adding
query items to the uri.⏎
The following options can be added⏎
</p>⏎
<ul>⏎
<li><tt>encoding=..</tt> defines the file encoding. The default is
"UTF-8"</li>⏎
<li><tt>type=(csv|regexp|whitespace)</tt> defines the delimiter type.
Valid values are csv, ⏎
regexp, and whitespace (which is just a special case of regexp). The
default is csv.</li>⏎
<li><tt>delimiter=...</tt> defines the delimiters that will be used for
csv formatted files, ⏎
or the regular expression for regexp formatted files. The default is ,
for CSV files. There is⏎
no default for regexp files.</li>⏎
<li><tt>quote=..</tt> (for csv files) defines the characters used to
quote fields. The default is "</li>⏎
<li><tt>escape=..</tt> (for csv files) defines the characters used to
escape the special meaning of the next character. The default is
"</li>⏎
<li><tt>skipLines=#</tt> defines the number of lines to discard from the
beginning of the file. The default is 0.</li>⏎
<li><tt>useHeader=(yes|no)</tt> defines whether the first data record
contains the names of the data fields. The default is yes.</li>⏎
<li><tt>trimFields=(yes|no)</tt> defines whether leading and trailing
whitespace is to be removed from unquoted fields. The default is no.</li>⏎
<li><tt>maxFields=#</tt> defines the maximum number of fields that will
be loaded from the file. ⏎
Additional fields in each record will be discarded. The default is 0 -
include all fields.⏎
(This option is not available from the delimited text layer dialog
box).</li>⏎
<li><tt>skipEmptyFields=(yes|no)</tt> defines whether empty unquoted
fields will be discarded (applied after trimFields). The default is
no.</li>⏎
<li><tt>decimalPoint=.</tt> specifies an alternative character that may
be used as a decimal point in numeric fields. The default is a point
(full stop) character.</li>⏎
<li><tt>wktField=fieldname</tt> specifies the name or number (starting
at 1) of the field containing a well known text geometry definition</li>⏎
<li><tt>xField=fieldname</tt> specifies the name or number (starting at
1) of the field the X coordinate (only applies if wktField is not
defined)</li>⏎
<li><tt>yField=fieldname</tt> specifies the name or number (starting at
1) of the field the Y coordinate (only applies if wktField is not
defined)</li>⏎
<li><tt>geomType=(auto|point|line|polygon|none)</tt> specifies type of
geometry for wkt fields, or none to load the file as an attribute-only
table. The default is auto.</li>⏎
<li><tt>subset=expression</tt> specifies an expression used to identify
a subset of the records that will be ⏎
used.</li>⏎
<li><tt>crs=...</tt> specifies the coordinate system to use for the
vector layer, in a format accepted by
QgsCoordinateReferenceSystem.createFromString (for example
"EPSG:4167"). If this is not ⏎
specified then a dialog box may request this information from the user⏎
when the layer is loaded (depending on QGIS CRS settings).</li>⏎
<li><tt>subsetIndex=(yes|no)</tt> specifies whether the provider should
build an index to define subset during the initial file scan. The index
will apply both for explicitly defined subsets, and for the implicit
subset of features for which the geometry definition is valid. By
default the subset index is built if it is applicable.</li>⏎
<li><tt>spatialIndex=(yes|no)</tt> specifies whether the provider should
build a spatial index during the initial file scan. By default the
spatial index is not built. </li>⏎
<li><tt>watchFile=(yes|no)</tt> specifies whether the provider should
use a file system watcher to monitor for changes to the file.</li>⏎
<li><tt>quiet=(yes|no)</tt> specifies whether errors encountered loading
the layer are presented in a dialog box (they will be written to the
QGIS log in any case). The default is no. This option is not available
from the GUI</li>⏎
</ul>⏎
⏎
⏎
More information about the Qgis-tr
mailing list