bi0m3trics / spanner

Utilities to support landscape-, forest-, and tree-related data collection, manipulation, analysis, modelling, and visualization.
GNU General Public License v3.0
24 stars 8 forks source link

The file doesn't seem to exist on get_raster_eigen_treelocs 7/14 step #5

Closed cingularities closed 1 year ago

cingularities commented 1 year ago

The file does exist but I am running into an error.

MBA_myTreeLocs = spanner::get_raster_eigen_treelocs(las = MBA_AGL_clean, res = 0.05, pt_spacing = 0.0254, dens_threshold = 0.2, neigh_sizes=c(0.333, 0.166, 0.5), eigen_threshold = 0.5, grid_slice_min = 0.6666, grid_slice_max = 2.0, minimum_polygon_area = 0.025, cylinder_fit_type = "ransac", output_location = "//snow/projects/Babst_TLidar_Tree_Rings/", max_dia=0.5, SDvert = 0.25)

Gridding verticality... (7/14)

Error: Cannot open "//snow/projects/Babst_TLidar_Tree_Rings/temp_vertical_0.6666-2_0.5threshold_res-0.05.shp"; The file doesn't seem to exist. In addition: Warning message: [writeVector] nothing to write

bi0m3trics commented 1 year ago

Hmmm... with a reproducible example, I'll have to just start troubleshooting somewhere. Does your code work with any of the provided las datasets accessed via getExampleData()?

cingularities commented 1 year ago

I can't seem to get the data either.

Hmmm... with a reproducible example, I'll have to just start troubleshooting somewhere. Does your code work with any of the provided las datasets accessed via getExampleData()?

I am getting an error when trying to load the data. Error in download.file(paste0("http://quantitativeecology.org/files/spanner/", : the 'internal' method for http:// URLs is defunct

Here is a sample dataset: https://drive.google.com/file/d/1qegUHoKWwK8KA9tl6r4dI6mawxwCtrjy/view?usp=sharing

Please let me know if you can access the data, I am hoping to get this running by end of day! thank you Cindy

bi0m3trics commented 1 year ago

Try grabbing one from here.. Same link, just not an automated download. http://quantitativeecology.org/files/spanner/

cingularities commented 1 year ago

Running it now and it worked with your laz file

bi0m3trics commented 1 year ago

Sent you a request to access the file you linked... had to use my gmail acct since my official nau email isn't linked to Google for faculty if you were once a student here. weird. I know.

cingularities commented 1 year ago

Shared, hopefully that worked. Here is the the script from reading the points to detect trees.

Separate trees from ground using lidr

MBA_xyz <- "mtb_A_utm.las"

MBA_points = readTLS(MBA_xyz)

MBA_points_classify = classify_ground(MBA_points, algorithm = csf(sloop_smooth = TRUE, class_threshold = 0.1, cloth_resolution = 0.5, rigidness = 2))

plot(points_classify, color = 'Classification')

Make a point cloud file for just ground points

MBA_ground_points = filter_poi(MBA_points_classify, Classification == 2) plot(MBA_ground_points)

Make a point cloud file for just non-ground (trees) points

MBA_tree_points = filter_poi(MBA_points_classify, Classification != 2)

plot(tree_points)

Create a grided digital terrain model from ground points

MBA_DTM = grid_terrain(MBA_ground_points, res = 0.5, algorithm = knnidw(k = 10, p = 2))

Calculate vertical distance of each tree point above the DTM. This creates a vegetation height point cloud.

MBA_normalized_height = lidR::normalize_height(las = MBA_points_classify, algorithm = MBA_DTM)

Remove points that are below 0

MBA_AGL_clean = filter_poi(MBA_normalized_height, Z >= 0.1, Z <= 40) plot(MBA_AGL_clean)

Export normalized point cloud to .las

Create canopy height model raster. I don't think this is totally necessary.

MBA_CHM = rasterize_canopy(MBA_normalized_height, res = 0.5)

#########################################################

The eigen method seems to find more tree occurrences than the hough method

####################XYZ DATA PREP##########

gc() set_lidr_threads(8) library(spanner) ############TreeLS and spanner#### las_check(MBA_normalized_height)

MBA_myTreeLocs = spanner::get_raster_eigen_treelocs(las = MBA_AGL_clean, res = 0.05, pt_spacing = 0.0254, dens_threshold = 0.2, neigh_sizes=c(0.333, 0.166, 0.5), eigen_threshold = 0.5, grid_slice_min = 0.6666, grid_slice_max = 2.0, minimum_polygon_area = 0.025, cylinder_fit_type = "ransac", output_location = "//snow/projects/Babst_TLidar_Tree_Rings/", max_dia=0.5, SDvert = 0.25)

cingularities commented 1 year ago

Sent you a request to access the file you linked... had to use my gmail acct since my official nau email isn't linked to Google for faculty if you were once a student here. weird. I know.

I ran it again without voxelizing the points and it seems to be working or you maybe updated it already! I will let you know if I run into issues. Thank you for the quick help