Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Polygon Query on Raster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FACT
FACT Utils
Polygon Query on Raster
Commits
a8bf24f8
Commit
a8bf24f8
authored
1 year ago
by
Riccardo Boero
Browse files
Options
Downloads
Patches
Plain Diff
Rewriting results for categorical bands
parent
49deb748
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
polygonqueryonraster/app.py
+5
-0
5 additions, 0 deletions
polygonqueryonraster/app.py
with
5 additions
and
0 deletions
polygonqueryonraster/app.py
+
5
−
0
View file @
a8bf24f8
...
@@ -175,6 +175,7 @@ class GeoTIFFService:
...
@@ -175,6 +175,7 @@ class GeoTIFFService:
and non-categorical data, producing different statistical measures accordingly.
and non-categorical data, producing different statistical measures accordingly.
For categorical data, it computes statistics for each band separately, treating each band as a different category.
For categorical data, it computes statistics for each band separately, treating each band as a different category.
For non-categorical data, it computes standard statistical measures for each band.
Args:
Args:
combined_raster_data (numpy.ndarray): The combined raster data from all relevant tiles.
combined_raster_data (numpy.ndarray): The combined raster data from all relevant tiles.
...
@@ -194,6 +195,9 @@ class GeoTIFFService:
...
@@ -194,6 +195,9 @@ class GeoTIFFService:
masked_band_data
=
band_data
*
polygon_mask
if
num_bands
>
1
else
band_data
*
polygon_mask
.
squeeze
()
masked_band_data
=
band_data
*
polygon_mask
if
num_bands
>
1
else
band_data
*
polygon_mask
.
squeeze
()
if
categorical
:
if
categorical
:
# Ignore no-data value (assumed to be 0)
masked_band_data
=
masked_band_data
[
masked_band_data
!=
0
]
# Compute categorical statistics for each band
# Compute categorical statistics for each band
unique
,
counts
=
np
.
unique
(
masked_band_data
,
return_counts
=
True
)
unique
,
counts
=
np
.
unique
(
masked_band_data
,
return_counts
=
True
)
stats_result
[
f
'
band_
{
band
}
'
]
=
dict
(
zip
(
unique
.
tolist
(),
counts
.
tolist
()))
stats_result
[
f
'
band_
{
band
}
'
]
=
dict
(
zip
(
unique
.
tolist
(),
counts
.
tolist
()))
...
@@ -214,6 +218,7 @@ class GeoTIFFService:
...
@@ -214,6 +218,7 @@ class GeoTIFFService:
@staticmethod
@staticmethod
def
compute_entropy
(
x
):
def
compute_entropy
(
x
):
"""
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment