Skip to content

Commit

Permalink
revert forsys changes (#2023)
Browse files Browse the repository at this point in the history
  • Loading branch information
george-silva authored Dec 18, 2024
1 parent 022cf84 commit 7c1c8c6
Showing 1 changed file with 9 additions and 4 deletions.
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

0 comments on commit 7c1c8c6

Please sign in to comment.