EcoMetriQReference Book

3. Data input (Data Input)

Tab: 📂 Data Input · Code: ui/main_dialog.py:200-383 (interface), modules/spatial_analysis.py:196-438 SpeciesCSVParser (reading and summary)

3.1 What this tab does

The Data Input tab accepts two kinds of input:

  1. CSV file: each row is a species record (species name + coordinates; optionally count, site, date). The alpha, rarefaction, beta, gamma, spatial analysis and validation tabs use this file.
  2. Manual species table: a "species name + count" table without coordinates. It is used for alpha indices that do not require coordinates and for rarefaction.

When a CSV is loaded, the program reads the records, extracts counts per species, shows the first 500 rows in a preview table and writes a summary line. Later tabs use this summary (self.summary) and the record list (self.records).

3.2 Screen layout

Figure 3.1. The Data Input tab, empty. At the top, the CSV format description, file path and coordinate system; in the middle, the preview; at the bottom, the sample CSV button and the manual entry table.
Figure 3.1. The Data Input tab, empty. At the top, the CSV format description, file path and coordinate system; in the middle, the preview; at the bottom, the sample CSV button and the manual entry table.
Name in the interface What it does Default Code
📂 Load CSV File group Path of the CSV file, coordinate system and load button - ui/main_dialog.py:203-240
Path box + Browse Selects the CSV file empty ui/main_dialog.py:218-223
Coordinate System of the CSV: Coordinate system of the X/Y columns in the CSV (QGIS projection selector; any CRS) EPSG:4326 - WGS 84 ui/main_dialog.py:224-233
📥 Load & Preview CSV Reads the file, transforms the coordinates to WGS84, previews and summarizes - ui/main_dialog.py:295-348
Data Preview Species, X (lon), Y (lat) columns of the first 500 records empty ui/main_dialog.py:349-356
Summary line Number of records, number of species, the five species with the most records; if rows were skipped, the numbers of skipped rows "No data loaded yet." ui/main_dialog.py:332-345
📄 Create Sample CSV Writes a small 15-row sample CSV - ui/main_dialog.py:358-383
✏️ Manual Species Entry Manual table of species names and counts (+ Add, - Remove) 8 bird species ui/main_dialog.py:259-286

3.3 CSV file format

The program reads the CSV with Python's standard csv.DictReader, as comma-separated and UTF-8 (with or without BOM) (modules/spatial_analysis.py:302-372). The first row contains the column names. Column names are matched ignoring case and leading/trailing spaces. The accepted names are, in order of priority (modules/spatial_analysis.py:206-211); if a file has two candidate columns for the same role, the name further to the left in the table wins:

Information Accepted column names (in order of priority) Required
Species name species, name, taxon, sp, tur, ad yes
X (longitude) x, lon, longitude, easting, east, boylam yes
Y (latitude) y, lat, latitude, northing, north, enlem yes
Count / abundance count, abundance, n, number, sayi, bolluk no
Site site, plot, location, station, alan, istasyon no (required for beta, gamma and site-based rarefaction)
Date date, year, time, tarih, yil, zaman no (read, not used in computations)

If one of the required columns is missing, the message "CSV is missing required columns: species name (species/name), X coordinate (x/lon), and Y coordinate (y/lat)." is shown together with the column names found in the file.

First rows of the sample data file:

Species,X,Y,site
Acantholimon acerosum,30.83357333,37.73549831,aksu_cayi
Acantholimon acerosum subsp. Acerosum,30.830445,37.73868833,aksu_cayi

The following rules apply when rows are read (modules/spatial_analysis.py:302-371):

Skipped rows are counted by reason and reported after loading in both the information box and the summary line (e.g. "skipped rows: 3 with unreadable or non-finite coordinates, 2 with zero or negative counts, 1 with non-integer counts"). When rows are skipped, the summary line is written in orange instead of green. The Processing algorithms write the same numbers to the processing log (Chapter 10).

CSV saved by Excel with a decimal-comma locale

Excel with a locale that uses a decimal comma (e.g. Turkish, German) separates fields with semicolons in its "CSV" option and uses a comma as the decimal separator (30,8335;37,7355). EcoMetriQ reads only comma-separated files that use a decimal point. If a semicolon-delimited file is loaded, the program recognizes it and rejects the file with the message "The file appears to be semicolon-delimited …" (modules/spatial_analysis.py:248-257). Save the file as "CSV UTF-8 (Comma delimited)", or convert the layer to CSV in QGIS with Export › Save Features As…. Check in the preview table that the coordinate columns use a decimal point. Tab-delimited files are also read. A file that is not UTF-8 (Excel's ANSI output on Turkish systems) is read as Windows-1254 and a note is given in the loading message; repeated spaces in species names are collapsed, and names that differ only in letter case are counted as different species but listed in the message.

3.4 Coordinate system

All spatial computations use the coordinates as WGS84 latitude-longitude (degrees) and convert them to their own metric projection (Chapter 8.2). Therefore, in the Coordinate System of the CSV: selector, choose the actual coordinate system of the X/Y columns in your file: when the file is loaded, all coordinates are transformed from this system to EPSG:4326 (ui/main_dialog.py:304-311). The selector is the standard QGIS projection selector; any CRS that QGIS recognizes can be selected, including UTM zones and TM and ITRF96 systems. The preview table shows the transformed coordinates (degrees).

If, after the transformation, any record has a longitude outside -180° to 180° or a latitude outside -90° to 90°, the program stops loading and gives the message "… records lie outside the longitude/latitude range after loading. Check that 'Coordinate System of the CSV' matches the X/Y columns of the file; the data were NOT loaded." (ui/main_dialog.py:312-320). This message usually indicates that a file with coordinates in meters was loaded while EPSG:4326 was selected. The program cannot check whether the selection really matches the X/Y columns: coordinates that stay within the degree range but are read with the wrong CRS do not raise an error, so after loading, check with a spatial analysis layer that the points lie in the expected region.

3.5 Records or individuals?

This is the most important distinction when interpreting EcoMetriQ results.

No count/abundance column was found: each record was treated as one individual.
Chao1, ACE, Good's coverage and rarefaction assume a random sample of individuals
from a closed assemblage and should not be interpreted as richness/coverage
estimates for occurrence records.

Why does this matter? Shannon, Simpson, Chao1, ACE, sample coverage and rarefaction assume that the sample consists of individuals drawn at random from a community. In point records, the number of times a species was recorded reflects not only the abundance of that species but also where and how often the observer looked. Therefore these measures, when computed from record counts, should be read as "descriptive measures based on record frequency". For example, Chao1 does not say "there are at least 992 species in the basin"; it says "this distribution of records points to an incomplete inventory". Measures based on presence/absence (richness, Jaccard, Sørensen, Baselga partitioning, Whittaker beta, EOO, AOO) are not affected by the abundance assumption, but they are affected by sampling effort and imperfect detection: an unrecorded species is counted as absent.

3.6 Why name cleaning matters

EcoMetriQ compares species names as they are. A spelling difference, an extra space or a subspecies name creates a new "species". The same computations on the raw and the cleaned versions of the sample data are shown below (the cleaned file is not distributed with this book). In the cleaning, 20 non-vascular taxa (19 fungi, Testudo graeca) were removed, 26 spelling errors were corrected, subspecies and varieties were merged at species level, and 50 duplicate records for the same species-point-site were reduced to one.

Measure Raw sample data Cleaned data Difference
Records 1,818 1,732 -86
Species (S) 694 613 -81
Shannon H' 6.1913 6.0776 -0.114
Chao1 (classic) 992.1 836.5 -155.6
Multi-site \beta_{SOR} 0.8181 0.7932 -0.025
Multi-site \beta_{SIM} 0.7339 0.7035 -0.030
Species unique to one sub-watershed 461 376 -85
EOO (km²) 23,340 23,340 0
AOO (km², 2 km) 3,580 3,508 -72

Spelling errors inflate the number of singletons (f_1) and the number of "species found in only one basin"; this in turn raises Chao1 and turnover. EOO did not change, because the extreme points that define the convex hull were not affected by the cleaning. Errors such as a tortoise record entering a plant list cannot be caught by the program.

Checklist before loading

  • The file is comma-separated, and the decimal separator is a point.
  • The coordinate system is known and correctly chosen in the selector; longitude (east) in the X column, latitude (north) in the Y column.
  • Species names are in a single form: the same taxon has a single spelling, and your subspecies decision is consistent.
  • Records that do not belong to the target group (e.g. fungi in a plant study) have been removed.
  • There are no absence rows or rows with zero counts (if there are, they are skipped and reported; compare their number with what you expect).
  • If sites are to be compared, the site column is filled and site names have a single spelling.

3.7 Running

  1. Select the CSV with Browse (or paste the path).
  2. Press the 📥 Load & Preview CSV button.
  3. The information box "1818 records loaded. 694 distinct species." appears; the summary line turns green.
Figure 3.2. After the sample data are loaded. The preview table shows the first 500 records; the summary line shows the number of records and species and the five species with the most records.
Figure 3.2. After the sample data are loaded. The preview table shows the first 500 records; the summary line shows the number of records and species and the five species with the most records.

For the sample data, the summary line is:

✓ 1818 coordinates | 694 species | Point counts: Cistus creticus:22, Salvia tomentosa:22,
  Arbutus andrachne:21, Phillyrea latifolia:19, Myrtus communis:18 ...

"Point counts" is the number of rows of the species in the file (the sum of abundances if there is a count column). The first thing to check here is whether the number of species matches what you expect: if it is higher than expected, there are most likely spelling differences.

3.8 Manual species table

The ✏️ Manual Species Entry (Coordinate-free Alpha Index) table has two columns: Species and Count. By default it is filled with eight bird species (e.g. Parus major 45, Passer domesticus 67; ui/main_dialog.py:274-281). + Add adds an empty row, - Remove deletes the selected row.

The table can be selected as a source in the following places:

Rows whose count is not a positive integer are left out and listed in a message (ui/main_dialog.py:426-457). If the same species is written in two rows, their counts are summed, and the message says so. If "CSV" is selected as the source but no file is loaded, the program does not fall back to the table; it warns and stops.

The default source of the alpha tab is the manual table

After a CSV is loaded, the Source box in the Alpha Indices tab still shows Manual Table (Data Input tab). To get the indices of the CSV, set the source to CSV (loaded from Data Input); otherwise you will see the results for the eight bird species.

3.9 Creating a sample CSV

The 📄 Create Sample CSV button writes a 15-row file to the location you choose: columns species,x,y, nine tree and shrub species at coordinates near Isparta (30.54° E; 37.76° N) (ui/main_dialog.py:358-383). It is useful for seeing the file format and trying out the plugin; since it has no site column, it cannot be used in the beta and gamma tabs.

3.10 Expert questions

Q1. What happens if there are two records of the same species at the same point? Both are counted; the abundance of the species becomes 2. The program does not remove duplicate records. If you are sure that the same observation was entered twice, delete the duplicate before loading the file. This matters for Chao1 and sample coverage: a duplicate record turns a singleton (a species seen once) into a doubleton.

Q2. Which column takes which role; what if a file has both x and lon? For each role, the program takes the first name found in the file in the order of priority given in §3.3 (modules/spatial_analysis.py:374-378): if both x and lon are present, x is used and lon is ignored. To avoid confusion, it is still good practice not to leave more than one candidate column for the same role.

Q3. Does the date column enter the computations? No. It is read and written as an attribute to the points layer, but it is not used in any computation.

Q4. Which file do the beta and gamma tabs read? These two tabs read the file at the path in Data Input again (with their own readers), not the loaded record list (ui/main_dialog.py:966-1088, 1285-1343). If you change the file after loading it, beta and gamma use the new version, while the alpha and spatial tabs use the old version. If you have changed the file, load it again.

Q5. How many records and species can be handled? No limit is set. Alpha, beta and gamma computations are instantaneous for tens of thousands of records. The rarefaction variance is not computed for S>400 species (Chapter 5). Gi* and the density-based Gi* option grow with the square of the number of points (Chapter 8).