brycefrank / pyfor

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

Update axis labels on plot of cropped cloud. #15

Closed bw4sz closed 6 years ago

bw4sz commented 6 years ago

I think the plot function needs to re-calculate the extent of the cloud.las.points objects before plotting. If you crop and then plot, the same extent is used?

Tile is here: https://github.com/weecology/TreeSegmentation/blob/master/data/training/NEON_D03_OSBS_DP1_407000_3291000_classified_point_cloud.laz

import pyfor
from shapely import geometry

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 some coords.
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_ymin, window_ymax)

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

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

#View result

image

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

clipped.plot()

image

Version

(pyfor_env) MacBook-Pro:pyfor ben$ git log
commit a893ddb23d9192ea4f4b49d32ef1583ed6446dbe (HEAD -> master, origin/master, origin/HEAD)
Author: brycefrank <bryce.frank@oregonstate.edu>
Date:   Sat Jun 23 11:16:15 2018 -0700

    test data fix
brycefrank commented 6 years ago

Thanks, Ben. I am expecting to get to this next week along with a merge of 0.2.2 to master.

brycefrank commented 6 years ago

Fixed in 0.2.2, was referencing the laspy header class, which does not update until written to (for many reasons). Raster.plot now references the pyfor cloud header.

https://github.com/brycefrank/pyfor/blob/5e85ee2b68d8156484a8ea8a3305e9052fff2c4d/pyfor/rasterizer.py#L228