NCRN / ForestVeg

Front end application for NCRN Forest Vegetation Access database.
3 stars 1 forks source link

Missing data in the Aspect field of the Locations table makes Aspect a text field #211

Open johnpauls opened 3 years ago

johnpauls commented 3 years ago

In the locations table there is an aspect field that indicates what direction the plot is facing. Typically this field is numeric - degrees between 0 and 360. There are 2 cases when it can be something else:

  1. If the aspect of the plot has not yet been determined then there is no data for the field.
  2. If the plot has a slope of 0, then the plot is flat and by definition it has no aspect.

Currently when the slope is 0, the database is putting "N/A" in the aspect field. When this is imported into R it make all the data into text. If this was switched to NA (no slash) then R would read that as missing data and keep the rest numeric.

There may be other solutions as well, but preventing the conversion to Text is what is needed.

blcampbell commented 3 years ago

@johnpauls Some questions for identifying how these should be adjusted.

If the answers don't otherwise dictate, a flat plot could be set w/ aspect 0. This would eliminate the need for text and allow the aspect field to be tightened to handle numbers only. Missing aspects from the past could be identified by NULL values which have an associated missing value flag. Aspects for the future could then be required so that NULL values wouldn't be allowed for additional new plots.

Thoughts?

johnpauls commented 3 years ago

@blcampbell

I am not sure how requiring an aspect would work. That is something we measure in the field, so typically we would pull up an existing plot and then enter the data. Would aspect need to be measured before the plot could be in the database?

blcampbell commented 3 years ago

@johnpauls

So the actual range for aspect is 1-360 vs. 0-360.

Based on this, the only way to 'require' the location record to have an aspect would be to force users to include this value in the data entry form when the info is updated. In general, a field in a table cannot be changed to required unless all of the records have a value for it. (Doing so can drop records that don't have a value in the newly required field.)

Since 0 isn't viable and has other unintended consequences, requiring aspect in the form would mean that a user entering data would need to add the aspect value every time slope > 0. The two would need to be tied (they may already be - need to investigate).

For 0 slope plots, a flag would need to be entered to identify the plot aspect as NA and not simply missing. This would result in a flag record for the aspect of the plot and a NULL value in the plot's aspect field.

Exports will require a discussion of the latest flagging views which display both the field & the flag for the field. In this case the location record would display ...slope, slope_flag, aspect, aspect_flag... Example .... slope, slope_flag, aspect, aspect_flag ... .... 35, NULL, 22, NULL ... .... 10, NULL, NULL, 99805 ... .... 0, NULL, NULL, 99880 ... where 99805 would be the flag for missing aspect data, 99880 the flag for NA with a 0 slope. Broader discussion will be needed to make sure exports work well w/ R code while meeting this field, field_flag pattern.