Skip to content

[Feature]: x, y and wkt reach the delimited and workbook members of a zip (layer.addData / layer.addUrl) #3062

Done

Description

@elpidioassinaturas

Before you start

What problem does this solve?

#2984 made a zip read its workbook members, each one's first sheet, as when the workbook is added by itself. The zip reader passes those members, and its delimited ones, only the crs (read_zip_layers_budget builds CsvOptions { crs, ..Default::default() }). The x, y, wkt and delimiter given to layer.addData or layer.addUrl never reach them. A member whose coordinate columns the name detection doesn't recognise opens as a table with no geometry, and there's no way to say which columns they are.

The case behind this. The Geological Survey of Brazil publishes HYBRAS, the hydrophysical database of Brazilian soils (Ottoni et al., 2018, Vadose Zone Journal; 445 profiles, 1,075 horizons with water retention, van Genuchten parameters and Ksat). It comes only as a zip of four workbooks in its repository: https://rigeo.sgb.gov.br/bitstream/doc/19021/11/hybras_v1_2020.zip (1.65 MB, no login).

  • The flat table is HYBRAS_excel_arquivoShape_modif18_7_2019.xlsx. Its first sheet, ALL, has one row per horizon, with the coordinates in LongitudeOR and LatitudeOR (decimal degrees, WGS 84).
  • The workbook added by itself: layer.addData with "x": "LongitudeOR", "y": "LatitudeOR", "layer": "ALL" gives 1,075 points, in the 0.5.0 and 0.8.0 command line.
  • The same workbook without x and y: it opens as a table. The detection doesn't take LatitudeOR for a latitude, which is fair: the OR suffix isn't a bracketed note.
  • The zip, by path or by address: 0.8.0 refuses it ("no supported layers or tables in the archive could be read: … (unsupported file type: xlsx)"). On main since fix(data): a zip and pasted text read workbooks, GeoRSS, LandXML and every layer of a KML or GPX file #2984, it reads the members, but as tables only, because the x and y given are dropped.

A plugin (BrasilData) wants to add the profiles in the user's area straight from that address, without redistributing a copy of the data. Its licence isn't declared, so copying it isn't an option.

Proposed solution

The zip reader passes the caller's x, y, wkt and delimiter to its delimited and workbook members, as it passes crs today.

  • Which members: a member that has the columns named gets them, and its rows become points (or WKT geometry), as when the member is added by itself.
  • Which members are left as they are: a member that lacks one of the columns is read as now, with detection, and the notice names it: "HYBRAS_COMPLETE_V1.xlsx: no column LongitudeOR; read as a table". Shapefiles, KML and other members ignore the options, as their own readers do.
  • The delimiter applies only to delimited members.
  • Where it reaches: layer.addData, layer.addUrl, layer.addDownload (the URL's options already travel with the download), the command line, Python and the browser's bytes route. All of them read a zip with read_zip, so the change is in one place.
    • read_zip_in / read_zip_layers take CsvOptions (or the columns beside crs) instead of crs alone.
  • Never silent: the notice counts the members that took the columns and names those that didn't have them.
  • layer keeps its meaning: one layer of the zip, by name ("layer": "HYBRAS_excel_arquivoShape_modif18_7_2019"). With it, only that member becomes a layer.

Choices in this issue:

  • Apply the columns to every member that has them, rather than require layer. A zip of several CSVs with the same columns (a common way to publish data by year or region) then gives every one as points.
  • Don't widen the name detection to LatitudeOR and the like. Guessing suffixes risks taking a wrong column; explicit x and y are safer and already the documented way.
  • Leave the sheet choice inside a member for later. It would need layer to name a member and a sheet together, for example "member.xlsx/Sheet". The first sheet covers this case and keeps fix(data): a zip and pasted text read workbooks, GeoRSS, LandXML and every layer of a KML or GPX file #2984's rule.

Crates: data (read_zip* take the column options and pass them to read_delimited_bytes_budget and sheets::read) and engine (layer.addData, layer.addUrl and layer.addDownload pass them through). No new dependency, command or parameter.

Testing:

  • In data: a zip built in the test with two CSVs and one XLSX, all with lon_x/lat_y columns that detection doesn't recognise, plus a CSV that lacks them.
    • With x and y, the three members with the columns become points, and the fourth is a table with its notice.
    • Without them, nothing changes from main.
    • With wkt, a member's WKT column becomes geometry.
    • With delimiter, a ; member is read right.
  • In engine: layer.addData of that zip, and layer.addUrl against a local server.
  • By hand: the HYBRAS zip by its address gives 1,075 points.

Estimated scope

Small: threading options that already exist through one reader.

Alternatives considered

  • Run XY Table To Point on the table the zip gives. This works on main for a person, and a plugin could call the tool too. But it takes a second step and a second layer for what layer.addData already does for a file by itself, and the same zip read by path and inside a zip would still differ.
  • Detect suffixed names (LatitudeOR, lat_y). See the choices: explicit columns are safer.
  • The plugin redistributes a CSV. The data's licence isn't declared, so that isn't an option here.

Activity

  1. choupeanut commented on Nov 27, 2026

    @choupeanut
    Contributor

    I'd like to take this one: I'll route every zip through the zip reader with the x, y, wkt and delimiter options (today they only reach it when a crs is also given, and the member options are built from crs alone), and say so for a member that lacks a named column. PR coming shortly.

  2. elpidioassinaturas commented on Nov 28, 2026

    @elpidioassinaturas
    ContributorAuthor

    Thanks @choupeanut for taking this on and for #3167, and thanks @Mavrick-F for the merge. With the x, y, wkt and delimiter options now reaching a zip's delimited and workbook members, the zipped tables I had in mind load as point and WKT layers directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions