Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color: fix images bbox to prevent in edge cases where points were at … #64

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# dev
- Color: fix images bbox to prevent in edge cases where points were at the edge of the last pixel

# 1.7.4
- Add possibility to remove points of somes classes in standardize
- Add possibility to remove points of some classes in standardize

# 1.7.3
- Add method to get a point cloud origin
Expand Down
22 changes: 13 additions & 9 deletions pdaltools/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ def is_image_white(filename: str):
def download_image_from_geoplateforme(
proj, layer, minx, miny, maxx, maxy, pixel_per_meter, outfile, timeout, check_images
):
# Give single-point clouds a width/height of at least one pixel to have valid BBOX and SIZE
if minx == maxx:
maxx = minx + 1 / pixel_per_meter
if miny == maxy:
maxy = miny + 1 / pixel_per_meter
# Force a 1-pixel margin in the east and south borders
# to make sure that no point of the pointcloud is on the limit of the last pixel
# to prevent interpolation issues
maxx = maxx + 1 / pixel_per_meter
miny = miny - 1 / pixel_per_meter

# for layer in layers:
URL_GPP = "https://data.geopf.fr/wms-r/wms?"
Expand Down Expand Up @@ -136,22 +136,26 @@ def color(

tmp_ortho = None
if color_rvb_enabled:
tmp_ortho = tempfile.NamedTemporaryFile()
tmp_ortho = tempfile.NamedTemporaryFile(suffix="_rvb.tif")
download_image_from_geoplateforme_retrying(
proj, stream_RGB, minx, miny, maxx, maxy, pixel_per_meter, tmp_ortho.name, timeout_second, check_images
)

# Warning: the initial color is multiplied by 256 despite its initial 8-bits encoding
# which turns it to a 0 to 255*256 range.
# It is kept this way because of other dependencies that have been tuned to fit this range
pipeline |= pdal.Filter.colorization(
raster=tmp_ortho.name, dimensions="Red:1:256.0, Green:2:256.0, Blue:3:256.0"
)

tmp_ortho_irc = None
if color_ir_enabled:
tmp_ortho_irc = tempfile.NamedTemporaryFile()
tmp_ortho_irc = tempfile.NamedTemporaryFile(suffix="_irc.tif")
download_image_from_geoplateforme_retrying(
proj, stream_IRC, minx, miny, maxx, maxy, pixel_per_meter, tmp_ortho_irc.name, timeout_second, check_images
)

# Warning: the initial color is multiplied by 256 despite its initial 8-bits encoding
# which turns it to a 0 to 255*256 range.
# It is kept this way because of other dependencies that have been tuned to fit this range
pipeline |= pdal.Filter.colorization(raster=tmp_ortho_irc.name, dimensions="Infrared:1:256.0")

pipeline |= pdal.Writer.las(
Expand Down