Skip to content

Commit

Permalink
Adding test for KrausPfeifer1998, fixing .classify for same. Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
brycefrank committed Oct 12, 2019
1 parent 4963445 commit b6b6ef0
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 22 deletions.
21 changes: 5 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,9 @@ changelog_0.2.1.md
pyfortest/temp.*
/.idea
/.vs
/docs/api/setup.rst
/docs/api/pyfortest.test_pyfor.rst
/docs/api/pyfortest.test_collection.rst
/docs/api/pyfortest.rst
/docs/html/.doctrees/advanced
/docs/html/.doctrees/api
/docs/html/.doctrees/topics
/docs/html/.doctrees
/docs/html/api/pyfortest.html
/docs/html/api/pyfortest.test_collection.html
/docs/html/api/pyfortest.test_pyfor.html
/docs/html/api/setup.html
/docs/html/_sources
/docs/html/_static
/pyfortest/__pycache__
/__pycache__
/environment.yml~
/CHANGELOG.md~
/README.md~
/.environment.yml.un~
/.CHANGELOG.md.un~
/temp_tif.tif
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ memory optimized API for managing large collections of tiles.

## Release Status

Current Release: 0.3.5
Current Release: 0.3.6

Release Date: September 9, 2019
Release Date: []

Release Status: 0.3.5 is an adolescent LiDAR data processing package adequate for single tile processing and large acqusitions.
Release Status: 0.3.6 is an adolescent LiDAR data processing package adequate for single tile processing and large acqusitions.

## What Does pyfor Do?

Expand Down
128 changes: 128 additions & 0 deletions pyfor.pyproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{aa3e2147-3c18-4aa6-9a18-4dd5b1504264}</ProjectGuid>
<ProjectHome />
<StartupFile>setup.py</StartupFile>
<SearchPath />
<WorkingDirectory>.</WorkingDirectory>
<OutputPath>.</OutputPath>
<ProjectTypeGuids>{888888a0-9f3d-457c-b088-3a5042f75d52}</ProjectTypeGuids>
<LaunchProvider>Standard Python launcher</LaunchProvider>
<InterpreterId>CondaEnv|CondaEnv|pyfor_env</InterpreterId>
<TestFramework>unittest</TestFramework>
<UnitTestPattern>test_*.py</UnitTestPattern>
<UnitTestRootDirectory>pyfortest</UnitTestRootDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'" />
<PropertyGroup Condition="'$(Configuration)' == 'Release'" />
<PropertyGroup>
<VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup>
<Content Include="docs\html\advanced\groundfilter.html" />
<Content Include="docs\html\advanced\handlinglargeacquisitions.html" />
<Content Include="docs\html\advanced\index.html" />
<Content Include="docs\html\advanced\understandingcomponents.html" />
<Content Include="docs\html\api\index.html" />
<Content Include="docs\html\api\modules.html" />
<Content Include="docs\html\api\pyfor.clip.html" />
<Content Include="docs\html\api\pyfor.cloud.html" />
<Content Include="docs\html\api\pyfor.collection.html" />
<Content Include="docs\html\api\pyfor.gisexport.html" />
<Content Include="docs\html\api\pyfor.ground_filter.html" />
<Content Include="docs\html\api\pyfor.html" />
<Content Include="docs\html\api\pyfor.metrics.html" />
<Content Include="docs\html\api\pyfor.rasterizer.html" />
<Content Include="docs\html\api\pyfor.voxelizer.html" />
<Content Include="docs\html\genindex.html" />
<Content Include="docs\html\gettingstarted.html" />
<Content Include="docs\html\index.html" />
<Content Include="docs\html\installation.html" />
<Content Include="docs\html\introduction.html" />
<Content Include="docs\html\py-modindex.html" />
<Content Include="docs\html\search.html" />
<Content Include="docs\html\searchindex.js" />
<Content Include="docs\html\structure.html" />
<Content Include="docs\html\topics\canopyheightmodel.html" />
<Content Include="docs\html\topics\clipping.html" />
<Content Include="docs\html\topics\index.html" />
<Content Include="docs\html\topics\normalization.html" />
<Content Include="docs\html\_images\chm_final.png" />
<Content Include="docs\html\_images\simple_plot.png" />
<Content Include="docs\html\_sources\index.rst.txt" />
<Content Include="docs\html\_static\ajax-loader.gif" />
<Content Include="docs\html\_static\basic.css" />
<Content Include="docs\html\_static\comment-bright.png" />
<Content Include="docs\html\_static\comment-close.png" />
<Content Include="docs\html\_static\comment.png" />
<Content Include="docs\html\_static\css\badge_only.css" />
<Content Include="docs\html\_static\css\theme.css" />
<Content Include="docs\html\_static\doctools.js" />
<Content Include="docs\html\_static\documentation_options.js" />
<Content Include="docs\html\_static\down-pressed.png" />
<Content Include="docs\html\_static\down.png" />
<Content Include="docs\html\_static\file.png" />
<Content Include="docs\html\_static\fonts\fontawesome-webfont.svg" />
<Content Include="docs\html\_static\jquery-3.2.1.js" />
<Content Include="docs\html\_static\jquery.js" />
<Content Include="docs\html\_static\js\modernizr.min.js" />
<Content Include="docs\html\_static\js\theme.js" />
<Content Include="docs\html\_static\minus.png" />
<Content Include="docs\html\_static\plus.png" />
<Content Include="docs\html\_static\pygments.css" />
<Content Include="docs\html\_static\searchtools.js" />
<Content Include="docs\html\_static\underscore-1.3.1.js" />
<Content Include="docs\html\_static\underscore.js" />
<Content Include="docs\html\_static\up-pressed.png" />
<Content Include="docs\html\_static\up.png" />
<Content Include="docs\html\_static\websupport.js" />
<Content Include="docs\img\chm_final.png" />
<Content Include="docs\img\clipped.png" />
<Content Include="docs\img\simple_plot.png" />
<Content Include="docs\img\unclipped.png" />
<Content Include="docs\index.html" />
<Content Include="docs\logo.png" />
<Content Include="docs\norm_sample.png" />
<Content Include="docs\tile.png" />
<Content Include="License.txt" />
</ItemGroup>
<ItemGroup>
<Compile Include="docs\conf.py" />
<Compile Include="pyfortest\test_collection.py" />
<Compile Include="pyfortest\test_pyfor.py" />
<Compile Include="pyfortest\__init__.py" />
<Compile Include="pyfor\clip.py" />
<Compile Include="pyfor\cloud.py" />
<Compile Include="pyfor\collection.py" />
<Compile Include="pyfor\gisexport.py" />
<Compile Include="pyfor\ground_filter.py" />
<Compile Include="pyfor\metrics.py" />
<Compile Include="pyfor\rasterizer.py" />
<Compile Include="pyfor\voxelizer.py" />
<Compile Include="pyfor\__init__.py" />
<Compile Include="setup.py" />
</ItemGroup>
<ItemGroup>
<Folder Include="docs" />
<Folder Include="docs\html" />
<Folder Include="docs\html\advanced" />
<Folder Include="docs\html\api" />
<Folder Include="docs\html\topics" />
<Folder Include="docs\html\_images" />
<Folder Include="docs\html\_sources" />
<Folder Include="docs\html\_static" />
<Folder Include="docs\html\_static\css" />
<Folder Include="docs\html\_static\fonts" />
<Folder Include="docs\html\_static\js" />
<Folder Include="docs\img" />
<Folder Include="pyfor" />
<Folder Include="pyfortest" />
</ItemGroup>
<ItemGroup>
<InterpreterReference Include="CondaEnv|CondaEnv|pyfor_env" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
</Project>
13 changes: 13 additions & 0 deletions pyfor/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ def __init__(self, path):
self.normalized = None
self.crs = None

@classmethod
def from_pdal(cls, ins):
"""
Converts a PDAL `ins` argument from a PDAL `filters.python` into a `Cloud` object.
:param ins: The `ins` argument from PDAL.
"""

df = pd.DataFrame(ins)
df = df.rename(columns={"X": "x", "Y": "y", "Z":"z", "ReturnNumber": "return_num"})
cloud_data = pyfor.cloud.CloudData(df, header=None)
return cls(cloud_data)

def _get_las_points(self, las):
"""
Reads points into pandas dataframe.
Expand Down
11 changes: 8 additions & 3 deletions pyfor/ground_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ def _filter(self, grid):
"""
Runs the actual ground filter. Generally used as an internal function that is called by user functions
(.bem, .classify, .ground_points).
:param grid: A `pyfor.rasterizer.Grid` object.
:return: A `pandas.DataFrame` of filtered points.
"""
np.seterr(divide='ignore', invalid='ignore')

Expand Down Expand Up @@ -256,7 +259,9 @@ def bem(self, cloud, cell_size):
def classify(self, cloud, ground_int=2):
"""
Sets the classification of the original input cloud points to ground (default 2 as per las specification). This
performs the adjustment of the input `Cloud` object **in place**. Only implemented for `.las` files.
performs the adjustment of the input `Cloud` object **in place**. Only implemented for `.las` files. Additionally,
the original ground classification is preserved if it exists, so this will only add additional ground points for
already classified point clouds.
:param cloud: A cloud object.
:param ground_int: The integer to set classified points to, the default is 2 in the las specification for ground
Expand All @@ -265,8 +270,8 @@ def classify(self, cloud, ground_int=2):

if cloud.extension == '.las':
grid = cloud.grid(self.cell_size)
self._filter(grid)
grid.cloud.data.points["classification"][grid.cloud.data.points['v_i'] <= self.g + self.w] = ground_int
filtered_point_ids = self._filter(grid).index
grid.cloud.data.points["classification"][filtered_point_ids] = ground_int
else:
print("This is only implemented for .las files.")

Expand Down
Binary file added pyfortest/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file not shown.
Binary file added pyfortest/__pycache__/test_pyfor.cpython-36.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions pyfortest/test_pyfor.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ def setUp(self):
def test_filter(self):
self.test_kp_filter._filter(self.test_cloud.grid(self.test_kp_filter.cell_size))

def test_classify(self):
self.test_kp_filter.classify(self.test_cloud)
self.assertEqual(133410, np.sum(self.test_cloud.data.points["classification"] == 2))

class Zhang2003TestCase(unittest.TestCase):
def setUp(self):
self.test_cloud = cloud.Cloud(test_las)
Expand Down
27 changes: 27 additions & 0 deletions test_environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: pyfor_env

dependencies:
- python=3.7
- gdal
- rasterio
- conda-forge::pyproj
- numpy
- pandas
- scipy
- scikit-image
- scikit-learn
- pyqtgraph
- matplotlib
- pyopengl
- numba
- libkml
- geopandas
- joblib
- poppler
- conda-forge::lastools
- pip:
- laspy
- laxpy
- sphinx_rtd_theme
- python-coveralls
- plyfile

0 comments on commit b6b6ef0

Please sign in to comment.