crsuggest::suggest_crs hangs on simple LINESTRING feature
I extracted this feature from OSM as GeoJSON
https://www.openstreetmap.org/way/1289170894
and saved it to file way_1289170894.geojson for this test.
{
"type": "Feature",
"id": "way/1289170894",
"properties": {
"highway": "service",
"service": "alley",
"id": "way/1289170894"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
-119.2543,
35.77777
],
[
-119.2543197,
35.7795115
]
]
}
}
Read it in a look at it
test <- sf::st_read("way_1289170894.geojson")
test
Simple feature collection with 1 feature and 3 fields
Geometry type: LINESTRING
Dimension: XY
Bounding box: xmin: -119.2543 ymin: 35.77777 xmax: -119.2543 ymax: 35.77951
Geodetic CRS: WGS 84
highway service id geometry
1 service alley way/1289170894 LINESTRING (-119.2543 35.77...
Now run the key code
crsuggest::suggest_crs(test)
This just hangs. I have not dug super deeply into why that is, but can do if it would be helpful.
I do note that the convex hull of two points is problematic, though this might not be the issue.
I am on a macbook:
platform aarch64-apple-darwin20
arch aarch64
os darwin20
system aarch64, darwin20
status
major 4
minor 4.0
year 2024
month 04
day 24
svn rev 86474
language R
version.string R version 4.4.0 (2024-04-24)
nickname Puppy Cup
and also on a linux machine
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 4
minor 2.3
year 2023
month 03
day 15
svn rev 83980
language R
version.string R version 4.2.3 (2023-03-15)
nickname Shortstop Beagle
It hangs on both.
Thanks.
OK, replying to my own comment here.
It seems yes, this is possibly related to the fact that the input is a simple one segment linestring. The convex hull is obviously thin, which means that the negative buffering is a problem.
This loop is what hangs
while (rows == 0) {
new_buf <- st_buffer(sf_poly, bufdist)
crs_sub <- crs_type[new_buf, ]
rows <- nrow(crs_sub)
bufdist <- bufdist/2
}