Comments (10)
from pyfor.
Ben,
You have found a bit of a sore spot for me. I have been looking to get this consistent myself. I am wrapping up a small assignment right now, but I can hop on this in a few minutes.
from pyfor.
Sure, i'm trying to think about how to make a reproducible example. its within the deep learning data generator that would take alot for you to bury into. Trying now. My labmate thinks its option 2. The rgb image plot shows the UTM N increasing as you go up, which i guess is arbitrary, but we should be consistent.
from pyfor.
To be honest there is a deep nest of flips and unflips in pyfor (one of those things, you know). The least I can tell you is that line 170 only flips for visualization. It may be worthwhile to matshow the image and CHM separately in two different plot for debugging. You could probably take advantage of the top left corner of the image you have to make sure they are correct. You can access the chm
array like so:
pc = Cloud('my_las.las')
my_chm = pc.chm(1)
chm.array
My other though is that when I generate the bins for the points to convert to a raster is that, I think, they start from the bottom left, rather than the top left. Hence all the flipping/flopping. I will come up with a more formal solution soon. Keep me posted on here (or gitter if you want more instant feedback)!
from pyfor.
Okay this should be reproducible.
Data: Archive.zip
import pyfor
from PIL import Image
from matplotlib import pyplot
import numpy as np
pc=pyfor.cloud.Cloud("/Users/ben/Documents/DeepLidar/data/SJER/SJER_002.laz")
im=Image.open("/Users/ben/Documents/DeepLidar/data/SJER/SJER_002.tif")
#Maybe numpy inverts the image from PIL?
image = np.array(im)
pc.normalize(2)
chm = pc.chm(cell_size = 0.1 , interp_method = "nearest", pit_filter = "median", kernel_size = 9)
fig, ax = pyplot.subplots()
ax.imshow(image)
ax.matshow(chm.array,alpha=0.4)
fig.title="Original"
#versus
fig, ax = pyplot.subplots()
ax.imshow(image)
ax.matshow(np.flip(chm.array,0),alpha=0.4)
fig.title="CHM Flipped"
pyplot.show()
I'm going to assume that the CHM is flipped for some reason (UTM N facing down, not up) and just move forward.
from pyfor.
Ben,
I just arrived to the same conclusion. The index [0,0] of chm.array
refers to the bottom left of the CHM (in real space). When we display this in matplotlib using plt.matshow(chm.array)
it is displayed upside-down for this reason.
I will need to think about the implications down the line for flipping it up in rasterizer.Raster
. It seems to be an easy fix, but I need to write some tests for this sort of thing anyway. I
I am committing the rest of the day (barring any other unforeseen work) to the testing suite and other fixes you have presented. I will let you know when I push to laz_fix
, and I will include a UserWarning
in this push when the array is constructed such that [0,0] refers to the top left when rasterizer.Raster
is initialized.
from pyfor.
Ben,
A quick update. I am debating fixing this way up at the top (when the bins themselves are assigned). This will likely take a day or two to solidify. At least we know the temporary solution works for now. There are a lot of loose threads as well that I think would benefit from fixing all the way back in Grid.__init__
specifically:
https://github.com/brycefrank/pyfor/blob/laz_fix/pyfor/rasterizer.py#L28-L30
Edit
After spending a bit of time with it it is much more maintainable to do the fix all the way up in Grid
. All of the calls to np.flipud
are no longer needed. I have to un-do a few more of these types of calls, but I am much more happy with how it is turning out. I will push to laz_fix
in an hour or so.
from pyfor.
This fix (along with the laz_fix
branch) has been merged to master. If you update, make sure to remove any flipping you have done yourself. It should no longer be needed (a UserWarning
is issued any time a Grid
object is initialized, I'll leave this in until 0.3.2 is merged to master, which will be a while).
from pyfor.
from pyfor.
Looking forward to the next challenge ;)
from pyfor.
Related Issues (20)
- Cryptic error when clipping a particular polygon and point set HOT 2
- Travis fails on write .laz
- Subversive pyproj error for Windows conda environment HOT 4
- Unclear argument parameter name in `retile_raster`
- Point cloud colors HOT 2
- `KrausPfeifer1998` classify fails HOT 1
- Add heightbreak for all metrics
- Eliminate `ResourceWarning`s from testing suite HOT 1
- `create_index` should be multithreaded by default
- Scanning files for a collection should be generalized to `.las/z` files
- Point gridding can be simplified
- Migrate to `conda-forge` testing
- Warning for `force_extent` bbox
- Docstring for `array_to_raster` is out of date HOT 1
- Make minimal area-based approach example
- Add ability to pass additional arguments through par_apply HOT 2
- Area-Based Metrics dodument is missing
- missing else branch for tolerance parameter in KrausPfeifer1998 HOT 2
- Conda forge gdal issue HOT 7
- Failed rasterization HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyfor.