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

revert forsys changes #2023

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/planscape/rscripts/forsys.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ library("tidyr")
library("friendlyeval")
library("uuid")

# do not use spherical geometries
sf_use_s2(FALSE)
readRenviron("../../.env")

options <- list(
Expand Down Expand Up @@ -262,7 +264,7 @@ get_restrictions <- function(connection, scenario_id, restrictions) {
ps.id = {scenario_id}
)
SELECT
ST_Union(ST_Buffer(rr.geometry, 0)) as \"geometry\"
ST_Transform(ST_Union(ST_Buffer(rr.geometry, 0)), 5070) as \"geometry\"
FROM restrictions_restriction rr, plan_scenario
WHERE
type IN ({restrictions*}) AND
Expand All @@ -274,8 +276,9 @@ get_restrictions <- function(connection, scenario_id, restrictions) {
layer = NULL,
query = restrictions_statement,
geometry_column = "geometry",
crs = 4269
crs = st_crs(5070)
)
log_info(paste("restriction data using", st_crs(restriction_data)))
return(restriction_data)
}

Expand All @@ -293,7 +296,7 @@ get_stands <- function(connection, scenario_id, stand_size, restrictions) {
)
SELECT
ss.id AS \"stand_id\",
ss.geometry AS \"geometry\",
ST_Transform(ss.geometry, 5070) AS \"geometry\",
ST_Area(ss.geometry::geography, TRUE) / 4047 as \"area_acres\"
FROM stands_stand ss, plan_scenario
WHERE
Expand All @@ -307,9 +310,11 @@ get_stands <- function(connection, scenario_id, stand_size, restrictions) {
layer = NULL,
query = query,
geometry_column = "geometry",
crs = 4269
crs = st_crs(5070)
)

log_info(paste("stand data using", st_crs(restriction_data)))

if (length(restrictions) > 0) {
log_info("Restrictions found!")
restriction_data <- get_restrictions(connection, scenario_id, restrictions)
Expand Down
Loading