brycefrank / pyfor

Tools for analyzing aerial point clouds of forest data.
MIT License
93 stars 19 forks source link

Error in median pit filtering for canopy height model. #16

Closed bw4sz closed 6 years ago

bw4sz commented 6 years ago

Sorry to issue blitz.

same tile as #15

import pyfor
from shapely import geometry
from matplotlib import pyplot

def createPolygon(xmin,xmax,ymin,ymax):
    '''
    Convert a pandas row into a polygon bounding box
    ''' 

    p1 = geometry.Point(xmin,ymax)
    p2 = geometry.Point(xmax,ymax)
    p3 = geometry.Point(xmax,ymin)
    p4 = geometry.Point(xmin,ymin)

    pointList = [p1, p2, p3, p4, p1]

    poly = geometry.Polygon([[p.x, p.y] for p in pointList])

    return poly

# Grab a polygon
window_xmin=407690.2
window_xmax=407715.2
window_ymin=3291477.2
window_ymax=3291452.2

#Create shapely polygon
poly=createPolygon(window_xmin, window_xmax, window_ymax,window_ymin)

#Read lidar tile
pc=pyfor.cloud.Cloud("/Users/ben/Documents/DeepForest/data/NEON_D03_OSBS_DP1_407000_3291000_classified_point_cloud.laz")

#Filter
pc.filter(min = -5, max = 100, dim = "z")

#Clip to geographic extent
clipped=pc.clip(poly)

#Compute Canopy model
chm = clipped.chm(cell_size = 0.5, interp_method = "nearest")
chm.plot()

image

chm = clipped.chm(cell_size = 0.5, interp_method = "nearest", pit_filter = "median", kernel_size = 3)

chm.plot()

image

I could be wrong, but I don't think passing a 3X3 filter across the image could create this image. Some kind of artifact being created. Should I try pulling from a different branch?

bw4sz commented 6 years ago

bad normalization. my error. closed.