Skip to content

Commit

Permalink
Added Python Challenges to Repository
Browse files Browse the repository at this point in the history
  • Loading branch information
cjsostad committed Dec 11, 2024
1 parent 8d4feef commit d43499b
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
** Press Ctrl+Shift+V to view Markdown Text

# Problem #1 - "Clipping" Data in Related Tables
You have a shapefile of lakes in the Omineca Region called Management Objectives. It was created by using the Omineca Wildlife Habitat Areas clipping the freshwater atlas layer. (For this exercies it is "Join Table")
This shapefile has 7 tables related to it. The tables are all related to the Management Objectives with Waterbody ID as the primary key.
Unfortunately, all of the tables contain data not just for Omineca, but the whole Province of BC. The client wants you to remove all data that is not in the Omineca region so that the related tables only contain the data for Omineca. If all the data was spatialized, you could use the Omineca Polygon to clip the related table data. However, the data isn't spatialized so you will need to use python to clean the data.

Hint** The Join Table (aka our shapefile) is already clipped to Omineca. Therefore, every waterbody Id in the join table is an Omineca Waterbody

Tables are here: (Make a copy in your working drive)
\\spatialfiles.bcgov\work\srm\nel\Local\Geomatics\Workarea\csostad\FishDataWebmap\ExcelSheets\Cleaned_Sheets_Master - Copy
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Find Only Coniferous Stands In VRI Data

### From the Client:

**"Conifer stand – I looked up the definition of what a conifer stand is to be sure – in our case, a conifer stand is any stand with less than 25% deciduous species.
This means that we can still have deciduous species in the SPEC_CD_1 to SPEC_CD_6 fields of the VRI.

Broadleaf species are "D", "DR", "DG","DM","U", "UP", "A", "AC", "ACB", "ACT", "AX", "AT", "R", "RA", "E", "EA", "EXP", "EP", "EW","G","GP", "M", "MB", "MV", "Q", "QG", "XH", "V", "VB", "VP", "W", "WS", "WA", "WB", "WD", "WP", "WT","ZH"**

So for any given polygon, if any of the species code listed above are in any of the SPEC_CD_1 to SPEC_CD_6 fields AND add up to more than 25% in the SPEC_PCT_1 to SPEC_PCT_6 fields combined, then we would drop that polygon. "


The python script should iterate through each of Species Code 1 - Species Code 6
If the species code contains a broadleaf species, it should read the percentage for that column. (Species_1_PCT)
if the species_pct is greater than 25%, delete the row.
if the species_pct is less than 25%, read the next species code (Species_Code_2).
If THAT species code contains a broadleaf species, add that value to the first broadleaf species percentage (if there was one)
If the new total is greater than 25%, delete the row.
Continue to iterate over each column 1 - 6 until all broadleaf species polygons of greater than 25% are eliminated.

Binary file not shown.

0 comments on commit d43499b

Please sign in to comment.