Skip to content

ST_Transform return empty geometry when PROJ coords are Inf #2531

Open
@latot

Description

@latot

Describe the bug
Hi, by accident someone wrote a weird point, using a real number very big, the issue is that the output with ST_Transform was a empty geometry...

An empty geometry is a valid geometry, with a clear geometry interpretation, so we are moving from a weird point to a completely different object.

I tested this example on PROJ and GEOS using python.

PROJ: returned coords (inf, inf)
GEOS: panic! stop and reports an error, also shows PROJ returned inf

Other one tested on GDAL, and it returns NULL.

Stop the app, NA, NULL any of this values would be fine, but a empty geometry really breaks the logic and introduces bugs on the workflows.

Thx!

To Reproduce

p <- sf::st_sfc(sf::st_point(c(1e+300, 1e+300)), crs = 4326)
sf::st_transform(p, 32719)
Geometry set for 1 feature  (with 1 geometry empty)
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: NA ymin: NA xmax: NA ymax: NA
Projected CRS: WGS 84 / UTM zone 19S
POINT EMPTY

Additional context
Add any other context about the problem here.

> sessionInfo() R version 4.4.3 (2025-02-28) Platform: x86_64-pc-linux-gnu Running under: Gentoo Linux

Matrix products: default
BLAS: /usr/lib64/libblas.so.3.12.0
LAPACK: /usr/lib64/liblapack.so.3.12.0

locale:
[1] LC_CTYPE=es_CL.utf8 LC_NUMERIC=C
[3] LC_TIME=es_CL.utf8 LC_COLLATE=es_CL.utf8
[5] LC_MONETARY=es_CL.utf8 LC_MESSAGES=es_CL.utf8
[7] LC_PAPER=es_CL.utf8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_CL.utf8 LC_IDENTIFICATION=C

time zone: Chile/Continental
tzcode source: system (glibc)

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] compiler_4.4.3 magrittr_2.0.3 class_7.3-23 tools_4.4.3
[5] DBI_1.2.3 units_0.8-7 proxy_0.4-27 Rcpp_1.0.14
[9] KernSmooth_2.23-26 grid_4.4.3 e1071_1.7-16 classInt_0.4-11
[13] sf_1.0-21

sf::sf_extSoftVersion()
GEOS GDAL proj.4 GDAL_with_GEOS USE_PROJ_H
"3.13.0" "3.9.3" "9.4.1" "true" "true"
PROJ
"9.4.1"

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