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

Delineate Crowns #438

Closed
Saadi4469 opened this issue Jun 7, 2021 · 4 comments
Closed

Delineate Crowns #438

Saadi4469 opened this issue Jun 7, 2021 · 4 comments
Assignees
Labels
Bug A bug in the package Enhancement Not actually a bug but a possible improvement

Comments

@Saadi4469
Copy link

Saadi4469 commented Jun 7, 2021

Good day Jean,

Thank you for responding to that question on gis.stackexchange. I tried sending you this via email, but your email server keeps on rejecting my email both from Outlook and Gmail. The code that I used is below:

# Bring in the ALS file
TP1 = readLAS("~/Sample.las")

# Then, normalize the data so that ground points are centered on 0.
TP1_DTM = grid_terrain(TP1.pmf, algorithm = knnidw(k = 8, p = 2))
TP1.normalized = normalize_height(TP1.pmf, TP1_DTM)

# Create a filter to remove points above 95th percentile of height
filter_noise = function(las, sensitivity)
{
  p99 = grid_metrics(las, ~quantile(Z, probs = 0.99), 10)
  las = merge_spatial(las, p99, "p99")
  las = filter_poi(las, Z < p99*sensitivity)
  las$p99 <- NULL
  return(las)
}

TP1_denoised = filter_noise(TP1.normalized, sensitivity = 1.2)

# Generate the Canopy Height Model (CHM)
TP1.CHM = grid_canopy(TP1_denoised, 0.5, pitfree(c(0,2,5,10,20), c(3,1.5), subcircle = 0.2))
plot_dtm3d(TP1.CHM)

# Here a single 5x5 moving window is used to apply a median filter:
win = matrix(1,5,5)
TP1.chm_s = focal(TP1.CHM, w = win, fun = median)

TP1.wtrshd = watershed(TP1.chm_s, th = 20)
TP1.ITD.wtrshd  = segment_trees(TP1_denoised, TP1.wtrshd)

# Hulls from the Watershed method
TP1_hulls_wtrshd  = delineate_crowns(TP1.ITD.wtrshd, func = .stdmetrics)

Error in sp::SpatialPolygons(hulls[["poly"]]) : is.list(Srl) is not TRUE

Kind Regards,

@Jean-Romain Jean-Romain self-assigned this Jun 7, 2021
@Jean-Romain Jean-Romain added the Enhancement Not actually a bug but a possible improvement label Jun 7, 2021
@Jean-Romain
Copy link
Collaborator

Jean-Romain commented Jun 7, 2021

I answered on gis.stackexchange. I keep the issue opened to improve the code and handle this edge case with a more informative error. Btw you should not be that scared of sharing a microscopic 1000 m² of data containing shurbs lost in the desert. Anyway I deleted the link after I downloaded the file in your message. because github is also a public place. You can remove the file from were it is strored. Thank you for reporting the issue.

@Saadi4469
Copy link
Author

Can I remove the file link though?

@Jean-Romain
Copy link
Collaborator

Yes

@Jean-Romain Jean-Romain added the Bug A bug in the package label Jun 8, 2021
@Jean-Romain
Copy link
Collaborator

segment_trees() now prints a message and delineate_crowns() throws a warning and returns NULL. No longer failure. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in the package Enhancement Not actually a bug but a possible improvement
Projects
None yet
Development

No branches or pull requests

2 participants