sf
                                
                                 sf copied to clipboard
                                
                                    sf copied to clipboard
                            
                            
                            
                        Avoid use of GDAL in st_dimension
st_dimension(x) copies its input into an OGR geometry type. In a test of 100,000 point-in-polygon intersections, this takes ~25% of the runtime:

It seems like the topological dimension could be more easily determined from class(x).