-
Notifications
You must be signed in to change notification settings - Fork 9
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
Binary inclusions results #170
Labels
bug
Something isn't working
Comments
Branch with a possible solution is https://github.com/NREL/reVX/tree/issue_170 |
Closed
mjgleason
added a commit
that referenced
this issue
Jan 30, 2023
Merged
mjgleason
added a commit
that referenced
this issue
Jan 30, 2023
Addressed in #173 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Description
setbacks
module will sometimes produce binary results (i.e., exclusions) for counties with ordinances when inclusions should be returned (i.e.,weights_calculation_upscale_factor
is greater than 1).Screen shot 1 shows an example of this occurring for roads setbacks in North Carolina. County boundaries are shown in black and the setbacks raster is displayed with a red/yellow/blue color ramp where
red=0
(full exclusion) andblue=1
(full inclusion). Several counties show up with colors only of red and blue, indicating binary results. This was confirmed by inspecting the actual pixel values.This same error occurs when there are no default setbacks used for counties without ordinances (see Screen shot 2). Interestingly, in this latter case, the resulting raster is actually of dtype
Byte
(i.e.,UInt8
) when it should befloat32
.Full Traceback
There is no traceback since this is a semantic error.
Code Sample
NA
To Reproduce
To reproduce this problem, you can run
setbacks from-config -c this_config.json
wherethis_config.json
isExpected behavior
The expected result should be a raster is returned with inclusion values ranging from 0 to 1 instead of exclusion values of only 0 and 1 for these counties.
Screenshots
![Screen Shot 2023-01-25 at 1 58 19 PM](https://user-images.githubusercontent.com/24549594/214690048-690fc8e0-1eb3-4364-98af-9e62943744b0.png)
Screen shot 1:
Screen shot 2:
![Screen Shot 2023-01-25 at 2 03 56 PM](https://user-images.githubusercontent.com/24549594/214690276-e6129425-952a-4362-91eb-8cf8d251d860.png)
Screen shot 3:
![Screen Shot 2023-01-25 at 2 19 49 PM](https://user-images.githubusercontent.com/24549594/214693538-1fcfaa3d-f18c-42fa-97a2-82c835224330.png)
Screen shot 4:
![Screen Shot 2023-01-25 at 2 19 55 PM](https://user-images.githubusercontent.com/24549594/214693562-80841f9f-e4bb-4751-8fe3-7d2af93a5f94.png)
System (please complete the following information):
Additional context
Interestingly, this problem does not occur for all counties with ordinances, but occurs on a state-by-state basis. If a state is affected, all the counties with ordinances will be affected. If not, no counties are affected.
I believe I've traced this problem back to a couple mechanisms. The first is https://github.com/NREL/reVX/blob/main/reVX/setbacks/base.py#L417, which filters the vector features for each county down to those that have a centroid within the county boundary. In some cases,
features
will be returned as an empty list, resulting in a constant array with all values of1
returned by this function. Notably, this raster is of anuint
data type.This raster is then combined with the existing exclusions array (https://github.com/NREL/reVX/blob/main/reVX/utilities/exclusions.py#L365). In many cases, this is fine, because the existing raster is already populated (by a previous county) and has an existing data type of
float32
. But if this issue occurs with the first county being processed, theexisting
array isNone
and the dtype is established based on the dtype of the local exclusions array:reVX/reVX/utilities/exclusions.py
Lines 484 to 485 in d247465
uint
(see previous paragraph), then we end up with anexisting
raster that is now initialized to a data type ofuint
. This will then convert the inclusions results for all subsequent counties in the state touint
, resulting in auint
layer for all counties with ordinances.I've worked out one solution to this and will post it to a new branch. I have tested enough to confirm it fixes the issue (see Screen shots 3 and 4 for before and after results in Wyoming), but have not tested it thoroughly enough to know that it is robust and doesn't have any unintended side effects. Also, it may not be the cleanest solution, but hopefully will provide additional insight into the problem.
Charge code
If you are at NREL and fixing this bug is urgent, please provide a charge code for our time.
The text was updated successfully, but these errors were encountered: