Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options for processing speed... #5

Open
bevingtona opened this issue Dec 15, 2023 · 1 comment
Open

Add options for processing speed... #5

bevingtona opened this issue Dec 15, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@bevingtona
Copy link
Collaborator

Simplify polygons?
Display as points?

@bevingtona bevingtona self-assigned this Dec 15, 2023
@bevingtona bevingtona added the enhancement New feature or request label Jan 18, 2024
@bevingtona
Copy link
Collaborator Author

Use ST_Subdivide in query ? Looks like it can speed things up substantially... like 300%

library(microbenchmark)
library(sf)

qq1 <- paste0("WITH subdivided_my_wkt AS (SELECT ST_Subdivide(ST_GeomFromText('", new_ws2_wkt, "', 3005), 100) AS geom),
             clipped_polys AS (
                 SELECT w.*, 
                        ST_Intersection(w.geom, s.geom) AS clipped_geom
                 FROM fwa_wetlands w 
                 CROSS JOIN subdivided_my_wkt s
                 WHERE ST_Intersects(w.geom, s.geom))
             SELECT *, 
             ST_Area(clipped_geom) AS clipped_area_m2
             FROM clipped_polys")


qq2 <- paste0("SELECT w.*, ST_Intersection(w.geom, ST_GeomFromText('", new_ws2_wkt, "', 3005)) AS clipped_geom
               FROM fwa_wetlands w 
               WHERE ST_Intersects(w.geom, ST_GeomFromText('", new_ws2_wkt, "', 3005))")

microbenchmark(st_read(conn, query = qq1),st_read(conn, query = qq2), times = 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant