Skip to content

[Bug]: Calculate Geometry stores area_km2 and perimeter_km rounded to 2 decimals, so small polygons get 0.0 #513

Closed

Description

@guncanrun

Before you start

  • I searched the existing issues and did not find a duplicate.
  • This is a bug report, not a usage question.

What happened?

calculateGeometry writes area_km2 and perimeter_km as Double fields, but the values are rounded to two decimals, i.e. to 0.01 km² (1 ha) and 0.01 km (10 m). Any polygon smaller than about half a hectare gets area_km2 = 0.0. This affects many building footprints and small parcels.

The rounding is explicit in the code (tools.rs#L780-L795), also for length_km of lines:

*v = Value::Float((a / 1e4).round() / 100.0);

Steps to reproduce

  1. Save as squares.csv (three squares of 50 m, 100 m and 1 km in EPSG:25832):
side;wkt
50 m;POLYGON ((500000 5700000, 500050 5700000, 500050 5700050, 500000 5700050, 500000 5700000))
100 m;POLYGON ((500000 5700000, 500100 5700000, 500100 5700100, 500000 5700100, 500000 5700000))
1 km;POLYGON ((500000 5700000, 501000 5700000, 501000 5701000, 500000 5701000, 500000 5700000))
  1. Run:
rustgis-cli run \
  --cmd 'layer.addData={"path":"squares.csv","name":"squares","wkt":"wkt","crs":"EPSG:25832","delimiter":";"}' \
  --cmd 'gp.run={"tool":"calculateGeometry","params":{"input":"squares"}}' \
  --cmd 'share.exportLayer={"layer":"squares","path":"squares_out.csv"}'
  1. squares_out.csv contains:
side,area_km2,perimeter_km
50 m,0,0.2
100 m,0.01,0.4
1 km,1,3.99

Expected behavior

Store the computed values without explicit rounding; apply display formatting only in the UI. For the 50 m square, the unrounded value from RustGIS's formula is about 0.0024927 km². Alternatively m² / m fields, or a units or precision option.

How are you running RustGIS?

Command line (rustgis-cli)

Version

main @ a38ad43 (built from source, 2026-10-18). Also reproduced with the Python package rustgis 0.3.0 from PyPI. Also reproduced on Windows with RustGIS 0.3.0 via its MCP server (same values for an EPSG:4647 version of the file).

Operating system, browser and graphics

Ubuntu 24.04.5 LTS, x86_64

Activity

  1. added a commit that references this issue on Oct 18, 2026
    90b9f43
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