Skip to content

Commit

Permalink
re-org
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbeaudette committed Jan 31, 2024
1 parent eacb579 commit fc053b0
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 9 deletions.
Binary file added SSA-complexity/FD-summary-FY2024-full.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion SSA-complexity/MU-entropy.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ epH <- Vectorize(equal.prob.H)

## how to incorporate area? H/area, by delineation?

# created on SoilWeb server
## created on SoilWeb server
# SSA/
x <- read.csv('entropy-by-mukey.csv.gz')
y <- read.csv('entropy-by-mukey-statsgo.csv.gz')

Expand Down
Binary file removed SSA-complexity/entropy-by-mukey-statsgo.csv.gz
Binary file not shown.
Binary file removed SSA-complexity/entropy-by-mukey.csv.gz
Binary file not shown.
15 changes: 8 additions & 7 deletions SSA-complexity/entropy-by-mukey.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
-- Compute Shanon Entropy
-- Compute Shanon Entropy via component percentages by map unit KEY
--
--

-- Data are saved to csv.gz for now, no permanent place in SoilWeb


--
Expand Down Expand Up @@ -113,15 +117,12 @@ GROUP BY areasymbol, projectscale, invesintens, mukind, mukey ;
\copy h TO 'entropy-by-mukey.csv' CSV HEADER
\copy hs TO 'entropy-by-mukey-statsgo.csv' CSV HEADER

--
-- compress
--

-- gzip -f entropy-by-mukey.csv
-- gzip -f entropy-by-mukey-statsgo.csv
-- TODO possibly load into permanent metadata tables


--
-- checking
-- checking: ok
--


Expand Down
Binary file added SSA-complexity/fractal-dimension-samples.csv.gz
Binary file not shown.
Binary file removed SSA-complexity/fractal-dimension-test.csv.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion SSA-complexity/notes.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ORDER BY m.vertex_count, m.mukey ;



x <- read.csv('fractal-dimension-test.csv.gz')
x <- read.csv('fractal-dimension-samples.csv.gz')
head(x)
nrow(x)

Expand Down
108 changes: 108 additions & 0 deletions SSA-complexity/polygon-complexity-analysis-full.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
library(data.table)
library(lattice)
library(latticeExtra)
library(hexbin)
library(tactile)

x <- fread(file = 'mu-polygon-complexity.txt.gz', header = FALSE, showProgress = TRUE, stringsAsFactors = FALSE, verbose = TRUE)

head(x)
names(x) <- c('areasymbol', 'ogc_fid', 'mukey', 'fd', "log_sq_m", "n_pts", "invesintens", "coryear", "projectscale")


## TODO: develop better filters for figures
## -> what are the extreme values all about?
## -> very small polygons, very large FD, negative FD !
## -> consider filtering on vertex count
summary(x)


## flag wacky polygons

#


## save links back to source data


## export as points / polygons / links




.fy <- '2024'



# figure elements and style
.title <- sprintf('FY%s SSURGO', .fy)
.cp <- hcl.colors(100, 'zissou1')
.cpf <- colorRampPalette(.cp)

## TODO: convert area to acres

options(scipen = 20)

p.1 <- hexbinplot(
fd ~ n_pts,
data = x,
xbins = 50,
main = .title,
xlab = 'Polygon Vertex Count',
ylab = 'Fractal Dimension',
trans = log,
inv = exp,
asp = 1,
colramp = .cpf,
type = 'g',
subset = log_sq_m > 0 & fd < 2,
scales = list(x = list(log = 10)),
xscale.components = xscale.components.log10ticks,
colorkey = FALSE,
par.settings = tactile.theme()
)

p.2 <- hexbinplot(
fd ~ log_sq_m,
data = x,
xbins = 50,
main = .title,
xlab = 'Log10 Polygon Area (sq.m)',
ylab = 'Fractal Dimension',
trans = log,
inv = exp,
asp = 1,
colramp = .cpf,
type = 'g',
subset = log_sq_m > 0 & fd < 2,
colorkey = FALSE,
par.settings = tactile.theme()
)

p.3 <- hexbinplot(
log_sq_m ~ n_pts,
data = x,
xbins = 50,
main = .title,
xlab = 'Polygon Vertex Count',
ylab = 'Log10 Polygon Area (sq.m)',
trans = log,
inv = exp,
asp = 1,
colramp = .cpf,
type = 'g',
subset = log_sq_m > 0 & fd < 2,
scales = list(x = list(log = 10)),
xscale.components = xscale.components.log10ticks,
colorkey = FALSE,
par.settings = tactile.theme()
)

.file <- sprintf("FD-summary-FY%s-full.png", .fy)
ragg::agg_png(file = .file, width = 1250, height = 500, scaling = 1.5)

print(p.3, split = c(1, 1, 3, 1), more = TRUE)
print(p.1, split = c(2, 1, 3, 1), more = TRUE)
print(p.2, split = c(3, 1, 3, 1), more = FALSE)

dev.off()

0 comments on commit fc053b0

Please sign in to comment.