Skip to content
Prev 29442 / 29559 Next

Polygons changed when the geom column is converted to text and then back to sfc

try 'digits = 8' or higher in st_as_text e.g.

test_chr <- test |>
  dplyr::mutate(geom = sf::st_as_text(geom, EWKT = TRUE, digits = 8)) |>
  as.data.frame()

(or set with options("digits" = <8 or higher>))

Default value doesn't seem to be documented in sf, but the source shows it
calls out to lwgeom::st_astext which defaults to whatever options("digits")
value is.

HTH
On Fri, Sep 27, 2024 at 6:23?PM Lo?c Val?ry <lvalery at outlook.fr> wrote:

            

  
    
Message-ID: <CAAcGz9-OHyCEHme7OdoUS1sHOwxSPKLAFHt5rqDJzA63oxq+4A@mail.gmail.com>
In-Reply-To: <PA4PR02MB8099930A4A1E72F0A8AF8FB6D06B2@PA4PR02MB8099.eurprd02.prod.outlook.com>