diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md deleted file mode 100644 index b6f363d..0000000 --- a/.github/copilot-instructions.md +++ /dev/null @@ -1,50 +0,0 @@ -## Copilot / Agent instructions for DisMAP - -Short, actionable notes to help an AI agent be productive in this repository. - -- Project split: - - `data_processing_rcode/` — R scripts to download and compile raw survey data. Entry point: open `DisMAP.Rproj` and run the `Compile_Dismap_Current.R` and `create_data_for_map_generation.R` scripts. These generate the CSV/GDB inputs consumed by the Python/ArcGIS layer. - - `ArcGIS-Analysis-Python/` — Python-based ArcGIS Pro tooling that reads the processed CSVs and generates interpolated rasters, mosaics and indicators. Main code is under `ArcGIS-Analysis-Python/src/dismap_tools/`. - -- Environment and how to run (high level): - - The Python tools require an ArcGIS Pro Python environment (ArcPy available). Run scripts from the ArcGIS Pro Python interpreter (for example `arcgispro-py3`). - - R workflows should be run from the R project (`DisMAP.Rproj`) so relative paths and project options work. - -- Project-specific patterns and conventions: - - Windows paths and raw f-strings are used widely (e.g., rf"{home_folder}\{project}.aprx"). Prefer Windows-style paths when editing code examples. - - The repository uses date-named version folders (e.g., `"August 1 2025"`) that contain geodatabases and build artifacts. Avoid editing large binary datasets in those folders; treat them as outputs. - - Many Python modules import `arcpy` and call `arcpy.mp.ArcGISProject(...)` (see `src/dismap_tools/publish_to_portal_director.py`, `dismap_project_setup.py`, and `dismap_metadata_processing.py`). Changes to ArcPy usage must be validated inside an ArcGIS Pro environment. - - The Python package uses a `src/` layout and a `setup.py` that expects `src/version.py`. Confirm `src/version.py` exists or define `__version__` before packaging. - -- Key files to open first (quick tour): - - `README.md` (repo root) — project overview and where R/ArcGIS pieces live. - - `DisMAP.Rproj` and `data_processing_rcode/Compile_Dismap_Current.R` — how raw data is ingested. - - `ArcGIS-Analysis-Python/src/dismap_tools/` — main Python processing scripts (directors/workers, publish scripts). - - `ArcGIS-Analysis-Python/DisMAP.aprx` — base ArcGIS Pro project referenced by scripts. - - `ArcGIS-Analysis-Python/setup.py` — packaging layout (src/ package style). - -- Common developer workflows (what agents should do / check): - - Before editing processing logic, reproduce a minimal run: run the R compile script to generate the CSV inputs, then run a single Python director (e.g., `dev_dismap_director.py`) inside ArcGIS Pro Python to confirm behavior. - - When adjusting ArcPy code, test in ArcGIS Pro (or the `arcgispro-py3` conda env) — unit tests are minimal/absent (`conftest.py` is empty), so use small smoke runs. - - Publishing scripts call portal APIs via ArcPy and require credentials and a valid `.aprx`. Don't attempt to publish during dry edits; mock or dry-run by inspecting `arcpy.mp` calls. - -- Examples (where to change things safely): - - To add a preprocessing step, modify `data_processing_rcode/create_data_for_map_generation.R` so outputs remain CSVs expected by `src/dismap_tools/*`. - - To run a single processing step in Python, open ArcGIS Pro Python prompt and run the target director script from `ArcGIS-Analysis-Python\\src\\dismap_tools\\`. - -- Integration points & external dependencies to be aware of: - - ArcGIS Pro / ArcPy (required). Scripts assume ArcGIS Pro APIs and Windows paths. - - ArcGIS Portal (used by `publish_to_portal_director.py`) — publishing requires portal credentials and network access. - - Large geodatabases and rasters are stored under versioned folders — these are produced artifacts. - -- Safety and commit guidance for agents: - - Do not modify or commit large binary geodatabases/raster files. Prefer changes to scripts that produce them. - - `.aprx` files are referenced but commonly ignored by `.gitignore`; double-check before committing APRX changes. - - If `src/version.py` is missing, do not fabricate a version without asking — instead add a comment and propose the change in a PR. - -- Quick checklist for a PR from an agent: - 1. Describe which director/worker you ran and the minimal dataset used. - 2. Confirm tests or smoke-runs and the ArcGIS Pro environment used (path to Python interpreter and Pro version). - 3. Point to exact input CSVs and output GDB/rasters affected (path under a version folder). - -If anything above is unclear or you want the file to include more specific run commands for your local ArcGIS Pro installation, tell me which pieces you want expanded and I'll iterate. diff --git a/.gitignore b/.gitignore index a304de2..bcd71a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,49 +1,5 @@ -# History files -.Rhistory -.Rapp.history -.RDataTmp +# Ignore all +. +.getignore -# Session Data files -.RData - -# User-specific files -.Ruserdata - -# Example code in package build process -*-Ex.R - -# Output files from R CMD build -/*.tar.gz - -# Output files from R CMD check -/*.Rcheck/ - -# RStudio files -.Rproj.user/ - -# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 -.httr-oauth - -# knitr and R markdown default cache directories -*_cache/ -/cache/ - -# Temporary files created by R markdown -*.utf8.md -*.knit.md - -# R Environment Variables -.Renviron - -/data_processing_rcode/data/ -/data_processing_rcode/output/ -/data_processing_rcode/notforgit/ - - -/code/.quarto/ -*.zip -*.tex -*.log -*.markdown -*.rmarkdown -__init__.py \ No newline at end of file +!/ArcGIS-Analysis-Python/* \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..288fa0f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ +# .pre-commit-config.yaml +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 # Use the latest version + hooks: +<<<<<<< HEAD +# - id: trailing-whitespace +======= + - id: trailing-whitespace +>>>>>>> Python-Processing +# - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-json + - id: detect-private-key +# - repo: https://github.com/psf/black +# rev: 24.3.0 # Use the latest version +# hooks: +# - id: black +# - repo: https://github.com/PyCQA/flake8 +# rev: 7.0.0 # Use the latest version +# hooks: +# - id: flake8 +# - repo: https://github.com/PyCQA/isort +# rev: 5.13.2 # Use the latest version +# hooks: +# - id: isort diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..8de8825 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.defaultInterpreterPath": "C:\\Users\\john.f.kennedy\\AppData\\Local\\ESRI\\conda\\envs\\arcgispro-py3-clone" +} \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/.gitignore b/ArcGIS-Analysis-Python/.gitignore index f80c368..6032fa2 100644 --- a/ArcGIS-Analysis-Python/.gitignore +++ b/ArcGIS-Analysis-Python/.gitignore @@ -1,187 +1,11 @@ -################# -## Visual Studio -################# +# Global ignore: everything +. -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. +# include Scripts folder and its contents +!/Scripts/dismap_tools/*.py +!/Scripts/dismap_tools/*.pyt -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -Initial Data -Data -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -NCEI Archive -*.pidb -*.log -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -############# -## Windows detritus -############# - -# Windows image file caches -src/dismap_tools_dev -ehthumbs.db - -# Folder config file -!src/dismap_tools/*.py -!src/dismap_tools_dev/*.py -!src/dismap_tools/dev_*.py -!src/dismap_tools/__init__.py -!src/dismap_tools/README.md - -# Mac crap -.DS_Store - -############# -## Python -############# - -*.py[co] -*.pyc -# Packages -*.egg -*.egg-info -dist/ -build/ -eggs/ -parts/ -var/ -sdist/ -develop-eggs/ -.installed.cfg - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox - -#Translations -*.mo - -#Mr Developer -.mr.developer.cfg - -# Tools, notes, outputs -___*.* -___* -*.log - -[Ss]ampleData/ -source/[Ss]ampleData/ -source/[Tt]est[Cc]onfigs/ -#src/service_monitor -error.txt - -############# -## ArcGIS -############# -*.gdb -*.ipynb -ImportLog -*.aprx -*.atbx -*.mxd -*.json - -############# -## ArcGIS-Analysis-Python ignores -############# -# Ignore Folders -.backups -.ipynb_checkpoints -__pycache__ -April 1 2023 -August 1 2025 -Bathymetry -Initial Data -Dataset Shapefiles -December 1 2024 -February 1 2026 -GpMessages -ImportLog -Index -Initial Data -July 1 2024 -Layout -May 16 2022 -NCEI Archive -Notebooks -RasterFunctionsHistory -RasterFunctionTemplates -Scratch -# Ignore Files -*.ags -*.docx -.pyHistory -*.py -*.~py -*.pyt -*.xml -*.xsl -*.zip -__init__.py -*.txt -conftest.py -main.py -setip.py -utils.py -Metadata.md -src/dismap_tools/esri -NCEI Archive -_Dataset Shapefiles -#src/dismap_tools_dev -############# -# Do not ignore these files +# include README files in root, Scripts, and dismap_tools !README.md -!src/dismap_tools/*.py -!src/dismap_tools_dev/*.py -src/dismap_tools/dev_*.py -src/dismap_tools/__init__.py -!src/dismap_tools/README.md +!Scripts/README.md +!Scripts/dismap_tools/README.md diff --git a/ArcGIS-Analysis-Python/src/README.md b/ArcGIS-Analysis-Python/Scripts/README.md similarity index 100% rename from ArcGIS-Analysis-Python/src/README.md rename to ArcGIS-Analysis-Python/Scripts/README.md diff --git a/ArcGIS-Analysis-Python/Scripts/__pycache__/__init__.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000..ed2c952 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/__pycache__/__init__.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/ISO 19115-3 Native Builder.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/ISO 19115-3 Native Builder.py new file mode 100644 index 0000000..355a1fd --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/ISO 19115-3 Native Builder.py @@ -0,0 +1,165 @@ +"""NOAA InPort to ArcGIS Native Injection Pipeline. + +Extracts legacy 19139 streams via OWSLib, pulls the target asset's native +Esri XML shell, surgically injects the metadata, and re-imports it to +bypass the arcgisscripting C++ parser crash. +""" + +import os +import sys +import arcpy +import requests +from arcpy import metadata as md +from lxml import etree + +try: + from owslib.iso import MD_Metadata +except ImportError: + print("❌ OWSLib is required. Please run: pip install OWSLib") + sys.exit(1) + + +def map_iso_role(role_string: str) -> str: + """Maps ISO/OWSLib role strings to ArcGIS integer domains.""" + mapping = { + "pointOfContact": "007", + "author": "011", + "publisher": "010", + "originator": "006", + "distributor": "005", + "owner": "003", + "custodian": "002", + "principalInvestigator": "004" + } + return mapping.get(role_string, "007") + + +def process_injection_pipeline(gdb_table: str, final_xml_out: str) -> None: + """Executes the Extract, Edit, Replace workflow.""" + + iso_url = "https://www.fisheries.noaa.gov/inportserve/waf/noaa/nmfs/ost/iso19115/xml/79319.xml" + + output_dir = os.path.dirname(final_xml_out) + if not os.path.exists(output_dir): + os.makedirs(output_dir) + + scratch_folder = arcpy.env.scratchFolder + raw_iso_tmp = os.path.join(scratch_folder, "raw_inport_iso.xml") + native_shell_tmp = os.path.join(scratch_folder, "native_esri_shell.xml") + + # 1. Download NOAA OWSLib Payload + print("📡 Pulling ISO 19115-2 (19139) payload stream via OWSLib...") + try: + response = requests.get(iso_url, headers={"User-Agent": "Mozilla/5.0"}, timeout=30) + response.raise_for_status() + with open(raw_iso_tmp, "wb") as f: + f.write(response.content) + except requests.RequestException as req_err: + print(f"❌ Network transfer failed: {req_err}") + sys.exit(1) + + try: + # 2. Extract Data via OWSLib + print("⚙️ Extracting InPort matrices via OWSLib...") + source_tree = etree.parse(raw_iso_tmp) + iso_md = MD_Metadata(source_tree) + + ident = None + if hasattr(iso_md, "identification") and isinstance(iso_md.identification, list) and len(iso_md.identification) > 0: + ident = iso_md.identification[0] + + # 3. Extract Target Asset's Native XML Shell + print(f"📂 Extracting native metadata shell from: {gdb_table}") + target_md = md.Metadata(gdb_table) + target_md.saveAsXML(native_shell_tmp) + + # 4. Surgically Edit the Native XML Shell + print("🧬 Injecting InPort arrays into Esri native structure...") + parser = etree.XMLParser(remove_blank_text=True) + esri_tree = etree.parse(native_shell_tmp, parser) + root = esri_tree.getroot() + + # Ensure exists + data_id_info = root.find("dataIdInfo") + if data_id_info is None: + data_id_info = etree.SubElement(root, "dataIdInfo") + + # Purge existing conflicting nodes to prevent duplication + for tag in ["idCitation", "idAbs", "idPurp", "idPoC", "geoBox"]: + for element in data_id_info.findall(tag): + data_id_info.remove(element) + + # Inject Title, Abstract, Purpose + id_citation = etree.SubElement(data_id_info, "idCitation") + res_title = etree.SubElement(id_citation, "resTitle") + res_title.text = getattr(ident, "title", None) or "DisMAP Survey Info" + + id_abs = etree.SubElement(data_id_info, "idAbs") + id_abs.text = getattr(ident, "abstract", None) or "" + + id_purp = etree.SubElement(data_id_info, "idPurp") + id_purp.text = getattr(ident, "purpose", None) or "" + + # Inject Contacts + contacts = [] + if ident and hasattr(ident, "contact") and ident.contact: + contacts.extend(ident.contact) + if hasattr(iso_md, "contact") and iso_md.contact: + contacts.extend(iso_md.contact) + + for contact in contacts: + poc = etree.SubElement(data_id_info, "idPoC") + if hasattr(contact, "organization") and contact.organization: + org = etree.SubElement(poc, "rpOrgName") + org.text = contact.organization + if hasattr(contact, "name") and contact.name: + ind = etree.SubElement(poc, "rpIndName") + ind.text = contact.name + if hasattr(contact, "email") and contact.email: + addr = etree.SubElement(poc, "cntAddress") + email = etree.SubElement(addr, "eMailAdd") + email.text = contact.email + if hasattr(contact, "role") and contact.role: + role = etree.SubElement(poc, "role") + role_cd = etree.SubElement(role, "RoleCd") + role_cd.set("value", map_iso_role(contact.role)) + + # Inject Geographic Bounds + if ident and hasattr(ident, "bbox") and ident.bbox: + bbox_list = ident.bbox if isinstance(ident.bbox, list) else [ident.bbox] + for box in bbox_list: + geo_box = etree.SubElement(data_id_info, "geoBox") + geo_box.set("esriExtentType", "search") + etree.SubElement(geo_box, "westBL").text = str(getattr(box, "minx", "")) + etree.SubElement(geo_box, "eastBL").text = str(getattr(box, "maxx", "")) + etree.SubElement(geo_box, "southBL").text = str(getattr(box, "miny", "")) + etree.SubElement(geo_box, "northBL").text = str(getattr(box, "maxy", "")) + + # Save modified tree + esri_tree.write(final_xml_out, pretty_print=True, encoding="UTF-8", xml_declaration=True) + + # 5. Re-Import using ARCGIS_METADATA mapping + print("💾 Committing injected schema back to the Geodatabase...") + target_md.importMetadata(final_xml_out, "ARCGIS_METADATA") + target_md.save() + + print("✅ Success: The workflow completed without tripping the C++ parser.") + + except etree.LxmlError as xml_err: + print(f"❌ XML Parsing failure: {xml_err}") + except Exception as db_err: + print(f"❌ Database commitment rejected: {db_err}") + finally: + for temp_file in [raw_iso_tmp, native_shell_tmp]: + if os.path.exists(temp_file): + os.remove(temp_file) + + +if __name__ == "__main__": + TARGET_ASSET = r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\February-1-2026\February-1-2026.gdb\DisMAP_Survey_Info" + FINAL_XML_EXPORT = r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\February-1-2026\Metadata_Export\Final_ArcGIS_Metadata_79319.xml" + + if arcpy.Exists(TARGET_ASSET): + process_injection_pipeline(TARGET_ASSET, FINAL_XML_EXPORT) + else: + print(f"❌ Error: Missing destination table at target: {TARGET_ASSET}") \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/InPortToHTML.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/InPortToHTML.py new file mode 100644 index 0000000..bdacb9a --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/InPortToHTML.py @@ -0,0 +1,50 @@ +import requests +from lxml import etree + +def generate_html_report(item_id, xslt_string): + # 1. Fetch the remote NOAA XML + url = f"https://www.fisheries.noaa.gov/inportserve/waf/noaa/nmfs/ost/iso19115/xml/{item_id}.xml" + response = requests.get(url) + + if response.status_code != 200: + print("Error: Could not reach NOAA servers.") + return + + # 2. Parse the XML and the XSLT + xml_tree = etree.fromstring(response.content) + xslt_tree = etree.XML(xslt_string) + + # 3. Perform the Transformation + transform = etree.XSLT(xslt_tree) + result_html = transform(xml_tree) + + # 4. Save to a file + output_file = f"Report_{item_id}.html" + with open(output_file, "wb") as f: + f.write(etree.tostring(result_html, pretty_print=True, method="html")) + + print(f"✅ Report generated: {output_file}") + +# Example Usage: +if __name__ == "__main__": + # We define the XSLT inside the script for easy replication by students + MY_XSLT = """ + + + +

NOAA Item #70032 Summary

+

Metadata Standard: ISO 19139

+
+ Dataset Title:
+ +
+

Abstract:
+

+ + +
+
""" + + generate_html_report(70032, MY_XSLT) \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/README.md b/ArcGIS-Analysis-Python/Scripts/dismap_tools/README.md similarity index 96% rename from ArcGIS-Analysis-Python/src/dismap_tools/README.md rename to ArcGIS-Analysis-Python/Scripts/dismap_tools/README.md index 32ce0ce..ad2fbf0 100644 --- a/ArcGIS-Analysis-Python/src/dismap_tools/README.md +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/README.md @@ -4,6 +4,7 @@ ### Table of contents ### > - [*Purpose*](#purpose) +> - [*DisMAP Processing Steps*](#dismap-processing-steps) > - [*DisMAP ArcGIS Python Processing Setup*](#dismap-arcigs-python-processing-setup) > - [Zip and Unzip CSV Data](#zip-and-unzip-csv-data) > - [Zip and Unzip Shapefile Data](#zip-and-unzip-shapefile-data) @@ -32,6 +33,51 @@ ### *Purpose* These Python scripts were developed for the DisMAP ArcGIS Python Processing phase of the project. In general the scripts listed below are ran in the order they are presented in a Python IDE such as [*Pyscripter*](https://sourceforge.net/projects/pyscripter/). +# DisMAP Processing Steps +- ### Step 1 create a folder for this project + +- ### Step 2 create an ArcGIS Pro project, call it DisMAP, and save in the folder above + +- ### Step 3 create three folders: Bathymetry, Dataset Shapefiles, and Initial Data, or use the python script dismap_base_project.py script + +- ### Step 4 place the contents of the Bathemetry zip file into the "Bathemetry folder" + +- ### Step 5 place the contents of the CSV zip file intp the "Initial Data" folder + +- ### Step 6 place the contents of the Dataset Shapefiles.zip file into the Dataset Shapefiles folder + +- ### Step 7 Update the create_base_bathymetry.py file by changing the project_folder variable to the base project folder created above + +- ### Step 8 Update the dismap_version_project_setup.py file by changing the new_project_folder variable to a version date, like "February 1 2026". Then run the script + +- ### Step 9 Update the create_data_dictionary_json_files.py file by changing the project_gdb variable to a version date, like "February 1 2026". Then run the script + +- ### Step 10 Update the create_metadata_json_files.py file by changing the project_folder variable to a version date, like "February 1 2026". Then run the script + +- ### Step 11 Update the import_datasets_species_filter_csv_data.py file by changing the project_gdb variable to a version date, like "February 1 2026". Then run the script + +- ### Step 12 Copy the contents from the folder "Dataset Shapefiles" to the version project folder "Dataset_Shapefiles" + +- ### Step 13 Update the create_regions_from_shapefiles_director.py file by changing the project_gdb variable to a version date, like "February 1 2026". Then run the script + +- ### Step 14 Update the create_region_fishnets_director.py file by changing the project_gdb variable to a version date, like "February 1 2026". Then run the script + +- ### Step 15 Update the create_region_bathymetry_director.py file by changing the project_gdb variable by updating the version folder. For example: from "Project Folder\August 1 2025\August 1 2025.gdb" to "Project Folder\February 1 2026\February 1 2026.gdb". Then run the script + +- ### Step 16 Update the create_species_year_image_name_table_director.py file by changing the project_gdb variable by updating the version folder. For example: from "Project Folder\August 1 025\August 1 2025.gdb" to "Project Folder\February 1 2026\February 1 2026.gdb". Then run the script + +- ### Step 17 Update the create_region_sample_locations_director.py file by changing the project_gdb variable by updating the version folder. For example: from "Project Folder\August 1 025\August 1 2025.gdb" to "Project Folder\February 1 2026\February 1 2026.gdb". Then run the script +- +- ### Step 18 Update the create_rasters_director.py file by changing the project_gdb variable by updating the version folder. For example: from "Project Folder\August 1 025\August 1 2025.gdb" to "Project Folder\February 1 2026\February 1 2026.gdb". Then run the script + +- ### Step 19 Update the create_species_richness_rasters_director.py file by changing the project_gdb variable by updating the version folder. For example: from "Project Folder\August 1 025\August 1 2025.gdb" to "Project Folder\February 1 2026\February 1 2026.gdb". Then run the script + +- ### Step 20 Update the create_mosaics_director.py file by changing the project_gdb variable by updating the version folder. For example: from "Project Folder\August 1 025\August 1 2025.gdb" to "Project Folder\February 1 2026\February 1 2026.gdb". Then run the script + +- ### Step 21 Update the create_indicators_table_director.py file by changing the project_gdb variable by updating the version folder. For example: from "Project Folder\August 1 025\August 1 2025.gdb" to "Project Folder\February 1 2026\February 1 2026.gdb". Then run the script + +- ### Step 22 Update the publish_to_portal_director.py file by changing the project_gdb variable by updating the version folder. For example: from "Project Folder\August 1 025\August 1 2025.gdb" to "Project Folder\February 1 2026\February 1 2026.gdb". Then run the script + ### *DisMAP ArcGIS Python Processing Project Setup* - #### Zip and Unzip CSV Data - The [zip_and_unzip_csv_data.py](zip_and_unzip_csv_data.py) file archives/extracts sample location and biomass measurements in a CSV data file diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/XML b/ArcGIS-Analysis-Python/Scripts/dismap_tools/XML new file mode 160000 index 0000000..aa78eef --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/XML @@ -0,0 +1 @@ +Subproject commit aa78eef520a7d1803d9ddaae10d5001e73d4f846 diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/__init__.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..e25f806 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/__init__.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/__init__.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000..ff94afb Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/__init__.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/bar.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/bar.cpython-311.pyc new file mode 100644 index 0000000..4ad330e Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/bar.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_indicators_table_worker.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_indicators_table_worker.cpython-311.pyc new file mode 100644 index 0000000..e36a14e Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_indicators_table_worker.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_indicators_table_worker.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_indicators_table_worker.cpython-313.pyc new file mode 100644 index 0000000..ee158c4 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_indicators_table_worker.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_mosaics_director.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_mosaics_director.cpython-313.pyc new file mode 100644 index 0000000..a7be841 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_mosaics_director.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_mosaics_worker.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_mosaics_worker.cpython-311.pyc new file mode 100644 index 0000000..463f912 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_mosaics_worker.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_mosaics_worker.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_mosaics_worker.cpython-313.pyc new file mode 100644 index 0000000..2356d69 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_mosaics_worker.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_rasters_director.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_rasters_director.cpython-313.pyc new file mode 100644 index 0000000..93b4e28 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_rasters_director.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_rasters_worker.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_rasters_worker.cpython-311.pyc new file mode 100644 index 0000000..a4ea3d6 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_rasters_worker.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_rasters_worker.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_rasters_worker.cpython-313.pyc new file mode 100644 index 0000000..af328fc Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_rasters_worker.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_bathymetry_director.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_bathymetry_director.cpython-313.pyc new file mode 100644 index 0000000..c6aab6d Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_bathymetry_director.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_bathymetry_worker.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_bathymetry_worker.cpython-311.pyc new file mode 100644 index 0000000..9b10c7e Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_bathymetry_worker.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_bathymetry_worker.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_bathymetry_worker.cpython-313.pyc new file mode 100644 index 0000000..9fd28d5 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_bathymetry_worker.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_fishnets_worker.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_fishnets_worker.cpython-311.pyc new file mode 100644 index 0000000..4b1355a Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_fishnets_worker.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_fishnets_worker.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_fishnets_worker.cpython-313.pyc new file mode 100644 index 0000000..f0a95b1 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_fishnets_worker.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_sample_locations_worker.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_sample_locations_worker.cpython-311.pyc new file mode 100644 index 0000000..aa680bf Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_sample_locations_worker.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_sample_locations_worker.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_sample_locations_worker.cpython-313.pyc new file mode 100644 index 0000000..e8da020 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_region_sample_locations_worker.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_regions_from_shapefiles_director.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_regions_from_shapefiles_director.cpython-311.pyc new file mode 100644 index 0000000..8a591c0 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_regions_from_shapefiles_director.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_regions_from_shapefiles_worker.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_regions_from_shapefiles_worker.cpython-311.pyc new file mode 100644 index 0000000..cbeda8e Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_regions_from_shapefiles_worker.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_regions_from_shapefiles_worker.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_regions_from_shapefiles_worker.cpython-313.pyc new file mode 100644 index 0000000..2f4a92e Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_regions_from_shapefiles_worker.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_richness_rasters_director.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_richness_rasters_director.cpython-311.pyc new file mode 100644 index 0000000..e037e05 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_richness_rasters_director.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_richness_rasters_director.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_richness_rasters_director.cpython-313.pyc new file mode 100644 index 0000000..8898020 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_richness_rasters_director.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_richness_rasters_worker.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_richness_rasters_worker.cpython-311.pyc new file mode 100644 index 0000000..59cc890 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_richness_rasters_worker.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_richness_rasters_worker.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_richness_rasters_worker.cpython-313.pyc new file mode 100644 index 0000000..f1f025d Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_richness_rasters_worker.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_year_image_name_table_director.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_year_image_name_table_director.cpython-313.pyc new file mode 100644 index 0000000..0bb981c Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_year_image_name_table_director.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_year_image_name_table_worker.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_year_image_name_table_worker.cpython-311.pyc new file mode 100644 index 0000000..255fd60 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_year_image_name_table_worker.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_year_image_name_table_worker.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_year_image_name_table_worker.cpython-313.pyc new file mode 100644 index 0000000..b7821b0 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/create_species_year_image_name_table_worker.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/dismap_tools.cpython-311.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/dismap_tools.cpython-311.pyc new file mode 100644 index 0000000..1a245a1 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/dismap_tools.cpython-311.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/dismap_tools.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/dismap_tools.cpython-313.pyc new file mode 100644 index 0000000..48bab7d Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/__pycache__/dismap_tools.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/analyze_noaa_metadata.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/analyze_noaa_metadata.py new file mode 100644 index 0000000..3f4a0e2 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/analyze_noaa_metadata.py @@ -0,0 +1,44 @@ +import requests +from lxml import etree + +# 1. THE MAP: Define the namespaces so Python knows where to look +NS_MAP = { + 'gmd': 'http://www.isotc211.org/2005/gmd', + 'gco': 'http://www.isotc211.org/2005/gco', + 'gmi': 'http://www.isotc211.org/2005/gmi', + 'gml': 'http://www.opengis.net/gml/3.2' +} + +def analyze_noaa_metadata(item_id): + # The direct link to the ISO 19115 XML for this NOAA record + url = f"https://www.fisheries.noaa.gov/inportserve/waf/noaa/nmfs/ost/iso19115/xml/{item_id}.xml" + + print(f"--- Accessing NOAA Item {item_id} ---") + response = requests.get(url) + + if response.status_code == 200: + # Parse the XML content + tree = etree.fromstring(response.content) + + # 2. THE PATH: Using XPath to find the Abstract + # We look for the CharacterString inside the Abstract element + abstract_xpath = ".//gmd:abstract/gco:CharacterString/text()" + abstract = tree.xpath(abstract_xpath, namespaces=NS_MAP) + + # 3. THE RESULT: Cleanly explain the output to the student + if abstract: + print("\n[DATASET ABSTRACT]") + print(abstract[0][:300] + "...") # Print first 300 chars + + # Finding the Bounding Box (GML) + west = tree.xpath(".//gmd:westBoundLongitude/gco:Decimal/text()", namespaces=NS_MAP) + east = tree.xpath(".//gmd:eastBoundLongitude/gco:Decimal/text()", namespaces=NS_MAP) + + if west and east: + print(f"\n[SPATIAL EXTENT]\nLongitudes: {west[0]} to {east[0]}") + + else: + print("Failed to retrieve record. Check the Item ID.") + +if __name__ == "__main__": + analyze_noaa_metadata(70032) \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/copy_initial_data.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/copy_initial_data.py new file mode 100644 index 0000000..a95dc5d --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/copy_initial_data.py @@ -0,0 +1,230 @@ +""" +Script documentation +- Tool parameters are accessed using arcpy.GetParameter() or + arcpy.GetParameterAsText() +- Update derived parameter values using arcpy.SetParameter() or + arcpy.SetParameterAsText() +""" + +import os + +import arcpy + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + filename = sys.path[0] + os.sep + "test.py" + synerror = traceback.format_exc().splitlines()[-1] + return line, filename, synerror + + +def script_tool( + project_folder="", csv_data_file="", dataset_shapefiles="", contacts_file="" +): + """Script code goes below""" + try: + from io import StringIO + from zipfile import ZipFile + + from arcpy import metadata as md + from lxml import etree + + arcpy.env.overwriteOutput = True + + # aprx = arcpy.mp.ArcGISProject("CURRENT") + # aprx.save() + # project_folder = aprx.homeFolder + arcpy.AddMessage(project_folder) + out_data_path = rf"{project_folder}\CSV_Data" + + import json + + json_path = rf"{out_data_path}\root_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + root_dict = json.load(json_file) + del json_file + del json_path + del json + + arcpy.AddMessage(out_data_path) + # Change Directory + os.chdir(out_data_path) + arcpy.AddMessage(f"Un-Zipping files from {os.path.basename(csv_data_file)}") + with ZipFile(csv_data_file, mode="r") as archive: + for file in archive.namelist(): + archive.extract(file, ".") + del file + del archive + arcpy.AddMessage( + f"Done Un-Zipping files from {os.path.basename(csv_data_file)}" + ) + tmp_workspace = arcpy.env.workspace + arcpy.env.workspace = rf"{out_data_path}\python" + + csv_files = arcpy.ListFiles("*_survey.csv") + + arcpy.AddMessage("Copying CSV Files and renaming the file") + for csv_file in csv_files: + arcpy.management.Copy( + rf"{out_data_path}\python\{csv_file}", + rf"{out_data_path}\{csv_file.replace('_survey', '_IDW')}", + ) + del csv_file + del csv_files + + arcpy.env.workspace = tmp_workspace + del tmp_workspace + + if arcpy.Exists(rf"{out_data_path}\python"): + arcpy.AddMessage("Removing the extract folder") + arcpy.management.Delete(rf"{out_data_path}\python") + else: + pass + + arcpy.AddMessage("Adding metadata to CSV file") + tmp_workspace = arcpy.env.workspace + arcpy.env.workspace = out_data_path + + csv_files = arcpy.ListFiles("*_IDW.csv") + for csv_file in csv_files: + arcpy.AddMessage(f"\t{csv_file}") + dataset_md = md.Metadata(rf"{out_data_path}\{csv_file}") + dataset_md.synchronize("ALWAYS") + dataset_md.save() + dataset_md.importMetadata(contacts_file, "ARCGIS_METADATA") + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + target_tree = etree.parse( + StringIO(dataset_md.xml), + parser=etree.XMLParser(encoding="UTF-8", remove_blank_text=True), + ) + target_root = target_tree.getroot() + target_root[:] = sorted(target_root, key=lambda x: root_dict[x.tag]) + new_item_name = target_root.find( + "Esri/DataProperties/itemProps/itemName" + ).text + arcpy.AddMessage(new_item_name) + ## onLineSrcs = target_root.findall("distInfo/distTranOps/onLineSrc") + ## #arcpy.AddMessage(onLineSrcs) + ## for onLineSrc in onLineSrcs: + ## if onLineSrc.find('./protocol').text == "ESRI REST Service": + ## old_linkage_element = onLineSrc.find('./linkage') + ## old_linkage = old_linkage_element.text + ## #arcpy.AddMessage(old_linkage) + ## old_item_name = old_linkage[old_linkage.find("/services/")+len("/services/"):old_linkage.find("/FeatureServer")] + ## new_linkage = old_linkage.replace(old_item_name, new_item_name) + ## #arcpy.AddMessage(new_linkage) + ## old_linkage_element.text = new_linkage + ## #arcpy.AddMessage(old_linkage_element.text) + ## del old_linkage_element + ## del old_item_name, old_linkage, new_linkage + ## onLineSrc.find('./orName').text = f"{new_item_name} Feature Service" + ## del onLineSrcs, new_item_name + etree.indent(target_root, space=" ") + dataset_md.xml = etree.tostring( + target_tree, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + + del dataset_md + + del csv_file + del csv_files + + arcpy.env.workspace = tmp_workspace + del tmp_workspace + + # Imports + del md + + # Function Variables + del project_folder, csv_data_file, dataset_shapefiles, contacts_file + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +if __name__ == "__main__": + try: + project_folder = arcpy.GetParameterAsText(0) + if not project_folder: + project_folder = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026", + ) + else: + pass + + csv_data_file = arcpy.GetParameterAsText(1) + if not csv_data_file: + csv_data_file = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\Initial Data\\CSV Data 20260201.zip", + ) + else: + pass + + dataset_shapefiles = arcpy.GetParameterAsText(2) + if not dataset_shapefiles: + dataset_shapefiles = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\Initial Data\\Dataset Shapefiles 20260201.zip", + ) + else: + pass + + contacts_file = arcpy.GetParameterAsText(3) + if not contacts_file: + contacts_file = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\Initial Data\\DisMAP Contacts 20260201.xml", + ) + else: + pass + + script_tool(project_folder, csv_data_file, dataset_shapefiles, contacts_file) + + arcpy.SetParameterAsText(3, True) + + del project_folder, csv_data_file, dataset_shapefiles, contacts_file + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_base_bathymetry.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_base_bathymetry.py new file mode 100644 index 0000000..b0a5592 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_base_bathymetry.py @@ -0,0 +1,844 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: create_base_bathymetry +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 05/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import os +import sys + +import arcpy # third-parties second + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] if ", " in tbinfo else "?" + filename = sys.path[0] + os.sep + "test.py" + synerror = traceback.print_exc() + return line, filename, synerror + + +def raster_properties_report(dataset=""): + try: + if not dataset: + arcpy.AddWarning(f"{dataset} is missing") + return False + if not arcpy.Exists(dataset): + arcpy.AddError(f"Dataset not found: {dataset}") + return False + pixel_types = { + "U1": "1 bit", + "U2": "2 bits", + "U4": "4 bits", + "U8": "Unsigned 8-bit integers", + "S8": "8-bit integers", + "U16": "Unsigned 16-bit integers", + "S16": "16-bit integers", + "U32": "Unsigned 32-bit integers", + "S32": "32-bit integers", + "F32": "Single-precision floating point", + "F64": "Double-precision floating point", + } + + raster = arcpy.Raster(dataset) + + arcpy.AddMessage(f"\t\t {raster.name}") + arcpy.AddMessage( + f"\t\t\t Spatial Reference: {raster.spatialReference.name}" + ) + arcpy.AddMessage( + f"\t\t\t XYResolution: {raster.spatialReference.XYResolution} {raster.spatialReference.linearUnitName}s" + ) + arcpy.AddMessage( + f"\t\t\t XYTolerance: {raster.spatialReference.XYTolerance} {raster.spatialReference.linearUnitName}s" + ) + arcpy.AddMessage( + f"\t\t\t Extent: {raster.extent.XMin} {raster.extent.YMin} {raster.extent.XMax} {raster.extent.YMax} (XMin, YMin, XMax, YMax)" + ) + arcpy.AddMessage( + f"\t\t\t Cell Size: {raster.meanCellHeight}, {raster.meanCellWidth} (H, W)" + ) + arcpy.AddMessage( + f"\t\t\t Rows, Columns: {raster.height} {raster.width} (H, W)" + ) + arcpy.AddMessage( + f"\t\t\t Statistics: {raster.minimum} {raster.maximum} {raster.mean} {raster.standardDeviation} (Min, Max, Mean, STD)" + ) + arcpy.AddMessage( + f"\t\t\t Pixel Type: {pixel_types[raster.pixelType]}" + ) + + del raster + del pixel_types + del dataset + + except arcpy.ExecuteError: + line, filename, err = trace() + arcpy.AddError(f"Geoprocessing error on {line} of {filename} :\n{err}") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except Exception as e: + line, filename, err = trace() + arcpy.AddError(f"Python error on {line} of {filename}\n{err}") + return False + else: + return True + + +def create_alasaka_bathymetry(project_folder=""): + try: + # Imports + import dismap_tools + from arcpy import metadata as md + + # Set History and Metadata logs, set serverity and message level + arcpy.SetLogHistory(True) + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel(1) + arcpy.SetMessageLevels(["NORMAL"]) + + # Set basic workkpace variables + csv_data_folder = os.path.join(project_folder, "CSV_Data") + arcpy.env.workspace = rf"{project_folder}\Bathymetry\Bathymetry.gdb" + arcpy.env.scratchWorkspace = rf"{project_folder}\Scratch\scratch.gdb" + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + arcpy.env.cellSize = 1000 + arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR DEFAULT 75 NO_SKIP" + arcpy.env.rasterStatistics = "STATISTICS 1 1" + arcpy.env.resamplingMethod = "BILINEAR" + arcpy.env.outputCoordinateSystem = None + + arcpy.AddMessage("Processing Alaska Bathymetry") + + # Setting up the base folder bathymetry for all projects + ai_bathy = rf"{project_folder}\Bathymetry\Alaska Bathymetry\AI_IDW_Bathy.grd" + ebs_bathy = rf"{project_folder}\Bathymetry\Alaska Bathymetry\EBS_IDW_Bathy.grd" + goa_bathy = rf"{project_folder}\Bathymetry\Alaska Bathymetry\GOA_IDW_Bathy.grd" + + # Fail fast if files are missing + for f in [ai_bathy, ebs_bathy, goa_bathy]: + if not arcpy.Exists(f): + arcpy.AddError(f"Missing required raster: {f}") + return False + + ai_bathy_grid = rf"{project_folder}\Bathymetry\Bathymetry.gdb\AI_IDW_Bathy_Grid" + ebs_bathy_grid = rf"{project_folder}\Bathymetry\Bathymetry.gdb\EBS_IDW_Bathy_Grid" + goa_bathy_grid = rf"{project_folder}\Bathymetry\Bathymetry.gdb\GOA_IDW_Bathy_Grid" + + ai_bathy_raster = rf"{project_folder}\Bathymetry\Bathymetry.gdb\AI_IDW_Bathy_Raster" + ebs_bathy_raster = rf"{project_folder}\Bathymetry\Bathymetry.gdb\EBS_IDW_Bathy_Raster" + goa_bathy_raster = rf"{project_folder}\Bathymetry\Bathymetry.gdb\GOA_IDW_Bathy_Raster" + + ai_bathymetry = rf"{project_folder}\Bathymetry\Bathymetry.gdb\AI_IDW_Bathymetry" + ebs_bathymetry = rf"{project_folder}\Bathymetry\Bathymetry.gdb\EBS_IDW_Bathymetry" + goa_bathymetry = rf"{project_folder}\Bathymetry\Bathymetry.gdb\GOA_IDW_Bathymetry" + enbs_bathymetry = rf"{project_folder}\Bathymetry\Bathymetry.gdb\ENBS_IDW_Bathymetry" + nbs_bathymetry = rf"{project_folder}\Bathymetry\Bathymetry.gdb\NBS_IDW_Bathymetry" + + arcpy.AddMessage("Processing Esri Raster Grids") + + spatial_ref = arcpy.Describe(ai_bathy).spatialReference.name + arcpy.AddMessage(f"Spatial Reference for {os.path.basename(ai_bathy)}: {spatial_ref}") + spatial_ref = arcpy.Describe(ai_bathy).spatialReference + arcpy.env.outputCoordinateSystem = spatial_ref + + if spatial_ref.linearUnitName == "Kilometer": + arcpy.env.cellSize = 1 + arcpy.env.XYResolution = 0.1 + arcpy.env.XYResolution = 1.0 + elif spatial_ref.linearUnitName == "Meter": + arcpy.env.cellSize = 1000 + arcpy.env.XYResolution = 0.0001 + arcpy.env.XYResolution = 0.001 + del spatial_ref + + arcpy.AddMessage("Copy AI_IDW_Bathy.grd to AI_IDW_Bathy_Grid") + arcpy.management.CopyRaster(ai_bathy, ai_bathy_grid) + arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + del ai_bathy + + arcpy.AddMessage("Copy EBS_IDW_Bathy.grd to EBS_IDW_Bathy_Grid") + arcpy.management.CopyRaster(ebs_bathy, ebs_bathy_grid) + arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + del ebs_bathy + + arcpy.AddMessage("Copy GOA_IDW_Bathy.grd to GOA_IDW_Bathy_Grid") + arcpy.management.CopyRaster(goa_bathy, goa_bathy_grid) + arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + del goa_bathy + + arcpy.AddMessage("Converting AI_IDW_Bathy_Grid from positive values to negative") + tmp_grid = arcpy.sa.Times(ai_bathy_grid, -1) + arcpy.AddMessage("\tTimes: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + tmp_grid.save(ai_bathy_raster) + del tmp_grid + + arcpy.AddMessage("Converting EBS_IDW_Bathy_Grid from positive values to negative") + tmp_grid = arcpy.sa.Times(ebs_bathy_grid, -1) + arcpy.AddMessage("\tTimes: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + tmp_grid.save(ebs_bathy_raster) + del tmp_grid + + arcpy.AddMessage("Setting values equal to and less than 0 in the GOA_IDW_Bathy_Grid Null values") + tmp_grid = arcpy.sa.SetNull(goa_bathy_grid, goa_bathy_grid, "Value < -1.0") + arcpy.AddMessage("\tSet Null: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + tmp_grid.save(goa_bathy_raster + "_SetNull") + del tmp_grid + + arcpy.AddMessage("Converting the GOA_IDW_Bathy_Grid from positive values to negative") + tmp_grid = arcpy.sa.Times(goa_bathy_raster + "_SetNull", -1) + arcpy.AddMessage("\tTimes: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + tmp_grid.save(goa_bathy_raster) + del tmp_grid + + arcpy.AddMessage("Deleteing the GOA_IDW_Bathy Null grid") + arcpy.management.Delete(goa_bathy_raster + "_SetNull") + arcpy.AddMessage("\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + + arcpy.AddMessage("Appending the AI raster to the GOA grid to ensure complete coverage") + extent = arcpy.Describe(goa_bathy_raster).extent + X_Min, Y_Min, X_Max, Y_Max = ( + extent.XMin - (1000 * 366), + extent.YMin - (1000 * 80), + extent.XMax, + extent.YMax, + ) + extent = f"{X_Min} {Y_Min} {X_Max} {Y_Max}" + arcpy.env.extent = extent + + arcpy.management.Append( + inputs=ai_bathy_raster, + target=goa_bathy_raster, + schema_type="TEST", + field_mapping="", + subtype="", + ) + arcpy.AddMessage("\tAppend: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + + arcpy.AddMessage("Cliping GOA Raster") + arcpy.management.Clip(goa_bathy_raster, extent, goa_bathy_raster + "_Clip") + arcpy.AddMessage("\tClip: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + del extent + + arcpy.AddMessage("Copying GOA Raster") + arcpy.management.CopyRaster(goa_bathy_raster + "_Clip", goa_bathy_raster) + arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + + arcpy.management.Delete(goa_bathy_raster + "_Clip") + arcpy.AddMessage("\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + + arcpy.AddMessage("Appending the EBS raster to the AI grid to ensure complete coverage") + extent = arcpy.Describe(ai_bathy_raster).extent + X_Min, Y_Min, X_Max, Y_Max = extent.XMin, extent.YMin, extent.XMax, extent.YMax + extent = f"{X_Min} {Y_Min} {X_Max} {Y_Max}" + arcpy.env.extent = extent + del X_Min, Y_Min, X_Max, Y_Max + + arcpy.management.Append( + inputs=ebs_bathy_raster, + target=ai_bathy_raster, + schema_type="TEST", + field_mapping="", + subtype="", + ) + arcpy.AddMessage("\tAppend: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + + arcpy.AddMessage("Cliping AI Raster") + arcpy.management.Clip(ai_bathy_raster, extent, ai_bathy_raster + "_Clip") + arcpy.AddMessage("\tClip: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + del extent + + arcpy.AddMessage("Copying AI Raster") + arcpy.management.CopyRaster(ai_bathy_raster + "_Clip", ai_bathy_raster) + arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + + arcpy.ClearEnvironment("extent") + + # Final copy of rasters in Base Folder Start + region = "AI_IDW" + arcpy.env.outputCoordinateSystem = arcpy.SpatialReference( + rf"{project_folder}\Dataset Shapefiles\{region}\{region}_Region.prj" + ) + del region + arcpy.AddMessage("Copy AI_IDW_Bathymetry_Raster to AI_IDW_Bathymetry") + arcpy.management.CopyRaster(ai_bathy_raster, ai_bathymetry) + arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + arcpy.AddMessage(f"Importing metadata for {os.path.basename(ai_bathymetry)}") + dismap_tools.import_metadata(csv_data_folder, ai_bathymetry) + ai_md = md.Metadata(ai_bathymetry) + ai_md.title = os.path.basename(ai_bathymetry).replace("_", " ") + ai_md.save() + ai_md.synchronize("ALWAYS") + ai_md.save() + del ai_md + + region = "EBS_IDW" + arcpy.env.outputCoordinateSystem = arcpy.SpatialReference( + rf"{project_folder}\Dataset Shapefiles\{region}\{region}_Region.prj" + ) + del region + arcpy.AddMessage("Copy EBS_IDW_Bathymetry_Raster to EBS_IDW_Bathymetry") + arcpy.management.CopyRaster(ebs_bathy_raster, ebs_bathymetry) + arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + arcpy.AddMessage(f"Importing metadata for {os.path.basename(ebs_bathymetry)}") + dismap_tools.import_metadata(csv_data_folder, ebs_bathymetry) + ebs_md = md.Metadata(ebs_bathymetry) + ebs_md.title = os.path.basename(ebs_bathymetry).replace("_", " ") + ebs_md.save() + ebs_md.synchronize("ALWAYS") + ebs_md.save() + del ebs_md + + region = "ENBS_IDW" + arcpy.env.outputCoordinateSystem = arcpy.SpatialReference( + rf"{project_folder}\Dataset Shapefiles\{region}\{region}_Region.prj" + ) + del region + arcpy.AddMessage("Copy EBS_IDW_Bathymetry_Raster to ENBS_Bathymetry") + arcpy.management.CopyRaster(ebs_bathy_raster, enbs_bathymetry) + arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + arcpy.AddMessage(f"Importing metadata for {os.path.basename(enbs_bathymetry)}") + dismap_tools.import_metadata(csv_data_folder, enbs_bathymetry) + enbs_md = md.Metadata(enbs_bathymetry) + enbs_md.title = os.path.basename(enbs_bathymetry).replace("_", " ") + enbs_md.save() + enbs_md.synchronize("ALWAYS") + enbs_md.save() + del enbs_md + + region = "NBS_IDW" + arcpy.env.outputCoordinateSystem = arcpy.SpatialReference( + rf"{project_folder}\Dataset Shapefiles\{region}\{region}_Region.prj" + ) + del region + arcpy.AddMessage("Copy EBS_IDW_Bathymetry_Raster to NBS_Bathymetry") + arcpy.management.CopyRaster(ebs_bathy_raster, nbs_bathymetry) + arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + arcpy.AddMessage(f"Importing metadata for {os.path.basename(nbs_bathymetry)}") + dismap_tools.import_metadata(csv_data_folder, nbs_bathymetry) + nbs_md = md.Metadata(nbs_bathymetry) + nbs_md.title = os.path.basename(nbs_bathymetry).replace("_", " ") + nbs_md.save() + nbs_md.synchronize("ALWAYS") + nbs_md.save() + del nbs_md + + region = "GOA_IDW" + arcpy.env.outputCoordinateSystem = arcpy.SpatialReference( + rf"{project_folder}\Dataset Shapefiles\{region}\{region}_Region.prj" + ) + del region + arcpy.AddMessage("Copy GOA_IDW_Bathymetry_Raster to GOA_IDW_Bathymetry") + arcpy.management.CopyRaster(goa_bathy_raster, goa_bathymetry) + arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + arcpy.AddMessage(f"Importing metadata for {os.path.basename(goa_bathymetry)}") + dismap_tools.import_metadata(csv_data_folder, goa_bathymetry) + goa_md = md.Metadata(goa_bathymetry) + goa_md.title = os.path.basename(goa_bathymetry).replace("_", " ") + goa_md.save() + goa_md.synchronize("ALWAYS") + goa_md.save() + del goa_md + + del ai_bathy_grid, ebs_bathy_grid, goa_bathy_grid + del ai_bathy_raster, ebs_bathy_raster, goa_bathy_raster + + gdb = rf"{project_folder}\Bathymetry\Bathymetry.gdb" + arcpy.AddMessage(f"Compacting the {os.path.basename(gdb)} GDB") + arcpy.management.Compact(gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + del gdb + + # Declared Variables for this function only + del csv_data_folder + del ai_bathymetry, ebs_bathymetry, goa_bathymetry, enbs_bathymetry, nbs_bathymetry + # Imports + del md, dismap_tools + # Function parameter + del project_folder + + except arcpy.ExecuteError: + line, filename, err = trace() + arcpy.AddError(f"Geoprocessing error on {line} of {filename} :\n{err}") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except Exception as e: + line, filename, err = trace() + arcpy.AddError(f"Python error on {line} of {filename}\n{err}") + return False + else: + return True + + +def create_hawaii_bathymetry(project_folder=""): + try: + # Imports + import dismap_tools + from arcpy import metadata as md + + # Set History and Metadata logs, set serverity and message level + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # Set basic workkpace variables + csv_data_folder = os.path.join(project_folder, "CSV_Data") + arcpy.env.workspace = rf"{project_folder}\Bathymetry\Bathymetry.gdb" + arcpy.env.scratchWorkspace = rf"{project_folder}\Scratch\scratch.gdb" + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + arcpy.env.cellSize = 500 + + arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR DEFAULT 75 NO_SKIP" + arcpy.env.rasterStatistics = "STATISTICS 1 1" + arcpy.env.resamplingMethod = "BILINEAR" + + arcpy.env.outputCoordinateSystem = None + + hi_bathy_grid = rf"{project_folder}\Bathymetry\Hawaii Bathymetry\BFISH_PSU.shp" + hi_bathy_raster = ( + rf"{project_folder}\Bathymetry\Bathymetry.gdb\HI_IDW_Bathy_Raster" + ) + hi_bathymetry = rf"{project_folder}\Bathymetry\Bathymetry.gdb\HI_IDW_Bathymetry" + + arcpy.AddMessage("Converting Hawaii Polygon Grid to a Raster") + + arcpy.conversion.PolygonToRaster( + in_features=hi_bathy_grid, + value_field="Depth_MEDI", + out_rasterdataset=hi_bathy_raster, + cell_assignment="CELL_CENTER", + priority_field="NONE", + cellsize="500", + ) + arcpy.AddMessage( + "\tPolygon To Raster: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + + tmp_grid = arcpy.sa.Times(hi_bathy_raster, -1.0) + arcpy.AddMessage( + "\tTimes: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + tmp_grid.save(hi_bathymetry) + del tmp_grid + + arcpy.AddMessage(f"Importing metadata for {os.path.basename(hi_bathymetry)}") + dismap_tools.import_metadata(csv_data_folder, hi_bathymetry) + hi_md = md.Metadata(hi_bathymetry) + hi_md.title = os.path.basename(hi_bathymetry).replace("_", " ") + hi_md.save() + hi_md.synchronize("ALWAYS") + hi_md.save() + del hi_md + + ## arcpy.AddMessage("Copy Hawaii Raster to the Bathymetry GDB") + ## + ## arcpy.management.CopyRaster(hi_bathymetry, rf"{project_folder}\Bathymetry\Bathymetry.gdb\HI_IDW_Bathymetry") + ## arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) + ## + ## gdb = rf"{project_folder}\Bathymetry\Bathymetry.gdb" + ## arcpy.AddMessage(f"Compacting the {os.path.basename(gdb)} GDB") + ## arcpy.management.Compact(gdb) + ## arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) + ## del gdb + + gdb = rf"{project_folder}\Bathymetry\Bathymetry.gdb" + arcpy.AddMessage(f"Compacting the {os.path.basename(gdb)} GDB") + arcpy.management.Compact(gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + del gdb + + # Declared Variables for this function only + del csv_data_folder, hi_bathy_grid, hi_bathy_raster, hi_bathymetry + # Imports + del md, dismap_tools + # Function parameter + del project_folder + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def gebco_bathymetry(project_folder=""): + try: + + # Imports + import dismap_tools + from arcpy import metadata as md + + # Set History and Metadata logs, set serverity and message level + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # Set basic workkpace variables + csv_data_folder = os.path.join(project_folder, "CSV_Data") + arcpy.env.workspace = rf"{project_folder}\Bathymetry\Bathymetry.gdb" + arcpy.env.scratchWorkspace = rf"{project_folder}\Scratch\scratch.gdb" + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + arcpy.env.cellSize = 1000 + + arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR DEFAULT 75 NO_SKIP" + arcpy.env.rasterStatistics = "STATISTICS 1 1" + arcpy.env.resamplingMethod = "BILINEAR" + + arcpy.env.outputCoordinateSystem = None + + arcpy.AddMessage("Processing GEBCO Raster Grids") + + # gebco_dict = get_dms_points_for_gebco(project_gdb) + gebco_dict = { + "GMEX_IDW": "gebco_2022_n30.6_s25.8_w-97.4_e-81.6.asc", + "NEUS_FAL_IDW": "gebco_2022_n44.8_s35.0_w-75.8_e-65.4.asc", + "NEUS_SPR_IDW": "gebco_2022_n44.8_s35.0_w-75.8_e-65.4.asc", + "SEUS_FAL_IDW": "gebco_2022_n35.4_s28.6_w-81.4_e-75.6.asc", + "SEUS_SPR_IDW": "gebco_2022_n35.4_s28.6_w-81.4_e-75.6.asc", + "SEUS_SUM_IDW": "gebco_2022_n35.4_s28.6_w-81.4_e-75.6.asc", + "WC_ANN_IDW": "gebco_2022_n48.6_s32.0_w-126.0_e-115.8.asc", + "WC_TRI_IDW": "gebco_2022_n49.2_s36.0_w-126.6_e-121.6.asc", + } + + arcpy.AddMessage("Processing Regions") + # Start looping over the datasets array as we go region by region. + for table_name in gebco_dict: + gebco_file_name = gebco_dict[table_name] + + gebco_grid = ( + rf"{project_folder}\Bathymetry\GEBCO Bathymetry\{gebco_file_name}" + ) + bathy_grid = ( + rf"{project_folder}\Bathymetry\Bathymetry.gdb\{table_name}_Bathy_Grid" + ) + bathy_raster = ( + rf"{project_folder}\Bathymetry\Bathymetry.gdb\{table_name}_Bathy_Raster" + ) + bathymetry = ( + rf"{project_folder}\Bathymetry\Bathymetry.gdb\{table_name}_Bathymetry" + ) + + arcpy.AddMessage( + f"Copy GEBCO File: {os.path.basename(gebco_grid)} to {os.path.basename(bathy_grid)}" + ) + + # Execute ASCIIToRaster + arcpy.conversion.ASCIIToRaster(gebco_grid, bathy_grid, "FLOAT") + arcpy.AddMessage( + "\tASCII To Raster: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + + arcpy.AddMessage(f"Define projection for {os.path.basename(bathy_grid)}") + + arcpy.management.DefineProjection( + bathy_grid, gebco_grid.replace(".asc", ".prj") + ) + arcpy.AddMessage( + "\tDefine Projection: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + + arcpy.AddMessage( + f"Project Raster to create: {os.path.basename(bathy_raster)}" + ) + + # Get the reference system defined for the region in datasets + # Set the output coordinate system to what is needed for the + # DisMAP project + region_sr = arcpy.SpatialReference( + rf"{project_folder}\Dataset Shapefiles\{table_name}\{table_name}_Region.prj" + ) + + if region_sr.linearUnitName == "Kilometer": + arcpy.env.cellSize = 0.1 + arcpy.env.XYResolution = 0.0001 + arcpy.env.XYResolution = 0.001 + elif region_sr.linearUnitName == "Meter": + arcpy.env.cellSize = 1000 + arcpy.env.XYResolution = 0.0001 + arcpy.env.XYResolution = 0.001 + + arcpy.env.outputCoordinateSystem = region_sr + # arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" + transform = dismap_tools.check_transformation(bathy_grid, region_sr) + arcpy.env.geographicTransformations = transform + + arcpy.AddMessage(f"\tOut Spatial Reference: {region_sr.name}") + arcpy.AddMessage(f"\tGeographic Transformations: {transform}") + + # Project Raster management + arcpy.management.ProjectRaster( + in_raster=bathy_grid, out_raster=bathy_raster, out_coor_system=region_sr + ) + arcpy.AddMessage( + "\tProject Raster: {0}".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + + # Cleanup after last use + del region_sr, transform + + arcpy.AddMessage( + f"Set Null for positive elevation values to create: {os.path.basename(bathymetry)}" + ) + with arcpy.EnvManager( + scratchWorkspace=arcpy.env.scratchGDB, workspace=arcpy.env.workspace + ): + out_raster = arcpy.sa.SetNull( + in_conditional_raster=bathy_raster, + in_false_raster_or_constant=bathy_raster, + where_clause="Value > 1.0", + ) + arcpy.AddMessage( + "\tSet Null: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + out_raster.save(bathymetry) + del out_raster + + arcpy.AddMessage(f"Importing metadata for {os.path.basename(bathymetry)}") + dismap_tools.import_metadata(csv_data_folder, bathymetry) + bathy_md = md.Metadata(bathymetry) + bathy_md.title = os.path.basename(bathymetry).replace("_", " ") + bathy_md.save() + bathy_md.synchronize("ALWAYS") + bathy_md.save() + del bathy_md + + del gebco_grid, bathy_grid, bathy_raster, bathymetry + del gebco_file_name, table_name + + del gebco_dict + + gdb = rf"{project_folder}\Bathymetry\Bathymetry.gdb" + arcpy.AddMessage(f"Compacting the {os.path.basename(gdb)} GDB") + arcpy.management.Compact(gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + del gdb + + # Declared Variables for this function only + del csv_data_folder + # Imports + del md, dismap_tools + # Function parameter + del project_folder + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def main(project_folder=""): + try: + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + # Create Scratch Workspace for Project + if not arcpy.Exists(rf"{project_folder}\Scratch\scratch.gdb"): + if not arcpy.Exists(rf"{project_folder}\Scratch"): + os.makedirs(rf"{project_folder}\Scratch") + if not arcpy.Exists(rf"{project_folder}\Scratch\scratch.gdb"): + arcpy.management.CreateFileGDB(rf"{project_folder}\Scratch", "scratch") + + # Base Bathymetry Folder + if not os.path.isdir(rf"{project_folder}\Bathymetry"): + arcpy.AddMessage("Create Folder: 'Bathymetry'") + arcpy.management.CreateFolder(rf"{project_folder}\Bathymetry") + get_messages = "\t" + arcpy.GetMessages().replace("\n", "\n\t") + "\n" + arcpy.AddMessage(f"{get_messages}") + del get_messages + else: + pass + # Base Bathymetry GDB + if not arcpy.Exists(rf"{project_folder}\Bathymetry\Bathymetry.gdb"): + arcpy.AddMessage("Create File GDB: 'Bathymetry.gdb'") + arcpy.management.CreateFileGDB( + rf"{project_folder}\Bathymetry", "Bathymetry" + ) + get_messages = "\t" + arcpy.GetMessages().replace("\n", "\n\t") + "\n" + arcpy.AddMessage(f"{get_messages}") + del get_messages + else: + pass + + test = True + # Process base Alaska bathymetry + if test: + result = create_alasaka_bathymetry(project_folder) + # arcpy.AddMessage(result) + del result + else: + pass + + test = False + # Process base Hawaii bathymetry + if test: + result = create_hawaii_bathymetry(project_folder) + # arcpy.AddMessage(result) + del result + else: + pass + + test = False + # Process base GEBCO bathymetry + if test: + result = gebco_bathymetry(project_folder) + # arcpy.AddMessage(result) + del result + else: + pass + + del test + + # Declared Varaiables + + # Imports + + # Function Parameters + del project_folder + + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage( + f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}" + ) + arcpy.AddMessage( + "Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) + ) + arcpy.AddMessage(f"{'-' * 80}") + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +if __name__ == "__main__": + try: + project_folder = arcpy.GetParameterAsText(0) + + if not project_folder: + project_folder = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python", + ) + else: + pass + + result = main(project_folder) + arcpy.SetParameterAsText(1, result) + del result + + # Declared Variables + del project_folder + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_data_dictionary_json_files.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_data_dictionary_json_files.py new file mode 100644 index 0000000..a6eb284 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_data_dictionary_json_files.py @@ -0,0 +1,2416 @@ +""" +Script documentation + +- Tool parameters are accessed using arcpy.GetParameter() or + arcpy.GetParameterAsText() +- Update derived parameter values using arcpy.SetParameter() or + arcpy.SetParameterAsText() +""" + + +import os +import inspect +import traceback +import json + +import arcpy + + +def script_tool(project_gdb=""): + """Script code goes below""" + try: + # Imports + # Use all of the cores on the machine + arcpy.env.parallelProcessingFactor = "100%" + arcpy.env.overwriteOutput = True + + # Define variables + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{project_folder}\Scratch" + scratch_gdb = os.path.join(scratch_folder, "scratch.gdb") + + # Set the workspace environment to local file geodatabase + arcpy.env.workspace = project_gdb + # Set the scratchWorkspace environment to local file geodatabase + arcpy.env.scratchWorkspace = scratch_gdb + # Clean-up variables + del scratch_folder, scratch_gdb + + arcpy.AddMessage(f"\n{'--Start' * 10}--\n") + arcpy.AddMessage( + f"Creating Table and Field definitions for: {os.path.basename(project_gdb)}" + ) + + field_definitions = { + "Absence_Presence": { + "field_aliasName": "Absence Presence", + "field_baseName": "Absence_Presence", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 4, + "field_name": "Absence_Presence", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Integer", + "field_attrdef": "Absence Presence", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Absence Presence"}, + }, + "Bio_Inc_Dec": { + "field_aliasName": "Bio_Inc_Dec", + "field_baseName": "Bio_Inc_Dec", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 30, + "field_name": "Bio_Inc_Dec", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Bio_Inc_Dec", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Bio_Inc_Dec"}, + }, + "Child_GUID": { + "field_aliasName": "Child GUID", + "field_baseName": "Child_GUID", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 30, + "field_name": "Child_GUID", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Child_GUID", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Child_GUID"}, + }, + "CSVFile": { + "field_aliasName": "CSV File", + "field_baseName": "CSVFile", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 20, + "field_name": "CSVFile", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "CSV File", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "CSV File"}, + }, + "Category": { + "field_aliasName": "Category", + "field_baseName": "Category", + "field_defaultValue": "null", + "field_domain": "MosaicCatalogItemCategoryDomain", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 4, + "field_name": "Category", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Integer", + "field_attrdef": "Category", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Category"}, + }, + "CellSize": { + "field_aliasName": "Cell Size", + "field_baseName": "CellSize", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 4, + "field_name": "CellSize", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Cell Size", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Cell Size"}, + }, + "CenterOfGravityDepth": { + "field_aliasName": "Center of Gravity Depth", + "field_baseName": "CenterOfGravityDepth", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "CenterOfGravityDepth", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Center of Gravity Depth", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Center of Gravity Depth"}, + }, + "CenterOfGravityDepthSE": { + "field_aliasName": "Center of Gravity Depth Standard Error", + "field_baseName": "CenterOfGravityDepthSE", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "CenterOfGravityDepthSE", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Center of Gravity Depth Standard Error", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Center of Gravity Depth Standard Error"}, + }, + "CenterOfGravityLatitude": { + "field_aliasName": "Center of Gravity Latitude", + "field_baseName": "CenterOfGravityLatitude", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "CenterOfGravityLatitude", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Center of Gravity Latitude", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Center of Gravity Latitude"}, + }, + "CenterOfGravityLatitudeSE": { + "field_aliasName": "Center of Gravity Latitude Standard Error", + "field_baseName": "CenterOfGravityLatitudeSE", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "CenterOfGravityLatitudeSE", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Center of Gravity Latitude Standard Error", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Center of Gravity Latitude Standard Error"}, + }, + "CenterOfGravityLongitude": { + "field_aliasName": "Center of Gravity Longitude", + "field_baseName": "CenterOfGravityLongitude", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "CenterOfGravityLongitude", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Center of Gravity Longitude", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Center of Gravity Longitude"}, + }, + "CenterOfGravityLongitudeSE": { + "field_aliasName": "Center of Gravity Longitude Standard Error", + "field_baseName": "CenterOfGravityLongitudeSE", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "CenterOfGravityLongitudeSE", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Center of Gravity Longitude Standard Error", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": { + "udom": "Center of Gravity Longitude Standard Error" + }, + }, + "CenterX": { + "field_aliasName": "CenterX", + "field_baseName": "CenterX", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "CenterX", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "CenterX", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "CenterX"}, + }, + "CenterY": { + "field_aliasName": "CenterY", + "field_baseName": "CenterY", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "CenterY", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "CenterY", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "CenterY"}, + }, + "CommonName": { + "field_aliasName": "Common Name", + "field_baseName": "CommonName", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 40, + "field_name": "CommonName", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Common Name", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Common Name"}, + }, + "CommonNameSpecies": { + "field_aliasName": "Common Name (Species)", + "field_baseName": "CommonNameSpecies", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 90, + "field_name": "CommonNameSpecies", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Common Name (Species)", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Common Name (Species)"}, + }, + "CoreSpecies": { + "field_aliasName": "Core Species", + "field_baseName": "CoreSpecies", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 5, + "field_name": "CoreSpecies", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Core Species", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Core Species"}, + }, + "Count": { + "field_aliasName": "Count", + "field_baseName": "Count", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "false", + "field_isNullable": "true", + "field_length": 8, + "field_name": "Count", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Count", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Count"}, + }, + "DataCitation": { + "field_aliasName": "Data Citation", + "field_baseName": "DataCitation", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 255, + "field_name": "DataCitation", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Data Citation", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Data Citation"}, + }, + "DataFilteringNotes": { + "field_aliasName": "Data Filtering Notes", + "field_baseName": "DataFilteringNotes", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 150, + "field_name": "DataFilteringNotes", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Data Filtering Notes", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Data Filtering Notes"}, + }, + "DataSource": { + "field_aliasName": "Data Source", + "field_baseName": "DataSource", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 100, + "field_name": "DataSource", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Data Source", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Data Source"}, + }, + "DatasetCode": { + "field_aliasName": "Dataset Code", + "field_baseName": "DatasetCode", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 50, + "field_name": "DatasetCode", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Dataset Code", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Dataset Code"}, + }, + "DateCode": { + "field_aliasName": "Date Code", + "field_baseName": "DateCode", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 20, + "field_name": "DateCode", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Date Code", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Date Code"}, + }, + "Depth": { + "field_aliasName": "Depth", + "field_baseName": "Depth", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "Depth", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Depth", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Depth"}, + }, + "Dimensions": { + "field_aliasName": "Dimensions", + "field_baseName": "Dimensions", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 10, + "field_name": "Dimensions", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Dimensions", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Dimensions"}, + }, + "DistributionProjectCode": { + "field_aliasName": "Distribution Project Code", + "field_baseName": "DistributionProjectCode", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 10, + "field_name": "DistributionProjectCode", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Distribution Project Code", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Distribution Project Code"}, + }, + "DistributionProjectName": { + "field_aliasName": "Distribution Project Name", + "field_baseName": "DistributionProjectName", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 60, + "field_name": "DistributionProjectName", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Distribution Project Name", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Distribution Project Name"}, + }, + "Easting": { + "field_aliasName": "Easting", + "field_baseName": "Easting", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "Easting", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Easting", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Easting"}, + }, + "FeatureClassName": { + "field_aliasName": "Feature Class Name", + "field_baseName": "FeatureClassName", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 60, + "field_name": "FeatureClassName", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Feature Class Name", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Feature Class Name"}, + }, + "FeatureServiceName": { + "field_aliasName": "Feature Service Name", + "field_baseName": "FeatureServiceName", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 60, + "field_name": "FeatureServiceName", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Feature Service Name", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Feature Service Name"}, + }, + "FeatureServiceTitle": { + "field_aliasName": "Feature Service Title", + "field_baseName": "FeatureServiceTitle", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 80, + "field_name": "FeatureServiceTitle", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Feature Service Title", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Feature Service Title"}, + }, + "FilterRegion": { + "field_aliasName": "Filter Region", + "field_baseName": "FilterRegion", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 25, + "field_name": "FilterRegion", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Filter Region", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Filter Region"}, + }, + "FilterSubRegion": { + "field_aliasName": "Filter Sub-Region", + "field_baseName": "FilterSubRegion", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 40, + "field_name": "FilterSubRegion", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Filter Sub-Region", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Filter Sub-Region"}, + }, + "Frequency": { + "field_aliasName": "Frequency", + "field_baseName": "Frequency", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 25, + "field_name": "Frequency", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Frequency", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Frequency"}, + }, + "GearType": { + "field_aliasName": "Gear Type", + "field_baseName": "GearType", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 150, + "field_name": "GearType", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Gear Type", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Gear Type"}, + }, + "GeographicArea": { + "field_aliasName": "Geographic Area", + "field_baseName": "GeographicArea", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 20, + "field_name": "GeographicArea", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Geographic Area", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Geographic Area"}, + }, + "Grandchild_GUID": { + "field_aliasName": "Grandchild_GUID", + "field_baseName": "Grandchild_GUID", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 30, + "field_name": "Grandchild_GUID", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Grandchild_GUID", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Grandchild_GUID"}, + }, + "GroupName": { + "field_aliasName": "Group Name", + "field_baseName": "GroupName", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 100, + "field_name": "GroupName", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Group Name", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Group Name"}, + }, + "HaulBin": { + "field_aliasName": "Haul Bin", + "field_baseName": "HaulBin", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 20, + "field_name": "HaulBin", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Haul Bin", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Haul Bin"}, + }, + "Haul_Inc_Dec": { + "field_aliasName": "Haul_Inc_Dec", + "field_baseName": "Haul_Inc_Dec", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 30, + "field_name": "Haul_Inc_Dec", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Haul_Inc_Dec", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Haul_Inc_Dec"}, + }, + "HaulProportion": { + "field_aliasName": "Haul Proportion", + "field_baseName": "HaulProportion", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "HaulProportion", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Haul Proportion", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Haul Proportion"}, + }, + "HighPS": { + "field_aliasName": "HighPS", + "field_baseName": "HighPS", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "HighPS", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "HighPS", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "HighPS"}, + }, + "ID": { + "field_aliasName": "ID", + "field_baseName": "ID", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 2, + "field_name": "ID", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "ID", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "ID"}, + }, + "ImageName": { + "field_aliasName": "Image Name", + "field_baseName": "ImageName", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 100, + "field_name": "ImageName", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Image Name", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Image Name"}, + }, + "ImageServiceName": { + "field_aliasName": "Image Service Name", + "field_baseName": "ImageServiceName", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 40, + "field_name": "ImageServiceName", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Image Service Name", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Image Service Name"}, + }, + "ImageServiceTitle": { + "field_aliasName": "Image Service Title", + "field_baseName": "ImageServiceTitle", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 60, + "field_name": "ImageServiceTitle", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Image Service Title", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Image Service Title"}, + }, + "ItemTS": { + "field_aliasName": "ItemTS", + "field_baseName": "ItemTS", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "ItemTS", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "ItemTS", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "ItemTS"}, + }, + "Latitude": { + "field_aliasName": "Latitude", + "field_baseName": "Latitude", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "Latitude", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Latitude", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Latitude"}, + }, + "Longitude": { + "field_aliasName": "Longitude", + "field_baseName": "Longitude", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "Longitude", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Longitude", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Longitude"}, + }, + "LowPS": { + "field_aliasName": "LowPS", + "field_baseName": "LowPS", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "LowPS", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "LowPS", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "LowPS"}, + }, + "ManagementBody": { + "field_aliasName": "Management Body", + "field_baseName": "ManagementBody", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 20, + "field_name": "ManagementBody", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Management Body", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Management Body"}, + }, + "ManagementPlan": { + "field_aliasName": "Management Plan", + "field_baseName": "ManagementPlan", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 90, + "field_name": "ManagementPlan", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Management Plan", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Management Plan"}, + }, + "MapValue": { + "field_aliasName": "Map Value", + "field_baseName": "MapValue", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "MapValue", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Map Value", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Map Value"}, + }, + "MaxPS": { + "field_aliasName": "MaxPS", + "field_baseName": "MaxPS", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "MaxPS", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "MaxPS", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "MaxPS"}, + }, + "MaximumDepth": { + "field_aliasName": "Maximum Depth", + "field_baseName": "MaximumDepth", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "MaximumDepth", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Maximum Depth", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Maximum Depth"}, + }, + "MaximumLatitude": { + "field_aliasName": "Maximum Latitude", + "field_baseName": "MaximumLatitude", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "MaximumLatitude", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Maximum Latitude", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Maximum Latitude"}, + }, + "MaximumLongitude": { + "field_aliasName": "Maximum Longitude", + "field_baseName": "MaximumLongitude", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "MaximumLongitude", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Maximum Longitude", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Maximum Longitude"}, + }, + "MedianEstimate": { + "field_aliasName": "Median Estimate", + "field_baseName": "MedianEstimate", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "MedianEstimate", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Median Estimate", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Median Estimate"}, + }, + "MinPS": { + "field_aliasName": "MinPS", + "field_baseName": "MinPS", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "MinPS", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "MinPS", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "MinPS"}, + }, + "MinimumDepth": { + "field_aliasName": "Minimum Depth", + "field_baseName": "MinimumDepth", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "MinimumDepth", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Minimum Depth", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Minimum Depth"}, + }, + "MinimumLatitude": { + "field_aliasName": "Minimum Latitude", + "field_baseName": "MinimumLatitude", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "MinimumLatitude", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Minimum Latitude", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Minimum Latitude"}, + }, + "MinimumLongitude": { + "field_aliasName": "Minimum Longitude", + "field_baseName": "MinimumLongitude", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "MinimumLongitude", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Minimum Longitude", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Minimum Longitude"}, + }, + "MosaicName": { + "field_aliasName": "Mosaic Name", + "field_baseName": "MosaicName", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 20, + "field_name": "MosaicName", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Mosaic Name", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Mosaic Name"}, + }, + "MosaicTitle": { + "field_aliasName": "Mosaic Title", + "field_baseName": "MosaicTitle", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 60, + "field_name": "MosaicTitle", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Mosaic Title", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Mosaic Title"}, + }, + "Name": { + "field_aliasName": "Name", + "field_baseName": "Name", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 200, + "field_name": "Name", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Name", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Name"}, + }, + "NetWTCPUE": { + "field_aliasName": "Net WTCPUE", + "field_baseName": "NetWTCPUE", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "NetWTCPUE", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Net WTCPUE", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Net WTCPUE"}, + }, + "Northing": { + "field_aliasName": "Northing", + "field_baseName": "Northing", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "Northing", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Northing", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Northing"}, + }, + "Notes": { + "field_aliasName": "Notes", + "field_baseName": "Notes", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 40, + "field_name": "Notes", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Notes", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Notes"}, + }, + "OffsetDepth": { + "field_aliasName": "Offset Depth", + "field_baseName": "OffsetDepth", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "OffsetDepth", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Offset Depth", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Offset Depth"}, + }, + "OffsetLatitude": { + "field_aliasName": "Offset Latitude", + "field_baseName": "OffsetLatitude", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "OffsetLatitude", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Offset Latitude", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Offset Latitude"}, + }, + "OffsetLongitude": { + "field_aliasName": "Offset Longitude", + "field_baseName": "OffsetLongitude", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "OffsetLongitude", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Offset Longitude", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Offset Longitude"}, + }, + "Parent_GUID": { + "field_aliasName": "Parent GUID", + "field_baseName": "Parent_GUID", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 30, + "field_name": "Parent_GUID", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Parent_GUID", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Parent_GUID"}, + }, + "Percentile": { + "field_aliasName": "Percentile", + "field_baseName": "Percentile", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "Percentile", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Percentile", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Percentile"}, + }, + "PercentileBin": { + "field_aliasName": "Percentile Bin", + "field_baseName": "PercentileBin", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 20, + "field_name": "PercentileBin", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Percentile Bin", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Percentile Bin"}, + }, + "PointFeatureType": { + "field_aliasName": "Point Feature Type", + "field_baseName": "PointFeatureType", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 20, + "field_name": "PointFeatureType", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Point Feature Type", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Point Feature Type"}, + }, + "Prop": { + "field_aliasName": "Prop", + "field_baseName": "Prop", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 0, + "field_name": "Prop", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Prop", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Prop"}, + }, + "Prop_inc_dec": { + "field_aliasName": "Prop_inc_dec", + "field_baseName": "Prop_inc_dec", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 100, + "field_name": "Prop_inc_dec", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Prop_inc_dec", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Prop_inc_dec"}, + }, + "ProductName": { + "field_aliasName": "Product Name", + "field_baseName": "ProductName", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 100, + "field_name": "ProductName", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Product Name", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Product Name"}, + }, + "Raster": { + "field_aliasName": "Raster", + "field_baseName": "Raster", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 0, + "field_name": "Raster", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Raster", + "field_attrdef": "Raster", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Raster"}, + }, + "Region": { + "field_aliasName": "Region", + "field_baseName": "Region", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 40, + "field_name": "Region", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Region", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Region"}, + }, + "SampleID": { + "field_aliasName": "Sample ID", + "field_baseName": "SampleID", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 20, + "field_name": "SampleID", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Sample ID", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Sample ID"}, + }, + "Season": { + "field_aliasName": "Season", + "field_baseName": "Season", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 15, + "field_name": "Season", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Season", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Season"}, + }, + "SpatialGroup": { + "field_aliasName": "SpatialGroup", + "field_baseName": "SpatialGroup", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 50, + "field_name": "SpatialGroup", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "SpatialGroup", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "SpatialGroup"}, + }, + "SpatialName": { + "field_aliasName": "Spatial Name", + "field_baseName": "SpatialName", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 50, + "field_name": "SpatialName", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Spatial Name", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Spatial Name"}, + }, + "Species": { + "field_aliasName": "Species", + "field_baseName": "Species", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 50, + "field_name": "Species", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Species", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Species"}, + }, + "SpeciesCommonName": { + "field_aliasName": "Species (Common Name)", + "field_baseName": "SpeciesCommonName", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 90, + "field_name": "SpeciesCommonName", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Species (Common Name)", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Species (Common Name)"}, + }, + "StandardError": { + "field_aliasName": "Standard Error", + "field_baseName": "StandardError", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "StandardError", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Standard Error", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Standard Error"}, + }, + "Status": { + "field_aliasName": "Status", + "field_baseName": "Status", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 10, + "field_name": "Status", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Status", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Status"}, + }, + "StdTime": { + "field_aliasName": "StdTime", + "field_baseName": "StdTime", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "StdTime", + "field_precision": 1, + "field_required": "true", + "field_scale": 0, + "field_type": "Date", + "field_attrdef": "StdTime", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "StdTime"}, + }, + "Stratum": { + "field_aliasName": "Stratum", + "field_baseName": "Stratum", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 20, + "field_name": "Stratum", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Stratum", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Stratum"}, + }, + "StratumArea": { + "field_aliasName": "Stratum Area", + "field_baseName": "StratumArea", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "StratumArea", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "Stratum Area", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Stratum Area"}, + }, + "SummaryProduct": { + "field_aliasName": "Summary Product", + "field_baseName": "SummaryProduct", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 5, + "field_name": "SummaryProduct", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Summary Product", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Summary Product"}, + }, + "SurveyName": { + "field_aliasName": "Survey Name", + "field_baseName": "SurveyName", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 100, + "field_name": "SurveyName", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Survey Name", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Survey Name"}, + }, + "TableName": { + "field_aliasName": "Table Name", + "field_baseName": "TableName", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 50, + "field_name": "TableName", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Table Name", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Table Name"}, + }, + "Tag": { + "field_aliasName": "Tag", + "field_baseName": "Tag", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 100, + "field_name": "Tag", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Tag", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Tag"}, + }, + "TaxonomicGroup": { + "field_aliasName": "Taxonomic Group", + "field_baseName": "TaxonomicGroup", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 80, + "field_name": "TaxonomicGroup", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Taxonomic Group", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Taxonomic Group"}, + }, + "TotalSpeciesCount": { + "field_aliasName": "Total Species Count", + "field_baseName": "TotalSpeciesCount", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 4, + "field_name": "TotalSpeciesCount", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Total Species Count", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Total Species Count"}, + }, + "TransformUnit": { + "field_aliasName": "Transform Unit", + "field_baseName": "TransformUnit", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 20, + "field_name": "TransformUnit", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Transform Unit", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Transform Unit"}, + }, + "TrendCategory": { + "field_aliasName": "Trend Category", + "field_baseName": "TrendCategory", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 40, + "field_name": "TrendCategory", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Trend Category", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Trend Category"}, + }, + "TypeID": { + "field_aliasName": "Raster Type ID", + "field_baseName": "TypeID", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 4, + "field_name": "TypeID", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Integer", + "field_attrdef": "Raster Type ID", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Raster Type ID"}, + }, + "Uri": { + "field_aliasName": "Uri", + "field_baseName": "Uri", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 0, + "field_name": "Uri", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Blob", + "field_attrdef": "Uri", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Uri"}, + }, + "UriHash": { + "field_aliasName": "UriHash", + "field_baseName": "UriHash", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 50, + "field_name": "UriHash", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "UriHash", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "UriHash"}, + }, + "Value": { + "field_aliasName": "Value", + "field_baseName": "Value", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 50, + "field_name": "Value", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Value", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Value"}, + }, + "Variable": { + "field_aliasName": "Variable", + "field_baseName": "Variable", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 50, + "field_name": "Variable", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Variable", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Variable"}, + }, + "WTCPUE": { + "field_aliasName": "WTCPUE", + "field_baseName": "WTCPUE", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 8, + "field_name": "WTCPUE", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Double", + "field_attrdef": "WTCPUE", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "WTCPUE"}, + }, + "Year": { + "field_aliasName": "Year", + "field_baseName": "Year", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 4, + "field_name": "Year", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + "field_attrdef": "Year", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Year"}, + }, + "Years": { + "field_aliasName": "Years", + "field_baseName": "Years", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 25, + "field_name": "Years", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "String", + #"field_type": "Integer", + "field_attrdef": "Years", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "Years"}, + }, + "ZOrder": { + "field_aliasName": "ZOrder", + "field_baseName": "ZOrder", + "field_defaultValue": "null", + "field_domain": "", + "field_editable": "true", + "field_isNullable": "true", + "field_length": 4, + "field_name": "ZOrder", + "field_precision": 0, + "field_required": "true", + "field_scale": 0, + "field_type": "Integer", + "field_attrdef": "ZOrder", + "field_attrdefs": "DisMAP Project GDB Data Dictionary", + "field_attrdomv": {"udom": "ZOrder"}, + }, + } + + _Bathymetry = [] + _Boundary = ["DatasetCode", "Region", "Season", "DistributionProjectCode"] + _Datasets = [ + "DatasetCode", + "CSVFile", + "TransformUnit", + "TableName", + "GeographicArea", + "CellSize", + "PointFeatureType", + "FeatureClassName", + "Region", + "Season", + "DateCode", + "Status", + "DistributionProjectCode", + "DistributionProjectName", + "SummaryProduct", + "FilterRegion", + "FilterSubRegion", + "FeatureServiceName", + "FeatureServiceTitle", + "MosaicName", + "MosaicTitle", + "ImageServiceName", + "ImageServiceTitle", + ] + _DisMAP_Survey_Info = [ + "SurveyName", + "Region", + "Season", + "GearType", + "Years", + "Frequency", + "DataFilteringNotes", + "TotalSpeciesCount", + "DataSource", + "DataCitation", + ] + _Extent_Points = ["Easting", "Northing", "Longitude", "Latitude"] + _Fishnet = [] + # _GLMME = ["DatasetCode", "Region", "SummaryProduct", "Year", "StdTime", + # "Species", "WTCPUE", "MapValue", "StandardError", "TransformUnit", + # "CommonName", "SpeciesCommonName", "CommonNameSpecies", "Easting", + # "Northing", "Latitude", "Longitude", "MedianEstimate", "Depth"] + # _GRID_Points = ["DatasetCode", "Region", "SummaryProduct", "Year", + # "StdTime", "Species", "WTCPUE", "MapValue", "StandardError", + # "TransformUnit", "CommonName", "SpeciesCommonName", + # "CommonNameSpecies", "Easting", "Northing", "Latitude", + # "Longitude", "MedianEstimate", "Depth"] + _IDW = [ + "DatasetCode", + "Region", + "Season", + "DistributionProjectName", + "SummaryProduct", + "SampleID", + "Year", + "StdTime", + "Species", + "WTCPUE", + "MapValue", + "TransformUnit", + "CommonName", + "SpeciesCommonName", + "CommonNameSpecies", + "CoreSpecies", + "Stratum", + "StratumArea", + "Latitude", + "Longitude", + "Depth", + ] + _Indicators = [ + "DatasetCode", + "Region", + "Season", + "DateCode", + "Species", + "CommonName", + "CoreSpecies", + "Year", + "DistributionProjectName", + "DistributionProjectCode", + "SummaryProduct", + "CenterOfGravityLatitude", + "MinimumLatitude", + "MaximumLatitude", + "OffsetLatitude", + "CenterOfGravityLatitudeSE", + "CenterOfGravityLongitude", + "MinimumLongitude", + "MaximumLongitude", + "OffsetLongitude", + "CenterOfGravityLongitudeSE", + "CenterOfGravityDepth", + "MinimumDepth", + "MaximumDepth", + "OffsetDepth", + "CenterOfGravityDepthSE", + ] + _LayerSpeciesYearImageName = [ + "DatasetCode", + "Region", + "Season", + "SummaryProduct", + "FilterRegion", + "FilterSubRegion", + "Species", + "CommonName", + "SpeciesCommonName", + "CommonNameSpecies", + "TaxonomicGroup", + "ManagementBody", + "ManagementPlan", + "DistributionProjectName", + "CoreSpecies", + "Year", + "StdTime", + "Variable", + "Value", + "Dimensions", + "ImageName", + ] + _Lat_Long = ["Easting", "Northing", "Longitude", "Latitude"] + _Latitude = [] + _Longitude = [] + _Mosaic = [ + "Raster", + "Name", + "MinPS", + "MaxPS", + "LowPS", + "HighPS", + "Category", + "Tag", + "GroupName", + "ProductName", + "CenterX", + "CenterY", + "ZOrder", + "TypeID", + "ItemTS", + "UriHash", + "Uri", + "DatasetCode", + "Region", + "Season", + "Species", + "CommonName", + "SpeciesCommonName", + "CoreSpecies", + "Year", + "StdTime", + "Variable", + "Value", + "Dimensions", + ] + _Raster_Mask = ["Value", "Count", "ID"] + _Region = ["DatasetCode", "Region", "Season", "DistributionProjectCode"] + _Sample_Locations = [ + "DatasetCode", + "Region", + "Season", + "SummaryProduct", + "SampleID", + "Year", + "StdTime", + "Species", + "WTCPUE", + "MapValue", + "TransformUnit", + "CommonName", + "SpeciesCommonName", + "CommonNameSpecies", + "CoreSpecies", + "Stratum", + "StratumArea", + "Latitude", + "Longitude", + "Depth", + ] + _Species_Filter = [ + "Species", + "CommonName", + "TaxonomicGroup", + "FilterRegion", + "FilterSubRegion", + "ManagementBody", + "ManagementPlan", + "DistributionProjectName", + ] + _SpeciesPersistenceIndicatorTrend = [ + "Region", + "SurveyName", + "Species", + "CommonName", + "TrendCategory", + "Notes", + "Haul_Inc_Dec", + "Bio_Inc_Dec", + ] + _SpeciesPersistenceIndicatorPercentileBin = [ + "Region", + "SurveyName", + "Year", + "Species", + "CommonName", + "PercentileBin", + "WTCPUE", + "HaulProportion", + "HaulBin", + ] + _SpatialGroup_SpeciesPersistenceIndicator = [ + "Region", + "SurveyName", + "Year", + "Species", + "CommonName", + "WTCPUE", + "Prop", + "Absence_Presence", + "Prop_inc_dec", + "TrendCategory", + "SpatialGroup", + "SpatialName", + ] + + # datasets_table = arcpy.ListTables("Datasets")[0] + # datasets_table_fields = [f.name for f in arcpy.ListFields(datasets_table) if f.type not in ["Geometry", "OID"] and f.name not in ["Shape_Area", "Shape_Length"]] + + data_dictionary = dict() + # arcpy.AddMessage(datasets_table_fields) + # ['DatasetCode', 'CSVFile', 'TransformUnit', 'TableName', + # 'GeographicArea', 'CellSize', 'PointFeatureType', 'FeatureClassName', + # 'Region', 'Season', 'DateCode', 'Status', 'DistributionProjectCode', + # 'DistributionProjectName', 'SummaryProduct', 'FilterRegion', + # 'FilterSubRegion', 'FeatureServiceName', 'FeatureServiceTitle', + # 'MosaicName', 'MosaicTitle', 'ImageServiceName', 'ImageServiceTitle'] + + table_names = [ + "AI_IDW", + "EBS_IDW", + "ENBS_IDW", + "GMEX_IDW", + "GOA_IDW", + "HI_IDW", + "NBS_IDW", + "NEUS_FAL_IDW", + "NEUS_SPR_IDW", + "SEUS_FAL_IDW", + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + "WC_ANN_IDW", + "WC_TRI_IDW", + "DisMAP_Regions", + "Datasets", + "LayerSpeciesYearImageName", + "Indicators", + "Species_Filter", + "DisMAP_Survey_Info", + "SpeciesPersistenceIndicatorTrend", + "SpeciesPersistenceIndicatorPercentileBin", + "SpatialGroup_SpeciesPersistenceIndicator", + ] + + for table_name in table_names: + arcpy.AddMessage(table_name) + if table_name == "DisMAP_Regions": + data_dictionary[table_name] = _Region + + elif table_name == "Datasets": + data_dictionary[table_name] = _Datasets + + elif table_name == "LayerSpeciesYearImageName": + data_dictionary[table_name] = _LayerSpeciesYearImageName + + elif table_name == "Indicators": + data_dictionary[table_name] = _Indicators + + elif table_name == "Species_Filter": + data_dictionary[table_name] = _Species_Filter + + elif table_name == "DisMAP_Survey_Info": + data_dictionary[table_name] = _DisMAP_Survey_Info + + elif table_name == "SpatialGroup_SpeciesPersistenceIndicator": + data_dictionary[table_name] = _SpatialGroup_SpeciesPersistenceIndicator + + elif table_name == "SpeciesPersistenceIndicatorPercentileBin": + data_dictionary[table_name] = _SpeciesPersistenceIndicatorPercentileBin + + elif table_name == "SpeciesPersistenceIndicatorTrend": + data_dictionary[table_name] = _SpeciesPersistenceIndicatorTrend + + elif table_name.endswith("_IDW"): # or table_name.endswith("_GLMME"): + if table_name.endswith("_IDW"): + data_dictionary[table_name] = _IDW + data_dictionary[f"{table_name}_Sample_Locations"] = ( + _Sample_Locations + ) + data_dictionary[f"{table_name}_Indicators"] = _Indicators + # elif table_name.endswith("_GLMME"): + # data_dictionary[table_name] = _GLMME + # data_dictionary[f"{table_name}_GRID_Points"] = _GRID_Points + else: + pass + data_dictionary[f"{table_name}_Bathymetry"] = _Bathymetry + data_dictionary[f"{table_name}_Boundary"] = _Boundary + data_dictionary[f"{table_name}_Extent_Points"] = _Extent_Points + data_dictionary[f"{table_name}_Fishnet"] = _Fishnet + data_dictionary[f"{table_name}_LayerSpeciesYearImageName"] = ( + _LayerSpeciesYearImageName + ) + data_dictionary[f"{table_name}_Lat_Long"] = _Lat_Long + data_dictionary[f"{table_name}_Latitude"] = _Latitude + data_dictionary[f"{table_name}_Longitude"] = _Longitude + data_dictionary[f"{table_name}_Mosaic"] = _Mosaic + data_dictionary[f"{table_name}_Raster_Mask"] = _Raster_Mask + data_dictionary[f"{table_name}_Region"] = _Region + else: + pass + del table_name + + ## fields = ['DatasetCode', 'DistributionProjectCode'] + + ## with arcpy.da.SearchCursor(datasets_table, fields) as cursor: + ## for row in cursor: + ## DatasetCode = f'{row[0]}' + ## DistributionProjectCode = f'{"_"+row[1] if row[1] is not None and row[1] not in row[0] else ""}' + ## table_name = f'{DatasetCode}{DistributionProjectCode}' + ## arcpy.AddMessage(table_name) + ## if table_name == "DisMAP_Regions": + ## data_dictionary[table_name] = _Region + ## elif table_name == "Datasets": + ## data_dictionary[table_name] = _Datasets + ## elif table_name == "LayerSpeciesYearImageName": + ## data_dictionary[table_name] = _LayerSpeciesYearImageName + ## elif table_name == "Indicators": + ## data_dictionary[table_name] = _Indicators + ## elif table_name == "Species_Filter": + ## data_dictionary[table_name] = _Species_Filter + ## elif table_name == "DisMAP_Survey_Info": + ## data_dictionary[table_name] = _DisMAP_Survey_Info + ## elif table_name == "SpeciesPersistenceIndicatorPercentileBin": + ## data_dictionary[table_name] = _SpeciesPersistenceIndicatorPercentileBin + ## elif table_name == "SpeciesPersistenceIndicatorTrend": + ## data_dictionary[table_name] = _SpeciesPersistenceIndicatorTrend + ## elif table_name.endswith("_IDW") or table_name.endswith("_GLMME"): + ## if table_name.endswith("_IDW"): + ## data_dictionary[table_name] = _IDW + ## data_dictionary[f"{table_name}_Sample_Locations"] = _Sample_Locations + ## data_dictionary[f"{table_name}_Indicators"] = _Indicators + ## elif table_name.endswith("_GLMME"): + ## data_dictionary[table_name] = _GLMME + ## data_dictionary[f"{table_name}_GRID_Points"] = _GRID_Points + ## else: + ## pass + ## data_dictionary[f"{table_name}_Bathymetry"] = _Bathymetry + ## data_dictionary[f"{table_name}_Boundary"] = _Boundary + ## data_dictionary[f"{table_name}_Extent_Points"] = _Extent_Points + ## data_dictionary[f"{table_name}_Fishnet"] = _Fishnet + ## data_dictionary[f"{table_name}_LayerSpeciesYearImageName"] = _LayerSpeciesYearImageName + ## data_dictionary[f"{table_name}_Lat_Long"] = _Lat_Long + ## data_dictionary[f"{table_name}_Latitude"] = _Latitude + ## data_dictionary[f"{table_name}_Longitude"] = _Longitude + ## data_dictionary[f"{table_name}_Mosaic"] = _Mosaic + ## data_dictionary[f"{table_name}_Raster_Mask"] = _Raster_Mask + ## data_dictionary[f"{table_name}_Region"] = _Region + ## else: + ## pass + ## del DistributionProjectCode + ## del DatasetCode + ## del table_name + ## del row + ## del cursor + + for key in sorted(data_dictionary): + arcpy.AddMessage(f"Table: {key}") + _fields = data_dictionary[key] + for _field in _fields: + arcpy.AddMessage(f"\t{_field}") + del _field + del _fields + del key + + table_definitions = {k: v for k, v in sorted(data_dictionary.items())} + + +# "C:\\Users\\john.f.kennedy\\Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\August-1-2025\\CSV_Data\\" +# "C:\\Users\\john.f.kennedy\\Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\August-1-2025\\CSV_Data\\table_definitions.json' + # Write to File + json_path = os.path.join(project_folder, "CSV_Data\\table_definitions.json") + # print(f"project folder: {project_folder}") + # arcpy.AddError(json_path) + with open(json_path, "w", encoding='utf-8') as json_file: + json.dump(table_definitions, json_file, indent=4) + del json_file + del json_path + + + for table in table_definitions: + # arcpy.AddMessage(f"{table}") + fields = table_definitions[table] + # arcpy.AddMessage(f"\t{type(fields)}") + del table + for field in fields: + # arcpy.AddMessage(f"\t{field}") + if field in field_definitions.keys(): + pass + # arcpy.AddMessage(f"\t{field_definitions[field]}") + else: + pass + # arcpy.AddMessage(f"\t\t###--->>> {field} not in _field_definitions") + del field + del fields + del table_definitions + + # for key in sorted(field_definitions): + # #arcpy.AddMessage(f"Table: {key}") + # _fields = field_definitions[key] + # if "attrdef" not in _fields: + # field_definitions[key]["field_attrdef"] = field_definitions[key]["field_aliasName"] + # if "attrdefs" not in _fields: + # field_definitions[key]["field_attrdefs"] = "DisMAP Project GDB Data Dictionary" + # if "attrdomv" not in _fields: + # field_definitions[key]["field_attrdomv"] = {"udom": f"{field_definitions[key]['field_aliasName']}"} + # else: + # pass + # del _fields + # del key + + # for key in sorted(field_definitions): + # #arcpy.AddMessage(f"Table: {key}") + # _fields = field_definitions[key] + # for _field in _fields: + # #arcpy.AddMessage(f"\t{_field}") + # del _field + # del _fields + # del key + + + + # Write to File + json_path = os.path.join(project_folder, "CSV_Data\\field_definitions.json") + with open(json_path, "w", encoding='utf-8') as json_file: + json.dump(field_definitions, json_file, indent=4) + del json_file + del json_path + + + del field_definitions + del data_dictionary, table_names + del ( + _Bathymetry, + _Boundary, + _Datasets, + _DisMAP_Survey_Info, + ) + del ( + _Extent_Points, + _Fishnet, + _IDW, + _Indicators, + ) + # del _GLMME, _GRID_Points, + del ( + _LayerSpeciesYearImageName, + _Lat_Long, + _Latitude, + _Longitude, + ) + del _Mosaic, _Raster_Mask, _Region, _Sample_Locations, _Species_Filter + del _SpeciesPersistenceIndicatorPercentileBin + del _SpeciesPersistenceIndicatorTrend + + # Compact GDB + # arcpy.AddMessage(f"\nCompacting: {os.path.basename(project_gdb)}" ) + arcpy.management.Compact(project_gdb) + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + else: + arcpy.AddMessage("\nScript finished successfully.") + return True + finally: + arcpy.AddMessage(f"\n{'--End' * 10}--") + + +if __name__ == "__main__": + try: + + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + # project_name = "August-1-2025" + project_name = "June-1-2026" + project_gdb = os.path.join( + os.path.expanduser("~"), + f"Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\{project_name}\\{project_name}.gdb", + ) + del project_name + else: + pass + + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + + except SystemExit: + pass + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + except Exception: + traceback.print_exc() + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_indicators_table_director.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_indicators_table_director.py new file mode 100644 index 0000000..4782bb2 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_indicators_table_director.py @@ -0,0 +1,534 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: create_indicators_table_director +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 09/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import os +import sys +import traceback + +import arcpy # third-parties second + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + # filename = sys.path[0] + os.sep + f"{os.path.basename(__file__)}" + filename = os.path.basename(__file__) + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror + + +def director(project_gdb="", Sequential=True, table_names=[]): + try: + # Imports + import dismap_tools + from create_indicators_table_worker import preprocessing, worker + + # Test if passed workspace exists, if not sys.exit() + if not arcpy.Exists(rf"{project_gdb}"): + arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") + arcpy.AddError(arcpy.GetMessages(2)) + sys.exit() + else: + pass + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # project_folder = os.path.dirname(project_gdb) + scratch_workspace = rf"{os.path.dirname(project_gdb)}\Scratch\scratch.gdb" + scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" + csv_data_folder = rf"{os.path.dirname(project_gdb)}\CSV_Data" + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + + preprocessing( + project_gdb=project_gdb, table_names=table_names, clear_folder=True + ) + + # Sequential Processing + if Sequential: + arcpy.AddMessage("Sequential Processing") + for i in range(0, len(table_names)): + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + try: + worker(region_gdb=region_gdb) + except: # noqa: E722 + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del region_gdb, table_name + del i + else: + pass + + # Non-Sequential Processing + if not Sequential: + arcpy.AddMessage("Non-Sequential Processing") + # Imports + import multiprocessing + from time import gmtime, localtime, sleep, strftime, time + + arcpy.AddMessage("Start multiprocessing using the ArcGIS Pro pythonw.exe.") + # Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS + # get_install_path() uses a registry query to figure out 64bit python exe if available + multiprocessing.set_executable(os.path.join(sys.exec_prefix, "pythonw.exe")) + # Get CPU count and then take 2 away for other process + _processes = multiprocessing.cpu_count() - 2 + _processes = ( + _processes if len(table_names) >= _processes else len(table_names) + ) + arcpy.AddMessage( + f"Creating the multiprocessing Pool with {_processes} processes" + ) + # Create a pool of workers, keep one cpu free for surfing the net. + # Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) + with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: + arcpy.AddMessage("\tPrepare arguments for processing") + # Use apply_async so we can handle exceptions gracefully + jobs = {} + for i in range(0, len(table_names)): + try: + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + jobs[table_name] = pool.apply_async(worker, [region_gdb]) + del table_name, region_gdb + except: # noqa: E722 + pool.terminate() + traceback.print_exc() + sys.exit() + del i + all_finished = False + # Set a start time so that we can see how log things take + start_time = time() + result_completed = {} + while True: + all_finished = True + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + arcpy.AddMessage( + f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage("Have the workers finished?") + finish_time = strftime("%a %b %d %I:%M %p", localtime()) + time_elapsed = "Elapsed Time {0} (H:M:S)".format( + strftime("%H:%M:%S", gmtime(elapse_time)) + ) + arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") + finish_time = f"{finish_time}.\n\t{time_elapsed}" + del time_elapsed + for table_name, result in jobs.items(): + if result.ready(): + if table_name not in result_completed: + result_completed[table_name] = finish_time + try: + # wait for and get the result from the task + result.get() + except: # noqa: E722 + pool.terminate() + traceback.print_exc() + sys.exit() + else: + pass + arcpy.AddMessage( + f"Process {table_name}\n\tFinished on {result_completed[table_name]}" + ) + else: + all_finished = False + arcpy.AddMessage(f"Process {table_name} is running. . .") + del table_name, result + del elapse_time, end_time, finish_time + if all_finished: + break + sleep(_processes * 7.5) + del result_completed + del start_time + del all_finished + arcpy.AddMessage("\tClose the process pool") + # close the process pool + pool.close() + # wait for all tasks to complete and processes to close + arcpy.AddMessage( + "\tWait for all tasks to complete and processes to close" + ) + pool.join() + # Just in case + pool.terminate() + del pool + del jobs + del _processes + del time, multiprocessing, localtime, strftime, sleep, gmtime + arcpy.AddMessage("\tDone with multiprocessing Pool") + + # Post-Processing + arcpy.AddMessage("Post-Processing Begins") + + datasets = list() + walk = arcpy.da.Walk(scratch_folder, datatype=["Table", "FeatureClass"]) + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + for dataset in datasets: + datasets_short_path = f".. {'/'.join(dataset.split(os.sep)[-4:])}" + dataset_name = os.path.basename(dataset) + region_gdb = os.path.dirname(dataset) + arcpy.AddMessage(f"\tDataset: '{dataset_name}'") + arcpy.AddMessage(f"\t\tPath: '{datasets_short_path}'") + arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") + arcpy.management.Copy(dataset, rf"{project_gdb}\{dataset_name}") + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + # arcpy.management.Delete(dataset) + # arcpy.AddMessage(f"\t\tAlter Fields for: '{dataset}'") + # dismap_tools.alter_fields(csv_data_folder, rf"{project_gdb}\{dataset}") + del region_gdb, dataset_name, datasets_short_path + del dataset + del datasets + + arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") + arcpy.management.Compact(project_gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + # Declared Variables + del scratch_folder, csv_data_folder, scratch_workspace + # Imports + del preprocessing, worker, dismap_tools + # Function Parameters + del project_gdb, Sequential, table_names + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def process_indicator_tables(project_gdb=""): + try: + # Import + import dismap_tools + from arcpy import metadata as md + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + project_folder = os.path.dirname(project_gdb) + scratch_folder = os.path.join(project_folder, "Scratch") + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + csv_data_folder = os.path.join(project_folder, f"CSV_Data") + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + arcpy.management.CreateTable(project_gdb, "Indicators", "", "", "") + arcpy.AddMessage( + "\tCreate Table: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + indicators = rf"{project_gdb}\Indicators" + + dismap_tools.add_fields(csv_data_folder, indicators) + # dismap_tools.alter_fields(csv_data_folder, indicators) + dismap_tools.import_metadata(csv_data_folder, indicators) + + # in_tables = [it for it in arcpy.ListTables("*_Indicators") if it == "AI_IDW_Indicators"] + # in_tables = [it for it in arcpy.ListTables("*_Indicators") if not any(lo in it for lo in ["GFDL", "GLMME"])] + in_tables = [it for it in arcpy.ListTables("*_Indicators")] + + if not in_tables: + arcpy.AddWarning( + f"Indicator Tables are not present in the {os.path.basename(project_gdb)} GDB" + ) + else: + for in_table in sorted(in_tables): + arcpy.AddMessage(f"Table: {in_table}") + in_table_path = rf"{project_gdb}\{in_table}" + del in_table + + arcpy.AddMessage( + "\tUpdating field values to replace None with empty string" + ) + + fields = [ + f.name + for f in arcpy.ListFields(in_table_path) + if f.type == "String" + ] + # for field in fields: + # arcpy.AddMessage(f"\t{field.name}\t{field.type}") + # del field + # Create update cursor for feature class + with arcpy.da.UpdateCursor(in_table_path, fields) as cursor: + for row in cursor: + # arcpy.AddMessage(row) + for field_value in row: + # arcpy.AddMessage(field_value) + if field_value is None: + row[row.index(field_value)] = "" + cursor.updateRow(row) + del field_value + del row + del cursor + del fields + + fields = [ + f.name + for f in arcpy.ListFields(in_table_path) + if f.name == "DateCode" + ] + # for field in fields: + # arcpy.AddMessage(f"\t{field.name}\t{field.type}") + # del field + # Create update cursor for feature class + with arcpy.da.UpdateCursor(in_table_path, fields) as cursor: + for row in cursor: + # arcpy.AddMessage(row) + # arcpy.AddMessage(dismap_tools.date_code(row[0])) + datecode = dismap_tools.date_code(row[0]) + # arcpy.AddMessage(datecode) + row[0] = datecode + cursor.updateRow(row) + del datecode + del row + del cursor + del fields + + arcpy.management.Append( + inputs=in_table_path, + target=indicators, + schema_type="TEST", + field_mapping="", + subtype="", + ) + arcpy.AddMessage( + "\tAppend: {0} {1}\n".format( + f"{os.path.basename(in_table_path)}", + arcpy.GetMessages(0).replace("\n", "\n\t"), + ) + ) + + del in_table_path + # end for loop + + dataset_md = md.Metadata(indicators) + dataset_md.synchronize("ALWAYS") + dataset_md.save() + del dataset_md + + arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") + arcpy.management.Compact(project_gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + # Declared Variables assigned in function + del in_tables, indicators + del scratch_folder, scratch_workspace, csv_data_folder, project_folder + # Imports + del dismap_tools, md + # Function Parameters + del project_gdb + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def script_tool(project_gdb=""): + try: + # Imports + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + # Test if passed workspace exists, if not sys.exit() + if not arcpy.Exists(project_gdb): + sys.exit(f"{os.path.basename(project_gdb)} is missing!!") + else: + pass + + try: + pass + # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", + # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", + + Test = False + if Test: + director( + project_gdb=project_gdb, + Sequential=True, + table_names=[ + "AI_IDW", + "HI_IDW", + ], + ) + elif not Test: + pass + # director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "EBS_IDW", "ENBS_IDW", "GOA_IDW", "NBS_IDW",]) + # director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) + # director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW", "WC_ANN_IDW", "WC_TRI_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW",]) + # director(project_gdb=project_gdb, Sequential=False, table_names=["HI_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW",]) + else: + pass + del Test + + # Combine Indicator Tables + CombineIndicatorTables = True + if CombineIndicatorTables: + process_indicator_tables(project_gdb=project_gdb) + else: + pass + del CombineIndicatorTables + + except: # noqa: E722 + traceback.print_exc() + sys.exit() + + # Declared Variables + # Imports + # Function Parameters + del project_gdb + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) + minutes, seconds = divmod(rem, 60) + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) + arcpy.AddMessage(f"{'-' * 80}") + del hours, rem, minutes, seconds + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +if __name__ == "__main__": + try: + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) + else: + pass + + script_tool(project_gdb) + + arcpy.SetParameterAsText(1, "Result") + + del project_gdb + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_indicators_table_worker.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_indicators_table_worker.py new file mode 100644 index 0000000..f19f5df --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_indicators_table_worker.py @@ -0,0 +1,1387 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: dev_create_indicators_table_worker +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 09/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import inspect +import os +import sys +import traceback + +import arcpy # third-parties second + + +def printRowContent(region_indicators): + try: + arcpy.AddMessage("Print records in the Region Indicators table") + + fields = [ + f.name + for f in arcpy.ListFields(region_indicators) + if f.type not in ["Geometry", "OID"] + ] + with arcpy.da.SearchCursor(region_indicators, fields) as cursor: + # with arcpy.da.SearchCursor(region_indicators, fields, "CoreSpecies = 'No'") as cursor: + for row in cursor: + # arcpy.AddMessage(', '.join((row))) + + DatasetCode = row[0] + Region = row[1] + Season = row[2] + DateCode = row[3] + Species = row[4] + CommonName = row[5] + CoreSpecies = row[6] + Year = row[7] + # DistributionProjectName = row[8] + DistributionProjectCode = row[9] + SummaryProduct = row[10] + CenterOfGravityLatitude = "" if row[11] is None else f"{row[11]:.1f}" + MinimumLatitude = "" if row[12] is None else f"{row[12]:.1f}" + MaximumLatitude = "" if row[13] is None else f"{row[13]:.1f}" + OffsetLatitude = "" if row[14] is None else f"{row[14]:.1f}" + CenterOfGravityLatitudeSE = "" if row[15] is None else f"{row[15]:.1f}" + CenterOfGravityLongitude = "" if row[16] is None else f"{row[16]:.1f}" + MinimumLongitude = "" if row[17] is None else f"{row[17]:.1f}" + MaximumLongitude = "" if row[18] is None else f"{row[18]:.1f}" + OffsetLongitude = "" if row[19] is None else f"{row[19]:.1f}" + CenterOfGravityLongitudeSE = "" if row[20] is None else f"{row[20]:.1f}" + CenterOfGravityDepth = "" if row[21] is None else f"{row[21]:.1f}" + MinimumDepth = "" if row[22] is None else f"{row[22]:.1f}" + MaximumDepth = "" if row[23] is None else f"{row[23]:.1f}" + OffsetDepth = "" if row[24] is None else f"{row[24]:.1f}" + CenterOfGravityDepthSE = "" if row[25] is None else f"{row[25]:.1f}" + + # arcpy.AddMessage(DatasetCode, Region, Season, DateCode, Species, CommonName, CoreSpecies, Year, DistributionProjectName, DistributionProjectCode, SummaryProduct, CenterOfGravityLatitude, MinimumLatitude, MaximumLatitude, OffsetLatitude, CenterOfGravityLatitudeSE, CenterOfGravityLongitude, MinimumLongitude, MaximumLongitude, OffsetLongitude, CenterOfGravityLongitudeSE, CenterOfGravityDepth, MinimumDepth, MaximumDepth, OffsetDepth, CenterOfGravityDepthSE) + arcpy.AddMessage( + f"{DatasetCode}, {Region}, {Season}, {DateCode}, {Species}, {CommonName}, {CoreSpecies}, {Year}, {DistributionProjectCode}, {SummaryProduct}, {CenterOfGravityLatitude}, {MinimumLatitude}, {MaximumLatitude}, {OffsetLatitude}, {CenterOfGravityLatitudeSE}, {CenterOfGravityLongitude}, {MinimumLongitude}, {MaximumLongitude}, {OffsetLongitude}, {CenterOfGravityLongitudeSE}, {CenterOfGravityDepth}, {MinimumDepth}, {MaximumDepth}, {OffsetDepth}, {CenterOfGravityDepthSE}" + ) + + del DatasetCode, Region, Season, DateCode, Species, CommonName + # del DistributionProjectName + del CoreSpecies, Year + del DistributionProjectCode, SummaryProduct, CenterOfGravityLatitude + del MinimumLatitude, MaximumLatitude, OffsetLatitude + del CenterOfGravityLatitudeSE, CenterOfGravityLongitude + del MinimumLongitude, MaximumLongitude, OffsetLongitude + del CenterOfGravityLongitudeSE, CenterOfGravityDepth, MinimumDepth + del MaximumDepth, OffsetDepth, CenterOfGravityDepthSE + + del row + del cursor + del fields + + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddWarning(arcpy.GetMessages(1)) + traceback.print_exc() + sys.exit() + except arcpy.ExecuteError: + arcpy.AddError( + f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except SystemExit as se: + arcpy.AddError( + f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function." + ) + sys.exit() + except Exception as e: + arcpy.AddError( + f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + except: # noqa: E722 + arcpy.AddError( + f"Caught an except error in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + arcpy.AddMessage( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def worker(region_gdb=""): + try: + # Test if passed workspace exists, if not sys.exit() + if not arcpy.Exists(rf"{region_gdb}"): + arcpy.AddError(f"{os.path.basename(region_gdb)} is missing!!") + arcpy.AddError( + f"Function: '{inspect.stack()[0][3]}', Line Number: {inspect.stack()[0][2]}" + ) + sys.exit() + else: + pass + + import math + + import dismap_tools + import numpy as np + + np.seterr(divide="ignore", invalid="ignore") + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 2 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + table_name = os.path.basename(region_gdb).replace(".gdb", "") + scratch_folder = os.path.dirname(region_gdb) + project_folder = os.path.dirname(scratch_folder) + csv_data_folder = os.path.join(project_folder, f"CSV_Data") + image_folder = rf"{project_folder}\Images" + scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" + + arcpy.AddMessage( + f"Table Name: {table_name}\nProject Folder: {os.path.basename(project_folder)}\nScratch Folder: {os.path.basename(scratch_folder)}\n" + ) + + arcpy.env.workspace = region_gdb + arcpy.env.scratchWorkspace = scratch_workspace + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + # arcpy.env.compression = "LZ77" + # arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" + # arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR LZ77 NO_SKIP" + arcpy.env.resamplingMethod = "BILINEAR" + arcpy.env.rasterStatistics = "STATISTICS 1 1" + # arcpy.env.buildStatsAndRATForTempRaster = True + + arcpy.management.CreateTable(region_gdb, f"{table_name}_Indicators", "", "", "") + arcpy.AddMessage( + "\tCreate Table: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + dismap_tools.add_fields( + csv_data_folder, os.path.join(region_gdb, f"{table_name}_Indicators") + ) + # dismap_tools.import_metadata(rf"{region_gdb}\{table_name}_Indicators") + + del csv_data_folder + + arcpy.AddMessage(f"Generating {table_name} Indicators Table") + + # "DatasetCode", "CSVFile", "TransformUnit", "TableName", "GeographicArea", + # "CellSize", "PointFeatureType", "FeatureClassName", "Region", "Season", + # "DateCode", "Status", "DistributionProjectCode", "DistributionProjectName", + # "SummaryProduct", "FilterRegion", "FilterSubRegion", "FeatureServiceName", + # "FeatureServiceTitle", "MosaicName", "MosaicTitle", "ImageServiceName", + # "ImageServiceTitle" + + arcpy.AddMessage( + f"\tGet list of vaules for the {table_name} Indicators table from the Datasets table" + ) + + fields = [ + "DatasetCode", + "TableName", + "CellSize", + "Region", + "Season", + "DateCode", + "DistributionProjectCode", + "DistributionProjectName", + "SummaryProduct", + ] + region_list = [ + row + for row in arcpy.da.SearchCursor( + rf"{region_gdb}\Datasets", + fields, + where_clause=f"TableName = '{table_name}'", + ) + ][0] + del fields + + # Assigning variables from items in the chosen table list + # ['AI_IDW', 'AI_IDW_Region', 'AI', 'Aleutian Islands', None, 'IDW'] + datasetcode = region_list[0] + table_name = region_list[1] + cellsize = region_list[2] + region = region_list[3] + season = region_list[4] + datecode = region_list[5] + distributionprojectcode = region_list[6] + distributionprojectname = region_list[7] + summaryproduct = region_list[8] + del region_list + + # Convert the Month Day Year date code to YYYYMMDD + # datecode = dismap.date_code(datecode) + # arcpy.AddMessage(datecode) + # arcpy.AddMessage(dismap.date_code(datecode)) + + arcpy.env.cellSize = cellsize + del cellsize + + # Region Raster Mask + datasetcode_raster_mask = os.path.join(region_gdb, f"{table_name}_Raster_Mask") + + # we need to set the mask and extent of the environment, or the raster and items may not come out correctly. + arcpy.env.extent = arcpy.Describe(datasetcode_raster_mask).extent + arcpy.env.mask = datasetcode_raster_mask + arcpy.env.snapRaster = datasetcode_raster_mask + del datasetcode_raster_mask + + # Region Indicators + region_indicators = rf"{region_gdb}\{table_name}_Indicators" + + # Region Bathymetry + region_bathymetry = rf"{region_gdb}\{table_name}_Bathymetry" + + # Region Latitude + region_latitude = rf"{region_gdb}\{table_name}_Latitude" + + # Region Longitude + region_longitude = rf"{region_gdb}\{table_name}_Longitude" + + layerspeciesyearimagename = ( + rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName" + ) + + input_rasters = {} + + arcpy.AddMessage("\tCreate a list of input biomass raster path locations") + + # fields = "DatasetCode;Region;Season;Species;CommonName;SpeciesCommonName;CoreSpecies;Year;StdTime;Variable;Value;Dimensions" + # fields = fields.split(";") + fields = [ + "ImageName", + "Variable", + "Species", + "CommonName", + "CoreSpecies", + "Year", + ] + + # arcpy.AddMessage(fields) + # fields = [f.name for f in arcpy.ListFields(datasetcode_tmp) if f.type not in ['Geometry', 'OID']] + with arcpy.da.SearchCursor( + layerspeciesyearimagename, + fields, + where_clause=f"DatasetCode = '{datasetcode}'", + ) as cursor: + for row in cursor: + image_name, variable, species, commonname, corespecies, year = ( + row[0], + row[1], + row[2], + row[3], + row[4], + row[5], + ) + # if variable not in variables: variables.append(variable) + # arcpy.AddMessage(variable, image_name) + # variable = f"_{variable}" if "Species Richness" in variable else variable + if "Species Richness" not in variable: + # arcpy.AddMessage(variable, year) + input_raster_path = ( + rf"{image_folder}\{table_name}\{variable}\{image_name}.tif" + ) + # arcpy.AddMessage(input_raster_path) + # input_rasters[variable, year] = [image_name, variable, species, commonname, corespecies, year, input_raster_path] + # input_rasters[variable][year] = [image_name, variable, species, commonname, corespecies, year, input_raster_path] + # input_rasters[variable] = {year : image_name} + if variable not in input_rasters: + input_rasters[variable] = { + year: [ + image_name, + variable, + species, + commonname, + corespecies, + year, + input_raster_path, + ] + } + else: + value = input_rasters[variable] + if year not in value: + value[year] = [ + image_name, + variable, + species, + commonname, + corespecies, + year, + input_raster_path, + ] + input_rasters[variable] = value + del value + + del input_raster_path + + del row, image_name, variable, species, commonname, corespecies, year + del cursor + + # arcpy.AddMessage(variables) + del fields + # del variables + del layerspeciesyearimagename + del image_folder + + # Start with empty row_values list of list + row_values = [] + + arcpy.AddMessage("Interate over the species names") + + for variable in sorted(input_rasters): + + first_year = 9999 + + raster_years = input_rasters[variable] + + for raster_year in sorted(raster_years): + + ( + image_name, + variable, + species, + commonname, + corespecies, + year, + input_raster_path, + ) = raster_years[raster_year] + + PrintRecord = False + if PrintRecord: + arcpy.AddMessage(f"\t> Image Name: {image_name}") + arcpy.AddMessage(f"\t\t> Variable: {variable}") + arcpy.AddMessage(f"\t\t> Species: {species}") + arcpy.AddMessage(f"\t\t> Common Name: {commonname}") + arcpy.AddMessage(f"\t\t> Core Species: {corespecies}") + arcpy.AddMessage(f"\t\t> Year: {year}") + arcpy.AddMessage( + f"\t\t> Output Raster: {os.path.basename(input_raster_path)}" + ) + del PrintRecord + + arcpy.AddMessage( + f"Processing {image_name} Biomass Raster for year: {raster_year}" + ) + + # Get maximumBiomass value to filter out "zero" rasters + maximumBiomass = float( + arcpy.management.GetRasterProperties( + input_raster_path, "MAXIMUM" + ).getOutput(0) + ) + + arcpy.AddMessage(f"\t> Biomass Raster Maximum: {maximumBiomass}") + + # arcpy.AddMessage(variable, corespecies, first_year, year) + + # If maximumBiomass greater than zero, then process raster + if maximumBiomass > 0.0: + # Test is for first year + + first_year = year if year < first_year else first_year + # arcpy.AddMessage(f"\t{first_year}, {year} {first_year == year}") + + arcpy.AddMessage("\t> Calculating biomassArray") + + biomassArray = arcpy.RasterToNumPyArray( + input_raster_path, nodata_to_value=np.nan + ) + biomassArray[biomassArray <= 0.0] = np.nan + + # sumWtCpue = sum of all wtcpue values (get this from input_raster_path stats??) + sumBiomassArray = np.nansum(biomassArray) + + arcpy.AddMessage(f"\t> sumBiomassArray: {sumBiomassArray}") + + arcpy.AddMessage( + f"\t> biomassArray non-nan count: {np.count_nonzero(~np.isnan(biomassArray))}" + ) + + # ###--->>> Biomass End + + arcpy.AddMessage("\t> Calculating latitudeArray") + + # ###--->>> Latitude Start + # CenterOfGravityLatitude = None + # MinimumLatitude = None + # MaximumLatitude = None + # OffsetLatitude = None + # CenterOfGravityLatitudeSE = None + + # Latitude + latitudeArray = arcpy.RasterToNumPyArray( + region_latitude, nodata_to_value=np.nan + ) + # arcpy.AddMessage(latitudeArray.shape) + latitudeArray[np.isnan(biomassArray)] = np.nan + # arcpy.AddMessage(latitudeArray.shape) + + # arcpy.AddMessage(f"\t\t> latitudeArray non-nan count: {np.count_nonzero(~np.isnan(latitudeArray)):,d}") + + # arcpy.AddMessage(f"\t\t> Latitude Min: {np.nanmin(latitudeArray)}") + + # arcpy.AddMessage(f"\t\t> Latitude Max: {np.nanmax(latitudeArray)}") + + # make the biomass and latitude arrays one dimensional + + flatBiomassArray = biomassArray.flatten() + + flatLatitudeArray = latitudeArray.flatten() + + # latsInds is an array of indexes representing the sort + + latsInds = flatLatitudeArray.argsort() + + # sort biomass and latitude arrays by lat sorted index + + sortedBiomassArray = flatBiomassArray[latsInds] + sortedLatitudeArray = flatLatitudeArray[latsInds] + + # calculate the cumulative sum of the sorted biomass values + + sortedBiomassArrayCumSum = np.nancumsum(sortedBiomassArray) + + # quantile is cumulative sum value divided by total biomass + + sortedBiomassArrayQuantile = sortedBiomassArrayCumSum / np.nansum( + flatBiomassArray + ) + + # find the difference between 0.95 and each cumulative sum value ... asbolute value gives the closest distance + + diffArray = np.abs(sortedBiomassArrayQuantile - 0.95) + + # find the index of the smallest difference + + minIndex = diffArray.argmin() + + # get the lat at that index + + # maxLat = sortedLatitudeArray[minIndex] + MaximumLatitude = sortedLatitudeArray[minIndex] + + # do the same for 0.05 + + diffArray = np.abs(sortedBiomassArrayQuantile - 0.05) + + minIndex = diffArray.argmin() + + # minLat = sortedLatitudeArray[minIndex] + MinimumLatitude = sortedLatitudeArray[minIndex] + + del sortedBiomassArrayCumSum, sortedBiomassArrayQuantile + del diffArray, minIndex + del sortedLatitudeArray, sortedBiomassArray, flatBiomassArray + del latsInds, flatLatitudeArray + + weightedLatitudeArray = np.multiply(biomassArray, latitudeArray) + + sumWeightedLatitudeArray = np.nansum(weightedLatitudeArray) + + # arcpy.AddMessage("\t\t> Sum Weighted Latitude: {sumWeightedLatitudeArray}") + + CenterOfGravityLatitude = sumWeightedLatitudeArray / sumBiomassArray + + if year == first_year: + first_year_offset_latitude = CenterOfGravityLatitude + + OffsetLatitude = ( + CenterOfGravityLatitude - first_year_offset_latitude + ) + + weightedLatitudeArrayVariance = np.nanvar(weightedLatitudeArray) + weightedLatitudeArrayCount = np.count_nonzero( + ~np.isnan(weightedLatitudeArray) + ) + + CenterOfGravityLatitudeSE = math.sqrt( + weightedLatitudeArrayVariance + ) / math.sqrt(weightedLatitudeArrayCount) + + del weightedLatitudeArrayVariance, weightedLatitudeArrayCount + + # arcpy.AddMessage(f"\t\t> Center of Gravity Latitude: {round(CenterOfGravityLatitude,6)}" + arcpy.AddMessage( + f"\t\t> Center of Gravity Latitude: {CenterOfGravityLatitude}" + ) + arcpy.AddMessage( + f"\t\t> Minimum Latitude (5th Percentile): {MinimumLatitude}" + ) + arcpy.AddMessage( + f"\t\t> Maximum Latitude (95th Percentile): {MaximumLatitude}" + ) + arcpy.AddMessage(f"\t\t> Offset Latitude: {OffsetLatitude}") + arcpy.AddMessage( + f"\t\t> Center of Gravity Latitude Standard Error: {CenterOfGravityLatitudeSE}" + ) + + del latitudeArray, weightedLatitudeArray, sumWeightedLatitudeArray + + # ###--->>> Latitude End + + arcpy.AddMessage("\t> Calculating longitudeArray") + + # ###--->>> Longitude Start + # CenterOfGravityLongitude = None + # MinimumLongitude = None + # MaximumLongitude = None + # OffsetLongitude = None + # CenterOfGravityLongitudeSE = None + + # For issue of international date line + # Added/Modified by JFK June 15, 2022 + longitudeArray = arcpy.RasterToNumPyArray( + region_longitude, nodata_to_value=np.nan + ) + + longitudeArray = np.mod(longitudeArray, 360.0) + + longitudeArray[np.isnan(biomassArray)] = np.nan + + # make the biomass and latitude arrays one dimensional + + flatBiomassArray = biomassArray.flatten() + + flatLongitudeArray = longitudeArray.flatten() + + # longsInds is an array of indexes representing the sort + + longsInds = flatLongitudeArray.argsort() + + # sort biomass and latitude arrays by long sorted index + + sortedBiomassArray = flatBiomassArray[longsInds] + sortedLongitudeArray = flatLongitudeArray[longsInds] + + # calculate the cumulative sum of the sorted biomass values + + sortedBiomassArrayCumSum = np.nancumsum(sortedBiomassArray) + + # quantile is cumulative sum value divided by total biomass + + sortedBiomassArrayQuantile = sortedBiomassArrayCumSum / np.nansum( + flatBiomassArray + ) + + # find the difference between 0.95 and each cumulative sum value ... asbolute value gives the closest distance + + diffArray = np.abs(sortedBiomassArrayQuantile - 0.95) + + # find the index of the smallest difference + + minIndex = diffArray.argmin() + + # get the lat at that index + + MaximumLongitude = sortedLongitudeArray[minIndex] + + # do the same for 0.05 + + diffArray = np.abs(sortedBiomassArrayQuantile - 0.05) + + minIndex = diffArray.argmin() + + MinimumLongitude = sortedLongitudeArray[minIndex] + + del ( + sortedBiomassArrayCumSum, + sortedBiomassArrayQuantile, + diffArray, + minIndex, + ) + del sortedLongitudeArray, sortedBiomassArray, flatBiomassArray + del longsInds, flatLongitudeArray + + weightedLongitudeArray = np.multiply(biomassArray, longitudeArray) + + sumWeightedLongitudeArray = np.nansum(weightedLongitudeArray) + + CenterOfGravityLongitude = ( + sumWeightedLongitudeArray / sumBiomassArray + ) + + if year == first_year: + first_year_offset_longitude = CenterOfGravityLongitude + + OffsetLongitude = ( + CenterOfGravityLongitude - first_year_offset_longitude + ) + + weightedLongitudeArrayVariance = np.nanvar(weightedLongitudeArray) + weightedLongitudeArrayCount = np.count_nonzero( + ~np.isnan(weightedLongitudeArray) + ) + + CenterOfGravityLongitudeSE = math.sqrt( + weightedLongitudeArrayVariance + ) / math.sqrt(weightedLongitudeArrayCount) + + del weightedLongitudeArrayVariance, weightedLongitudeArrayCount + + # Convert 360 back to 180 + # Added/Modified by JFK June 15, 2022 + CenterOfGravityLongitude = ( + np.mod(CenterOfGravityLongitude - 180.0, 360.0) - 180.0 + ) + MinimumLongitude = np.mod(MinimumLongitude - 180.0, 360.0) - 180.0 + MaximumLongitude = np.mod(MaximumLongitude - 180.0, 360.0) - 180.0 + + # arcpy.AddMessage(f"\t\t> Sum Weighted Longitude: {0}".format(sumWeightedLongitudeArray)) + + # arcpy.AddMessage(f"\t\t> Center of Gravity Longitude: {round(CenterOfGravityLongitude,6)}" + arcpy.AddMessage( + f"\t\t> Center of Gravity Longitude: {CenterOfGravityLongitude}" + ) + + # arcpy.AddMessage(F"\t\t> Center of Gravity Longitude: {np.mod(CenterOfGravityLongitude - 180.0, 360.0) -180.0}") + + arcpy.AddMessage( + f"\t\t> Minimum Longitude (5th Percentile): {MinimumLongitude}" + ) + arcpy.AddMessage( + f"\t\t> Maximum Longitude (95th Percentile): {MaximumLongitude}" + ) + arcpy.AddMessage(f"\t\t> Offset Longitude: {OffsetLongitude}") + arcpy.AddMessage( + f"\t\t> Center of Gravity Longitude Standard Error: {CenterOfGravityLongitudeSE}" + ) + + del ( + longitudeArray, + weightedLongitudeArray, + sumWeightedLongitudeArray, + ) + + # ###--->>> Longitude End + + arcpy.AddMessage("\t> Calculating bathymetryArray") + + # ###--->>> Center of Gravity Depth (Bathymetry) Start + + # CenterOfGravityDepth = None + # MinimumDepth = None + # MaximumDepth = None + # OffsetDepth = None + # CenterOfGravityDepthSE = None + + # Bathymetry + bathymetryArray = arcpy.RasterToNumPyArray( + region_bathymetry, nodata_to_value=np.nan + ) + # If biomass cells are Null, make bathymetry cells Null as well + bathymetryArray[np.isnan(biomassArray)] = np.nan + # For bathymetry values zero are larger, make zero + bathymetryArray[bathymetryArray >= 0.0] = 0.0 + + # arcpy.AddMessage("\t\t> bathymetryArray non-nan count: {0}".format(np.count_nonzero(~np.isnan(bathymetryArray))) + # arcpy.AddMessage("\t\t> Bathymetry Min: {0}".format(np.nanmin(bathymetryArray)) + # arcpy.AddMessage("\t\t> Bathymetry Max: {0}".format(np.nanmax(bathymetryArray)) + # make the biomass and latitude arrays one dimensional + + flatBiomassArray = biomassArray.flatten() + + flatBathymetryArray = bathymetryArray.flatten() + + # bathyInds is an array of indexes representing the sort + + bathyInds = flatBathymetryArray.argsort() + + # sort biomass and latitude arrays by lat sorted index + + sortedBiomassArray = flatBiomassArray[bathyInds] + sortedBathymetryArray = flatBathymetryArray[bathyInds] + + # calculate the cumulative sum of the sorted biomass values + + sortedBiomassArrayCumSum = np.nancumsum(sortedBiomassArray) + + # quantile is cumulative sum value divided by total biomass + + sortedBiomassArrayQuantile = sortedBiomassArrayCumSum / np.nansum( + flatBiomassArray + ) + + # find the difference between 0.95 and each cumulative sum + # value ... asbolute value gives the closest distance + + diffArray = np.abs(sortedBiomassArrayQuantile - 0.95) + + # find the index of the smallest difference + + minIndex = diffArray.argmin() + + # get the lat at that index + + # maxLat = sortedBathymetryArray[minIndex] + MaximumDepth = sortedBathymetryArray[minIndex] + + # do the same for 0.05 + + diffArray = np.abs(sortedBiomassArrayQuantile - 0.05) + + minIndex = diffArray.argmin() + + # minLat = sortedBathymetryArray[minIndex] + MinimumDepth = sortedBathymetryArray[minIndex] + + del ( + sortedBiomassArrayCumSum, + sortedBiomassArrayQuantile, + diffArray, + minIndex, + ) + del sortedBathymetryArray, sortedBiomassArray, flatBiomassArray + del bathyInds, flatBathymetryArray + + weightedBathymetryArray = np.multiply(biomassArray, bathymetryArray) + + sumWeightedBathymetryArray = np.nansum(weightedBathymetryArray) + + arcpy.AddMessage( + f"\t\t> Sum Weighted Bathymetry: {sumWeightedBathymetryArray}" + ) + + CenterOfGravityDepth = sumWeightedBathymetryArray / sumBiomassArray + + if year == first_year: + first_year_offset_depth = CenterOfGravityDepth + + OffsetDepth = CenterOfGravityDepth - first_year_offset_depth + + weightedBathymetryArrayVariance = np.nanvar(weightedBathymetryArray) + weightedBathymetryArrayCount = np.count_nonzero( + ~np.isnan(weightedBathymetryArray) + ) + + CenterOfGravityDepthSE = math.sqrt( + weightedBathymetryArrayVariance + ) / math.sqrt(weightedBathymetryArrayCount) + + del weightedBathymetryArrayVariance, weightedBathymetryArrayCount + + arcpy.AddMessage( + "\t\t> Center of Gravity Depth: {0}".format( + CenterOfGravityDepth + ) + ) + + arcpy.AddMessage( + "\t\t> Minimum Depth (5th Percentile): {0}".format(MinimumDepth) + ) + + arcpy.AddMessage( + "\t\t> Maximum Depth (95th Percentile): {0}".format( + MaximumDepth + ) + ) + + arcpy.AddMessage("\t\t> Offset Depth: {0}".format(OffsetDepth)) + + arcpy.AddMessage( + "\t\t> Center of Gravity Depth Standard Error: {0}".format( + CenterOfGravityDepthSE + ) + ) + + del bathymetryArray, weightedBathymetryArray + del sumWeightedBathymetryArray + + # ###--->>> Center of Gravity Depth (Bathymetry) End + + # Clean Up + del biomassArray, sumBiomassArray + + elif maximumBiomass == 0.0: + CenterOfGravityLatitude = None + MinimumLatitude = None + MaximumLatitude = None + OffsetLatitude = None + CenterOfGravityLatitudeSE = None + CenterOfGravityLongitude = None + MinimumLongitude = None + MaximumLongitude = None + OffsetLongitude = None + CenterOfGravityLongitudeSE = None + CenterOfGravityDepth = None + MinimumDepth = None + MaximumDepth = None + OffsetDepth = None + CenterOfGravityDepthSE = None + + else: + arcpy.AddMessage("Something wrong with biomass raster") + + arcpy.AddMessage("\t> Assigning variables to row values") + + # Clean-up + del maximumBiomass + + # Standard for all records + DatasetCode = datasetcode + Region = region + Season = season + DateCode = datecode + Species = species + CommonName = commonname + CoreSpecies = corespecies + Year = year + DistributionProjectName = distributionprojectname + DistributionProjectCode = distributionprojectcode + SummaryProduct = summaryproduct + + row = [ + DatasetCode, + Region, + Season, + DateCode, + Species, + CommonName, + CoreSpecies, + Year, + DistributionProjectName, + DistributionProjectCode, + SummaryProduct, + CenterOfGravityLatitude, + MinimumLatitude, + MaximumLatitude, + OffsetLatitude, + CenterOfGravityLatitudeSE, + CenterOfGravityLongitude, + MinimumLongitude, + MaximumLongitude, + OffsetLongitude, + CenterOfGravityLongitudeSE, + CenterOfGravityDepth, + MinimumDepth, + MaximumDepth, + OffsetDepth, + CenterOfGravityDepthSE, + ] + + del DatasetCode, Region, Season, DateCode, Species, CommonName + del CoreSpecies, Year, DistributionProjectName + del DistributionProjectCode, SummaryProduct, CenterOfGravityLatitude + del MinimumLatitude, MaximumLatitude, OffsetLatitude + del CenterOfGravityLatitudeSE, CenterOfGravityLongitude + del MinimumLongitude, MaximumLongitude, OffsetLongitude + del CenterOfGravityLongitudeSE, CenterOfGravityDepth, MinimumDepth + del MaximumDepth, OffsetDepth, CenterOfGravityDepthSE + + # Append to list + row_values.append(row) + del row + + del ( + image_name, + variable, + species, + commonname, + corespecies, + year, + input_raster_path, + ) + del raster_year + + del raster_years + del first_year + + if "first_year_offset_latitude" in locals(): + del first_year_offset_latitude + if "first_year_offset_longitude" in locals(): + del first_year_offset_longitude + if "first_year_offset_depth" in locals(): + del first_year_offset_depth + + del region_bathymetry, region_latitude, region_longitude, input_rasters + + arcpy.AddMessage("Inserting records into the table") + + # This gets a list of fields in the table + fields = [ + f.name + for f in arcpy.ListFields(region_indicators) + if f.type not in ["Geometry", "OID"] + ] + + # Open an InsertCursor + cursor = arcpy.da.InsertCursor(region_indicators, fields) + del fields + + # Insert new rows into the table + for row in row_values: + try: + row = [None if x != x else x for x in row] + cursor.insertRow(row) + except: # noqa: E722 + # Get the traceback object + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + # Concatenate information together concerning the error into a message string + pymsg = ( + "PYTHON ERRORS:\nTraceback info:\n" + + tbinfo + + "\nError Info:\n" + + str(sys.exc_info()[1]) + ) + sys.exit()(pymsg) + finally: + del row + + # Delete cursor object + del cursor + + # Delete + del row_values + + getcount = arcpy.management.GetCount(region_indicators)[0] + arcpy.AddMessage( + f'\n> "{os.path.basename(region_indicators)}" has {getcount} records\n' + ) + del getcount + + PrintRowContent = False + if PrintRowContent: + printRowContent(region_indicators) + del PrintRowContent + + del region_indicators + + arcpy.management.Delete(rf"{region_gdb}\Datasets") + arcpy.management.Delete(rf"{region_gdb}\{table_name}_Bathymetry") + arcpy.management.Delete(rf"{region_gdb}\{table_name}_Latitude") + arcpy.management.Delete(rf"{region_gdb}\{table_name}_Longitude") + arcpy.management.Delete(rf"{region_gdb}\{table_name}_Raster_Mask") + arcpy.management.Delete(rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName") + + # Values from Datasets table + del datasetcode, region, season, datecode, distributionprojectcode + del distributionprojectname, summaryproduct + # Declared Variables assigned based on the passed paramater + del table_name, scratch_folder, project_folder, scratch_workspace + # Imported modules + del np, math, dismap_tools + # Passed paramater + del region_gdb + + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddWarning(arcpy.GetMessages(1)) + traceback.print_exc() + sys.exit() + except arcpy.ExecuteError: + arcpy.AddError( + f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except SystemExit as se: + arcpy.AddError( + f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function." + ) + sys.exit() + except Exception as e: + arcpy.AddError( + f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + except: # noqa: E722 + arcpy.AddError( + f"Caught an except error in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + arcpy.AddMessage( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def preprocessing(project_gdb="", table_names="", clear_folder=True): + try: + import dismap_tools + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # Set basic arcpy.env variables + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + # Set varaibales + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{project_folder}\Scratch" + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + + # Clear Scratch Folder + # ClearScratchFolder = True + # if ClearScratchFolder: + if clear_folder: + dismap_tools.clear_folder(folder=rf"{os.path.dirname(project_gdb)}\Scratch") + else: + pass + # del ClearScratchFolder + del clear_folder + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + del project_folder, scratch_workspace + + if not table_names: + table_names = [ + row[0] + for row in arcpy.da.SearchCursor( + os.path.join(project_gdb, "Datasets"), + "TableName", + where_clause="TableName LIKE '%_IDW'", + ) + ] + else: + pass + + for table_name in table_names: + arcpy.AddMessage(f"Pre-Processing: {table_name}") + + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + region_scratch_workspace = os.path.join( + scratch_folder, f"{table_name}", "scratch.gdb" + ) + + # Create Scratch Workspace for Region + if not arcpy.Exists(region_scratch_workspace): + os.makedirs(os.path.join(scratch_folder, table_name)) + if not arcpy.Exists(region_scratch_workspace): + arcpy.AddMessage(f"Create File GDB: '{table_name}'") + arcpy.management.CreateFileGDB( + os.path.join(scratch_folder, f"{table_name}"), "scratch" + ) + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + del region_scratch_workspace + # # # CreateFileGDB + arcpy.AddMessage(f"Creating File GDB: '{table_name}'") + arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + # # # CreateFileGDB + # # # Datasets + # Process: Make Table View (Make Table View) (management) + datasets = rf"{project_gdb}\Datasets" + arcpy.AddMessage( + f"'{os.path.basename(datasets)}' has {arcpy.management.GetCount(datasets)[0]} records" + ) + arcpy.management.Copy(datasets, rf"{region_gdb}\Datasets") + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + # # # Datasets + + # # # LayerSpeciesYearImageName + LayerSpeciesYearImageName = ( + rf"{project_gdb}\{table_name}_LayerSpeciesYearImageName" + ) + arcpy.AddMessage( + f"The table '{table_name}_LayerSpeciesYearImageName' has {arcpy.management.GetCount(LayerSpeciesYearImageName)[0]} records" + ) + arcpy.management.Copy( + rf"{project_gdb}\{table_name}_LayerSpeciesYearImageName", + rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + del LayerSpeciesYearImageName + # # # LayerSpeciesYearImageName + + # # # Raster_Mask + arcpy.AddMessage(f"Copy Raster Mask for '{table_name}'") + arcpy.management.Copy( + rf"{project_gdb}\{table_name}_Raster_Mask", + rf"{region_gdb}\{table_name}_Raster_Mask", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + # # # Raster_Mask + + # # # Bathymetry + arcpy.AddMessage(f"Copy Bathymetry for '{table_name}'") + arcpy.management.Copy( + rf"{project_gdb}\{table_name}_Bathymetry", + rf"{region_gdb}\{table_name}_Bathymetry", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + # # # Bathymetry + + # # # Latitude + arcpy.AddMessage(f"Copy Latitude for '{table_name}'") + arcpy.management.Copy( + rf"{project_gdb}\{table_name}_Latitude", + rf"{region_gdb}\{table_name}_Latitude", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + # # # Latitude + + # # # Longitude + arcpy.AddMessage(f"Copy Longitude for '{table_name}'") + arcpy.management.Copy( + rf"{project_gdb}\{table_name}_Longitude", + rf"{region_gdb}\{table_name}_Longitude", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + # # # Longitude + + # Declared Variables + del table_name + del datasets + + # Declared Variables + del scratch_folder, region_gdb + # Imports + del dismap_tools + # Function Parameters + del project_gdb, table_names + + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddWarning(arcpy.GetMessages(1)) + traceback.print_exc() + sys.exit() + except arcpy.ExecuteError: + arcpy.AddError( + f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except SystemExit as se: + arcpy.AddError( + f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function." + ) + sys.exit() + except Exception as e: + arcpy.AddError( + f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + except: # noqa: E722 + arcpy.AddError( + f"Caught an except error in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + arcpy.AddMessage( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def script_tool(project_gdb=""): + try: + # Imports + from time import gmtime, localtime, strftime, time + + import dismap_tools + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + ## # Set worker parameters + ## #table_name = "AI_IDW" + ## table_name = "HI_IDW" + ## #table_name = "NBS_IDW" + ## #table_name = "ENBS_IDW" + + table_names = [ + "HI_IDW", + ] + + # preprocessing(project_gdb=project_gdb, table_names=table_names, clear_folder=True) + + for table_name in table_names: + region_gdb = rf"{os.path.dirname(project_gdb)}\Scratch\{table_name}.gdb" + try: + pass + worker(region_gdb=region_gdb) + except SystemExit: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del table_name, region_gdb + del table_names + + # Declared Varaiables + # Imports + del dismap_tools + # Function Parameters + del project_gdb + + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) + minutes, seconds = divmod(rem, 60) + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) + arcpy.AddMessage(f"{'-' * 80}") + del hours, rem, minutes, seconds + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddWarning(arcpy.GetMessages(1)) + traceback.print_exc() + sys.exit() + except arcpy.ExecuteError: + arcpy.AddError( + f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except SystemExit as se: + arcpy.AddError( + f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function." + ) + sys.exit() + except Exception as e: + arcpy.AddError( + f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + except: # noqa: E722 + arcpy.AddError( + f"Caught an except error in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + arcpy.AddMessage( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +if __name__ == "__main__": + try: + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) + else: + pass + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + del project_gdb + except: # noqa: E722 + traceback.print_exc() + else: + pass + finally: + pass +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_metadata_json_files.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_metadata_json_files.py new file mode 100644 index 0000000..30048b6 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_metadata_json_files.py @@ -0,0 +1,737 @@ +""" +Script documentation + +- Tool parameters are accessed using arcpy.GetParameter() or + arcpy.GetParameterAsText() +- Update derived parameter values using arcpy.SetParameter() or + arcpy.SetParameterAsText() +""" + +import inspect +import os +import sys +import traceback + +import arcpy + + +def script_tool(project_gdb=""): + """Script code goes below""" + try: + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + arcpy.AddMessage("Creating JSON configuration files for metadata...") + project_folder = os.path.dirname(project_gdb) + out_data_path = os.path.join(project_folder, "CSV_Data") + + root_dict = { + "Esri": 0, + "dataIdInfo": 1, + "dqInfo": 2, + "distInfo": 3, + "mdContact": 4, + "mdLang": 5, + "mdChar": 6, + "mdDateSt": 7, + "mdHrLv": 8, + "mdHrLvName": 9, + "mdFileID": 10, + "mdParentID": 11, + "mdMaint": 12, + "refSysInfo": 13, + "spatRepInfo": 14, + "spdoinfo": 15, + "spref": 16, + "contInfo": 17, + "dataSetFn": 18, + "eainfo": 19, + "Binary": 20, + } + + import json + + json_path = rf"{out_data_path}\root_dict.json" + # Write to File + with open(json_path, "w", encoding='utf-8') as json_file: + json.dump(root_dict, json_file, indent=4) + del json_file + del root_dict + with open(json_path, "r", encoding='utf-8') as json_file: + root_dict = json.load(json_file) + del json_file + # arcpy.AddMessage(root_dict) + del root_dict + del json_path + del json + + esri_dict = { + "CreaDate": 0, + "CreaTime": 1, + "ArcGISFormat": 2, + "ArcGISstyle": 3, + "ArcGISProfile": 4, + "SyncOnce": 5, + "DataProperties": 6, + "lineage": 0, + "itemProps": 1, + "itemName": 0, + "imsContentType": 1, + "nativeExtBox": 2, + "westBL": 0, + "eastBL": 1, + "southBL": 2, + "northBL": 3, + "exTypeCode": 4, + "itemLocation": 3, + "linkage": 0, + "protocol": 1, # noqa: E261 + "coordRef": 4, + "type": 0, + "geogcsn": 1, + "csUnits": 2, + "projcsn": 3, + "peXml": 4, + "SyncDate": 7, + "SyncTime": 8, + "ModDate": 9, + "ModTime": 10, + "scaleRange": 11, + "minScale": 12, + "maxScale": 13, + "locales": 14, + } + + import json + + json_path = rf"{out_data_path}\esri_dict.json" + # Write to File + with open(json_path, "w", encoding='utf-8') as json_file: + json.dump(esri_dict, json_file, indent=4) + del json_file + del esri_dict + with open(json_path, "r", encoding='utf-8') as json_file: + esri_dict = json.load(json_file) + del json_file + # arcpy.AddMessage(esri_dict) + del esri_dict + del json_path + del json + + dataIdInfo_dict = { + "dataIdInfo": 0, + "envirDesc": 0, + "dataLang": 1, + "dataChar": 2, + "idCitation": 3, + "resTitle": 0, + "resAltTitle": 1, + "collTitle": 2, # noqa: E261 + "date": 3, + "presForm": 4, + "PresFormCd": 0, + "fgdcGeoform": 1, + "citRespParty": 5, + "spatRpType": 4, + "dataExt": 5, + "exDesc": 0, + "geoEle": 1, + "GeoBndBox": 0, # noqa: E261 + "exTypeCode": 0, + "westBL": 1, + "eastBL": 2, + "northBL": 3, + "southBL": 4, + "tempEle": 2, + "TempExtent": 0, + "exTemp": 0, + "TM_Period": 0, + "tmBegin": 0, # noqa: E261 + "tmEnd": 1, + "TM_Instant": 1, + "tmPosition": 0, + "searchKeys": 1, + "idPurp": 2, + "idAbs": 3, + "idCredit": 4, + "idStatus": 5, + "resConst": 6, + "discKeys": 7, # noqa: E261 + "keyword": 0, + "thesaName": 1, + "resTitle": 0, + "date": 1, + "createDate": 0, + "pubDate": 1, + "reviseDate": 2, + "citOnlineRes": 2, # noqa: E261 + "linkage": 0, + "orFunct": 1, + "OnFunctCd": 0, + "thesaLang": 2, + "languageCode": 0, + "countryCode": 1, + "themeKeys": 8, + "keyword": 0, + "thesaName": 1, + "resTitle": 0, + "date": 1, # noqa: E261 + "createDate": 0, + "pubDate": 1, + "reviseDate": 2, + "citOnlineRes": 2, + "linkage": 0, + "orFunct": 1, + "OnFunctCd": 0, + "thesaLang": 2, + "languageCode": 0, + "countryCode": 1, + "placeKeys": 9, + "keyword": 0, + "thesaName": 1, + "resTitle": 0, + "date": 1, # noqa: E261 + "createDate": 0, + "pubDate": 1, + "reviseDate": 2, + "citOnlineRes": 2, + "linkage": 0, + "orFunct": 1, + "OnFunctCd": 0, + "thesaLang": 2, + "languageCode": 0, + "countryCode": 1, + "tempKeys": 10, + "keyword": 0, + "thesaName": 1, + "resTitle": 0, + "date": 1, # noqa: E261 + "createDate": 0, + "pubDate": 1, + "reviseDate": 2, + "citOnlineRes": 2, + "linkage": 0, + "orFunct": 1, + "OnFunctCd": 0, + "thesaLang": 2, + "languageCode": 0, + "countryCode": 1, + "otherKeys": 11, + "keyword": 0, + "thesaName": 1, + "resTitle": 0, + "date": 1, # noqa: E261 + "createDate": 0, + "pubDate": 1, + "reviseDate": 2, + "citOnlineRes": 2, + "linkage": 0, + "orFunct": 1, + "OnFunctCd": 0, + "thesaLang": 2, + "languageCode": 0, + "countryCode": 1, + "idPoC": 11, # noqa: E261 + "resMaint": 12, + "tpCat": 18, + } + + import json + + json_path = rf"{out_data_path}\dataIdInfo_dict.json" + # Write to File + with open(json_path, "w", encoding='utf-8') as json_file: + json.dump(dataIdInfo_dict, json_file, indent=4) + del json_file + del dataIdInfo_dict + with open(json_path, "r", encoding='utf-8') as json_file: + dataIdInfo_dict = json.load(json_file) + del json_file + # arcpy.AddMessage(dataIdInfo_dict) + del dataIdInfo_dict + del json_path + del json + + idCitation_dict = { + "idCitation": 0, + "resTitle": 0, + "resAltTitle": 1, + "collTitle": 2, # noqa: E261 + "presForm": 3, + "PresFormCd": 0, + "fgdcGeoform": 1, + "date": 4, + "createDate": 0, + "pubDate": 1, + "reviseDate": 2, + "citRespParty": 6, + } + + import json + + json_path = rf"{out_data_path}\idCitation_dict.json" + # Write to File + with open(json_path, "w", encoding='utf-8') as json_file: + json.dump(idCitation_dict, json_file, indent=4) + del json_file + del idCitation_dict + with open(json_path, "r", encoding='utf-8') as json_file: + idCitation_dict = json.load(json_file) + del json_file + # arcpy.AddMessage(idCitation_dict) + del idCitation_dict + del json_path + del json + + contact_element_order_dict = { + "editorSource": 0, + "editorDigest": 1, + "rpIndName": 2, + "rpOrgName": 3, + "rpPosName": 4, + "rpCntInfo": 5, + "cntAddress": 0, + "delPoint": 0, # noqa: E261 + "city": 1, + "adminArea": 2, + "postCode": 3, + "eMailAdd": 4, + "country": 5, + "cntPhone": 1, + "voiceNum": 0, + "faxNum": 1, + "cntHours": 2, # noqa: E261 + "cntOnlineRes": 3, + "linkage": 0, + "protocol": 1, + "orName": 2, + "orDesc": 3, + "orFunct": 4, + "OnFunctCd": 0, + "editorSave": 6, + "displayName": 7, + "role": 8, + "RoleCd": 0, + "srcCitatn": 1, + "resTitle": 0, # noqa: E261 + "resAltTitle": 1, + "collTitle": 2, + "date": 10, + "createDate": 0, + "pubDate": 1, + "reviseDate": 2, + "presForm": 3, + "PresFormCd": 0, + "fgdcGeoform": 1, # noqa: E261 + "citRespParty": 6, + "citOnlineRes": 2, + } + + import json + + json_path = rf"{out_data_path}\contact_element_order_dict.json" + # Write to File + with open(json_path, "w", encoding='utf-8') as json_file: + json.dump(contact_element_order_dict, json_file, indent=4) + del json_file + del contact_element_order_dict + with open(json_path, "r", encoding='utf-8') as json_file: + contact_element_order_dict = json.load(json_file) + del json_file + # arcpy.AddMessage(contact_element_order_dict) + del contact_element_order_dict + del json_path + del json + + dqInfo_dict = { + "dqScope": 0, + "scpLvl": 0, + "ScopeCd": 0, + "scpLvlDesc": 1, # noqa: E261 + "datasetSet": 0, + "report": 1, + "measDesc": 0, + "measResult": 1, + "dataLineage": 3, + "statement": 0, + "dataSource": 1, + "srcDesc": 0, # noqa: E261 + "srcCitatn": 1, + "resTitle": 0, + "resAltTitle": 1, + "collTitle": 2, + "citOnlineRes": 2, + "linkage": 0, + "protocol": 1, + "orName": 2, + "orDesc": 3, + "orFunct": 4, + "OnFunctCd": 0, + "date": 3, + "createDate": 0, # noqa: E261 + "pubDate": 1, + "reviseDate": 2, + "otherCitDet": 4, + "presForm": 5, + "PresFormCd": 0, + "fgdcGeoform": 1, + "citRespParty": 6, + "editorSource": 0, + "editorDigest": 1, + "rpIndName": 2, + "rpOrgName": 3, + "rpPosName": 4, + "rpCntInfo": 5, + "cntAddress": 0, + "delPoint": 0, # noqa: E261 + "city": 1, + "adminArea": 2, + "postCode": 3, + "eMailAdd": 4, + "country": 5, + "cntPhone": 1, + "voiceNum": 0, + "faxNum": 1, + "cntHours": 2, # noqa: E261 + "cntOnlineRes": 3, + "linkage": 0, + "protocol": 1, + "orName": 2, + "orDesc": 3, + "orFunct": 4, + "OnFunctCd": 0, + "editorSave": 6, + "displayName": 7, + "role": 8, + "RoleCd": 0, + "srcMedName": 7, + "MedNameCd": 0, # noqa: E261 + "prcStep": 3, + "stepDesc": 0, + "stepProc": 1, + "editorSource": 0, + "editorDigest": 1, + "rpIndName": 2, + "rpOrgName": 3, + "rpPosName": 4, + "rpCntInfo": 5, + "cntAddress": 0, + "delPoint": 0, # noqa: E261 + "city": 1, + "adminArea": 2, + "postCode": 3, + "eMailAdd": 4, + "country": 5, + "cntPhone": 1, + "voiceNum": 0, + "faxNum": 1, + "cntHours": 2, # noqa: E261 + "cntOnlineRes": 3, + "linkage": 0, + "protocol": 1, + "orName": 2, + "orDesc": 3, + "orFunct": 4, + "OnFunctCd": 0, + "editorSave": 6, + "displayName": 7, + "role": 8, # noqa: E261 + "RoleCd": 0, + "stepDateTm": 2, + "cntOnlineRes": 3, + "linkage": 0, + "protocol": 1, + "orName": 2, + "orDesc": 3, + "orFunct": 4, + "OnFunctCd": 0, + } + + import json + + json_path = rf"{out_data_path}\dqInfo_dict.json" + # Write to File + with open(json_path, "w", encoding='utf-8') as json_file: + json.dump(dqInfo_dict, json_file, indent=4) + del json_file + del dqInfo_dict + with open(json_path, "r", encoding='utf-8') as json_file: + dqInfo_dict = json.load(json_file) + del json_file + # arcpy.AddMessage(dqInfo_dict) + del dqInfo_dict + del json_path + del json + + distInfo_dict = { + "distInfo": 0, + "distFormat": 0, + "formatName": 0, + "formatVer": 1, # noqa: E261 + "fileDecmTech": 2, + "formatInfo": 3, + "distributor": 1, + "distorCont": 0, + "editorSource": 0, + "editorDigest": 1, + "rpIndName": 2, + "rpOrgName": 3, + "rpPosName": 4, + "rpCntInfo": 5, + "cntAddress": 0, + "delPoint": 0, # noqa: E261 + "city": 1, + "adminArea": 2, + "postCode": 3, + "eMailAdd": 4, + "country": 5, + "cntPhone": 1, + "voiceNum": 0, + "faxNum": 1, + "cntHours": 2, # noqa: E261 + "cntOnlineRes": 3, + "linkage": 0, + "orName": 1, + "orDesc": 2, + "orFunct": 3, + "OnFunctCd": 0, + "editorSave": 6, + "displayName": 7, + "role": 8, + "RoleCd": 0, # noqa: E261 + "distTranOps": 2, + "unitsODist": 0, + "transSize": 1, + "onLineSrc": 2, + "linkage": 0, + "protocol": 1, + "orName": 2, + "orDesc": 3, + "orFunct": 4, + "OnFunctCd": 0, # noqa: E261 + } + + import json + + json_path = rf"{out_data_path}\distInfo_dict.json" + # Write to File + with open(json_path, "w", encoding='utf-8') as json_file: + json.dump(distInfo_dict, json_file, indent=4) + del json_file + del distInfo_dict + with open(json_path, "r", encoding='utf-8') as json_file: + distInfo_dict = json.load(json_file) + del json_file + # arcpy.AddMessage(distInfo_dict) + del distInfo_dict + del json_path + del json + + RoleCd_dict = { + "001": "Resource Provider", + "002": "Custodian", + "003": "Owner", + "004": "User", + "005": "Distributor", + "006": "Originator", + "007": "Point of Contact", + "008": "Principal Investigator", + "009": "Processor", + "010": "Publisher", + "011": "Author", + "012": "Collaborator", + "013": "Editor", + "014": "Mediator", + "015": "Rights Holder", + } + + import json + + json_path = rf"{out_data_path}\RoleCd_dict.json" + # Write to File + with open(json_path, "w", encoding='utf-8') as json_file: + json.dump(RoleCd_dict, json_file, indent=4) + + # role_dict = {"citRespParty" : , + # "idPoC" : , + # "distorCont" : , + # "mdContact" : , + # "stepProc" + + tpCat_dict = { + "002": '', + "007": '', + "014": '', + } + + import json + + json_path = rf"{out_data_path}\tpCat_dict.json" + # Write to File + with open(json_path, "w", encoding='utf-8') as json_file: + json.dump(tpCat_dict, json_file, indent=4) + del json_file + del tpCat_dict + with open(json_path, "r", encoding='utf-8') as json_file: + tpCat_dict = json.load(json_file) + del json_file + # arcpy.AddMessage(tpCat_dict) + del tpCat_dict + del json_path + del json + + # ###################### DisMAP ######################################## + RoleCd_dict = { + "001": "Resource Provider", + "002": "Custodian", + "003": "Owner", + "004": "User", + "005": "Distributor", + "006": "Originator", + "007": "Point of Contact", + "008": "Principal Investigator", + "009": "Processor", + "010": "Publisher", + "011": "Author", + "012": "Collaborator", + "013": "Editor", + "014": "Mediator", + "015": "Rights Holder", + } + contact_dict = { + "citRespParty": [ + { + "role": "Custodian", + "rpIndName": "Timothy J Haverland", + "eMailAdd": "tim.haverland@noaa.gov", + }, + ], + "idPoC": [ + { + "role": "Point of Contact", + "rpIndName": "Melissa Ann Karp", + "eMailAdd": "melissa.karp@noaa.gov", + }, + ], + "distorCont": [ + { + "role": "Distributor", + "rpIndName": "Timothy J Haverland", + "eMailAdd": "tim.haverland@noaa.gov", + }, + ], + "mdContact": [ + { + "role": "Author", + "rpIndName": "John F Kennedy", + "eMailAdd": "john.f.kennedy@noaa.gov", + }, + ], + "srcCitatn": [ + { + "role": "Principal Investigator", + "rpIndName": "Melissa Ann Karp", + "eMailAdd": "melissa.karp@noaa.gov", + }, + ], + "stepProc": [ + { + "role": "Processor", + "rpIndName": "John F Kennedy", + "eMailAdd": "john.f.kennedy@noaa.gov", + }, + { + "role": "Processor", + "rpIndName": "Melissa Ann Karp", + "eMailAdd": "melissa.karp@noaa.gov", + }, + ], + } + del RoleCd_dict + + import json + + json_path = rf"{out_data_path}\contact_dict.json" + # arcpy.AddMessage(json_path) + # Write to File + with open(json_path, "w", encoding='utf-8') as json_file: + json.dump(contact_dict, json_file, indent=4) + + arcpy.AddMessage("Successfully created JSON configuration files.") + + # ###################### DisMAP ######################################## + + # Compact GDB + # arcpy.AddMessage(f"\nCompacting: {os.path.basename(project_gdb)}" ) + arcpy.management.Compact(project_gdb) + + # Declared Varaiables + del project_folder, out_data_path + # Imports + # Function Parameters + del json + del project_gdb + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + else: + arcpy.AddMessage("\nScript finished successfully.") + return True + finally: + arcpy.AddMessage(f"\n{'--End' * 10}--") + + +if __name__ == "__main__": + try: + + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + # project_name = "August-1-2025" + project_name = "June-1-2026" + project_gdb = os.path.join( + os.path.expanduser("~"), + f"Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\{project_name}\\{project_name}.gdb", + ) + del project_name + else: + pass + + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + + except SystemExit: + pass + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + except Exception: + traceback.print_exc() + + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_mosaics_director.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_mosaics_director.py new file mode 100644 index 0000000..63dba87 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_mosaics_director.py @@ -0,0 +1,614 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: create_species_year_image_name_table_director +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 09/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import os +import sys +import traceback + +import arcpy # third-parties second + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + # filename = sys.path[0] + os.sep + f"{os.path.basename(__file__)}" + filename = os.path.basename(__file__) + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror + + +def preprocessing(project_gdb="", table_names="", clear_folder=True): + try: + import dismap_tools + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # Set basic arcpy.env variables + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + # Set varaibales + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{project_folder}\Scratch" + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + + # Clear Scratch Folder + # ClearScratchFolder = True + # if ClearScratchFolder: + if clear_folder: + dismap_tools.clear_folder(folder=rf"{os.path.dirname(project_gdb)}\Scratch") + else: + pass + # del ClearScratchFolder + del clear_folder + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + del project_folder, scratch_workspace + + if not table_names: + table_names = [ + row[0] + for row in arcpy.da.SearchCursor( + os.path.join(project_gdb, "Datasets"), + "TableName", + where_clause="TableName LIKE '%_IDW'", + ) + ] + else: + pass + + for table_name in table_names: + arcpy.AddMessage(f"Pre-Processing: {table_name}") + + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + region_scratch_workspace = os.path.join( + scratch_folder, f"{table_name}", "scratch.gdb" + ) + + # Create Scratch Workspace for Region + if not arcpy.Exists(region_scratch_workspace): + os.makedirs(os.path.join(scratch_folder, table_name)) + if not arcpy.Exists(region_scratch_workspace): + arcpy.AddMessage(f"Create File GDB: '{table_name}'") + arcpy.management.CreateFileGDB( + os.path.join(scratch_folder, f"{table_name}"), "scratch" + ) + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + del region_scratch_workspace + # # # CreateFileGDB + arcpy.AddMessage(f"Creating File GDB: '{table_name}'") + arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + # # # CreateFileGDB + # # # Datasets + # Process: Make Table View (Make Table View) (management) + datasets = rf"{project_gdb}\Datasets" + arcpy.AddMessage( + f"'{os.path.basename(datasets)}' has {arcpy.management.GetCount(datasets)[0]} records" + ) + arcpy.management.Copy(datasets, rf"{region_gdb}\Datasets") + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + # # # Datasets + + # # # LayerSpeciesYearImageName + LayerSpeciesYearImageName = ( + rf"{project_gdb}\{table_name}_LayerSpeciesYearImageName" + ) + arcpy.AddMessage( + f"The table '{table_name}_LayerSpeciesYearImageName' has {arcpy.management.GetCount(LayerSpeciesYearImageName)[0]} records" + ) + arcpy.management.Copy( + rf"{project_gdb}\{table_name}_LayerSpeciesYearImageName", + rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + del LayerSpeciesYearImageName + # # # LayerSpeciesYearImageName + + # # # Raster_Mask + arcpy.AddMessage(f"Copy Raster Mask for '{table_name}'") + arcpy.management.Copy( + rf"{project_gdb}\{table_name}_Raster_Mask", + rf"{region_gdb}\{table_name}_Raster_Mask", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + # # # Raster_Mask + + del datasets + # Declared Variables + del table_name + + # Declared Variables + del scratch_folder, region_gdb + # Imports + del dismap_tools + # Function Parameters + del project_gdb, table_names + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def director(project_gdb="", Sequential=True, table_names=[]): + try: + # Imports + import dismap_tools + from create_mosaics_worker import worker + + # Test if passed workspace exists, if not sys.exit() + if not arcpy.Exists(rf"{project_gdb}"): + arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") + arcpy.AddError(arcpy.GetMessages(2)) + sys.exit() + else: + pass + + # Set History and Metadata logs, set serverity and message level + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 2 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # Set basic arcpy.env values + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = ( + rf"{os.path.dirname(project_gdb)}\Scratch\scratch.gdb" + ) + + preprocessing( + project_gdb=project_gdb, table_names=table_names, clear_folder=True + ) + + # Set basic workkpace variables + scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" + csv_data_folder = rf"{os.path.dirname(project_gdb)}\CSV_Data" + + # Sequential Processing + if Sequential: + arcpy.AddMessage("Sequential Processing") + for i in range(0, len(table_names)): + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + try: + worker(region_gdb=region_gdb) + except SystemExit: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del region_gdb, table_name + del i + else: + pass + + # Non-Sequential Processing + if not Sequential: + arcpy.AddMessage("Non-Sequential Processing") + # Imports + import multiprocessing + from time import gmtime, localtime, sleep, strftime, time + + arcpy.AddMessage("Start multiprocessing using the ArcGIS Pro pythonw.exe.") + # Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS + # get_install_path() uses a registry query to figure out 64bit python exe if available + multiprocessing.set_executable(os.path.join(sys.exec_prefix, "pythonw.exe")) + # Get CPU count and then take 2 away for other process + _processes = multiprocessing.cpu_count() - 2 + _processes = ( + _processes if len(table_names) >= _processes else len(table_names) + ) + arcpy.AddMessage( + f"Creating the multiprocessing Pool with {_processes} processes" + ) + # Create a pool of workers, keep one cpu free for surfing the net. + # Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) + with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: + arcpy.AddMessage("\tPrepare arguments for processing") + # Use apply_async so we can handle exceptions gracefully + jobs = {} + for i in range(0, len(table_names)): + try: + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + jobs[table_name] = pool.apply_async(worker, [region_gdb]) + del table_name, region_gdb + except: # noqa: E722 + pool.terminate() + traceback.print_exc() + sys.exit() + del i + all_finished = False + # Set a start time so that we can see how log things take + start_time = time() + result_completed = {} + while True: + all_finished = True + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + arcpy.AddMessage( + f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage("Have the workers finished?") + finish_time = strftime("%a %b %d %I:%M %p", localtime()) + time_elapsed = "Elapsed Time {0} (H:M:S)".format( + strftime("%H:%M:%S", gmtime(elapse_time)) + ) + arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") + finish_time = f"{finish_time}.\n\t{time_elapsed}" + del time_elapsed + for table_name, result in jobs.items(): + if result.ready(): + if table_name not in result_completed: + result_completed[table_name] = finish_time + try: + # wait for and get the result from the task + result.get() + except: # noqa: E722 + pool.terminate() + traceback.print_exc() + sys.exit() + else: + pass + arcpy.AddMessage( + f"Process {table_name}\n\tFinished on {result_completed[table_name]}" + ) + else: + all_finished = False + arcpy.AddMessage(f"Process {table_name} is running. . .") + del table_name, result + del elapse_time, end_time, finish_time + if all_finished: + break + sleep(_processes * 7.5) + del result_completed + del start_time + del all_finished + arcpy.AddMessage("Close the process pool") + # close the process pool + pool.close() + # wait for all tasks to complete and processes to close + arcpy.AddMessage( + "\tWait for all tasks to complete and processes to close" + ) + pool.join() + # Just in case + pool.terminate() + del pool + del jobs + del _processes + del time, multiprocessing, localtime, strftime, sleep, gmtime + arcpy.AddMessage("Done with multiprocessing Pool\n") + + # Post-Processing + arcpy.AddMessage("Post-Processing Begins") + + crf_folder = rf"{os.path.dirname(project_gdb)}\CRFs" + + datasets = list() + walk = arcpy.da.Walk( + scratch_folder, datatype=["RasterDataset", "MosaicDataset"] + ) + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + for dataset in datasets: + datasets_short_path = f".. {'/'.join(dataset.split(os.sep)[-4:])}" + dataset_name = os.path.basename(dataset) + dataset_type = arcpy.Describe(dataset).datatype + region_gdb = os.path.dirname(dataset) + arcpy.AddMessage(f"\tDataset: '{dataset_name}'") + arcpy.AddMessage(f"\t\tType: '{dataset_type}'") + arcpy.AddMessage(f"\t\tPath: '{datasets_short_path}'") + arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") + if dataset.endswith("Mosaic"): + try: + if arcpy.Exists(rf"{project_gdb}\{dataset_name}"): + arcpy.management.Delete(rf"{project_gdb}\{dataset_name}") + else: + pass + arcpy.AddMessage(f"Copy '{dataset_name}'") + arcpy.management.Copy( + in_data=dataset, + out_data=rf"{project_gdb}\{dataset_name}", + data_type="MosaicDataset", + associated_data="MosaicCatalogItemCategoryDomain 'CV domain' MosaicCatalogItemCategoryDomain DEFAULTS", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + # arcpy.AddMessage(f"\t\tAlter Fields for: '{dataset_name}'") + # dismap_tools.alter_fields(csv_data_folder, rf"{project_gdb}\{dataset_name}") + dismap_tools.import_metadata( + csv_data_folder, rf"{project_gdb}\{dataset_name}" + ) + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + + elif dataset.endswith(".crf"): + try: + if arcpy.Exists(rf"{crf_folder}\{dataset_name}"): + arcpy.management.Delete(rf"{crf_folder}\{dataset_name}") + else: + pass + arcpy.AddMessage(f"Copy '{dataset_name}'") + arcpy.management.Copy( + in_data=dataset, + out_data=rf"{crf_folder}\{dataset_name}", + data_type="MosaicDataset", + associated_data="MosaicCatalogItemCategoryDomain 'CV domain' MosaicCatalogItemCategoryDomain DEFAULTS", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + dismap_tools.import_metadata( + csv_data_folder, rf"{project_gdb}\{dataset_name}" + ) + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + raise SystemExit + else: + pass + arcpy.management.Delete(dataset) + arcpy.AddMessage( + "\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + del region_gdb, dataset_name, datasets_short_path, dataset_type + del dataset + del datasets + + arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") + arcpy.management.Compact(project_gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages().replace("\n", "\n\t")) + # Declared Variables assigned in function + del scratch_folder, csv_data_folder, crf_folder + # Imports + del worker, dismap_tools + # Function Parameters + del project_gdb, Sequential, table_names + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def script_tool(project_gdb=""): + try: + # Imports + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + ## # Clear Scratch Folder + ## ClearScratchFolder = False + ## if ClearScratchFolder: + ## import dismap_tools + ## dismap_tools.clear_folder(folder=scratch_folder) + ## del dismap_tools + ## else: + ## pass + ## del ClearScratchFolder + + try: + # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", + # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", + Test = False + if Test: + director( + project_gdb=project_gdb, + Sequential=True, + table_names=[ + "SEUS_FAL_IDW", + "HI_IDW", + "NBS_IDW", + ], + ) + elif not Test: + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "AI_IDW", + "EBS_IDW", + "ENBS_IDW", + "GMEX_IDW", + "GOA_IDW", + "HI_IDW", + "NBS_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NEUS_FAL_IDW", + "NEUS_SPR_IDW", + "SEUS_FAL_IDW", + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + "WC_ANN_IDW", + "WC_TRI_IDW", + ], + ) + else: + pass + del Test + + except: # noqa: E722 + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + + # Declared Variables + + # Imports + # Function Parameters + del project_gdb + + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) + minutes, seconds = divmod(rem, 60) + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) + arcpy.AddMessage(f"{'-' * 80}") + del hours, rem, minutes, seconds + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +if __name__ == "__main__": + try: + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) + else: + pass + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + del project_gdb + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_mosaics_worker.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_mosaics_worker.py new file mode 100644 index 0000000..559b8d0 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_mosaics_worker.py @@ -0,0 +1,553 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: create_species_year_image_name_table_worker +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 09/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import os +import sys +import traceback + +import arcpy # third-parties second + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + # filename = sys.path[0] + os.sep + f"{os.path.basename(__file__)}" + filename = os.path.basename(__file__) + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror + + +def worker(region_gdb=""): + try: + + # Set History and Metadata logs, set serverity and message level + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 2 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + table_name = os.path.basename(region_gdb).replace(".gdb", "") + scratch_folder = os.path.dirname(region_gdb) + project_folder = os.path.dirname(scratch_folder) + scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" + region_raster_mask = rf"{region_gdb}\{table_name}_Raster_Mask" + + arcpy.AddMessage( + f"Table Name: {table_name}\nProject Folder: {os.path.basename(project_folder)}\nScratch Folder: {os.path.basename(scratch_folder)}\n" + ) + + # Set basic workkpace variables + arcpy.env.workspace = region_gdb + arcpy.env.scratchWorkspace = scratch_workspace + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + # arcpy.env.compression = "LZ77" + # arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" + # arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR LZ77 NO_SKIP" + arcpy.env.resamplingMethod = "BILINEAR" + arcpy.env.rasterStatistics = "STATISTICS 1 1" + # arcpy.env.buildStatsAndRATForTempRaster = True + + # DatasetCode, CSVFile, TransformUnit, TableName, GeographicArea, CellSize, + # PointFeatureType, FeatureClassName, Region, Season, DateCode, Status, + # DistributionProjectCode, DistributionProjectName, SummaryProduct, + # FilterRegion, FilterSubRegion, FeatureServiceName, FeatureServiceTitle, + # MosaicName, MosaicTitle, ImageServiceName, ImageServiceTitle + + # Get values for table_name from Datasets table + fields = [ + "TableName", + "GeographicArea", + "DatasetCode", + "CellSize", + "MosaicName", + "MosaicTitle", + ] + region_list = [ + row + for row in arcpy.da.SearchCursor( + rf"{region_gdb}\Datasets", + fields, + where_clause=f"TableName = '{table_name}'", + ) + ][0] + del fields + + # Assigning variables from items in the chosen table list + # ['AI_IDW', 'AI_IDW_Region', 'AI', 'Aleutian Islands', None, 'IDW'] + table_name = region_list[0] + # geographic_area = region_list[1] + datasetcode = region_list[2] + cell_size = region_list[3] + mosaic_name = region_list[4] + mosaic_title = region_list[5] + del region_list + + # Start of business logic for the worker function + arcpy.AddMessage(f"Processing: {table_name}") + + # geographic_area_sr = rf"{project_folder}\Dataset_Shapefiles\{table_name}\{geographic_area}.prj" + # Set the output coordinate system to what is needed for the + # DisMAP project + # psr = arcpy.SpatialReference(geographic_area_sr) + # arcpy.env.outputCoordinateSystem = psr + # del geographic_area_sr, geographic_area + + arcpy.AddMessage( + "\tSet the 'outputCoordinateSystem' based on the projection information for the geographic region" + ) + psr = arcpy.Describe(region_raster_mask).spatialReference + arcpy.env.outputCoordinateSystem = psr + del region_raster_mask + + arcpy.AddMessage("Building the 'input_raster_paths' list") + + layerspeciesyearimagename = ( + rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName" + ) + + input_raster_paths = [] + + fields = ["Variable", "ImageName"] + with arcpy.da.SearchCursor( + layerspeciesyearimagename, + fields, + where_clause=f"DatasetCode = '{datasetcode}'", + ) as cursor: + for row in cursor: + variable, image_name = row[0], row[1] + # if variable not in variables: variables.append(variable) + # arcpy.AddMessage(f"{variable}, {image_name}") + variable = ( + f"_{variable}" if "Species Richness" in variable else variable + ) + input_raster_path = ( + rf"{project_folder}\Images\{table_name}\{variable}\{image_name}.tif" + ) + if arcpy.Exists(input_raster_path): + # arcpy.AddMessage(input_raster_path) + input_raster_paths.append(input_raster_path) + else: + arcpy.AddError( + f"{os.path.basename(input_raster_path)} is missing!!" + ) + # arcpy.AddMessage(input_raster_path) + del row, variable, image_name, input_raster_path + del cursor + del fields + + mosaic_path = os.path.join(region_gdb, mosaic_name) + + # Loading images into the Mosaic. + arcpy.AddMessage( + f"Loading the '{table_name}' Mosaic. This may take a while. . . Please wait. . ." + ) + + with arcpy.EnvManager(scratchWorkspace=scratch_workspace, workspace=region_gdb): + arcpy.management.CreateMosaicDataset( + in_workspace=region_gdb, + in_mosaicdataset_name=mosaic_name, + coordinate_system=psr, + num_bands="1", + pixel_type="32_BIT_FLOAT", + product_definition="", + product_band_definitions="", + ) + + arcpy.AddMessage( + "\tCreate Mosaic Dataset: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + + arcpy.AddMessage(f"Loading Rasters into the {os.path.basename(mosaic_path)}.") + + arcpy.management.AddRastersToMosaicDataset( + in_mosaic_dataset=mosaic_path, + raster_type="Raster Dataset", + input_path=input_raster_paths, + update_cellsize_ranges="UPDATE_CELL_SIZES", + # update_cellsize_ranges = "NO_CELL_SIZES", + update_boundary="UPDATE_BOUNDARY", + # update_boundary = "NO_BOUNDARY", + update_overviews="NO_OVERVIEWS", + maximum_pyramid_levels=None, + maximum_cell_size="0", + minimum_dimension="1500", + spatial_reference=psr, + filter="", + sub_folder="NO_SUBFOLDERS", + # duplicate_items_action = "OVERWRITE_DUPLICATES", + duplicate_items_action="EXCLUDE_DUPLICATES", + build_pyramids="NO_PYRAMIDS", + # calculate_statistics = "CALCULATE_STATISTICS", + calculate_statistics="NO_STATISTICS", + # build_thumbnails = "BUILD_THUMBNAILS", + build_thumbnails="NO_THUMBNAILS", + operation_description="DisMAP", + # force_spatial_reference= "NO_FORCE_SPATIAL_REFERENCE", + force_spatial_reference="FORCE_SPATIAL_REFERENCE", + # estimate_statistics = "ESTIMATE_STATISTICS", + estimate_statistics="NO_STATISTICS", + ) + arcpy.AddMessage( + "\tAdd Rasters To Mosaic Dataset: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + del input_raster_paths + del psr + + arcpy.AddMessage( + f"Joining {os.path.basename(mosaic_path)} with {os.path.basename(layerspeciesyearimagename)}" + ) + + arcpy.management.JoinField( + in_data=mosaic_path, + in_field="Name", + join_table=layerspeciesyearimagename, + join_field="ImageName", + fields="DatasetCode;Region;Season;Species;CommonName;SpeciesCommonName;CoreSpecies;Year;StdTime;Variable;Value;Dimensions", + ) + arcpy.AddMessage( + "\tJoin Field: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + del layerspeciesyearimagename + + arcpy.AddMessage(f"Removing field index from {os.path.basename(mosaic_path)}") + + try: + arcpy.management.RemoveIndex( + mosaic_path, + [ + f"{table_name}_MosaicSpeciesIndex", + ], + ) + except: # noqa: E722 + pass + + arcpy.AddMessage(f"Adding field index to {os.path.basename(mosaic_path)}") + + # Add Attribute Index + arcpy.management.AddIndex( + mosaic_path, + ["Species", "CommonName", "SpeciesCommonName", "Year"], + f"{table_name}_MosaicSpeciesIndex", + "NON_UNIQUE", + "NON_ASCENDING", + ) + arcpy.AddMessage( + "\tAdd Index: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + arcpy.management.CalculateStatistics(mosaic_path, 1, 1, [], "OVERWRITE", "") + arcpy.AddMessage( + "\tCalculate Statistics: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + + # --->>> SetMosaicDatasetProperties + arcpy.AddMessage( + f"Set Mosaic Dataset Properties for {os.path.basename(mosaic_path)}" + ) + + # fields = [f.name for f in arcpy.ListFields(mosaic_path) if f.type not in ['Geometry', 'OID'] and f.name not in ["Shape", "Raster", "Category", "TypeID", "ItemTS", "UriHash", "Uri",]] + fields = [f.name for f in arcpy.ListFields(mosaic_path)] + + fields = ";".join(fields) + + arcpy.management.SetMosaicDatasetProperties( + in_mosaic_dataset=mosaic_path, + rows_maximum_imagesize=4100, + columns_maximum_imagesize=15000, + allowed_compressions="LZ77;None", + default_compression_type="LZ77", + JPEG_quality=75, + LERC_Tolerance=0.01, + resampling_type="BILINEAR", + clip_to_footprints="NOT_CLIP", + footprints_may_contain_nodata="FOOTPRINTS_MAY_CONTAIN_NODATA", + clip_to_boundary="CLIP", + color_correction="NOT_APPLY", + allowed_mensuration_capabilities="Basic", + default_mensuration_capabilities="Basic", + allowed_mosaic_methods="None", + default_mosaic_method="None", + order_field="StdTime", + order_base="", + sorting_order="ASCENDING", + mosaic_operator="FIRST", + blend_width=10, + view_point_x=600, + view_point_y=300, + max_num_per_mosaic=50, + cell_size_tolerance=0.8, + cell_size=f"{cell_size} {cell_size}", + metadata_level="FULL", + transmission_fields=fields, + use_time="ENABLED", + start_time_field="StdTime", + end_time_field="StdTime", + time_format="YYYY", # YYYYMMDD + geographic_transform=None, + max_num_of_download_items=20, + max_num_of_records_returned=1000, + data_source_type="GENERIC", + minimum_pixel_contribution=1, + processing_templates="None", + default_processing_template="None", + time_interval=1, + time_interval_units="Years", + product_definition="NONE", + product_band_definitions=None, + ) + arcpy.AddMessage( + "\tSet Mosaic Dataset Properties: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + del fields + + arcpy.AddMessage(f"Analyze Mosaic {os.path.basename(mosaic_path)} Dataset") + + arcpy.management.AnalyzeMosaicDataset( + in_mosaic_dataset=mosaic_path, + where_clause="", + checker_keywords="FOOTPRINT;FUNCTION;RASTER;PATHS;SOURCE_VALIDITY;STALE;PYRAMIDS;STATISTICS;PERFORMANCE;INFORMATION", + ) + arcpy.AddMessage( + "\tSet Mosaic Dataset Properties: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + + arcpy.AddMessage( + f"Adding Multidimensional Information to {os.path.basename(mosaic_path)} Dataset" + ) + + with arcpy.EnvManager(scratchWorkspace=scratch_workspace, workspace=region_gdb): + arcpy.md.BuildMultidimensionalInfo( + in_mosaic_dataset=mosaic_path, + variable_field="Variable", + dimension_fields=[ + ["StdTime", "Time Step", "Year"], + ], + variable_desc_units=None, + delete_multidimensional_info="NO_DELETE_MULTIDIMENSIONAL_INFO", + ) + arcpy.AddMessage( + "\tBuild Multidimensional Info: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + + # arcpy.management.CalculateStatistics(mosaic_path, 1, 1, [], "OVERWRITE", "") + # arcpy.AddMessage("\tCalculate Statistics: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) + + # Copy Raster to CRF + crf_path = ( + rf"{scratch_folder}\{table_name}\{mosaic_name.replace('_Mosaic', '')}.crf" + ) + + arcpy.management.CopyRaster( + in_raster=mosaic_path, + out_rasterdataset=crf_path, + config_keyword="", + background_value=None, + nodata_value="-3.40282e+38", + onebit_to_eightbit="NONE", + colormap_to_RGB="NONE", + pixel_type="32_BIT_FLOAT", + scale_pixel_value="NONE", + RGB_to_Colormap="NONE", + format="CRF", + transform=None, + process_as_multidimensional="ALL_SLICES", + build_multidimensional_transpose="NO_TRANSPOSE", + ) + arcpy.AddMessage( + "\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + arcpy.AddMessage(f"Calculate Statistics for {os.path.basename(crf_path)}") + + arcpy.management.CalculateStatistics(crf_path, 1, 1, [], "OVERWRITE", "") + arcpy.AddMessage( + "\tCalculate Statistics: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + del crf_path + del mosaic_path + + # End of business logic for the worker function + arcpy.AddMessage(f"Processing for: {table_name} complete") + + arcpy.management.Delete(rf"{region_gdb}\Datasets") + arcpy.management.Delete(rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName") + arcpy.management.Delete(rf"{region_gdb}\{table_name}_Raster_Mask") + + # Declared Variables for this function only + del datasetcode, cell_size, mosaic_name, mosaic_title + # Basic variables + del table_name, scratch_folder, project_folder, scratch_workspace + # Imports + # Function parameter + del region_gdb + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def script_tool(project_gdb=""): + try: + # Imports + from time import gmtime, localtime, strftime, time + + import dismap_tools + from create_mosaics_director import preprocessing + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + ## # Set worker parameters + ## #table_name = "AI_IDW" + ## table_name = "HI_IDW" + ## #table_name = "NBS_IDW" + ## #table_name = "ENBS_IDW" + + table_names = ["HI_IDW", "NBS_IDW"] + + preprocessing( + project_gdb=project_gdb, table_names=table_names, clear_folder=True + ) + + for table_name in table_names: + region_gdb = rf"{os.path.dirname(project_gdb)}\Scratch\{table_name}.gdb" + try: + pass + worker(region_gdb=region_gdb) + except SystemExit: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del table_name, region_gdb + del table_names + + # Declared Varaiables + # Imports + del dismap_tools + # Function Parameters + del project_gdb + + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) + minutes, seconds = divmod(rem, 60) + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) + arcpy.AddMessage(f"{'-' * 80}") + del hours, rem, minutes, seconds + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +if __name__ == "__main__": + try: + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) + else: + pass + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + del project_gdb + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_rasters_director.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_rasters_director.py new file mode 100644 index 0000000..14bc16b --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_rasters_director.py @@ -0,0 +1,547 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: create_species_year_image_name_table_director +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 09/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import os +import sys +import traceback + +import arcpy # third-parties second + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + filename = sys.path[0] + os.sep + f"{__file__}" + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror + + +def preprocessing(project_gdb="", table_names="", clear_folder=True): + try: + import dismap_tools + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # Set basic arcpy.env variables + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + # Set varaibales + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{project_folder}\Scratch" + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + + # Clear Scratch Folder + # ClearScratchFolder = True + # if ClearScratchFolder: + if clear_folder: + dismap_tools.clear_folder(folder=scratch_folder) + else: + pass + # del ClearScratchFolder + del clear_folder + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + del project_folder, scratch_workspace + + if not table_names: + table_names = [ + row[0] + for row in arcpy.da.SearchCursor( + os.path.join(project_gdb, "Datasets"), + "TableName", + where_clause="TableName LIKE '%_IDW'", + ) + ] + else: + pass + + for table_name in table_names: + arcpy.AddMessage(f"Pre-Processing: {table_name}") + + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + region_scratch_workspace = os.path.join( + scratch_folder, f"{table_name}", "scratch.gdb" + ) + + # Create Scratch Workspace for Region + if not arcpy.Exists(region_scratch_workspace): + os.makedirs(os.path.join(scratch_folder, table_name)) + if not arcpy.Exists(region_scratch_workspace): + arcpy.management.CreateFileGDB( + os.path.join(scratch_folder, f"{table_name}"), "scratch" + ) + del region_scratch_workspace + + sample_locations = rf"{table_name}_Sample_Locations" + + arcpy.AddMessage(f"Creating File GDB: {table_name}") + arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + + # Process: Make Table View (Make Table View) (management) + datasets = rf"{project_gdb}\Datasets" + arcpy.AddMessage( + f"\t{os.path.basename(datasets)} has {arcpy.management.GetCount(datasets)[0]} records" + ) + + table_name_view = "Dataset Table View" + arcpy.management.MakeTableView( + in_table=datasets, + out_view=table_name_view, + where_clause=f"TableName = '{table_name}'", + ) + arcpy.AddMessage( + f"\tThe table {table_name_view} has {arcpy.management.GetCount(table_name_view)[0]} records" + ) + arcpy.management.CopyRows(table_name_view, rf"{region_gdb}\Datasets") + arcpy.AddMessage( + "\tCopy Rows: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + filter_region = [ + row[0] + for row in arcpy.da.SearchCursor( + rf"{region_gdb}\Datasets", "FilterRegion" + ) + ][0].replace("'", "''") + filter_subregion = [ + row[0] + for row in arcpy.da.SearchCursor( + rf"{region_gdb}\Datasets", "FilterSubRegion" + ) + ][0].replace("'", "''") + + arcpy.management.Delete(table_name_view) + del table_name_view + + arcpy.AddMessage( + f"Copying: The table {table_name}_LayerSpeciesYearImageName" + ) + arcpy.management.Copy( + rf"{project_gdb}\{table_name}_LayerSpeciesYearImageName", + rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + # + arcpy.AddMessage("Make Feature Layer (Make Feature Layer) (management)") + # Process: Make Feature Layer (Make Feature Layer) (management) + idw_lyr = arcpy.management.MakeFeatureLayer( + in_features=rf"{project_gdb}\{sample_locations}", + out_layer="IDW_Sample_Locations_Layer", + where_clause="DistributionProjectName = 'NMFS/Rutgers IDW Interpolation'", + workspace="", + field_info="OBJECTID OBJECTID VISIBLE NONE;Shape Shape VISIBLE NONE;DatasetCode DatasetCode VISIBLE NONE;Region Region VISIBLE NONE;Season Season VISIBLE NONE;DistributionProjectName DistributionProjectName VISIBLE NONE;SummaryProduct SummaryProduct VISIBLE NONE;SampleID SampleID VISIBLE NONE;Year Year VISIBLE NONE;StdTime StdTime VISIBLE NONE;Species Species VISIBLE NONE;WTCPUE WTCPUE VISIBLE NONE;MapValue MapValue VISIBLE NONE;TransformUnit TransformUnit VISIBLE NONE;CommonName CommonName VISIBLE NONE;SpeciesCommonName SpeciesCommonName VISIBLE NONE;CommonNameSpecies CommonNameSpecies VISIBLE NONE;CoreSpecies CoreSpecies VISIBLE NONE;Stratum Stratum VISIBLE NONE;StratumArea StratumArea VISIBLE NONE;Latitude Latitude VISIBLE NONE;Longitude Longitude VISIBLE NONE;Depth Depth VISIBLE NONE", + ) + + arcpy.AddMessage("Copy Features (Copy Features) (management)") + arcpy.management.CopyFeatures(idw_lyr, rf"{region_gdb}\{sample_locations}") + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + # + arcpy.AddMessage("Copy") + arcpy.management.Copy( + rf"{project_gdb}\{table_name}_Raster_Mask", + rf"{region_gdb}\{table_name}_Raster_Mask", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + arcpy.management.Delete(idw_lyr) + del idw_lyr + + del sample_locations + del region_gdb, table_name + del datasets, filter_region, filter_subregion + # Declared Variables + del scratch_folder + # Imports + del dismap_tools + # Function Parameters + del project_gdb, table_names + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def director(project_gdb="", Sequential=True, table_names=[]): + try: + from create_rasters_worker import worker + + # Test if passed workspace exists, if not sys.exit() + if not arcpy.Exists(rf"{project_gdb}"): + arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") + arcpy.AddError(arcpy.GetMessages(2)) + sys.exit() + # sys.exit() + else: + pass + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + project_folder = os.path.dirname(project_gdb) + scratch_folder = os.path.join(project_folder, "Scratch") + del project_folder + + preprocessing( + project_gdb=project_gdb, table_names=table_names, clear_folder=True + ) + + # Sequential Processing + if Sequential: + arcpy.AddMessage("Sequential Processing") + for i in range(0, len(table_names)): + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = rf"{os.path.dirname(project_gdb)}\Scratch\{table_name}.gdb" + try: + pass + worker(region_gdb=region_gdb) + except: # noqa: E722 + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del region_gdb, table_name + del i + else: + pass + + # Non-Sequential Processing + if not Sequential: + import multiprocessing + from time import gmtime, localtime, sleep, strftime, time + + arcpy.AddMessage("Start multiprocessing using the ArcGIS Pro pythonw.exe.") + # Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS + # get_install_path() uses a registry query to figure out 64bit python exe if available + multiprocessing.set_executable(os.path.join(sys.exec_prefix, "pythonw.exe")) + # Get CPU count and then take 2 away for other process + _processes = multiprocessing.cpu_count() - 2 + _processes = ( + _processes if len(table_names) >= _processes else len(table_names) + ) + arcpy.AddMessage( + f"Creating the multiprocessing Pool with {_processes} processes" + ) + # Create a pool of workers, keep one cpu free for surfing the net. + # Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) + with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: + arcpy.AddMessage("\tPrepare arguments for processing") + # Use apply_async so we can handle exceptions gracefully + jobs = {} + for i in range(0, len(table_names)): + try: + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + jobs[table_name] = pool.apply_async(worker, [region_gdb]) + del table_name, region_gdb + except: # noqa: E722 + pool.terminate() + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del i + all_finished = False + # Set a start time so that we can see how log things take + start_time = time() + result_completed = {} + while True: + all_finished = True + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + arcpy.AddMessage( + f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage("Have the workers finished?") + finish_time = strftime("%a %b %d %I:%M %p", localtime()) + time_elapsed = "Elapsed Time {0} (H:M:S)".format( + strftime("%H:%M:%S", gmtime(elapse_time)) + ) + arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") + finish_time = f"{finish_time}.\n\t{time_elapsed}" + del time_elapsed + for table_name, result in jobs.items(): + if result.ready(): + if table_name not in result_completed: + result_completed[table_name] = finish_time + try: + # wait for and get the result from the task + result.get() + except: # noqa: E722 + pool.terminate() + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + pass + arcpy.AddMessage( + f"Process {table_name}\n\tFinished on {result_completed[table_name]}" + ) + else: + all_finished = False + arcpy.AddMessage(f"Process {table_name} is running. . .") + del table_name, result + del elapse_time, end_time, finish_time + if all_finished: + break + sleep(_processes * 7.5) + del result_completed + del start_time + del all_finished + arcpy.AddMessage("\tClose the process pool") + # close the process pool + pool.close() + # wait for all tasks to complete and processes to close + arcpy.AddMessage( + "\tWait for all tasks to complete and processes to close" + ) + pool.join() + # Just in case + pool.terminate() + del pool + del jobs + del _processes + del time, multiprocessing, localtime, strftime, sleep, gmtime + arcpy.AddMessage("\tDone with multiprocessing Pool") + + # No Post-Processing + + arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") + arcpy.management.Compact(project_gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + + # Declared Variables assigned in function + del scratch_folder + + # Imports + del worker + + # Function Parameters + del project_gdb, Sequential, table_names + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def script_tool(project_gdb=""): + try: + # Imports + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + try: + pass + # table_names = ["AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW",] + + Test = False + if Test: + director( + project_gdb=project_gdb, + Sequential=True, + table_names=[ + "HI_IDW", + "AI_IDW", + ], + ) + + elif not Test: + # + # director(project_gdb=project_gdb, Sequential=False, table_names = ["AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW",]) + # director(project_gdb=project_gdb, Sequential=False, table_names = ["EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "NBS_IDW", ]) + # director(project_gdb=project_gdb, Sequential=False, table_names = ["HI_IDW",]) + # director(project_gdb=project_gdb, Sequential=False, table_names = [ "WC_ANN_IDW", "WC_TRI_IDW",]) + # director(project_gdb=project_gdb, Sequential=False, table_names = ["SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) + # director(project_gdb=project_gdb, Sequential=False, table_names = ["NEUS_FAL_IDW", "NEUS_SPR_IDW", ]) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "EBS_IDW", + "ENBS_IDW", + "GMEX_IDW", + "GOA_IDW", + "NBS_IDW", + "NEUS_FAL_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NEUS_SPR_IDW", + "SEUS_FAL_IDW", + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + "WC_ANN_IDW", + "WC_TRI_IDW", + ], + ) + # director(project_gdb=project_gdb, Sequential=False, table_names=[]) + else: + pass + del Test + + except: # noqa: E722 + pass + # arcpy.AddError(arcpy.GetMessages(2)) + # traceback.print_exc() + # sys.exit() + + # Declared Varaiables + # Imports + + # Function Parameters + del project_gdb + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) + minutes, seconds = divmod(rem, 60) + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) + arcpy.AddMessage(f"{'-' * 80}") + del hours, rem, minutes, seconds + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +if __name__ == "__main__": + try: + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) + else: + pass + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + del project_gdb + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_rasters_worker.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_rasters_worker.py similarity index 60% rename from ArcGIS-Analysis-Python/src/dismap_tools/create_rasters_worker.py rename to ArcGIS-Analysis-Python/Scripts/dismap_tools/create_rasters_worker.py index 6aabe61..c126fea 100644 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_rasters_worker.py +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_rasters_worker.py @@ -9,12 +9,23 @@ # Copyright: (c) john.f.kennedy 2024 # Licence: #------------------------------------------------------------------------------- -import os, sys # built-ins first +import os +import sys import traceback -import inspect +import arcpy # third-parties second -import arcpy # third-parties second + +def trace(): + import sys # noqa: E401 + import traceback + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + #filename = sys.path[0] + os.sep + f"{os.path.basename(__file__)}" + filename = os.path.basename(__file__) + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror def print_table(table=""): try: @@ -30,10 +41,22 @@ def print_table(table=""): del row del desc, fields, oid del table - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() + except arcpy.ExecuteError: + #Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + #Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True def worker(region_gdb=""): try: @@ -90,9 +113,9 @@ def worker(region_gdb=""): # Assigning variables from items in the chosen table list # ['AI_IDW', 'AI_IDW_Region', 'AI', 'Aleutian Islands', None, 'IDW'] table_name = region_list[0] - geographic_area = region_list[1] + #geographic_area = region_list[1] datasetcode = region_list[2] - cell_size = region_list[3] if type(region_list[3]) != "str" else int(region_list[3]) + cell_size = region_list[3] if not isinstance(region_list[3], type("str")) else int(region_list[3]) region = region_list[4] season = region_list[5] distri_code = region_list[6] @@ -188,18 +211,22 @@ def worker(region_gdb=""): msg = msg + f"\t\t\tSpecies: {species}\n" msg = msg + f"\t\t\tYear: {year}\n" msg = msg + f"\t\t\tOutput Raster: {os.path.basename(output_raster_path)}\n" - arcpy.AddMessage(msg); del msg + arcpy.AddMessage(msg) + del msg - arcpy.AddMessage(f'\t\t\tSelect Layer by Attribute: "CLEAR_SELECTION"') + arcpy.AddMessage('\t\t\tSelect Layer by Attribute: "CLEAR_SELECTION"') arcpy.management.SelectLayerByAttribute( sample_locations_path_layer, "CLEAR_SELECTION" ) arcpy.AddMessage(f"\t\t\tSelect Layer by Attribute: Species = '{species}' AND Year = {year}") # Select for species and year - arcpy.management.SelectLayerByAttribute( sample_locations_path_layer, - "NEW_SELECTION", - f"Species = '{species}' AND Year = {year}" + #print(sample_locations_path_layer) + #print(f"Species = '{species}' AND Year = {year}") + arcpy.management.SelectLayerByAttribute( in_layer_or_view = sample_locations_path_layer, + selection_type = "NEW_SELECTION", + where_clause = f"Species = '{species}' And Year = {year}", + invert_where_clause=None ) # Get the count of records for selected species @@ -211,7 +238,7 @@ def worker(region_gdb=""): #if summary_product == "Yes": - arcpy.AddMessage(f"\t\t\tProcessing IDW") + arcpy.AddMessage("\t\t\tProcessing IDW") # Select weighted years arcpy.management.SelectLayerByAttribute( sample_locations_path_layer, @@ -336,188 +363,36 @@ def worker(region_gdb=""): # Function parameter del region_gdb - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() + #Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + #Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk return True - finally: - pass - -def preprocessing(project_gdb="", table_names="", clear_folder=True): - try: - import dismap_tools - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic arcpy.env variables - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - # Set varaibales - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - - # Clear Scratch Folder - #ClearScratchFolder = True - #if ClearScratchFolder: - if clear_folder: - dismap_tools.clear_folder(folder=scratch_folder) - else: - pass - #del ClearScratchFolder - del clear_folder - - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - del project_folder, scratch_workspace - - if not table_names: - table_names = [row[0] for row in arcpy.da.SearchCursor(f"{project_gdb}\Datasets", - "TableName", - where_clause = "TableName LIKE '%_IDW'")] - else: - pass - - for table_name in table_names: - arcpy.AddMessage(f"Pre-Processing: {table_name}") - - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - - # Create Scratch Workspace for Region - if not arcpy.Exists(region_scratch_workspace): - os.makedirs(rf"{scratch_folder}\{table_name}") - if not arcpy.Exists(region_scratch_workspace): - arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") - del region_scratch_workspace - - sample_locations = rf"{table_name}_Sample_Locations" - - arcpy.AddMessage(f"Creating File GDB: {table_name}") - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - - # Process: Make Table View (Make Table View) (management) - datasets = rf'{project_gdb}\Datasets' - arcpy.AddMessage(f"\t{os.path.basename(datasets)} has {arcpy.management.GetCount(datasets)[0]} records") - - table_name_view = "Dataset Table View" - arcpy.management.MakeTableView(in_table = datasets, - out_view = table_name_view, - where_clause = f"TableName = '{table_name}'" - ) - arcpy.AddMessage(f"\tThe table {table_name_view} has {arcpy.management.GetCount(table_name_view)[0]} records") - arcpy.management.CopyRows(table_name_view, rf"{region_gdb}\Datasets") - arcpy.AddMessage("\tCopy Rows: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - filter_region = [row[0] for row in arcpy.da.SearchCursor(rf"{region_gdb}\Datasets", "FilterRegion")][0].replace("'", "''") - filter_subregion = [row[0] for row in arcpy.da.SearchCursor(rf"{region_gdb}\Datasets", "FilterSubRegion")][0].replace("'", "''") - - arcpy.management.Delete(table_name_view) - del table_name_view - - arcpy.AddMessage(f"Copying: The table {table_name}_LayerSpeciesYearImageName") - arcpy.management.Copy(rf"{project_gdb}\{table_name}_LayerSpeciesYearImageName", rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # - arcpy.AddMessage(f"Make Feature Layer (Make Feature Layer) (management)") - # Process: Make Feature Layer (Make Feature Layer) (management) - idw_lyr = arcpy.management.MakeFeatureLayer( in_features = rf"{project_gdb}\{sample_locations}", - out_layer = "IDW_Sample_Locations_Layer", - where_clause = "DistributionProjectName = 'NMFS/Rutgers IDW Interpolation'", - workspace = "", - field_info = "OBJECTID OBJECTID VISIBLE NONE;Shape Shape VISIBLE NONE;DatasetCode DatasetCode VISIBLE NONE;Region Region VISIBLE NONE;Season Season VISIBLE NONE;DistributionProjectName DistributionProjectName VISIBLE NONE;SummaryProduct SummaryProduct VISIBLE NONE;SampleID SampleID VISIBLE NONE;Year Year VISIBLE NONE;StdTime StdTime VISIBLE NONE;Species Species VISIBLE NONE;WTCPUE WTCPUE VISIBLE NONE;MapValue MapValue VISIBLE NONE;TransformUnit TransformUnit VISIBLE NONE;CommonName CommonName VISIBLE NONE;SpeciesCommonName SpeciesCommonName VISIBLE NONE;CommonNameSpecies CommonNameSpecies VISIBLE NONE;CoreSpecies CoreSpecies VISIBLE NONE;Stratum Stratum VISIBLE NONE;StratumArea StratumArea VISIBLE NONE;Latitude Latitude VISIBLE NONE;Longitude Longitude VISIBLE NONE;Depth Depth VISIBLE NONE" - ) - - arcpy.AddMessage(f"Copy Features (Copy Features) (management)") - arcpy.management.CopyFeatures(idw_lyr, rf"{region_gdb}\{sample_locations}") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # - arcpy.AddMessage(f"Copy") - arcpy.management.Copy(rf"{project_gdb}\{table_name}_Raster_Mask", rf"{region_gdb}\{table_name}_Raster_Mask") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.management.Delete(idw_lyr) - del idw_lyr - - del sample_locations - del region_gdb, table_name - del datasets, filter_region, filter_subregion - # Declared Variables - del scratch_folder - # Imports - del dismap_tools - # Function Parameters - del project_gdb, table_names - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass def script_tool(project_gdb=""): try: # Imports - import dismap_tools from time import gmtime, localtime, strftime, time + + import dismap_tools + from create_rasters_director import preprocessing + # Set a start time so that we can see how log things take start_time = time() arcpy.AddMessage(f"{'-' * 80}") arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") arcpy.AddMessage(f"Python Version: {sys.version}") arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") @@ -558,7 +433,7 @@ def script_tool(project_gdb=""): # Declared Varaiables # Imports - del dismap_tools + del dismap_tools, preprocessing # Function Parameters del project_gdb # Elapsed time @@ -576,48 +451,44 @@ def script_tool(project_gdb=""): del elapse_time, end_time, start_time del gmtime, localtime, strftime, time - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() + #Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + #Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk return True - finally: - pass if __name__ == '__main__': try: project_gdb = arcpy.GetParameterAsText(0) if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" + project_gdb = os.path.join(os.path.expanduser('~'), "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb") else: pass script_tool(project_gdb) arcpy.SetParameterAsText(1, "Result") del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file + + except arcpy.ExecuteError: + #Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + #Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_bathymetry_director.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_bathymetry_director.py new file mode 100644 index 0000000..a0550f4 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_bathymetry_director.py @@ -0,0 +1,590 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: module1 +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 05/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import os +import sys # built-ins first +import traceback + +import arcpy # third-parties second + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + filename = sys.path[0] + os.sep + "test.py" + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror + + +def preprocessing(project_gdb="", table_names="", clear_folder=True): + try: + import dismap_tools + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # Set basic arcpy.env variables + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + # Set varaibales + project_folder = os.path.dirname(project_gdb) + scratch_folder = os.path.join(project_folder, "Scratch") + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + csv_data_folder = os.path.join(project_folder, "CSV_Data") + base_project_bathymetry_gdb = os.path.join( + os.path.dirname(project_folder), "Bathymetry\\Bathymetry.gdb" + ) + + ## # Clear Scratch Folder + ## #ClearScratchFolder = True + ## #if ClearScratchFolder: + ## if clear_folder: + ## dismap_tools.clear_folder(folder = scratch_folder) + ## else: + ## pass + ## #del ClearScratchFolder + ## del clear_folder + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + del project_folder, scratch_workspace + + if not table_names: + table_names = [ + row[0] + for row in arcpy.da.SearchCursor( + os.path.join(project_gdb, "Datasets"), + "TableName", + where_clause="TableName LIKE '%_IDW'", + ) + ] + else: + pass + + for table_name in table_names: + arcpy.AddMessage(f"Pre-Processing: {table_name}") + + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + region_scratch_workspace = os.path.join( + scratch_folder, f"{table_name}", "scratch.gdb" + ) + + # Create Scratch Workspace for Region + if not arcpy.Exists(region_scratch_workspace): + os.makedirs(os.path.join(scratch_folder, table_name)) + if not arcpy.Exists(region_scratch_workspace): + arcpy.AddMessage(f"Create File GDB: '{table_name}'") + arcpy.management.CreateFileGDB( + os.path.join(scratch_folder, table_name), "scratch" + ) + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + del region_scratch_workspace + # # # CreateFileGDB + arcpy.AddMessage(f"Creating File GDB: '{table_name}'") + arcpy.management.CreateFileGDB(scratch_folder, table_name) + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + # # # CreateFileGDB + + # # # Datasets + # Process: Make Table View (Make Table View) (management) + datasets = rf"{project_gdb}\Datasets" + arcpy.AddMessage( + f"'{os.path.basename(datasets)}' has {arcpy.management.GetCount(datasets)[0]} records" + ) + arcpy.management.Copy(datasets, os.path.join(region_gdb, "Datasets")) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + del datasets + # # # Datasets + + # # # Fishnet + region_fishnet = os.path.join(project_gdb, f"{table_name}_Fishnet") + arcpy.AddMessage( + f"The table '{table_name}_Fishnet' has {arcpy.management.GetCount(region_fishnet)[0]} records" + ) + arcpy.management.Copy( + region_fishnet, os.path.join(region_gdb, f"{table_name}_Fishnet") + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + del region_fishnet + # # # Fishnet + + # # # Raster_Mask + region_raster_mask = os.path.join(project_gdb, f"{table_name}_Raster_Mask") + arcpy.AddMessage(f"Copy Raster Mask for '{table_name}'") + # arcpy.management.Copy(os.path.join(project_gdb, f"{table_name}_Raster_Mask"), os.path.join(region_gdb, f"{table_name}_Raster_Mask")) + arcpy.management.CopyRaster( + region_raster_mask, + os.path.join(region_gdb, f"{table_name}_Raster_Mask"), + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + del region_raster_mask + # # # Raster_Mask + + # # # Bathymetry + base_fishnet_bathymetry = os.path.join( + base_project_bathymetry_gdb, f"{table_name}_Bathymetry" + ) + arcpy.AddMessage(f"Copy Bathymetry for '{table_name}'") + # arcpy.management.Copy(os.path.join(project_bathymetry_gdb, f"{table_name}_Bathymetry"), os.path.join(region_gdb, f"{table_name}_Fishnet_Bathymetry")) + arcpy.management.CopyRaster( + base_fishnet_bathymetry, + os.path.join(region_gdb, f"{table_name}_Fishnet_Bathymetry"), + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + del base_fishnet_bathymetry + # # # Bathymetry + + # Declared Variables + del table_name + + # Declared Variables + del scratch_folder, region_gdb + del csv_data_folder, base_project_bathymetry_gdb + # Imports + del dismap_tools + # Function Parameters + del project_gdb, table_names + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def director(project_gdb="", Sequential=True, table_names=[]): + try: + # Imports + import dismap_tools + from create_region_bathymetry_worker import worker + + # Test if passed workspace exists, if not sys.exit() + if not arcpy.Exists(project_gdb): + arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") + arcpy.AddError(arcpy.GetMessages(2)) + sys.exit() + else: + pass + + # Set History and Metadata logs, set serverity and message level + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 2 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" + scratch_workspace = rf"{os.path.dirname(project_gdb)}\Scratch\scratch.gdb" + csv_data_folder = rf"{os.path.dirname(project_gdb)}\CSV_Data" + # project_bathymetry_gdb = rf"{os.path.dirname(project_gdb)}\Bathymetry\Bathymetry.gdb" + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + + preprocessing( + project_gdb=project_gdb, table_names=table_names, clear_folder=True + ) + + del project_folder, scratch_workspace + + # Sequential Processing + if Sequential: + arcpy.AddMessage("Sequential Processing") + for i in range(0, len(table_names)): + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + try: + pass + worker(region_gdb=region_gdb) + except: # noqa: E722 + traceback.print_exc() + del region_gdb, table_name + del i + else: + pass + + # Non-Sequential Processing + if not Sequential: + import multiprocessing + from time import gmtime, localtime, sleep, strftime, time + + arcpy.AddMessage("Sequential Processing") + # Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS + # get_install_path() uses a registry query to figure out 64bit python exe if available + multiprocessing.set_executable(os.path.join(sys.exec_prefix, "pythonw.exe")) + # Get CPU count and then take 2 away for other process + _processes = multiprocessing.cpu_count() - 2 + _processes = ( + _processes if len(table_names) >= _processes else len(table_names) + ) + arcpy.AddMessage( + f"Creating the multiprocessing Pool with {_processes} processes" + ) + # Create a pool of workers, keep one cpu free for surfing the net. + # Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) + with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: + arcpy.AddMessage("\tPrepare arguments for processing") + # Use apply_async so we can handle exceptions gracefully + jobs = {} + for i in range(0, len(table_names)): + try: + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + jobs[table_name] = pool.apply_async(worker, [region_gdb]) + del table_name, region_gdb + except: # noqa: E722 + pool.terminate() + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del i + all_finished = False + # Set a start time so that we can see how log things take + start_time = time() + result_completed = {} + while True: + all_finished = True + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + arcpy.AddMessage( + f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage("Have the workers finished?") + finish_time = strftime("%a %b %d %I:%M %p", localtime()) + time_elapsed = "Elapsed Time {0} (H:M:S)".format( + strftime("%H:%M:%S", gmtime(elapse_time)) + ) + arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") + finish_time = f"{finish_time}.\n\t{time_elapsed}" + del time_elapsed + for table_name, result in jobs.items(): + if result.ready(): + if table_name not in result_completed: + result_completed[table_name] = finish_time + try: + # wait for and get the result from the task + result.get() + except SystemExit: + pool.terminate() + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except: # noqa: E722 + pool.terminate() + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + pass + arcpy.AddMessage( + f"Process {table_name}\n\tFinished on {result_completed[table_name]}" + ) + else: + all_finished = False + arcpy.AddMessage(f"Process {table_name} is running. . .") + del table_name, result + del elapse_time, end_time, finish_time + if all_finished: + break + sleep(_processes * 7.5) + del result_completed + del start_time + del all_finished + arcpy.AddMessage("\tClose the process pool") + # close the process pool + pool.close() + # wait for all tasks to complete and processes to close + arcpy.AddMessage( + "\tWait for all tasks to complete and processes to close" + ) + pool.join() + # Just in case + pool.terminate() + del pool + del jobs + del _processes + del time, multiprocessing, localtime, strftime, sleep, gmtime + + arcpy.AddMessage("\tDone with multiprocessing Pool") + + # Post-Processing + arcpy.AddMessage("Post-Processing Begins") + arcpy.AddMessage("Processing Results") + + datasets = list() + + walk = arcpy.da.Walk(scratch_folder, datatype="RasterDataset", type=[]) + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + + for dataset in datasets: + dataset_short_path = f"..{'/'.join(__file__.split(os.sep)[-4:])}" + # arcpy.AddMessage(fc_short_path) + dataset_name = os.path.basename(dataset) + region_gdb = os.path.dirname(dataset) + arcpy.AddMessage(f"\tDataset: '{dataset_name}'") + arcpy.AddMessage(f"\t\tPath: '{dataset_short_path}'") + arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") + + ## if arcpy.Exists(rf"{project_gdb}\{dataset_name}"): + ## arcpy.management.Delete(rf"{project_gdb}\{dataset_name}") + ## else: + ## pass + + arcpy.management.CopyRaster(dataset, rf"{project_gdb}\{dataset_name}") + arcpy.AddMessage( + "\tCopy: {0} {1}\n".format( + f"{dataset_name}", arcpy.GetMessages(0).replace("\n", "\n\t") + ) + ) + + desc = arcpy.da.Describe(dataset) + if desc["dataType"] in ["FeatureClass", "Table", "MosaicDataset"]: + dismap_tools.alter_fields( + csv_data_folder, rf"{project_gdb}\{dataset_name}" + ) + del desc + + del region_gdb, dataset_name, dataset_short_path, dataset + + del datasets + + arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") + arcpy.management.Compact(project_gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + + # Declared Variables + del csv_data_folder, scratch_folder + # Imports + del dismap_tools, worker + # Function Parameters + del project_gdb, Sequential, table_names + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def script_tool(project_gdb=""): + try: + # Imports + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: ..{'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + ## # Clear Scratch Folder + ## ClearScratchFolder = False + ## if ClearScratchFolder: + ## import dismap_tools + ## dismap_tools.clear_folder(folder=scratch_folder) + ## del dismap_tools + ## else: + ## pass + ## del ClearScratchFolder + + ## tbn = ["AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW",] + ## preprocessing(project_gdb=project_gdb, table_names=tbn, clear_folder=True) + ## del tbn + + try: + # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", + # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", + + Test = False + if Test: + director( + project_gdb=project_gdb, Sequential=True, table_names=["HI_IDW"] + ) + else: + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NBS_IDW", + "ENBS_IDW", + "HI_IDW", + "SEUS_FAL_IDW", + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "WC_TRI_IDW", + "GMEX_IDW", + "AI_IDW", + "GOA_IDW", + "WC_ANN_IDW", + "NEUS_FAL_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=["NEUS_SPR_IDW", "EBS_IDW"], + ) + del Test + + except: # noqa: E722 + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + + # Declared Varaiables + # Imports + + # Function Parameters + del project_gdb + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) + minutes, seconds = divmod(rem, 60) + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) + arcpy.AddMessage(f"{'-' * 80}") + del hours, rem, minutes, seconds + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +if __name__ == "__main__": + try: + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) + else: + pass + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + del project_gdb + + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_bathymetry_worker.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_bathymetry_worker.py new file mode 100644 index 0000000..c230b93 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_bathymetry_worker.py @@ -0,0 +1,341 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: module1 +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 05/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import inspect +import os +import sys +import traceback + +import arcpy # third-parties second + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + filename = sys.path[0] + os.sep + "test.py" + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror + + +def worker(region_gdb=""): + try: + # Test if passed workspace exists, if not sys.exit() + if not arcpy.Exists(rf"{region_gdb}"): + sys.exit()(f"{os.path.basename(region_gdb)} is missing!!") + + # Imports + import dismap_tools + from arcpy import metadata as md + + # Set History and Metadata logs, set serverity and message level + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 2 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # Set basic workkpace variables + table_name = os.path.basename(region_gdb).replace(".gdb", "") + scratch_folder = os.path.dirname(region_gdb) + project_folder = os.path.dirname(scratch_folder) + csv_data_folder = os.path.join(project_folder, f"CSV_Data") + scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" + + arcpy.AddMessage( + f"Table Name: {table_name}\nProject Folder: {os.path.basename(project_folder)}\nScratch Folder: {os.path.basename(scratch_folder)}\n" + ) + + # Set basic workkpace variables + arcpy.env.workspace = region_gdb + arcpy.env.scratchWorkspace = scratch_workspace + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.env.compression = "LZ77" + # arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" + arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR LZ77 NO_SKIP" + arcpy.env.resamplingMethod = "BILINEAR" + arcpy.env.rasterStatistics = "STATISTICS 1 1" + # arcpy.env.XYResolution = "0.1 Meters" + # arcpy.env.XYResolution = "0.01 Meters" + # arcpy.env.cellAlignment = "ALIGN_WITH_PROCESSING_EXTENT" # Set the cell alignment environment using a keyword. + + # DatasetCode, CSVFile, TransformUnit, TableName, GeographicArea, CellSize, + # PointFeatureType, FeatureClassName, Region, Season, DateCode, Status, + # DistributionProjectCode, DistributionProjectName, SummaryProduct, + # FilterRegion, FilterSubRegion, FeatureServiceName, FeatureServiceTitle, + # MosaicName, MosaicTitle, ImageServiceName, ImageServiceTitle + + # Get values for table_name from Datasets table + # fields = ["TableName", "GeographicArea", "DatasetCode", "CellSize", "MosaicName", "MosaicTitle"] + # region_list = [row for row in arcpy.da.SearchCursor(rf"{region_gdb}\Datasets", fields, where_clause = f"TableName = '{table_name}'")][0] + # del fields + + # Assigning variables from items in the chosen table list + # ['AI_IDW', 'AI_IDW_Region', 'AI', 'Aleutian Islands', None, 'IDW'] + # table_name = region_list[0] + # geographic_area = region_list[1] + # datasetcode = region_list[2] + # cell_size = region_list[3] + # mosaic_name = region_list[4] + # mosaic_title = region_list[5] + # del region_list + + # Start of business logic for the worker function + arcpy.AddMessage(f"Processing: {table_name}") + + # Input + region_fishnet = os.path.join(region_gdb, f"{table_name}_Fishnet") + region_raster_mask = os.path.join(region_gdb, f"{table_name}_Raster_Mask") + region_fishnet_bathymetry = os.path.join( + region_gdb, f"{table_name}_Fishnet_Bathymetry" + ) + # Output + region_bathymetry = os.path.join(region_gdb, f"{table_name}_Bathymetry") + + # Get the reference system defined for the region in datasets + # Set the output coordinate system to what is needed for the + # DisMAP project + region_prj = arcpy.Describe(region_raster_mask).spatialReference + # arcpy.AddMessage(f"region_prj: {region_prj}") + if region_prj.linearUnitName == "Kilometer": + arcpy.env.cellSize = 1 + arcpy.env.XYResolution = 0.1 + arcpy.env.XYResolution = 1.0 + elif region_prj.linearUnitName == "Meter": + arcpy.env.cellSize = 1000 + arcpy.env.XYResolution = 0.0001 + arcpy.env.XYResolution = 0.001 + + # Process: Point to Raster Mask + arcpy.env.outputCoordinateSystem = region_prj + arcpy.env.cellSize = int( + arcpy.Describe(f"{region_raster_mask}/Band_1").meanCellWidth + ) + arcpy.env.extent = arcpy.Describe(region_raster_mask).extent + arcpy.env.mask = region_raster_mask + arcpy.env.snapRaster = region_raster_mask + + del region_prj + + arcpy.AddMessage( + f"\tCalculating Zonal Statistics using {os.path.basename(region_fishnet)} and {os.path.basename(region_fishnet_bathymetry)} to create {os.path.basename(region_bathymetry)}" + ) + # Execute ZonalStatistics + # out_raster = arcpy.sa.ZonalStatistics(region_fishnet, "OID", region_fishnet_bathymetry, "MEDIAN", "NODATA") + # out_raster = arcpy.sa.ZonalStatistics(region_fishnet, "OID", region_fishnet_bathymetry, "MEDIAN", "DATA") + + with arcpy.EnvManager(scratchWorkspace=arcpy.env.scratchWorkspace): + # print(region_fishnet) + # rint(region_fishnet_bathymetry) + out_raster = arcpy.sa.ZonalStatistics( + in_zone_data=region_fishnet, + zone_field="OID", + in_value_raster=region_fishnet_bathymetry, + statistics_type="MEDIAN", + ignore_nodata="DATA", + process_as_multidimensional="CURRENT_SLICE", + percentile_value=90, + percentile_interpolation_type="AUTO_DETECT", + circular_calculation="ARITHMETIC", + circular_wrap_value=360, + ) + + arcpy.AddMessage( + "\tZonal Statistics: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + # Save the output + out_raster.save(region_bathymetry) + arcpy.AddMessage( + "\tSave: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + del out_raster + + dismap_tools.import_metadata(csv_data_folder, region_bathymetry) + + del region_bathymetry + + arcpy.management.Delete(os.path.join(region_gdb, "Datasets")) + arcpy.AddMessage( + "\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + arcpy.management.Delete(region_raster_mask) + arcpy.AddMessage( + "\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + arcpy.management.Delete(region_fishnet) + arcpy.AddMessage( + "\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + arcpy.management.Delete(region_fishnet_bathymetry) + arcpy.AddMessage( + "\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + del region_raster_mask, region_fishnet, region_fishnet_bathymetry + + arcpy.management.Compact(region_gdb) + + # Declared Variables for this function only + del scratch_folder, scratch_workspace + del table_name, project_folder, csv_data_folder + # Imports + del md, dismap_tools + # Function parameter + del region_gdb + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def script_tool(project_gdb=""): + try: + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + ## # Set worker parameters + ## #table_name = "AI_IDW" + ## table_name = "HI_IDW" + ## #table_name = "NBS_IDW" + ## #table_name = "ENBS_IDW" + + table_names = [ + "NBS_IDW", + ] + + from create_region_bathymetry_director import preprocessing + + preprocessing( + project_gdb=project_gdb, table_names=table_names, clear_folder=True + ) + + del preprocessing + + for table_name in table_names: + region_gdb = rf"{os.path.dirname(project_gdb)}\Scratch\{table_name}.gdb" + try: + pass + worker(region_gdb=region_gdb) + except SystemExit: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del table_name, region_gdb + del table_names + + # Declared Varaiables + # Imports + # Function Parameters + del project_gdb + + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) + minutes, seconds = divmod(rem, 60) + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) + arcpy.AddMessage(f"{'-' * 80}") + del hours, rem, minutes, seconds + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +if __name__ == "__main__": + try: + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) + else: + pass + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + del project_gdb + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_fishnets_director.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_fishnets_director.py new file mode 100644 index 0000000..11def93 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_fishnets_director.py @@ -0,0 +1,531 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: create_region_fishnets_director.py +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 25/02/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import inspect +import os +import sys +import traceback + +import arcpy # third-parties second + + +def director(project_gdb="", Sequential=True, table_names=[]): + try: + # Imports + import dismap_tools + from create_region_fishnets_worker import worker + + # Set History and Metadata logs, set serverity and message level + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # Set basic workkpace variables + project_folder = os.path.dirname(project_gdb) + scratch_folder = os.path.join(project_folder, "Scratch") + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + csv_data_folder = os.path.join(project_folder, f"CSV_Data") + + # Clear Scratch Folder + dismap_tools.clear_folder(folder=scratch_folder) + + # Create Scratch Workspace for Project + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + if not arcpy.Exists(scratch_folder): + os.makedirs(scratch_folder) + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + arcpy.management.CreateFileGDB(rf"{scratch_folder}", "scratch") + + # Set basic workkpace variables + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + del project_folder + + if not table_names: + table_names = [ + row[0] + for row in arcpy.da.SearchCursor( + os.path.join(project_gdb, "Datasets"), + "TableName", + where_clause="TableName LIKE '%_IDW'", + ) + ] + else: + pass + + # Pre Processing + for table_name in table_names: + arcpy.AddMessage(f"Pre-Processing: {table_name}") + + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + region_scratch_workspace = os.path.join( + scratch_folder, f"{table_name}", "scratch.gdb" + ) + + # Create Scratch Workspace for Region + if not arcpy.Exists(region_scratch_workspace): + os.makedirs(os.path.join(scratch_folder, table_name)) + if not arcpy.Exists(region_scratch_workspace): + arcpy.management.CreateFileGDB( + os.path.join(scratch_folder, table_name), "scratch" + ) + del region_scratch_workspace + + datasets = [ + os.path.join(project_gdb, "Datasets"), + os.path.join(project_gdb, f"{table_name}_Region"), + ] + if not any(arcpy.management.GetCount(d)[0] == 0 for d in datasets): + if not arcpy.Exists(os.path.join(scratch_folder, f"{table_name}.gdb")): + arcpy.management.CreateFileGDB( + rf"{scratch_folder}", f"{table_name}" + ) + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + else: + pass + + arcpy.management.Copy( + os.path.join(project_gdb, "Datasets"), rf"{region_gdb}\Datasets" + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + arcpy.management.Copy( + os.path.join(project_gdb, f"{table_name}_Region"), + rf"{region_gdb}\{table_name}_Region", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + else: + arcpy.AddWarning("One or more datasets contains zero records!!") + for d in datasets: + arcpy.AddMessage( + f"\t{os.path.basename(d)} has {arcpy.management.GetCount(d)[0]} records" + ) + del d + arcpy.AddError( + f"SystemExit at line number: '{traceback.extract_stack()[-1].lineno}'" + ) + sys.exit() + + if "datasets" in locals().keys(): + del datasets + + del region_gdb, table_name + + del scratch_workspace + + # Sequential Processing + if Sequential: + arcpy.AddMessage("Sequential Processing") + for i in range(0, len(table_names)): + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + try: + pass + worker(region_gdb=region_gdb) + except: # noqa: E722 + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del region_gdb, table_name + del i + + # Non-Sequential Processing + if not Sequential: + import multiprocessing + from time import gmtime, localtime, sleep, strftime, time + + arcpy.AddMessage("Sequential Processing") + # Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS + # get_install_path() uses a registry query to figure out 64bit python exe if available + multiprocessing.set_executable(os.path.join(sys.exec_prefix, "pythonw.exe")) + # Get CPU count and then take 2 away for other process + _processes = multiprocessing.cpu_count() - 2 + _processes = ( + _processes if len(table_names) >= _processes else len(table_names) + ) + arcpy.AddMessage( + f"Creating the multiprocessing Pool with {_processes} processes" + ) + # Create a pool of workers, keep one cpu free for surfing the net. + # Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) + with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: + arcpy.AddMessage("\tPrepare arguments for processing") + # Use apply_async so we can handle exceptions gracefully + jobs = {} + for i in range(0, len(table_names)): + try: + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + jobs[table_name] = pool.apply_async(worker, [region_gdb]) + del table_name, region_gdb + except: # noqa: E722 + pool.terminate() + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del i + all_finished = False + # Set a start time so that we can see how log things take + start_time = time() + result_completed = {} + while True: + all_finished = True + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + arcpy.AddMessage( + f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage("Have the workers finished?") + finish_time = strftime("%a %b %d %I:%M %p", localtime()) + time_elapsed = "Elapsed Time {0} (H:M:S)".format( + strftime("%H:%M:%S", gmtime(elapse_time)) + ) + arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") + finish_time = f"{finish_time}.\n\t{time_elapsed}" + del time_elapsed + for table_name, result in jobs.items(): + if result.ready(): + if table_name not in result_completed: + result_completed[table_name] = finish_time + try: + # wait for and get the result from the task + result.get() + except SystemExit: + pool.terminate() + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except: # noqa: E722 + pool.terminate() + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + pass + arcpy.AddMessage( + f"Process {table_name}\n\tFinished on {result_completed[table_name]}" + ) + else: + all_finished = False + arcpy.AddMessage(f"Process {table_name} is running. . .") + del table_name, result + del elapse_time, end_time, finish_time + if all_finished: + break + sleep(_processes * 7.5) + del result_completed + del start_time + del all_finished + arcpy.AddMessage("\tClose the process pool") + # close the process pool + pool.close() + # wait for all tasks to complete and processes to close + arcpy.AddMessage( + "\tWait for all tasks to complete and processes to close" + ) + pool.join() + # Just in case + pool.terminate() + del pool + del jobs + del _processes + del time, multiprocessing, localtime, strftime, sleep, gmtime + arcpy.AddMessage("\tDone with multiprocessing Pool") + + arcpy.AddMessage("Post-Processing") + arcpy.AddMessage("Processing Results") + datasets = list() + # walk = arcpy.da.Walk(scratch_folder, datatype="FeatureClass", type=["Polyline", "Polygon"]) + walk = arcpy.da.Walk(scratch_folder) + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + for dataset in datasets: + datasets_short_path = f".. {'/'.join(dataset.split(os.sep)[-4:])}" + dataset_name = os.path.basename(dataset) + region_gdb = os.path.dirname(dataset) + arcpy.AddMessage(f"\tDataset: '{dataset_name}'") + arcpy.AddMessage(f"\t\tPath: '{datasets_short_path}'") + arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") + arcpy.management.Copy(dataset, rf"{project_gdb}\{dataset_name}") + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + arcpy.management.Delete(dataset) + arcpy.AddMessage( + "\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + arcpy.management.Compact(region_gdb) + arcpy.AddMessage( + "\tCompact: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + del region_gdb + del dataset + del dataset_name + del datasets_short_path + del datasets + arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") + arcpy.management.Compact(project_gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + # Declared Variables assigned in function + del scratch_folder, csv_data_folder + # Imports + del dismap_tools, worker + # Function Parameters + del project_gdb, Sequential, table_names + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError( + f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except SystemExit as se: + arcpy.AddError( + f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function." + ) + sys.exit() + except Exception as e: + arcpy.AddError( + f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + except: # noqa: E722 + arcpy.AddError( + f"Caught an except error in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + arcpy.AddMessage( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def script_tool(project_gdb=""): + try: + # Imports + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + # Set varaibales + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{project_folder}\Scratch" + del project_folder + + # Create project scratch workspace, if missing + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + if not arcpy.Exists(scratch_folder): + os.makedirs(scratch_folder) + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + arcpy.management.CreateFileGDB(rf"{scratch_folder}", "scratch") + del scratch_folder + + # Set basic arcpy.env variables + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + try: + pass + # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", + # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", + + test = False + if test: + # director(project_gdb=project_gdb, Sequential=True, table_names=["HI_IDW"]) + # director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "HI_IDW"]) + # director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "SEUS_FAL_IDW",]) + director( + project_gdb=project_gdb, + Sequential=True, + table_names=["NBS_IDW", "SEUS_FAL_IDW"], + ) + else: + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NBS_IDW", + "ENBS_IDW", + "HI_IDW", + "SEUS_FAL_IDW", + "SEUS_SPR_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "WC_TRI_IDW", + "GMEX_IDW", + "AI_IDW", + "GOA_IDW", + "WC_ANN_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NEUS_SPR_IDW", + "EBS_IDW", + "NEUS_FAL_IDW", + "SEUS_SUM_IDW", + ], + ) + del test + + except: # noqa: E722 + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + + # Declared Varaiables + # Imports + # Function Parameters + del project_gdb + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) + minutes, seconds = divmod(rem, 60) + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) + arcpy.AddMessage(f"{'-' * 80}") + del hours, rem, minutes, seconds + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError( + f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddError(arcpy.GetMessages(2)) + except SystemExit as se: + arcpy.AddError( + f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function." + ) + sys.exit() + except Exception as e: + arcpy.AddError( + f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + except: # noqa: E722 + arcpy.AddError( + f"Caught an except error in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + arcpy.AddMessage( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +if __name__ == "__main__": + try: + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + # project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\February 1 2026\February 1 2026.gdb" + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) + else: + pass + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + del project_gdb + except: # noqa: E722 + traceback.print_exc() + else: + pass + finally: + pass +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_fishnets_worker.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_fishnets_worker.py new file mode 100644 index 0000000..0bd165f --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_fishnets_worker.py @@ -0,0 +1,943 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: create_region_fishnets_worker.py +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 25/02/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import inspect +import os +import sys +import traceback + +import arcpy # third-parties second + + +def worker(region_gdb=""): + try: + # Test if passed workspace exists, if not sys.exit() + if not arcpy.Exists(rf"{region_gdb}"): + sys.exit()(f"{os.path.basename(region_gdb)} is missing!!") + + # Imports + import dismap_tools + from arcpy import metadata as md + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + table_name = os.path.basename(region_gdb).replace(".gdb", "") + scratch_folder = os.path.dirname(region_gdb) + project_folder = os.path.dirname(scratch_folder) + csv_data_folder = os.path.join(project_folder, f"CSV_Data") + scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" + + # arcpy.AddMessage(f"Table Name: {table_name}\nProject Folder: {os.path.basename(project_folder)}\nScratch Folder: {os.path.basename(scratch_folder)}\n") + + del scratch_folder, project_folder + + arcpy.env.workspace = region_gdb + arcpy.env.scratchWorkspace = scratch_workspace + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.env.compression = "LZ77" + # arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" + arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR DEFAULT 75 NO_SKIP NO_SIPS" + arcpy.env.resamplingMethod = "BILINEAR" + arcpy.env.rasterStatistics = "STATISTICS 1 1" + # arcpy.env.XYTolerance = "0.1 Meters" + # arcpy.env.XYResolution = "0.01 Meters" + + # DatasetCode, CSVFile, TransformUnit, TableName, GeographicArea, CellSize, + # PointFeatureType, FeatureClassName, Region, Season, DateCode, Status, + # DistributionProjectCode, DistributionProjectName, SummaryProduct, + # FilterRegion, FilterSubRegion, FeatureServiceName, FeatureServiceTitle, + # MosaicName, MosaicTitle, ImageServiceName, ImageServiceTitle + + fields = [ + "TableName", + "CellSize", + ] + region_list = [ + row + for row in arcpy.da.SearchCursor( + rf"{region_gdb}\Datasets", + fields, + where_clause=f"TableName = '{table_name}'", + ) + ][0] + del fields + + # Assigning variables from items in the chosen table list + # ['AI_IDW', 'AI_IDW_Region', 'AI', 'Aleutian Islands', None, 'IDW'] + table_name = region_list[0] + cell_size = region_list[1] + del region_list + + process_region = rf"{region_gdb}\{table_name}_Region" + region_raster_mask = rf"{table_name}_Raster_Mask" + region_extent_points = rf"{table_name}_Extent_Points" + region_fishnet = rf"{table_name}_Fishnet" + region_lat_long = rf"{table_name}_Lat_Long" + region_latitude = rf"{table_name}_Latitude" + region_longitude = rf"{table_name}_Longitude" + region_name = rf"{table_name}_Region" + + arcpy.AddMessage(f"Region: {region_name}") + arcpy.AddMessage(f"Region GDB: {os.path.basename(arcpy.env.workspace)}") + arcpy.AddMessage(f"Scratch GDB: {os.path.basename(arcpy.env.scratchWorkspace)}") + + psr = arcpy.Describe(process_region).spatialReference + arcpy.env.outputCoordinateSystem = psr + arcpy.AddMessage(f"\t\tSpatial Reference: {psr.name}") + # Set coordinate system of the output fishnet + # 4326 - World Geodetic System 1984 (WGS 84) and 3857 - Web Mercator + # Spatial Reference factory code of 4326 is : GCS_WGS_1984 + # Spatial Reference factory code of 5714 is : Mean Sea Level (Height) + # sr = arcpy.SpatialReference(4326, 5714) + # gsr = arcpy.SpatialReference(4326, 5714) + gsr = arcpy.SpatialReference(4326) + + # arcpy.AddMessage("process_region") + # arcpy.AddMessage(f"Spatial Reference: {str(arcpy.Describe(process_region).spatialReference.name)}") + # arcpy.AddMessage(f"Extent: {str(arcpy.Describe(process_region).extent).replace(' NaN', '')}") + # arcpy.AddMessage(f"Output Coordinate System: {arcpy.env.outputCoordinateSystem.name}") + # arcpy.AddMessage(f"Geographic Transformations: {arcpy.env.geographicTransformations}") + + # Creating Raster Mask + arcpy.AddMessage(f"Creating Raster Mask: {table_name}_Raster_Mask") + + cell_size = [ + row[0] + for row in arcpy.da.SearchCursor( + rf"{region_gdb}\Datasets", + "CellSize", + where_clause=f"GeographicArea = '{region_name}'", + ) + ][0] + + arcpy.management.CalculateField(rf"{process_region}", "ID", 1) + arcpy.AddMessage( + "\tCalculate Field 'ID' for {0}:\n\t\t{1}\n".format( + f"{region_name}", arcpy.GetMessages(0).replace("\n", "\n\t\t") + ) + ) + + arcpy.conversion.FeatureToRaster( + rf"{process_region}", "ID", rf"{region_gdb}\{region_raster_mask}", cell_size + ) + arcpy.AddMessage( + "\tFeature To Raster for {0}:\n\t\t{1}\n".format( + f"{region_name}", arcpy.GetMessages(0).replace("\n", "\n\t\t") + ) + ) + + arcpy.management.DeleteField(rf"{process_region}", "ID") + arcpy.AddMessage( + "\tDelete Field 'ID' field in {0}:\n\t\t{1}\n".format( + f"{region_name}", arcpy.GetMessages(0).replace("\n", "\n\t\t") + ) + ) + + # del edit + + # Creating Extent Points + arcpy.AddMessage(f"Creating Extent Points: {region_extent_points}") + + extent = arcpy.Describe(process_region).extent + X_Min, Y_Min, X_Max, Y_Max = extent.XMin, extent.YMin, extent.XMax, extent.YMax + del extent + + arcpy.AddMessage( + f"\t{region_name} Extent:\n\t\tX_Min: {X_Min}\n\t\tY_Min: {Y_Min}\n\t\tX_Max: {X_Max}\n\t\tY_Max: {Y_Max}\n" + ) + + # A list of coordinate pairs + pointList = [[X_Min, Y_Min], [X_Min, Y_Max], [X_Max, Y_Max]] + # Create an empty Point object + point = arcpy.Point() + # A list to hold the PointGeometry objects + pointGeometryList = [] + # For each coordinate pair, populate the Point object and create a new + # PointGeometry object + for pt in pointList: + point.X = pt[0] + point.Y = pt[1] + pointGeometry = arcpy.PointGeometry( + point, arcpy.Describe(process_region).spatialReference + ) + pointGeometryList.append(pointGeometry) + del pt, pointGeometry + # Delete after last use + del pointList, point + + # Create a copy of the PointGeometry objects, by using pointGeometryList as + # input to the CopyFeatures tool. + arcpy.management.CopyFeatures( + pointGeometryList, rf"{region_gdb}\{region_extent_points}" + ) + arcpy.AddMessage( + "\tCopy Features to {0}:\n\t\t{1}\n".format( + region_extent_points, arcpy.GetMessages(0).replace("\n", "\n\t\t") + ) + ) + + del pointGeometryList + + # arcpy.AddMessage("tmp_region_extent_points") + # tmp_region_extent_points = rf"{region_gdb}\{region_extent_points}" + # arcpy.AddMessage(f"Spatial Reference: {str(arcpy.Describe(tmp_region_extent_points).spatialReference.name)}") + # arcpy.AddMessage(f"Extent: {str(arcpy.Describe(tmp_region_extent_points).extent).replace(' NaN', '')}") + # arcpy.AddMessage(f"Output Coordinate System: {arcpy.env.outputCoordinateSystem.name}") + # arcpy.AddMessage(f"Geographic Transformations: {arcpy.env.geographicTransformations}") + # del tmp_region_extent_points + + with arcpy.EnvManager(outputCoordinateSystem=psr): + arcpy.management.AddXY(in_features=rf"{region_gdb}\{region_extent_points}") + arcpy.AddMessage( + "\tAdd XY:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + arcpy.management.AlterField( + in_table=rf"{region_gdb}\{region_extent_points}", + field="POINT_X", + new_field_name="Easting", + new_field_alias="Easting", + field_type="", + field_length=None, + field_is_nullable="NULLABLE", + clear_field_alias="DO_NOT_CLEAR", + ) + arcpy.AddMessage( + "\tAlter Field:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + arcpy.management.AlterField( + in_table=rf"{region_gdb}\{region_extent_points}", + field="POINT_Y", + new_field_name="Northing", + new_field_alias="Northing", + field_type="", + field_length=None, + field_is_nullable="NULLABLE", + clear_field_alias="DO_NOT_CLEAR", + ) + arcpy.AddMessage( + "\tAlter Field:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + tmp_outputCoordinateSystem = arcpy.env.outputCoordinateSystem + arcpy.env.outputCoordinateSystem = gsr + + with arcpy.EnvManager( + outputCoordinateSystem=gsr, + geographicTransformations=dismap_tools.check_transformation( + rf"{region_gdb}\{region_extent_points}", gsr + ), + ): + arcpy.management.AddXY(in_features=rf"{region_gdb}\{region_extent_points}") + arcpy.AddMessage( + "\tAdd XY:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + arcpy.env.outputCoordinateSystem = tmp_outputCoordinateSystem + del tmp_outputCoordinateSystem + + arcpy.management.AlterField( + in_table=rf"{region_gdb}\{region_extent_points}", + field="POINT_X", + new_field_name="Longitude", + new_field_alias="Longitude", + field_type="", + field_length=None, + field_is_nullable="NULLABLE", + clear_field_alias="DO_NOT_CLEAR", + ) + arcpy.AddMessage( + "\tAlter Field:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + arcpy.management.AlterField( + in_table=rf"{region_gdb}\{region_extent_points}", + field="POINT_Y", + new_field_name="Latitude", + new_field_alias="Latitude", + field_type="", + field_length=None, + field_is_nullable="NULLABLE", + clear_field_alias="DO_NOT_CLEAR", + ) + arcpy.AddMessage( + "\tAlter Field:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + # Creating Fishnet + arcpy.AddMessage(f"Creating Fishnet: {region_fishnet}") + arcpy.AddMessage( + f"\tCreate Fishnet for {region_name} with {cell_size} by {cell_size} cells" + ) + arcpy.management.CreateFishnet( + os.path.join(rf"{region_gdb}\{region_fishnet}"), + f"{X_Min} {Y_Min}", + f"{X_Min} {Y_Max}", + cell_size, + cell_size, + None, + None, + f"{X_Max} {Y_Max}", + "NO_LABELS", + "DEFAULT", + "POLYGON", + ) + arcpy.AddMessage( + "\tCreate Fishnet for {0}:\n\t\t{1}\n".format( + f"{region_name}", arcpy.GetMessages(0).replace("\n", "\n\t\t") + ) + ) + + del X_Min, Y_Min, X_Max, Y_Max + + arcpy.management.MakeFeatureLayer( + rf"{region_gdb}\{region_fishnet}", f"{region_name}_Fishnet_Layer" + ) + arcpy.AddMessage( + "\tMake Feature Layer for {0}:\n\t\t{1}\n".format( + f"{region_fishnet}", arcpy.GetMessages(0).replace("\n", "\n\t\t") + ) + ) + arcpy.AddMessage( + f"\t\tRecord Count: {int(arcpy.management.GetCount(f'{region_name}_Fishnet_Layer')[0]):,d}" + ) + + arcpy.management.SelectLayerByLocation( + f"{region_name}_Fishnet_Layer", + "WITHIN_A_DISTANCE", + process_region, + 2 * int(cell_size), + "NEW_SELECTION", + "INVERT", + ) + arcpy.AddMessage( + "\tSelect Layer By Location:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + arcpy.AddMessage( + f"\t\tRecord Count: {int(arcpy.management.GetCount(f'{region_name}_Fishnet_Layer')[0]):,d}" + ) + + arcpy.management.DeleteFeatures(f"{region_name}_Fishnet_Layer") + arcpy.AddMessage( + "\tDelete Features:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + arcpy.management.Delete(f"{region_name}_Fishnet_Layer") + arcpy.AddMessage( + "\tDelete {0}:\n\t\t{1}\n".format( + f"{region_name}_Fishnet_Layer", + arcpy.GetMessages(0).replace("\n", "\n\t\t"), + ) + ) + + # Creating Lat-Long + arcpy.AddMessage(f"Creating Lat-Long: {region_lat_long}") + arcpy.management.FeatureToPoint( + rf"{region_gdb}\{region_fishnet}", + rf"{region_gdb}\{region_lat_long}", + "CENTROID", + ) + arcpy.AddMessage( + "\tFeature To Point:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + # Execute DeleteField + arcpy.management.DeleteField(rf"{region_gdb}\{region_lat_long}", ["ORIG_FID"]) + arcpy.AddMessage( + "\tDelete Field:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + with arcpy.EnvManager(outputCoordinateSystem=psr): + arcpy.management.AddXY(in_features=rf"{region_gdb}\{region_lat_long}") + arcpy.AddMessage( + "\tAdd XY:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + arcpy.management.AlterField( + in_table=rf"{region_gdb}\{region_lat_long}", + field="POINT_X", + new_field_name="Easting", + new_field_alias="Easting", + field_type="", + field_length=None, + field_is_nullable="NULLABLE", + clear_field_alias="DO_NOT_CLEAR", + ) + arcpy.AddMessage( + "\tAlter Field:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + arcpy.management.AlterField( + in_table=rf"{region_gdb}\{region_lat_long}", + field="POINT_Y", + new_field_name="Northing", + new_field_alias="Northing", + field_type="", + field_length=None, + field_is_nullable="NULLABLE", + clear_field_alias="DO_NOT_CLEAR", + ) + arcpy.AddMessage( + "\tAlter Field:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + with arcpy.EnvManager( + outputCoordinateSystem=gsr, + geographicTransformations=dismap_tools.check_transformation( + rf"{region_gdb}\{region_extent_points}", gsr + ), + ): + arcpy.management.AddXY(in_features=rf"{region_gdb}\{region_lat_long}") + arcpy.AddMessage( + "\tAdd XY:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + arcpy.management.AlterField( + in_table=rf"{region_gdb}\{region_lat_long}", + field="POINT_X", + new_field_name="Longitude", + new_field_alias="Longitude", + field_type="", + field_length=None, + field_is_nullable="NULLABLE", + clear_field_alias="DO_NOT_CLEAR", + ) + arcpy.AddMessage( + "\tAlter Field:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + arcpy.management.AlterField( + in_table=rf"{region_gdb}\{region_lat_long}", + field="POINT_Y", + new_field_name="Latitude", + new_field_alias="Latitude", + field_type="", + field_length=None, + field_is_nullable="NULLABLE", + clear_field_alias="DO_NOT_CLEAR", + ) + arcpy.AddMessage( + "\tAlter Field:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + # arcpy.management.CalculateFields( + # in_table = rf"{region_gdb}\{region_lat_long}", + # expression_type = "PYTHON3", + # fields = "Easting 'round(!Easting!, 8)' #;Northing 'round(!Northing!, 8)' #;Longitude 'round(!Longitude!, 8)' #;Latitude 'round(!Latitude!, 8)' #", + # code_block = "", + # enforce_domains = "NO_ENFORCE_DOMAINS" + # ) + # arcpy.AddMessage("\tCalculate Fields:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) + + arcpy.AddMessage(f"Generating {table_name} Latitude and Longitude Rasters") + + # arcpy.env.cellSize = cell_size + # arcpy.env.extent = arcpy.Describe(rf"{region_gdb}\{region_raster_mask}").extent + # arcpy.env.mask = rf"{region_gdb}\{region_raster_mask}" + # arcpy.env.snapRaster = rf"{region_gdb}\{region_raster_mask}" + + raster_mask_extent = arcpy.Describe( + rf"{region_gdb}\{region_raster_mask}" + ).extent + + arcpy.AddMessage( + f"Point to Raster Conversion using {region_lat_long} to create {region_longitude}" + ) + + region_longitude_tmp = rf"{region_gdb}\tmp_{region_longitude}" + + with arcpy.EnvManager( + scratchWorkspace=scratch_workspace, + workspace=region_gdb, + cellSize=cell_size, + extent=raster_mask_extent, + mask=rf"{region_gdb}\{region_raster_mask}", + snapRaster=rf"{region_gdb}\{region_raster_mask}", + ): + arcpy.conversion.PointToRaster( + rf"{region_gdb}\{region_lat_long}", + "Longitude", + region_longitude_tmp, + "MOST_FREQUENT", + "NONE", + cell_size, + ) + arcpy.AddMessage( + "\tPoint To Raster:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + arcpy.AddMessage(f"Extract by Mask to create {region_longitude}") + + with arcpy.EnvManager( + scratchWorkspace=scratch_workspace, + workspace=region_gdb, + cellSize=cell_size, + extent=raster_mask_extent, + mask=rf"{region_gdb}\{region_raster_mask}", + snapRaster=rf"{region_gdb}\{region_raster_mask}", + ): + # Execute ExtractByMask + outExtractByMask = arcpy.sa.ExtractByMask( + region_longitude_tmp, rf"{region_gdb}\{region_raster_mask}", "INSIDE" + ) + arcpy.AddMessage( + "\tExtract By Mask:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + # Save the output + outExtractByMask.save(rf"{region_gdb}\{region_longitude}") + del outExtractByMask + + arcpy.management.Delete(region_longitude_tmp) + del region_longitude_tmp + + region_latitude_tmp = rf"{region_gdb}\tmp_{region_latitude}" + + arcpy.AddMessage( + f"Point to Raster Conversion using {region_lat_long} to create {region_latitude}" + ) + + with arcpy.EnvManager( + scratchWorkspace=scratch_workspace, + workspace=region_gdb, + cellSize=cell_size, + extent=raster_mask_extent, + mask=rf"{region_gdb}\{region_raster_mask}", + snapRaster=rf"{region_gdb}\{region_raster_mask}", + ): + # Process: Point to Raster Latitude + arcpy.conversion.PointToRaster( + rf"{region_gdb}\{region_lat_long}", + "Latitude", + region_latitude_tmp, + "MOST_FREQUENT", + "NONE", + cell_size, + "BUILD", + ) + arcpy.AddMessage( + "\tPoint To Raster:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + + arcpy.AddMessage(f"Extract by Mask to create {region_latitude}") + + with arcpy.EnvManager( + scratchWorkspace=scratch_workspace, + workspace=region_gdb, + cellSize=cell_size, + extent=raster_mask_extent, + mask=rf"{region_gdb}\{region_raster_mask}", + snapRaster=rf"{region_gdb}\{region_raster_mask}", + ): + # Execute ExtractByMask + outExtractByMask = arcpy.sa.ExtractByMask( + region_latitude_tmp, rf"{region_gdb}\{region_raster_mask}", "INSIDE" + ) + arcpy.AddMessage( + "\tExtract By Mask:\n\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t") + ) + ) + # Save the output + outExtractByMask.save(rf"{region_gdb}\{region_latitude}") + del outExtractByMask + + arcpy.management.Delete(region_latitude_tmp) + del region_latitude_tmp + + del raster_mask_extent + + arcpy.ClearEnvironment("cellSize") + arcpy.ClearEnvironment("extent") + arcpy.ClearEnvironment("mask") + arcpy.ClearEnvironment("snapRaster") + + # Reset environment settings to default settings. + arcpy.ResetEnvironments() + + arcpy.AddMessage(f"\t\tAlter Fields for: '{region_raster_mask}'") + # dismap_tools.alter_fields(csv_data_folder, rf"{region_gdb}\{region_raster_mask}") + dismap_tools.import_metadata( + csv_data_folder, dataset=rf"{region_gdb}\{region_raster_mask}" + ) + + # Create Metadata + dataset_md = md.Metadata(region_raster_mask) + dataset_md.synchronize("ALWAYS") + dataset_md.save() + del dataset_md + + arcpy.AddMessage(f"\t\tAlter Fields for: '{region_extent_points}'") + dismap_tools.alter_fields( + csv_data_folder, rf"{region_gdb}\{region_extent_points}" + ) + dismap_tools.import_metadata( + csv_data_folder, dataset=rf"{region_gdb}\{region_extent_points}" + ) + + # Create Metadata + dataset_md = md.Metadata(region_extent_points) + dataset_md.synchronize("ALWAYS") + dataset_md.save() + del dataset_md + + arcpy.AddMessage(f"\t\tAlter Fields for: '{region_fishnet}'") + dismap_tools.alter_fields(csv_data_folder, rf"{region_gdb}\{region_fishnet}") + dismap_tools.import_metadata( + csv_data_folder, dataset=rf"{region_gdb}\{region_fishnet}" + ) + + # Create Metadata + dataset_md = md.Metadata(region_fishnet) + dataset_md.synchronize("ALWAYS") + dataset_md.save() + del dataset_md + + arcpy.AddMessage(f"\t\tAlter Fields for: '{region_lat_long}'") + dismap_tools.alter_fields(csv_data_folder, rf"{region_gdb}\{region_lat_long}") + dismap_tools.import_metadata( + csv_data_folder, dataset=rf"{region_gdb}\{region_lat_long}" + ) + + # Create Metadata + dataset_md = md.Metadata(region_lat_long) + dataset_md.synchronize("ALWAYS") + dataset_md.save() + del dataset_md + + arcpy.AddMessage(f"\t\tAlter Fields for: '{region_latitude}'") + dismap_tools.import_metadata( + csv_data_folder, dataset=rf"{region_gdb}\{region_latitude}" + ) + + # Create Metadata + dataset_md = md.Metadata(region_latitude) + dataset_md.synchronize("ALWAYS") + dataset_md.save() + del dataset_md + + arcpy.AddMessage(f"\t\tAlter Fields for: '{region_longitude}'") + dismap_tools.import_metadata( + csv_data_folder, dataset=rf"{region_gdb}\{region_longitude}" + ) + + # Create Metadata + dataset_md = md.Metadata(region_longitude) + dataset_md.synchronize("ALWAYS") + dataset_md.save() + del dataset_md + + arcpy.management.Delete(process_region) + arcpy.management.Delete(rf"{region_gdb}\Datasets") + + del process_region, region_raster_mask, region_extent_points, region_fishnet + del region_lat_long, region_latitude, region_longitude + del psr, gsr + del cell_size + + arcpy.AddMessage(f"Compacting the {os.path.basename(region_gdb)} GDB") + arcpy.management.Compact(region_gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + + # End of business logic for the worker function + arcpy.AddMessage(f"Processing for: {table_name} complete") + + # Declared Variables + del region_name, table_name + del scratch_workspace, csv_data_folder + # Imports + del dismap_tools, md + # Function parameter + del region_gdb + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError( + f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except SystemExit as se: + arcpy.AddError( + f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function." + ) + sys.exit() + except Exception as e: + arcpy.AddError( + f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + except: # noqa: E722 + arcpy.AddError( + f"Caught an except error in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + arcpy.AddMessage( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def script_tool(project_gdb=""): + try: + from time import gmtime, localtime, strftime, time + + import dismap_tools + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + # Set basic arcpy.env variables + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + # Set varaibales + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{project_folder}\Scratch" + del project_folder + + # Clear Scratch Folder + dismap_tools.clear_folder(folder=scratch_folder) + + # Create project scratch workspace, if missing + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + if not arcpy.Exists(scratch_folder): + os.makedirs(scratch_folder) + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + arcpy.management.CreateFileGDB(rf"{scratch_folder}", "scratch") + + # Set worker parameters + table_name = "AI_IDW" + # table_name = "GMEX_IDW" + # table_name = "HI_IDW" + # table_name = "SEUS_FAL_IDW" + # table_name = "NBS_IDW" + + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" + + if not arcpy.Exists(scratch_workspace): + os.makedirs(os.path.join(scratch_folder, table_name)) + if not arcpy.Exists(scratch_workspace): + arcpy.management.CreateFileGDB( + os.path.join(scratch_folder, f"{table_name}"), "scratch" + ) + del scratch_workspace + + # Setup worker workspace and copy data + # datasets = [ros.path.join(project_gdb, "Datasets") os.path.join(project_gdb, f"{table_name}_Region")] + # if not any(arcpy.management.GetCount(d)[0] == 0 for d in datasets): + + if not arcpy.Exists(os.path.join(scratch_folder, f"{table_name}.gdb")): + arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + else: + pass + arcpy.management.Copy( + os.path.join(project_gdb, "Datasets"), rf"{region_gdb}\Datasets" + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + arcpy.management.Copy( + os.path.join(project_gdb, f"{table_name}_Region"), + rf"{region_gdb}\{table_name}_Region", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + # else: + # arcpy.AddWarning(f"One or more datasets contains zero records!!") + # for d in datasets: + # arcpy.AddMessage(f"\t{os.path.basename(d)} has {arcpy.management.GetCount(d)[0]} records") + # del d + # sys.exit() + # if "datasets" in locals().keys(): del datasets + + try: + pass + worker(region_gdb=region_gdb) + except SystemExit: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + + # Declared Varaiables + del region_gdb, table_name, scratch_folder + # Imports + del dismap_tools + # Function Parameters + del project_gdb + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) + minutes, seconds = divmod(rem, 60) + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) + arcpy.AddMessage(f"{'-' * 80}") + del hours, rem, minutes, seconds + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError( + f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except SystemExit as se: + arcpy.AddError( + f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function." + ) + sys.exit() + except Exception as e: + arcpy.AddError( + f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + except: # noqa: E722 + arcpy.AddError( + f"Caught an except error in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + arcpy.AddMessage( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +if __name__ == "__main__": + try: + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) + else: + pass + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + del project_gdb + except: # noqa: E722 + traceback.print_exc() + else: + pass + finally: + pass +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_sample_locations_director.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_sample_locations_director.py new file mode 100644 index 0000000..7b4f2c1 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_sample_locations_director.py @@ -0,0 +1,441 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: module1 +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 25/02/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import os +import sys +import traceback + +import arcpy # third-parties second + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + filename = sys.path[0] + os.sep + "test.py" + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror + + +def director(project_gdb="", Sequential=True, table_names=[]): + try: + # Imports + import dismap_tools + from arcpy import metadata as md + from create_region_sample_locations_worker import worker + + # Test if passed workspace exists, if not sys.exit() + if not arcpy.Exists(project_gdb): + sys.exit()(f"{os.path.basename(project_gdb)} is missing!!") + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + project_folder = os.path.dirname(project_gdb) + scratch_folder = os.path.join(project_folder, "Scratch") + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + csv_data_folder = rf"{project_folder}\CSV Data" + + # Clear Scratch Folder + dismap_tools.clear_folder(folder=scratch_folder) + + # Create Scratch Workspace for Project + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + if not arcpy.Exists(scratch_folder): + os.makedirs(scratch_folder) + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + arcpy.management.CreateFileGDB(rf"{scratch_folder}", "scratch") + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + del project_folder, scratch_workspace + + if not table_names: + table_names = [ + row[0] + for row in arcpy.da.SearchCursor( + os.path.join(project_gdb, "Datasets"), + "TableName", + where_clause="TableName LIKE '%_IDW'", + ) + ] + else: + pass + + # Pre Processing + for table_name in table_names: + arcpy.AddMessage(f"Pre-Processing: {table_name}") + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" + # Create Scratch Workspace for Region + if not arcpy.Exists(region_scratch_workspace): + os.makedirs(os.path.join(scratch_folder, table_name)) + if not arcpy.Exists(region_scratch_workspace): + arcpy.management.CreateFileGDB( + os.path.join(scratch_folder, f"{table_name}"), "scratch" + ) + del region_scratch_workspace + # datasets = [ros.path.join(project_gdb, "Datasets") os.path.join(project_gdb, f"{table_name}_Region")] + # if not any(arcpy.management.GetCount(d)[0] == 0 for d in datasets): + + if not arcpy.Exists(os.path.join(scratch_folder, f"{table_name}.gdb")): + arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + else: + pass + + arcpy.management.Copy( + os.path.join(project_gdb, "Datasets"), rf"{region_gdb}\Datasets" + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + arcpy.management.Copy( + os.path.join(project_gdb, f"{table_name}_Region"), + rf"{region_gdb}\{table_name}_Region", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + del region_gdb, table_name + + # Sequential Processing + if Sequential: + arcpy.AddMessage("Sequential Processing") + for i in range(0, len(table_names)): + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + try: + worker(region_gdb=region_gdb) + except: # noqa: E722 + traceback.print_exc() + sys.exit() + del region_gdb, table_name + del i + else: + pass + + # Non-Sequential Processing + if not Sequential: + arcpy.AddMessage("Non-Sequential Processing") + # Imports + import multiprocessing + from time import gmtime, localtime, sleep, strftime, time + + arcpy.AddMessage("Start multiprocessing using the ArcGIS Pro pythonw.exe.") + # Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS + # get_install_path() uses a registry query to figure out 64bit python exe if available + multiprocessing.set_executable(os.path.join(sys.exec_prefix, "pythonw.exe")) + # Get CPU count and then take 2 away for other process + _processes = multiprocessing.cpu_count() - 2 + _processes = ( + _processes if len(table_names) >= _processes else len(table_names) + ) + arcpy.AddMessage( + f"Creating the multiprocessing Pool with {_processes} processes" + ) + # Create a pool of workers, keep one cpu free for surfing the net. + # Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) + with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: + arcpy.AddMessage("\tPrepare arguments for processing") + # Use apply_async so we can handle exceptions gracefully + jobs = {} + for i in range(0, len(table_names)): + try: + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + jobs[table_name] = pool.apply_async(worker, [region_gdb]) + del table_name, region_gdb + except: # noqa: E722 + pool.terminate() + traceback.print_exc() + sys.exit() + del i + all_finished = False + # Set a start time so that we can see how log things take + start_time = time() + result_completed = {} + while True: + all_finished = True + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + arcpy.AddMessage( + f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage("Have the workers finished?") + + finish_time = strftime("%a %b %d %I:%M %p", localtime()) + time_elapsed = "Elapsed Time {0} (H:M:S)".format( + strftime("%H:%M:%S", gmtime(elapse_time)) + ) + arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") + finish_time = f"{finish_time}.\n\t{time_elapsed}" + del time_elapsed + for table_name, result in jobs.items(): + if result.ready(): + if table_name not in result_completed: + result_completed[table_name] = finish_time + try: + # wait for and get the result from the task + result.get() + except SystemExit: + pool.terminate() + traceback.print_exc() + sys.exit() + else: + pass + arcpy.AddMessage( + f"Process {table_name}\n\tFinished on {result_completed[table_name]}" + ) + else: + all_finished = False + arcpy.AddMessage(f"Process {table_name} is running. . .") + del table_name, result + del elapse_time, end_time, finish_time + if all_finished: + break + sleep(_processes * 7.5) + del result_completed + del start_time + del all_finished + arcpy.AddMessage("\tClose the process pool") + # close the process pool + pool.close() + # wait for all tasks to complete and processes to close + arcpy.AddMessage( + "\tWait for all tasks to complete and processes to close" + ) + pool.join() + # Just in case + pool.terminate() + del pool + del jobs + del _processes + del time, multiprocessing, localtime, strftime, sleep, gmtime + arcpy.AddMessage("\tDone with multiprocessing Pool") + + # Post-Processing + arcpy.AddMessage("Post-Processing Begins") + arcpy.AddMessage("Processing Results") + datasets = list() + walk = arcpy.da.Walk(scratch_folder, datatype=["Table", "FeatureClass"]) + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + for dataset in datasets: + datasets_short_path = f".. {'/'.join(dataset.split(os.sep)[-4:])}" + dataset_name = os.path.basename(dataset) + region_gdb = os.path.dirname(dataset) + arcpy.AddMessage(f"\tDataset: '{dataset_name}'") + arcpy.AddMessage(f"\t\tPath: '{datasets_short_path}'") + arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") + arcpy.management.Copy(dataset, rf"{project_gdb}\{dataset_name}") + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + # arcpy.management.Delete(dataset) + # arcpy.AddMessage(f"\t\tAlter Fields for: '{dataset}'") + # dismap_tools.alter_fields(csv_data_folder, rf"{project_gdb}\{dataset}") + del region_gdb, dataset_name, datasets_short_path + del dataset + del datasets + arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") + arcpy.management.Compact(project_gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + # Declared Variables assigned in function + del scratch_folder, csv_data_folder + # Imports + del dismap_tools, worker, md + # Function Parameters + del project_gdb, Sequential, table_names + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def script_tool(project_gdb=""): + try: + # Imports + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + # arcpy.AddMessage(project_gdb) + # Test if passed workspace exists, if not sys.exit() + if not arcpy.Exists(project_gdb): + arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") + sys.exit() + else: + pass + + try: + # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", + # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", + Test = False + if Test: + director( + project_gdb=project_gdb, Sequential=True, table_names=["GMEX_IDW"] + ) + # director(project_gdb=project_gdb, Sequential=True, table_names=["NBS_IDW", "HI_IDW"]) + elif not Test: + # director(project_gdb=project_gdb, Sequential=True, table_names=["AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", ]) + # director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_FAL_IDW", "NEUS_SPR_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW"]) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "AI_IDW", + "EBS_IDW", + "ENBS_IDW", + "GMEX_IDW", + "GOA_IDW", + "HI_IDW", + "NBS_IDW", + "NEUS_FAL_IDW", + "NEUS_SPR_IDW", + "SEUS_FAL_IDW", + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + "WC_ANN_IDW", + "WC_TRI_IDW", + ], + ) + else: + pass + del Test + except: # noqa: E722 + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + + # Declared Variables + # Imports + # Function Parameters + del project_gdb + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) + minutes, seconds = divmod(rem, 60) + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) + arcpy.AddMessage(f"{'-' * 80}") + del hours, rem, minutes, seconds + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +if __name__ == "__main__": + try: + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) + else: + pass + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + del project_gdb + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_region_sample_locations_worker.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_sample_locations_worker.py similarity index 51% rename from ArcGIS-Analysis-Python/src/dismap_tools/create_region_sample_locations_worker.py rename to ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_sample_locations_worker.py index 5dbda07..34fdd0f 100644 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_region_sample_locations_worker.py +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_region_sample_locations_worker.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------- # Name: module1 # Purpose: # @@ -8,27 +8,25 @@ # Created: 29/02/2024 # Copyright: (c) john.f.kennedy 2024 # Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first +# ------------------------------------------------------------------------------- +import inspect +import os +import sys import traceback -import inspect +import arcpy # third-parties second -import arcpy # third-parties second def worker(region_gdb=""): try: - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(rf"{region_gdb}"): - raise SystemExist(f"{os.path.basename(region_gdb)} is missing!!") - # Import the dismap_tools module to access tools + import warnings + import dismap_tools + import numpy as np + import pandas as pd # Import from arcpy import metadata as md - import pandas as pd - import numpy as np - import warnings # Use all of the cores on the machine arcpy.env.parallelProcessingFactor = "100%" @@ -36,30 +34,34 @@ def worker(region_gdb=""): # Set History and Metadata logs, set serverity and message levelarcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(2) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + arcpy.SetSeverityLevel( + 2 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION # Set basic workkpace variables - table_name = os.path.basename(region_gdb).replace(".gdb", "") - scratch_folder = os.path.dirname(region_gdb) - project_folder = os.path.dirname(scratch_folder) - csv_data_folder = rf"{project_folder}\CSV_Data" - process_table = rf"{csv_data_folder}\{table_name}.csv" - scratch_workspace = rf"{scratch_folder}\scratch.gdb" + table_name = os.path.basename(region_gdb).replace(".gdb", "") + scratch_folder = os.path.dirname(region_gdb) + project_folder = os.path.dirname(scratch_folder) + csv_data_folder = os.path.join(project_folder, f"CSV_Data") + process_table = rf"{csv_data_folder}\{table_name}.csv" + scratch_workspace = os.path.join(scratch_folder, "scratch.gdb") del scratch_folder # Set basic workkpace variables - arcpy.env.workspace = region_gdb + arcpy.env.workspace = region_gdb arcpy.env.scratchWorkspace = scratch_workspace field_csv_dtypes = dismap_tools.dTypesCSV(csv_data_folder, table_name) field_gdb_dtypes = dismap_tools.dTypesGDB(csv_data_folder, table_name) - #print(field_csv_dtypes) - #print(field_gdb_dtypes) - #sys.exit() + # print(field_csv_dtypes) + # print(field_gdb_dtypes) + # sys.exit() # DatasetCode, CSVFile, TransformUnit, TableName, GeographicArea, CellSize, # PointFeatureType, FeatureClassName, Region, Season, DateCode, Status, @@ -68,18 +70,32 @@ def worker(region_gdb=""): # MosaicName, MosaicTitle, ImageServiceName, ImageServiceTitle # Get values for table_name from Datasets table - fields = ["TableName", "GeographicArea", "DatasetCode", "Region", "Season", "DistributionProjectCode"] - region_list = [row for row in arcpy.da.SearchCursor(rf"{region_gdb}\Datasets", fields, where_clause = f"TableName = '{table_name}'")][0] + fields = [ + "TableName", + "GeographicArea", + "DatasetCode", + "Region", + "Season", + "DistributionProjectCode", + ] + region_list = [ + row + for row in arcpy.da.SearchCursor( + rf"{region_gdb}\Datasets", + fields, + where_clause=f"TableName = '{table_name}'", + ) + ][0] del table_name # Assigning variables from items in the chosen table list # ['AI_IDW', 'AI_IDW_Region', 'AI', 'Aleutian Islands', None, 'IDW'] - table_name = region_list[0] + table_name = region_list[0] geographic_area = region_list[1] - datasetcode = region_list[2] - region = region_list[3] - season = region_list[4] - distri_code = region_list[5] + datasetcode = region_list[2] + region = region_list[3] + season = region_list[4] + distri_code = region_list[5] del region_list # Start of business logic for the worker function @@ -94,55 +110,55 @@ def worker(region_gdb=""): encoding, index_column = dismap_tools.get_encoding_index_col(process_table) with warnings.catch_warnings(): - warnings.simplefilter(action='ignore', category=FutureWarning) + warnings.simplefilter(action="ignore", category=FutureWarning) # DataFrame df = pd.read_csv( - process_table, - index_col = index_column, - encoding = encoding, - delimiter = ",", - dtype = field_csv_dtypes, - ) + process_table, + index_col=index_column, + encoding=encoding, + delimiter=",", + dtype=field_csv_dtypes, + ) del encoding, index_column # Rename columns using the dictionary below and the defined list of field names # Easting,Northing,year,depth_m,median_est,mean_est,est5,est95,spp_sci,spp_common # mean_est, est5, est95 column_names = { - "common" : "CommonName", - "depth" : "Depth", - "depth_m" : "Depth", - "DistributionProjectName" : "DistributionProjectName", - "est5" : "Estimate5", - "est95" : "Estimate95", - "haulid" : "SampleID", - "lat" : "Latitude", - "lat_UTM" : "Northing", - "lon" : "Longitude", - "lon_UTM" : "Easting", - "mean_est" : "MeanEstimate", - "median_est" : "MedianEstimate", - "region" : "Region", - "sampleid" : "SampleID", - "spp" : "Species", - "spp_common" : "CommonName", - "spp_sci" : "Species", - "stratum" : "Stratum", - "stratumarea" : "StratumArea", - "transformed" : "MapValue", - "wtcpue" : "WTCPUE", - "year" : "Year", - "CoreSpecies" : "CoreSpecies" - } + "common": "CommonName", + "depth": "Depth", + "depth_m": "Depth", + "DistributionProjectName": "DistributionProjectName", + "est5": "Estimate5", + "est95": "Estimate95", + "haulid": "SampleID", + "lat": "Latitude", + "lat_UTM": "Northing", + "lon": "Longitude", + "lon_UTM": "Easting", + "mean_est": "MeanEstimate", + "median_est": "MedianEstimate", + "region": "Region", + "sampleid": "SampleID", + "spp": "Species", + "spp_common": "CommonName", + "spp_sci": "Species", + "stratum": "Stratum", + "stratumarea": "StratumArea", + "transformed": "MapValue", + "wtcpue": "WTCPUE", + "year": "Year", + "CoreSpecies": "CoreSpecies", + } df.rename(columns=column_names, inplace=True) del column_names # Print column names - #for column in list(df.columns): arcpy.AddMessage(column); del column # print columns + # for column in list(df.columns): arcpy.AddMessage(column); del column # print columns # ###--->>> - arcpy.AddMessage(f"Inserting additional columns into the dataframe\n") + arcpy.AddMessage("Inserting additional columns into the dataframe\n") arcpy.AddMessage(f"\tInserting 'DatasetCode' column into: {table_name}") df.insert(0, "DatasetCode", datasetcode) @@ -150,53 +166,67 @@ def worker(region_gdb=""): arcpy.AddMessage(f"\tInserting 'Region' column into: {table_name}") if "Region" not in list(df.columns): - df.insert(df.columns.get_loc("DatasetCode")+1, "Region", f"{region}") + df.insert(df.columns.get_loc("DatasetCode") + 1, "Region", f"{region}") arcpy.AddMessage(f"\tInserting 'StdTime' column into: {table_name}") if "StdTime" not in list(df.columns): - df.insert(df.columns.get_loc("Year")+1, "StdTime", pd.to_datetime(df["Year"], format="%Y").dt.tz_localize('Etc/GMT+12')) + df.insert( + df.columns.get_loc("Year") + 1, + "StdTime", + pd.to_datetime(df["Year"], format="%Y").dt.tz_localize("Etc/GMT+12"), + ) arcpy.AddMessage(f"\tInserting 'MapValue' column into: {table_name}") if "MapValue" not in list(df.columns): - df.insert(df.columns.get_loc("WTCPUE")+1, "MapValue", np.nan) - #-->> MapValue - arcpy.AddMessage(f"\tCalculating the MapValue values") - df["MapValue"] = df["WTCPUE"].pow((1.0/3.0)) + df.insert(df.columns.get_loc("WTCPUE") + 1, "MapValue", np.nan) + # -->> MapValue + arcpy.AddMessage("\tCalculating the MapValue values") + df["MapValue"] = df["WTCPUE"].pow((1.0 / 3.0)) arcpy.AddMessage(f"\tInserting 'SpeciesCommonName' column into: {table_name}") if "SpeciesCommonName" not in list(df.columns): - df.insert(df.columns.get_loc("CommonName")+1, "SpeciesCommonName", "") + df.insert(df.columns.get_loc("CommonName") + 1, "SpeciesCommonName", "") arcpy.AddMessage(f"\tInserting 'CommonNameSpecies' column into: {table_name}") if "CommonNameSpecies" not in list(df.columns): - df.insert(df.columns.get_loc("SpeciesCommonName")+1, "CommonNameSpecies", "") + df.insert( + df.columns.get_loc("SpeciesCommonName") + 1, "CommonNameSpecies", "" + ) # Test if 'IDW' in table name - #if "IDW" in table_name: + # if "IDW" in table_name: arcpy.AddMessage(f"\tInserting 'Season' {season} column into: {table_name}") if "Season" not in list(df.columns): - df.insert(df.columns.get_loc("Region")+1, "Season", season if season != None else "") + df.insert( + df.columns.get_loc("Region") + 1, + "Season", + season if season is not None else "", + ) arcpy.AddMessage(f"\tInserting 'SummaryProduct' column into: {table_name}") if "SummaryProduct" not in list(df.columns): - df.insert(df.columns.get_loc("Season")+1, "SummaryProduct", "Yes") + df.insert(df.columns.get_loc("Season") + 1, "SummaryProduct", "Yes") arcpy.AddMessage(f"\tInserting 'TransformUnit' column into: {table_name}") if "TransformUnit" not in list(df.columns): - df.insert(df.columns.get_loc("MapValue")+1, "TransformUnit", "cuberoot") + df.insert(df.columns.get_loc("MapValue") + 1, "TransformUnit", "cuberoot") arcpy.AddMessage(f"\tInserting 'CoreSpecies' column into: {table_name}") if "CoreSpecies" not in list(df.columns): - df.insert(df.columns.get_loc("CommonNameSpecies")+1, "CoreSpecies", "No") + df.insert(df.columns.get_loc("CommonNameSpecies") + 1, "CoreSpecies", "No") - arcpy.AddMessage(f"\tCalculate Null for 'StratumArea' column into: {table_name}") + arcpy.AddMessage( + f"\tCalculate Null for 'StratumArea' column into: {table_name}" + ) if "StratumArea" in list(df.columns): - #df["StratumArea"].fillna(np.nan, inplace = True) + # df["StratumArea"].fillna(np.nan, inplace = True) df["StratumArea"] = df["StratumArea"].fillna(np.nan) - arcpy.AddMessage(f"\tCalculate Null for 'DistributionProjectName' column into: {table_name}") + arcpy.AddMessage( + f"\tCalculate Null for 'DistributionProjectName' column into: {table_name}" + ) if "DistributionProjectName" in list(df.columns): - #df["DistributionProjectName"].fillna(np.nan, inplace = True) + # df["DistributionProjectName"].fillna(np.nan, inplace = True) df["DistributionProjectName"] = df["DistributionProjectName"].fillna(np.nan) arcpy.AddMessage(f"\tCalculate Null for 'WTCPUE' column into: {table_name}") @@ -218,58 +248,68 @@ def worker(region_gdb=""): del region, season # ###--->>> - #arcpy.AddMessage(f"Updating and calculating new values for some columns\n") - #-->> DistributionProjectName - arcpy.AddMessage(f"\tSetting 'NaN' in 'DistributionProjectName' to ''") - #df.loc[df['DistributionProjectName'] == 'nan', 'DistributionProjectName'] = "" + # arcpy.AddMessage(f"Updating and calculating new values for some columns\n") + # -->> DistributionProjectName + arcpy.AddMessage("\tSetting 'NaN' in 'DistributionProjectName' to ''") + # df.loc[df['DistributionProjectName'] == 'nan', 'DistributionProjectName'] = "" df["DistributionProjectName"] = df["DistributionProjectName"].fillna("") - #-->> CommonName - arcpy.AddMessage(f"\tSetting 'NaN' in 'CommonName' to ''") - #df.loc[df['CommonName'] == 'nan', 'CommonName'] = "" + # -->> CommonName + arcpy.AddMessage("\tSetting 'NaN' in 'CommonName' to ''") + # df.loc[df['CommonName'] == 'nan', 'CommonName'] = "" df["CommonName"] = df["CommonName"].fillna("") - arcpy.AddMessage(f"\tSetting 'CommonName' unicode'") + arcpy.AddMessage("\tSetting 'CommonName' unicode'") # Cast text as Unicode in the CommonName field df["CommonName"] = df["CommonName"].astype("unicode") - #-->> SpeciesCommonName - arcpy.AddMessage(f"\tCalculating SpeciesCommonName and setting it to 'Species (CommonName)'") - df["SpeciesCommonName"] = np.where(df["CommonName"] != "", df["Species"] + ' (' + df["CommonName"] + ')', "") - - #-->> CommonNameSpecies - arcpy.AddMessage(f"\tCalculating CommonNameSpecies and setting it to 'CommonName (Species)'") - df["CommonNameSpecies"] = np.where(df["CommonName"] != "", df["CommonName"] + ' (' + df["Species"] + ')', "") - - arcpy.AddMessage(f"\tReplacing Infinity values with Nulls") + # -->> SpeciesCommonName + arcpy.AddMessage( + "\tCalculating SpeciesCommonName and setting it to 'Species (CommonName)'" + ) + df["SpeciesCommonName"] = np.where( + df["CommonName"] != "", df["Species"] + " (" + df["CommonName"] + ")", "" + ) + + # -->> CommonNameSpecies + arcpy.AddMessage( + "\tCalculating CommonNameSpecies and setting it to 'CommonName (Species)'" + ) + df["CommonNameSpecies"] = np.where( + df["CommonName"] != "", df["CommonName"] + " (" + df["Species"] + ")", "" + ) + + arcpy.AddMessage("\tReplacing Infinity values with Nulls") # Replace Inf with Nulls # For some cell values in the 'WTCPUE' column, there is an Inf # value representing an infinit df.replace([np.inf, -np.inf], np.nan, inplace=True) # Left justify the column names - #df.columns = pd.Index([col.ljust(10) for col in df.columns]) + # df.columns = pd.Index([col.ljust(10) for col in df.columns]) table_definition = dismap_tools.table_definitions(csv_data_folder, table_name) - #arcpy.AddMessage(table_definition) + # arcpy.AddMessage(table_definition) # altering the DataFrame df = df[table_definition] del table_definition - #raise SystemExist(f"Line Number: {traceback.extract_stack()[-1].lineno}") + # raise SystemExist(f"Line Number: {traceback.extract_stack()[-1].lineno}") pd.set_option("display.max_colwidth", 12) # Change Table Style - df.style.set_table_styles([{'selector': 'td', 'props': 'white-space: nowrap !important;'}]) + df.style.set_table_styles( + [{"selector": "td", "props": "white-space: nowrap !important;"}] + ) arcpy.AddMessage(f"\nDataframe report:\n{df.head(5)}\n") - arcpy.AddMessage(f"Converting the Dataframe to an NumPy Array\n") + arcpy.AddMessage("Converting the Dataframe to an NumPy Array\n") try: - array = np.array(np.rec.fromrecords(df.values), dtype = field_gdb_dtypes) - except: + array = np.array(np.rec.fromrecords(df.values), dtype=field_gdb_dtypes) + except: # noqa: E722 arcpy.AddError(arcpy.GetMessages(2)) traceback.print_exc() sys.exit() @@ -277,12 +317,12 @@ def worker(region_gdb=""): del field_gdb_dtypes del field_csv_dtypes - del df # delete dataframe + del df # delete dataframe # Imports del pd, np # Temporary table - #tmp_table = f"memory\{table_name.lower()}_tmp" + # tmp_table = f"memory\{table_name.lower()}_tmp" tmp_table = rf"{region_gdb}\{table_name.lower()}_tmp" try: arcpy.da.NumPyArrayToTable(array, tmp_table) @@ -293,15 +333,15 @@ def worker(region_gdb=""): arcpy.AddError(arcpy.GetMessages(2)) traceback.print_exc() sys.exit() - except: + except: # noqa: E722 arcpy.AddError(arcpy.GetMessages(2)) traceback.print_exc() sys.exit() desc = arcpy.da.Describe(tmp_table) fields = [f.name for f in desc["fields"] if f.type == "String"] - #fields = ["Season", "Species", "CommonName", "SpeciesCommonName", "CommonNameSpecies", "Stratum"] - oid = desc["OIDFieldName"] + # fields = ["Season", "Species", "CommonName", "SpeciesCommonName", "CommonNameSpecies", "Stratum"] + oid = desc["OIDFieldName"] # Use SQL TOP to sort field values arcpy.AddMessage(f"{', '.join(fields)}") for row in arcpy.da.SearchCursor(tmp_table, fields, f"{oid} <= 5"): @@ -310,17 +350,19 @@ def worker(region_gdb=""): del desc, fields, oid out_table = rf"{region_gdb}\{table_name}" - #out_table = rf"{region_gdb}\{table_name}_TABLE" + # out_table = rf"{region_gdb}\{table_name}_TABLE" arcpy.AddMessage(f"Copying the {table_name} Table from memory to the GDB") arcpy.management.CopyRows(tmp_table, out_table, "") - arcpy.AddMessage("Copy Rows: \t{0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) + arcpy.AddMessage( + "Copy Rows: \t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) # Remove the temporary table arcpy.management.Delete(tmp_table) del tmp_table process_table_md = md.Metadata(process_table) - out_table_md = md.Metadata(out_table) + out_table_md = md.Metadata(out_table) out_table_md.copy(process_table_md) out_table_md.save() out_table_md.synchronize("OVERWRITE") @@ -330,33 +372,33 @@ def worker(region_gdb=""): del out_table_md del process_table_md - del process_table # delete passed variables + del process_table # delete passed variables # Test if 'IDW' in region name - #if distri_code == "IDW": + # if distri_code == "IDW": # # Calculate Core Species # dismap_tools.calculate_core_species(out_table) - #arcpy.conversion.ExportTable(in_table = out_table, out_table = f"{csv_data_folder}\_{table_name}.csv", where_clause="", use_field_alias_as_name = "NOT_USE_ALIAS") - #arcpy.AddMessage("Export Table: \t{0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) + # arcpy.conversion.ExportTable(in_table = out_table, out_table = f"{csv_data_folder}\_{table_name}.csv", where_clause="", use_field_alias_as_name = "NOT_USE_ALIAS") + # arcpy.AddMessage("Export Table: \t{0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) arcpy.AddMessage(f"Creating the {table_name} Sample Locations Dataset") # Set the output coordinate system to what is needed for the # DisMAP project - #geographic_area_sr = os.path.join(f"{project_folder}", "Dataset_Shapefiles", f"{table_name}", f"{geographic_area}.prj") - #psr = arcpy.SpatialReference(geographic_area_sr); del geographic_area_sr - #arcpy.env.outputCoordinateSystem = psr + # geographic_area_sr = os.path.join(f"{project_folder}", "Dataset_Shapefiles", f"{table_name}", f"{geographic_area}.prj") + # psr = arcpy.SpatialReference(geographic_area_sr); del geographic_area_sr + # arcpy.env.outputCoordinateSystem = psr psr = arcpy.Describe(rf"{region_gdb}\{table_name}_Region").spatialReference arcpy.env.outputCoordinateSystem = psr out_features = "" - #if distri_code == "IDW": + # if distri_code == "IDW": # 4326 - World Geodetic System 1984 (WGS 84) - gsr = arcpy.SpatialReference(4326) + gsr = arcpy.SpatialReference(4326) gsr_wkt = gsr.exportToString() psr_wkt = psr.exportToString() transformation = dismap_tools.get_transformation(gsr_wkt, psr_wkt) @@ -364,36 +406,40 @@ def worker(region_gdb=""): del gsr_wkt, psr_wkt del transformation - arcpy.AddMessage(f"\tMake XY Event layer for IDW datasets") + arcpy.AddMessage("\tMake XY Event layer for IDW datasets") # Set the output coordinate system to what is needed for the # DisMAP project - #gsr = "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]" - x_coord, y_coord = 'Longitude', 'Latitude' - xy_events = arcpy.management.MakeXYEventLayer(out_table, x_coord, y_coord, "xy_events", gsr, "#") + # gsr = "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]" + x_coord, y_coord = "Longitude", "Latitude" + xy_events = arcpy.management.MakeXYEventLayer( + out_table, x_coord, y_coord, "xy_events", gsr, "#" + ) del x_coord, y_coord out_features = rf"{region_gdb}\{table_name}_Sample_Locations" - with arcpy.EnvManager(scratchWorkspace = scratch_workspace, workspace = region_gdb): - arcpy.conversion.ExportFeatures(in_features = xy_events, - out_features = out_features, - where_clause = "", - use_field_alias_as_name = "", - field_mapping = "", - sort_field = "") + with arcpy.EnvManager(scratchWorkspace=scratch_workspace, workspace=region_gdb): + arcpy.conversion.ExportFeatures( + in_features=xy_events, + out_features=out_features, + where_clause="", + use_field_alias_as_name="", + field_mapping="", + sort_field="", + ) # Clear the XY Event Layer from memory. arcpy.management.Delete("xy_events") del xy_events, psr - #arcpy.AddMessage(f"\tXY TableToNumPyArray to Feature Class") - #fields = [f.name for f in arcpy.ListFields(out_table) if f.type not in ["Geometry", "OID"]] - #arr = arcpy.da.TableToNumPyArray(out_table, fields) - #arcpy.da.NumPyArrayToFeatureClass(arr, out_features, ('Longitude', 'Latitude'), gsr) - #del arr, fields + # arcpy.AddMessage(f"\tXY TableToNumPyArray to Feature Class") + # fields = [f.name for f in arcpy.ListFields(out_table) if f.type not in ["Geometry", "OID"]] + # arr = arcpy.da.TableToNumPyArray(out_table, fields) + # arcpy.da.NumPyArrayToFeatureClass(arr, out_features, ('Longitude', 'Latitude'), gsr) + # del arr, fields del gsr - #elif distri_code != "IDW": + # elif distri_code != "IDW": # # x_field, y_field = 'Easting', 'Northing' # out_features = rf"{region_gdb}\{table_name}_GRID_Points" @@ -406,19 +452,30 @@ def worker(region_gdb=""): del distri_code if arcpy.Exists(out_features): - arcpy.AddMessage(f"Adding field index in the {table_name} Point Locations Dataset") + arcpy.AddMessage( + f"Adding field index in the {table_name} Point Locations Dataset" + ) # Add Attribute Index - arcpy.management.AddIndex(out_features, ['Species', 'CommonName', 'SpeciesCommonName', 'Year'], f"{table_name}_SampleLocationsSpeciesIndex", "NON_UNIQUE", "NON_ASCENDING") + arcpy.management.AddIndex( + out_features, + ["Species", "CommonName", "SpeciesCommonName", "Year"], + f"{table_name}_SampleLocationsSpeciesIndex", + "NON_UNIQUE", + "NON_ASCENDING", + ) # Get the count of records for selected species getcount = arcpy.management.GetCount(out_features)[0] - arcpy.AddMessage(f"\t{os.path.basename(out_features)} has {getcount} records"); del getcount + arcpy.AddMessage( + f"\t{os.path.basename(out_features)} has {getcount} records" + ) + del getcount else: pass out_table_md = md.Metadata(out_table) - out_features_md = md.Metadata(out_features) + out_features_md = md.Metadata(out_features) out_features_md.copy(out_table_md) out_features_md.save() out_features_md.synchronize("OVERWRITE") @@ -460,49 +517,68 @@ def worker(region_gdb=""): except KeyboardInterrupt: sys.exit() except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") + arcpy.AddWarning( + f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function." + ) arcpy.AddWarning(arcpy.GetMessages(1)) except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") + arcpy.AddError( + f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function." + ) arcpy.AddError(arcpy.GetMessages(2)) traceback.print_exc() sys.exit() except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") + arcpy.AddError( + f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function." + ) sys.exit() except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") + arcpy.AddError( + f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function." + ) traceback.print_exc() sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") + except: # noqa: E722 + arcpy.AddError( + f"Caught an except error in the '{inspect.stack()[0][3]}' function." + ) traceback.print_exc() sys.exit() else: # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + arcpy.AddMessage( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk return True finally: pass + def script_tool(project_gdb=""): try: - import dismap_tools from time import gmtime, localtime, strftime, time + + import dismap_tools + # Set a start time so that we can see how log things take start_time = time() arcpy.AddMessage(f"{'-' * 80}") arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") arcpy.AddMessage(f"Python Version: {sys.version}") arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) arcpy.AddMessage(f"{'-' * 80}\n") # Imports # Set basic arcpy.env variables - arcpy.env.overwriteOutput = True + arcpy.env.overwriteOutput = True arcpy.env.parallelProcessingFactor = "100%" # Set varaibales @@ -523,52 +599,67 @@ def script_tool(project_gdb=""): sys.exit()(f"{os.path.basename(project_gdb)} is missing!!") # Create project scratch workspace, if missing - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): if not arcpy.Exists(scratch_folder): - os.makedirs(rf"{scratch_folder}") - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"scratch") + os.makedirs(scratch_folder) + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + arcpy.management.CreateFileGDB(rf"{scratch_folder}", "scratch") # Set worker parameters table_name = "AI_IDW" - #table_name = "HI_IDW" - #table_name = "NBS_IDW" - #table_name = "SEUS_SPR_IDW" - #table_name = "GMEX_IDW" - #table_name = "ENBS_IDW" + # table_name = "HI_IDW" + # table_name = "NBS_IDW" + # table_name = "SEUS_SPR_IDW" + # table_name = "GMEX_IDW" + # table_name = "ENBS_IDW" - region_gdb = rf"{scratch_folder}\{table_name}.gdb" + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" # Create worker scratch workspace, if missing if not arcpy.Exists(scratch_workspace): - os.makedirs(rf"{scratch_folder}\{table_name}") + os.makedirs(os.path.join(scratch_folder, table_name)) if not arcpy.Exists(scratch_workspace): - arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") + arcpy.management.CreateFileGDB( + os.path.join(scratch_folder, f"{table_name}"), "scratch" + ) del scratch_workspace # Setup worker workspace and copy data - #datasets = [rf"{project_gdb}\Datasets", rf"{project_gdb}\{table_name}_Region"] - #if not any(arcpy.management.GetCount(d)[0] == 0 for d in datasets): - if not arcpy.Exists(rf"{scratch_folder}\{table_name}.gdb"): + # datasets = [ros.path.join(project_gdb, "Datasets") os.path.join(project_gdb, f"{table_name}_Region")] + # if not any(arcpy.management.GetCount(d)[0] == 0 for d in datasets): + if not arcpy.Exists(os.path.join(scratch_folder, f"{table_name}.gdb")): arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) else: pass - arcpy.management.Copy(rf"{project_gdb}\Datasets", rf"{region_gdb}\Datasets") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.management.Copy(rf"{project_gdb}\{table_name}_Region", rf"{region_gdb}\{table_name}_Region") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - #else: + arcpy.management.Copy( + os.path.join(project_gdb, "Datasets"), rf"{region_gdb}\Datasets" + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + arcpy.management.Copy( + os.path.join(project_gdb, f"{table_name}_Region"), + rf"{region_gdb}\{table_name}_Region", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + # else: # arcpy.AddWarning(f"One or more datasets contains zero records!!") # for d in datasets: # arcpy.AddMessage(f"\t{os.path.basename(d)} has {arcpy.management.GetCount(d)[0]} records") # del d # se = f"SystemExit at line number: '{traceback.extract_stack()[-1].lineno}'" # sys.exit()(se) - #if "datasets" in locals().keys(): del datasets + # if "datasets" in locals().keys(): del datasets try: pass @@ -576,8 +667,7 @@ def script_tool(project_gdb=""): except SystemExit: arcpy.AddMessage(arcpy.GetMessages()) sys.exit() - #arcpy.AddMessage(f"caught SystemExit in '{inspect.stack()[0][3]}'") - + # arcpy.AddMessage(f"caught SystemExit in '{inspect.stack()[0][3]}'") # Declared Varaiables del region_gdb, table_name, scratch_folder @@ -587,61 +677,68 @@ def script_tool(project_gdb=""): del project_gdb # Elapsed time end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) minutes, seconds = divmod(rem, 60) arcpy.AddMessage(f"\n{'-' * 80}") arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) arcpy.AddMessage(f"{'-' * 80}") del hours, rem, minutes, seconds del elapse_time, end_time, start_time del gmtime, localtime, strftime, time - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk return True - finally: - pass -if __name__ == '__main__': + +if __name__ == "__main__": try: project_gdb = arcpy.GetParameterAsText(0) if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) else: pass script_tool(project_gdb) arcpy.SetParameterAsText(1, "Result") del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_regions_from_shapefiles_director.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_regions_from_shapefiles_director.py new file mode 100644 index 0000000..71d86d8 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_regions_from_shapefiles_director.py @@ -0,0 +1,581 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: module1 +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 03/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import inspect +import os +import sys +import traceback + +import arcpy # third-parties second + + +def create_dismap_regions(project_gdb=""): + try: + import dismap_tools + + project_folder = os.path.dirname(project_gdb) + csv_data_folder = os.path.join(project_folder, "CSV_Data") + + arcpy.env.overwriteOutput = True + + if arcpy.Exists(os.path.join(project_gdb, "DisMAP_Regions")): + arcpy.management.Delete(os.path.join(project_gdb, "DisMAP_Regions")) + + arcpy.AddMessage("Creating: 'DisMAP_Regions'") + # Execute Tool + # Spatial Reference factory code of 4326 is : GCS_WGS_1984 + # Spatial Reference factory code of 5714 is : Mean Sea Level (Height) + # sr = arcpy.SpatialReference(4326, 5714) + sp_ref = arcpy.SpatialReference("WGS_1984_Web_Mercator_Auxiliary_Sphere") + arcpy.management.CreateFeatureclass( + out_path=project_gdb, + out_name="DisMAP_Regions", + geometry_type="POLYLINE", + template="", + has_m="DISABLED", + has_z="DISABLED", + spatial_reference=sp_ref, + config_keyword="", + spatial_grid_1="0", + spatial_grid_2="0", + spatial_grid_3="0", + ) + arcpy.AddMessage( + "\tCreate Featureclass: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + del sp_ref + dismap_tools.add_fields( + csv_data_folder, os.path.join(project_gdb, "DisMAP_Regions") + ) + dismap_tools.import_metadata( + csv_data_folder, os.path.join(project_gdb, "DisMAP_Regions") + ) + + # Imports + del dismap_tools + # Function Parameter + + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError( + f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except SystemExit as se: + arcpy.AddError( + f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function." + ) + sys.exit() + except Exception as e: + arcpy.AddError( + f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + except: # noqa: E722 + arcpy.AddError( + f"Caught an except error in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + arcpy.AddMessage( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + arcpy.management.ClearWorkspaceCache() + + +def director(project_gdb="", Sequential=True, table_names=[]): + try: + # Imports + # Imports + import dismap_tools + from arcpy import metadata as md + from create_regions_from_shapefiles_worker import worker + + arcpy.env.overwriteOutput = True + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + project_folder = os.path.dirname(project_gdb) + scratch_folder = os.path.join(project_folder, "Scratch") + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + csv_data_folder = os.path.join(project_folder, f"CSV_Data") + + # Clear Scratch Folder + dismap_tools.clear_folder(folder=scratch_folder) + + # Create Scratch Workspace for Project + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + if not arcpy.Exists(scratch_folder): + os.makedirs(scratch_folder) + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + arcpy.management.CreateFileGDB(rf"{scratch_folder}", "scratch") + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + del project_folder, scratch_workspace + + create_dismap_regions(project_gdb) + + if not table_names: + table_names = [ + row[0] + for row in arcpy.da.SearchCursor( + os.path.join(project_gdb, "Datasets"), + "TableName", + where_clause="TableName LIKE '%_IDW'", + ) + ] + else: + pass + + # Pre Processing + for table_name in table_names: + arcpy.AddMessage(f"Pre-Processing: {table_name}") + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" + # Create Scratch Workspace for Region + if not arcpy.Exists(region_scratch_workspace): + os.makedirs(os.path.join(scratch_folder, table_name)) + if not arcpy.Exists(region_scratch_workspace): + arcpy.management.CreateFileGDB( + os.path.join(scratch_folder, f"{table_name}"), "scratch" + ) + del region_scratch_workspace + + # datasets = [ros.path.join(project_gdb, "Datasets"] + # if not any(arcpy.management.GetCount(d)[0] == 0 for d in datasets): + if not arcpy.Exists(os.path.join(scratch_folder, f"{table_name}.gdb")): + arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + else: + pass + + arcpy.management.Copy( + os.path.join(project_gdb, "Datasets"), rf"{region_gdb}\Datasets" + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + arcpy.management.CreateFeatureclass( + rf"{region_gdb}", + "DisMAP_Regions", + "POLYLINE", + os.path.join(project_gdb, "DisMAP_Regions"), + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + dismap_regions_md = md.Metadata(os.path.join(project_gdb, "DisMAP_Regions")) + dataset_md = md.Metadata(rf"{region_gdb}\DisMAP_Regions") + dataset_md.copy(dismap_regions_md) + dataset_md.save() + dataset_md.synchronize("OVERWRITE") + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + del dataset_md, dismap_regions_md + # else: + # arcpy.AddWarning(f"One or more datasets contains zero records!!") + # for d in datasets: + # arcpy.AddMessage(f"\t{os.path.basename(d)} has {arcpy.management.GetCount(d)[0]} records") + # del d + # se = f"SystemExit at line number: '{traceback.extract_stack()[-1].lineno}'" + # sys.exit()(se) + # if "datasets" in locals().keys(): del datasets + del region_gdb + del table_name + + # Sequential Processing + if Sequential: + arcpy.AddMessage("Sequential Processing") + for i in range(0, len(table_names)): + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + try: + worker(region_gdb=region_gdb) + except SystemExit: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del region_gdb, table_name + del i + else: + pass + + # Non-Sequential Processing + if not Sequential: + arcpy.AddMessage("Non-Sequential Processing") + # Imports + import multiprocessing + from time import gmtime, localtime, sleep, strftime, time + + arcpy.AddMessage("Start multiprocessing using the ArcGIS Pro pythonw.exe.") + # Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS + # get_install_path() uses a registry query to figure out 64bit python exe if available + multiprocessing.set_executable(os.path.join(sys.exec_prefix, "pythonw.exe")) + # Get CPU count and then take 2 away for other process + _processes = multiprocessing.cpu_count() - 2 + _processes = ( + _processes if len(table_names) >= _processes else len(table_names) + ) + arcpy.AddMessage( + f"Creating the multiprocessing Pool with {_processes} processes" + ) + # Create a pool of workers, keep one cpu free for surfing the net. + # Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) + with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: + arcpy.AddMessage("\tPrepare arguments for processing") + # Use apply_async so we can handle exceptions gracefully + jobs = {} + for i in range(0, len(table_names)): + try: + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + jobs[table_name] = pool.apply_async(worker, [region_gdb]) + del table_name, region_gdb + except: # noqa: E722 + pool.terminate() + traceback.print_exc() + sys.exit() + del i + all_finished = False + # Set a start time so that we can see how log things take + start_time = time() + result_completed = {} + while True: + all_finished = True + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + arcpy.AddMessage( + f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage("Have the workers finished?") + finish_time = strftime("%a %b %d %I:%M %p", localtime()) + time_elapsed = "Elapsed Time {0} (H:M:S)".format( + strftime("%H:%M:%S", gmtime(elapse_time)) + ) + arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") + finish_time = f"{finish_time}.\n\t{time_elapsed}" + del time_elapsed + for table_name, result in jobs.items(): + if result.ready(): + if table_name not in result_completed: + result_completed[table_name] = finish_time + try: + # wait for and get the result from the task + result.get() + except SystemExit: + pool.terminate() + traceback.print_exc() + sys.exit() + else: + pass + arcpy.AddMessage( + f"Process {table_name}\n\tFinished on {result_completed[table_name]}" + ) + else: + all_finished = False + arcpy.AddMessage(f"Process {table_name} is running. . .") + del table_name, result + del elapse_time, end_time, finish_time + if all_finished: + break + sleep(_processes * 7.5) + del result_completed + del start_time + del all_finished + arcpy.AddMessage("\tClose the process pool") + # close the process pool + pool.close() + # wait for all tasks to complete and processes to close + arcpy.AddMessage( + "\tWait for all tasks to complete and processes to close" + ) + pool.join() + # Just in case + pool.terminate() + del pool + del jobs + del _processes + del time, multiprocessing, localtime, strftime, sleep, gmtime + arcpy.AddMessage("\tDone with multiprocessing Pool") + + # Post-Processing + arcpy.AddMessage("Post-Processing Begins") + arcpy.AddMessage("Processing Results") + datasets = list() + walk = arcpy.da.Walk( + scratch_folder, datatype="FeatureClass", type=["Polyline", "Polygon"] + ) + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + for dataset in datasets: + # print(dataset) + datasets_short_path = f".. {'/'.join(dataset.split(os.sep)[-4:])}" + dataset_name = os.path.basename(dataset) + region_gdb = os.path.dirname(dataset) + arcpy.AddMessage(f"\tDataset: '{dataset_name}'") + arcpy.AddMessage(f"\t\tPath: '{datasets_short_path}'") + arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") + arcpy.management.Copy(dataset, rf"{project_gdb}\{dataset_name}") + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + if dataset_name.endswith("_Boundary"): + arcpy.AddMessage( + f"\tAppending the {dataset_name} Dataset to the DisMAP Regions Dataset" + ) + # Process: Append + arcpy.management.Append( + inputs=rf"{project_gdb}\{dataset_name}", + target=os.path.join(project_gdb, "DisMAP_Regions"), + schema_type="NO_TEST", + field_mapping="", + subtype="", + ) + arcpy.AddMessage( + "\tAppend: {0} {1}\n".format( + os.path.basename(dataset), + arcpy.GetMessages(0).replace("\n", "\n\t"), + ) + ) + else: + pass + # arcpy.AddMessage(f"\t\tAlter Fields for: '{dataset_name}'") + # dismap_tools.alter_fields(csv_data_folder, rf"{project_gdb}\{dataset_name}") + # dismap_tools.import_metadata(dataset=rf"{project_gdb}\{dataset_name}") + del region_gdb, dataset_name, datasets_short_path + del dataset + del datasets + arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") + arcpy.management.Compact(project_gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + # Declared Variables + del scratch_folder, csv_data_folder + # Imports + del dismap_tools, worker, md + # Function Parameters + del project_gdb, Sequential, table_names + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError( + f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except SystemExit as se: + arcpy.AddError( + f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function." + ) + sys.exit() + except Exception as e: + arcpy.AddError( + f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + except: # noqa: E722 + arcpy.AddError( + f"Caught an except error in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + arcpy.AddMessage( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def script_tool(project_gdb=""): + try: + # Imports + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + try: + pass + # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", + # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", + test = False + if test: + # director(project_gdb=project_gdb, Sequential=True, table_names=["HI_IDW"]) + director( + project_gdb=project_gdb, + Sequential=True, + table_names=["SEUS_SPR_IDW", "HI_IDW"], + ) + # create_dismap_regions(project_gdb) + elif not test: + # director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW", "HI_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) + # director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW", "AI_IDW", "GOA_IDW", "WC_ANN_IDW", "NEUS_FAL_IDW",]) + # director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW"]) + director(project_gdb=project_gdb, Sequential=False, table_names=[]) + del test + except: # noqa: E722 + traceback.print_exc() + sys.exit() + + # Declared Varaiables + del project_gdb + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) + minutes, seconds = divmod(rem, 60) + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) + arcpy.AddMessage(f"{'-' * 80}") + del hours, rem, minutes, seconds + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError( + f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function." + ) + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except SystemExit as se: + arcpy.AddError( + f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function." + ) + sys.exit() + except Exception as e: + arcpy.AddError( + f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + except: # noqa: E722 + arcpy.AddError( + f"Caught an except error in the '{inspect.stack()[0][3]}' function." + ) + traceback.print_exc() + sys.exit() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + arcpy.AddMessage( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +if __name__ == "__main__": + try: + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) + else: + pass + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + del project_gdb + except: # noqa: E722 + traceback.print_exc() + else: + pass + finally: + pass +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_regions_from_shapefiles_director.zip b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_regions_from_shapefiles_director.zip new file mode 100644 index 0000000..36a1a0d Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_regions_from_shapefiles_director.zip differ diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_regions_from_shapefiles_worker.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_regions_from_shapefiles_worker.py similarity index 78% rename from ArcGIS-Analysis-Python/src/dismap_tools/create_regions_from_shapefiles_worker.py rename to ArcGIS-Analysis-Python/Scripts/dismap_tools/create_regions_from_shapefiles_worker.py index 270258a..a5c5e6b 100644 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_regions_from_shapefiles_worker.py +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_regions_from_shapefiles_worker.py @@ -9,12 +9,13 @@ # Copyright: (c) john.f.kennedy 2024 # Licence: #------------------------------------------------------------------------------- -import os, sys # built-ins first +import inspect +import os +import sys import traceback -import inspect +import arcpy # third-parties second -import arcpy # third-parties second def worker(region_gdb=""): try: @@ -61,7 +62,7 @@ def worker(region_gdb=""): # FeatureServiceTitle MosaicName MosaicTitle ImageServiceName, ImageServiceTitle fields = ["TableName", "GeographicArea", "DatasetCode", "Region", "Season", "DistributionProjectCode"] - region_list = [row for row in arcpy.da.SearchCursor(rf"{region_gdb}\Datasets", fields, where_clause = f"TableName = '{table_name}'")][0] + region_list = [row for row in arcpy.da.SearchCursor(os.path.join(region_gdb, "Datasets"), fields, where_clause = f"TableName = '{table_name}'")][0] del fields # Assigning variables from items in the chosen table list @@ -82,8 +83,10 @@ def worker(region_gdb=""): arcpy.AddMessage(f"\tSeason: {season}") arcpy.AddMessage(f"\tDistri Code: {distri_code}") - geographicarea_sr = os.path.join(f"{project_folder}", "Dataset_Shapefiles", f"{table_name}", f"{geographic_area}.prj") - datasetcode_sr = arcpy.SpatialReference(geographicarea_sr); del geographicarea_sr + geographicarea_sr = os.path.join(project_folder, f"Dataset_Shapefiles\\{table_name}\\{geographic_area}.prj") + arcpy.AddMessage(geographicarea_sr) + datasetcode_sr = arcpy.SpatialReference(geographicarea_sr) + del geographicarea_sr if datasetcode_sr.linearUnitName == "Kilometer": arcpy.env.cellSize = 1 @@ -211,36 +214,31 @@ def worker(region_gdb=""): arcpy.AddError(arcpy.GetMessages(2)) traceback.print_exc() sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() except Exception as e: arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") traceback.print_exc() sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() + except SystemExit as se: + arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") sys.exit() else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk return True finally: pass -def script_tool(project_gdb=""): +def script_tool(home_folder, project_name): try: # Imports + from time import gmtime, localtime, strftime, time + import dismap_tools from arcpy import metadata as md - from time import gmtime, localtime, strftime, time + # Set a start time so that we can see how log things take start_time = time() arcpy.AddMessage(f"{'-' * 80}") arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") arcpy.AddMessage(f"Python Version: {sys.version}") arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") @@ -251,19 +249,19 @@ def script_tool(project_gdb=""): arcpy.env.parallelProcessingFactor = "100%" # Set varaibales - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - del project_folder + project_folder = os.path.join(home_folder, project_name) + scratch_folder = os.path.join(project_folder, "Scratch") + project_gdb = os.path.join(project_folder, f"{project_name}.gdb") # Clear Scratch Folder dismap_tools.clear_folder(folder=scratch_folder) # Create project scratch workspace, if missing - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): if not arcpy.Exists(scratch_folder): - os.makedirs(rf"{scratch_folder}") - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"scratch") + os.makedirs(scratch_folder) + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + arcpy.management.CreateFileGDB(scratch_folder, "scratch") else: pass @@ -275,71 +273,47 @@ def script_tool(project_gdb=""): #table_name = "NBS_IDW" #table_name = "SEUS_SPR_IDW" - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + scratch_workspace = os.path.join(scratch_folder, f"{table_name}\\scratch.gdb") # Create worker scratch workspace, if missing if not arcpy.Exists(scratch_workspace): - os.makedirs(rf"{scratch_folder}\{table_name}") + os.makedirs(os.path.join(scratch_folder, table_name)) if not arcpy.Exists(scratch_workspace): - arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") + arcpy.management.CreateFileGDB(os.path.join(scratch_folder, table_name), "scratch") del scratch_workspace -## edit = arcpy.da.Editor(region_gdb) -## arcpy.AddMessage("edit created") -## edit.startEditing() -## arcpy.AddMessage("edit started") -## edit.startOperation() -## arcpy.AddMessage("operation started") - # Setup worker workspace and copy data - #datasets = [rf"{project_gdb}\Datasets", rf"{project_gdb}\DisMAP_Regions"] + #datasets = [ros.path.join(project_gdb, "Datasets") os.path.join(project_gdb, "DisMAP_Regions")] #if not any(arcpy.management.GetCount(d)[0] == 0 for d in datasets): - if not arcpy.Exists(rf"{scratch_folder}\{table_name}.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") + if not arcpy.Exists(os.path.join(scratch_folder, f"{table_name}.gdb")): + arcpy.management.CreateFileGDB(scratch_folder, table_name) arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) else: pass - arcpy.management.Copy(rf"{project_gdb}\Datasets", rf"{region_gdb}\Datasets") + arcpy.management.Copy(os.path.join(project_gdb, "Datasets"), rf"{region_gdb}\Datasets") arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - arcpy.management.CreateFeatureclass(rf"{region_gdb}", "DisMAP_Regions", "POLYLINE", rf"{project_gdb}\DisMAP_Regions") + arcpy.management.CreateFeatureclass(rf"{region_gdb}", "DisMAP_Regions", "POLYLINE", os.path.join(project_gdb, "DisMAP_Regions")) arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - dismap_regions_md = md.Metadata(rf"{project_gdb}\DisMAP_Regions") + dismap_regions_md = md.Metadata(os.path.join(project_gdb, "DisMAP_Regions")) dataset_md = md.Metadata(rf"{region_gdb}\DisMAP_Regions") dataset_md.copy(dismap_regions_md) - dataset_md.save() - dataset_md.synchronize("OVERWRITE") - dataset_md.save() dataset_md.synchronize("ALWAYS") dataset_md.save() del dataset_md, dismap_regions_md - #else: - # arcpy.AddWarning(f"One or more datasets contains zero records!!") - # for d in datasets: - # arcpy.AddMessage(f"\t{os.path.basename(d)} has {arcpy.management.GetCount(d)[0]} records") - # del d - # sys.exit() - #if "datasets" in locals().keys(): del datasets - try: - pass - #worker(region_gdb=region_gdb) - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() + worker(region_gdb=region_gdb) # Declared Varaiables del region_gdb, table_name, scratch_folder # Imports - del director, md, dismap_tools + del md, dismap_tools # Function Parameters - del project_gdb # Elapsed time end_time = time() elapse_time = end_time - start_time @@ -365,38 +339,48 @@ def script_tool(project_gdb=""): arcpy.AddError(arcpy.GetMessages(2)) traceback.print_exc() sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() except Exception as e: arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") traceback.print_exc() sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() + except SystemExit as se: + arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") sys.exit() else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk return True finally: pass -if __name__ == '__main__': + +if __name__ == "__main__": try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" + + home_folder = arcpy.GetParameterAsText(0) + project_name = arcpy.GetParameterAsText(1) + + if not home_folder: + home_folder = os.path.join(os.path.expanduser("~"), "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python") else: pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: + + + if not project_name: + project_name = "August-1-2025" + else: # This else block is empty, can be removed. + pass + + script_tool(home_folder, project_name) + + arcpy.SetParameterAsText(2, "Result") + + del home_folder, project_name + + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) traceback.print_exc() - else: + except Exception as e: + arcpy.AddError(e) + traceback.print_exc() + except SystemExit: pass - finally: - pass \ No newline at end of file +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_species_richness_rasters_director.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_species_richness_rasters_director.py new file mode 100644 index 0000000..99fd56d --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_species_richness_rasters_director.py @@ -0,0 +1,515 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: create_species_year_image_name_table_director +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 09/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import os +import sys +import traceback + +import arcpy # third-parties second + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + # filename = sys.path[0] + os.sep + f"{os.path.basename(__file__)}" + filename = os.path.basename(__file__) + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror + + +def preprocessing(project_gdb="", table_names="", clear_folder=True): + try: + import dismap_tools + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # Set basic arcpy.env variables + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + # Set varaibales + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{project_folder}\Scratch" + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + + # Clear Scratch Folder + # ClearScratchFolder = True + # if ClearScratchFolder: + if clear_folder: + dismap_tools.clear_folder(folder=rf"{os.path.dirname(project_gdb)}\Scratch") + else: + pass + # del ClearScratchFolder + del clear_folder + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + del project_folder, scratch_workspace + + if not table_names: + table_names = [ + row[0] + for row in arcpy.da.SearchCursor( + os.path.join(project_gdb, "Datasets"), + "TableName", + where_clause="TableName LIKE '%_IDW'", + ) + ] + else: + pass + + for table_name in table_names: + arcpy.AddMessage(f"Pre-Processing: {table_name}") + + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" + + # Create Scratch Workspace for Region + if not arcpy.Exists(region_scratch_workspace): + os.makedirs(os.path.join(scratch_folder, table_name)) + if not arcpy.Exists(region_scratch_workspace): + arcpy.AddMessage(f"Create File GDB: '{table_name}'") + arcpy.management.CreateFileGDB( + os.path.join(scratch_folder, f"{table_name}"), "scratch" + ) + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + del region_scratch_workspace + # # # CreateFileGDB + arcpy.AddMessage(f"Creating File GDB: '{table_name}'") + arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + # # # CreateFileGDB + # # # Datasets + # Process: Make Table View (Make Table View) (management) + datasets = rf"{project_gdb}\Datasets" + arcpy.AddMessage( + f"'{os.path.basename(datasets)}' has {arcpy.management.GetCount(datasets)[0]} records" + ) + + table_name_view = "Dataset Table View" + arcpy.management.MakeTableView( + in_table=datasets, + out_view=table_name_view, + where_clause=f"TableName = '{table_name}'", + ) + arcpy.AddMessage( + f"The table '{table_name_view}' has {arcpy.management.GetCount(table_name_view)[0]} records" + ) + arcpy.management.CopyRows(table_name_view, rf"{region_gdb}\Datasets") + arcpy.AddMessage( + "\tCopy Rows: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + arcpy.management.Delete(table_name_view) + del table_name_view + # # # Datasets + # # # LayerSpeciesYearImageName + # arcpy.AddMessage(f"The table '{table_name}_LayerSpeciesYearImageName' has {arcpy.management.GetCount(table_name_view)[0]} records") + arcpy.management.Copy( + rf"{project_gdb}\{table_name}_LayerSpeciesYearImageName", + rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + # # # LayerSpeciesYearImageName + # # # Raster_Mask + arcpy.management.Copy( + rf"{project_gdb}\{table_name}_Raster_Mask", + rf"{region_gdb}\{table_name}_Raster_Mask", + ) + arcpy.AddMessage( + "\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + # # # Raster_Mask + + del datasets # , filter_region, filter_subregion + # Leave so we can block the above code + # Declared Variables + del table_name + + # Declared Variables + del scratch_folder, region_gdb + # Imports + del dismap_tools + # Function Parameters + del project_gdb, table_names + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def director(project_gdb="", Sequential=True, table_names=[]): + try: + from create_species_richness_rasters_worker import worker + + # Test if passed workspace exists, if not sys.exit() + if not arcpy.Exists(rf"{project_gdb}"): + arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") + arcpy.AddError(arcpy.GetMessages(2)) + sys.exit() + else: + pass + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + preprocessing( + project_gdb=project_gdb, table_names=table_names, clear_folder=True + ) + + ## project_folder = os.path.dirname(project_gdb) + ## scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" + ## scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + ## + ## arcpy.env.workspace = project_gdb + ## arcpy.env.scratchWorkspace = scratch_workspace + ## del project_folder, scratch_workspace + + # Sequential Processing + if Sequential: + arcpy.AddMessage("Sequential Processing") + for i in range(0, len(table_names)): + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = rf"{os.path.dirname(project_gdb)}\Scratch\{table_name}.gdb" + try: + pass + worker(region_gdb=region_gdb) + except: # noqa: E722 + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del region_gdb, table_name + del i + else: + pass + + # Non-Sequential Processing + if not Sequential: + import multiprocessing + from time import gmtime, localtime, sleep, strftime, time + + arcpy.AddMessage("Start multiprocessing using the ArcGIS Pro pythonw.exe.") + # Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS + # get_install_path() uses a registry query to figure out 64bit python exe if available + multiprocessing.set_executable(os.path.join(sys.exec_prefix, "pythonw.exe")) + # Get CPU count and then take 2 away for other process + _processes = multiprocessing.cpu_count() - 2 + _processes = ( + _processes if len(table_names) >= _processes else len(table_names) + ) + arcpy.AddMessage( + f"Creating the multiprocessing Pool with {_processes} processes" + ) + # Create a pool of workers, keep one cpu free for surfing the net. + # Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) + with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: + arcpy.AddMessage("\tPrepare arguments for processing") + # Use apply_async so we can handle exceptions gracefully + jobs = {} + for i in range(0, len(table_names)): + try: + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = ( + rf"{os.path.dirname(project_gdb)}\Scratch\{table_name}.gdb" + ) + jobs[table_name] = pool.apply_async(worker, [region_gdb]) + del table_name, region_gdb + except: # noqa: E722 + pool.terminate() + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del i + all_finished = False + # Set a start time so that we can see how log things take + start_time = time() + result_completed = {} + while True: + all_finished = True + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + arcpy.AddMessage("\nHave the workers finished?") + finish_time = strftime("%a %b %d %I:%M %p", localtime()) + time_elapsed = "Elapsed Time {0} (H:M:S)".format( + strftime("%H:%M:%S", gmtime(elapse_time)) + ) + arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + finish_time = f"{finish_time}.\n\t{time_elapsed}" + del time_elapsed + for table_name, result in jobs.items(): + if result.ready(): + if table_name not in result_completed: + result_completed[table_name] = finish_time + try: + # wait for and get the result from the task + result.get() + except: # noqa: E722 + pool.terminate() + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + pass + arcpy.AddMessage( + f"Process {table_name}\n\tFinished on {result_completed[table_name]}" + ) + else: + all_finished = False + arcpy.AddMessage(f"Process {table_name} is running. . .") + del table_name, result + del elapse_time, end_time, finish_time + if all_finished: + break + sleep(_processes * 7.5) + del result_completed + del start_time + del all_finished + arcpy.AddMessage("\tClose the process pool") + # close the process pool + pool.close() + # wait for all tasks to complete and processes to close + arcpy.AddMessage( + "\tWait for all tasks to complete and processes to close" + ) + pool.join() + # Just in case + pool.terminate() + del pool + del jobs + del _processes + del time, multiprocessing, localtime, strftime, sleep, gmtime + + arcpy.AddMessage("\tDone with multiprocessing Pool") + + arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") + arcpy.management.Compact(project_gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + + # Declared Variables assigned in function + # del scratch_folder + # Imports + del worker + # Function Parameters + del project_gdb, Sequential, table_names + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def script_tool(project_gdb=""): + try: + # Imports + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + try: + pass + # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", + # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", + + Test = False + if Test: + pass + director( + project_gdb=project_gdb, + Sequential=True, + table_names=["SEUS_FAL_IDW"], + ) + elif not Test: + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "AI_IDW", + "EBS_IDW", + "ENBS_IDW", + "GMEX_IDW", + "GOA_IDW", + "HI_IDW", + "NBS_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NEUS_FAL_IDW", + "NEUS_SPR_IDW", + "SEUS_FAL_IDW", + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + "WC_ANN_IDW", + "WC_TRI_IDW", + ], + ) + else: + pass + del Test + # except SystemExit: + except: # noqa: E722 + pass + # arcpy.AddError(arcpy.GetMessages(2)) + # traceback.print_exc() + # sys.exit() + + # Declared Variables + + # Function + del project_gdb + + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) + minutes, seconds = divmod(rem, 60) + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) + arcpy.AddMessage(f"{'-' * 80}") + del hours, rem, minutes, seconds + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +if __name__ == "__main__": + try: + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) + else: + pass + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + del project_gdb + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_species_richness_rasters_worker.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_species_richness_rasters_worker.py similarity index 61% rename from ArcGIS-Analysis-Python/src/dismap_tools/create_species_richness_rasters_worker.py rename to ArcGIS-Analysis-Python/Scripts/dismap_tools/create_species_richness_rasters_worker.py index f8f0347..40a23b0 100644 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_species_richness_rasters_worker.py +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_species_richness_rasters_worker.py @@ -9,12 +9,23 @@ # Copyright: (c) john.f.kennedy 2024 # Licence: #------------------------------------------------------------------------------- -import os, sys # built-ins first +import os +import sys import traceback -import inspect +import arcpy # third-parties second -import arcpy # third-parties second + +def trace(): + import sys # noqa: E401 + import traceback + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + #filename = sys.path[0] + os.sep + f"{os.path.basename(__file__)}" + filename = os.path.basename(__file__) + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror def print_table(table=""): try: @@ -30,23 +41,35 @@ def print_table(table=""): del row del desc, fields, oid del table - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() + except arcpy.ExecuteError: + #Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + #Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True def worker(region_gdb=""): try: # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(rf"{region_gdb}"): + if not arcpy.Exists(region_gdb): arcpy.AddError(f"{os.path.basename(region_gdb)} is missing!!") sys.exit() # Import - import numpy as np - from arcpy import metadata as md # Import the dismap module to access tools import dismap_tools + import numpy as np + from arcpy import metadata as md # Set History and Metadata logs, set serverity and message level arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History @@ -78,7 +101,7 @@ def worker(region_gdb=""): arcpy.AddMessage(f"Creating {table_name} Species Richness Rasters") - arcpy.AddMessage(f"\tGet list of variables from the 'Datasets' table") + arcpy.AddMessage("\tGet list of variables from the 'Datasets' table") # DatasetCode, CSVFile, TransformUnit, TableName, GeographicArea, CellSize, # PointFeatureType, FeatureClassName, Region, Season, DateCode, Status, @@ -99,6 +122,12 @@ def worker(region_gdb=""): cell_size = region_list[3] del region_list + + if isinstance(cell_size, type('str')): + cell_size = int(cell_size) + else: + pass + arcpy.AddMessage(f"\tGet the 'rowCount', 'columnCount', and 'lowerLeft' corner of '{table_name}_Raster_Mask'") # These are used later to set the rows and columns for a zero numpy array rowCount = int(arcpy.management.GetRasterProperties(region_raster_mask, "ROWCOUNT" ).getOutput(0)) @@ -109,7 +138,7 @@ def worker(region_gdb=""): lowerLeft = arcpy.Point(raster_mask_extent.extent.XMin, raster_mask_extent.extent.YMin) del raster_mask_extent - arcpy.AddMessage(f"\tSet the 'outputCoordinateSystem' based on the projection information for the geographic region") + arcpy.AddMessage("\tSet the 'outputCoordinateSystem' based on the projection information for the geographic region") #geographic_area_sr = rf"{project_folder}\Dataset_Shapefiles\{table_name}\{geographic_area}.prj" #geographic_area_sr = arcpy.Describe(region_raster_mask).spatialReference #geographic_area_sr = rf"{project_folder}\Dataset_Shapefiles\{table_name}\{geographic_area}.prj" @@ -119,7 +148,7 @@ def worker(region_gdb=""): #del geographic_area_sr, geographic_area, psr #del geographic_area - arcpy.AddMessage(f"\tGet information for input rasters") + arcpy.AddMessage("\tGet information for input rasters") layerspeciesyearimagename = rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName" @@ -143,7 +172,7 @@ def worker(region_gdb=""): # arcpy.AddMessage(input_raster, input_rasters[input_raster]) # del input_raster - arcpy.AddMessage(f"\tSet the output and scratch paths") + arcpy.AddMessage("\tSet the output and scratch paths") # Set species_richness_path species_richness_path = rf"{project_folder}\Images\{table_name}\_Species Richness" @@ -156,7 +185,7 @@ def worker(region_gdb=""): years = sorted(list(set([input_rasters[input_raster][2] for input_raster in input_rasters]))) - arcpy.AddMessage(f"\tProcessing all species") + arcpy.AddMessage("\tProcessing all species") for year in years: @@ -188,7 +217,7 @@ def worker(region_gdb=""): arcpy.AddMessage(f"\t\tCreating Species Richness Raster for year: {year}") - # Cast array as float32 + # Cast array as float321 richnessArray = richnessArray.astype('float32') # Convert Array to Raster @@ -217,7 +246,7 @@ def worker(region_gdb=""): # ###--->>> - arcpy.AddMessage(f"\tCreating the {table_name} Core Species Richness Rasters") + arcpy.AddMessage("\tCreating the {table_name} Core Species Richness Rasters") # Set core_species_richness_path core_species_richness_path = rf"{project_folder}\Images\{table_name}\_Core Species Richness" @@ -231,7 +260,7 @@ def worker(region_gdb=""): years = sorted(list(set([input_rasters[input_raster][2] for input_raster in input_rasters if input_rasters[input_raster][1] == "Yes"]))) # ###--->>> - arcpy.AddMessage(f"\t\tProcessing Core Species") + arcpy.AddMessage("\t\tProcessing Core Species") for year in years: @@ -304,173 +333,36 @@ def worker(region_gdb=""): # Function parameter del region_gdb - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() + #Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + #Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk return True - finally: - pass - -def preprocessing(project_gdb="", table_names="", clear_folder=True): - try: - import dismap_tools - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic arcpy.env variables - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - # Set varaibales - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - - # Clear Scratch Folder - #ClearScratchFolder = True - #if ClearScratchFolder: - if clear_folder: - dismap_tools.clear_folder(folder=rf"{os.path.dirname(project_gdb)}\Scratch") - else: - pass - #del ClearScratchFolder - del clear_folder - - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - del project_folder, scratch_workspace - - if not table_names: - table_names = [row[0] for row in arcpy.da.SearchCursor(f"{project_gdb}\Datasets", - "TableName", - where_clause = "TableName LIKE '%_IDW'")] - else: - pass - - for table_name in table_names: - arcpy.AddMessage(f"Pre-Processing: {table_name}") - - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - - # Create Scratch Workspace for Region - if not arcpy.Exists(region_scratch_workspace): - os.makedirs(rf"{scratch_folder}\{table_name}") - if not arcpy.Exists(region_scratch_workspace): - arcpy.AddMessage(f"Create File GDB: '{table_name}'") - arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del region_scratch_workspace - # # # CreateFileGDB - arcpy.AddMessage(f"Creating File GDB: '{table_name}'") - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # CreateFileGDB - # # # Datasets - # Process: Make Table View (Make Table View) (management) - datasets = rf'{project_gdb}\Datasets' - arcpy.AddMessage(f"'{os.path.basename(datasets)}' has {arcpy.management.GetCount(datasets)[0]} records") - - table_name_view = "Dataset Table View" - arcpy.management.MakeTableView(in_table = datasets, - out_view = table_name_view, - where_clause = f"TableName = '{table_name}'" - ) - arcpy.AddMessage(f"The table '{table_name_view}' has {arcpy.management.GetCount(table_name_view)[0]} records") - arcpy.management.CopyRows(table_name_view, rf"{region_gdb}\Datasets") - arcpy.AddMessage("\tCopy Rows: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.management.Delete(table_name_view) - del table_name_view - # # # Datasets - # # # LayerSpeciesYearImageName - #arcpy.AddMessage(f"The table '{table_name}_LayerSpeciesYearImageName' has {arcpy.management.GetCount(table_name_view)[0]} records") - arcpy.management.Copy(rf"{project_gdb}\{table_name}_LayerSpeciesYearImageName", rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # LayerSpeciesYearImageName - # # # Raster_Mask - arcpy.management.Copy(rf"{project_gdb}\{table_name}_Raster_Mask", rf"{region_gdb}\{table_name}_Raster_Mask") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # Raster_Mask - - del datasets #, filter_region, filter_subregion - # Leave so we can block the above code - # Declared Variables - del table_name - - # Declared Variables - del scratch_folder, region_gdb - # Imports - del dismap_tools - # Function Parameters - del project_gdb, table_names - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass def script_tool(project_gdb=""): try: # Imports - import dismap_tools from time import gmtime, localtime, strftime, time + + import dismap_tools + from create_species_richness_rasters_director import preprocessing + # Set a start time so that we can see how log things take start_time = time() arcpy.AddMessage(f"{'-' * 80}") arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") arcpy.AddMessage(f"Python Version: {sys.version}") arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") @@ -530,48 +422,45 @@ def script_tool(project_gdb=""): del elapse_time, end_time, start_time del gmtime, localtime, strftime, time - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() + #Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + #Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk return True - finally: - pass if __name__ == '__main__': try: project_gdb = arcpy.GetParameterAsText(0) if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" + project_gdb = os.path.join(os.path.expanduser('~'), "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb") else: pass script_tool(project_gdb) arcpy.SetParameterAsText(1, "Result") del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file + + except arcpy.ExecuteError: + #Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + #Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_species_year_image_name_table_director.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_species_year_image_name_table_director.py new file mode 100644 index 0000000..bff7f87 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_species_year_image_name_table_director.py @@ -0,0 +1,655 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: create_species_year_image_name_table_director +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 09/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import os +import sys +import traceback + +import arcpy # third-parties second + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + filename = sys.path[0] + os.sep + "test.py" + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror + + +def preprocessing(project_gdb="", table_names="", clear_folder=True): + try: + import dismap_tools + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # Set basic arcpy.env variables + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + # Set varaibales + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{project_folder}\Scratch" + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + + # Clear Scratch Folder + # ClearScratchFolder = True + # if ClearScratchFolder: + if clear_folder: + dismap_tools.clear_folder(folder=scratch_folder) + else: + pass + # del ClearScratchFolder + del clear_folder + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + del project_folder, scratch_workspace + + if not table_names: + table_names = [ + row[0] + for row in arcpy.da.SearchCursor( + os.path.join(project_gdb, "Datasets"), + "TableName", + where_clause="TableName LIKE '%_IDW'", + ) + ] + else: + pass + + for table_name in table_names: + arcpy.AddMessage(f"Pre-Processing: {table_name}") + + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" + + # Create Scratch Workspace for Region + if not arcpy.Exists(region_scratch_workspace): + os.makedirs(os.path.join(scratch_folder, table_name)) + if not arcpy.Exists(region_scratch_workspace): + arcpy.management.CreateFileGDB( + os.path.join(scratch_folder, f"{table_name}"), "scratch" + ) + del region_scratch_workspace + + arcpy.AddMessage(f"Creating File GDB: {table_name}") + arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") + arcpy.AddMessage( + "\tCreate File GDB: {0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t") + ) + ) + + # Process: Make Table View (Make Table View) (management) + datasets = rf"{project_gdb}\Datasets" + arcpy.AddMessage( + f"\t{os.path.basename(datasets)} has {arcpy.management.GetCount(datasets)[0]} records" + ) + + table_name_view = "Dataset Table View" + arcpy.management.MakeTableView( + in_table=datasets, + out_view=table_name_view, + where_clause=f"TableName = '{table_name}'", + ) + arcpy.AddMessage( + f"\tThe table {table_name_view} has {arcpy.management.GetCount(table_name_view)[0]} records" + ) + arcpy.management.CopyRows(table_name_view, rf"{region_gdb}\Datasets") + arcpy.AddMessage( + "\tCopy Rows: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + filter_region = [ + row[0] + for row in arcpy.da.SearchCursor( + rf"{region_gdb}\Datasets", "FilterRegion" + ) + ][0].replace("'", "''") + filter_subregion = [ + row[0] + for row in arcpy.da.SearchCursor( + rf"{region_gdb}\Datasets", "FilterSubRegion" + ) + ][0].replace("'", "''") + + arcpy.management.Delete(table_name_view) + del table_name_view + + region_table = rf"{project_gdb}\{table_name}" + arcpy.AddMessage( + f"\t{os.path.basename(region_table)} has {arcpy.management.GetCount(region_table)[0]} records" + ) + # Process: Make Table View (Make Table View) (management) + table_name_view = "IDW Table View" + arcpy.management.MakeTableView( + in_table=region_table, + out_view=table_name_view, + where_clause="DistributionProjectName = 'NMFS/Rutgers IDW Interpolation'", + ) + # Process: Copy Rows (Copy Rows) (management) + arcpy.AddMessage( + f"\t{table_name_view} has {arcpy.management.GetCount(table_name_view)[0]} records" + ) + arcpy.management.CopyRows( + in_rows=table_name_view, out_table=rf"{region_gdb}\{table_name}" + ) + arcpy.AddMessage( + "\tCopy Rows: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + arcpy.management.Delete(table_name_view) + del table_name_view + + # Process: Make Table View (Make Table View) (management) + # arcpy.AddMessage(filter_subregion) + species_filter = rf"{project_gdb}\Species_Filter" + arcpy.AddMessage( + f"\t{os.path.basename(species_filter)} has {arcpy.management.GetCount(species_filter)[0]} records" + ) + table_name_view = "Species Filter Table View" + arcpy.management.MakeTableView( + in_table=species_filter, + out_view=table_name_view, + # where_clause = f"FilterSubRegion = '{filter_subregion}'", + where_clause=f"FilterSubRegion = '{filter_subregion}' AND DistributionProjectName = 'NMFS/Rutgers IDW Interpolation'", + workspace=region_gdb, + field_info="OBJECTID OBJECTID VISIBLE NONE;Species Species VISIBLE NONE;CommonName CommonName VISIBLE NONE;TaxonomicGroup TaxonomicGroup VISIBLE NONE;FilterRegion FilterRegion VISIBLE NONE;FilterSubRegion FilterSubRegion VISIBLE NONE;ManagementBody ManagementBody VISIBLE NONE;ManagementPlan ManagementPlan VISIBLE NONE;DistributionProjectName DistributionProjectName VISIBLE NONE", + ) + + arcpy.AddMessage( + f"\t{table_name_view} has {arcpy.management.GetCount(table_name_view)[0]} records" + ) + arcpy.management.CopyRows( + in_rows=table_name_view, out_table=rf"{region_gdb}\Species_Filter" + ) + arcpy.AddMessage( + "\tCopy Rows: {0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) + ) + + arcpy.management.Delete(table_name_view) + del table_name_view + # print(filter_region, filter_subregion) + # + del region_table, species_filter + del datasets, filter_region, filter_subregion + # Leave so we can block the above code + # Declared Variables + del table_name + + # Declared Variables + del scratch_folder, region_gdb + # Imports + del dismap_tools + # Function Parameters + del project_gdb, table_names + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + sys.exit() + return False + else: + return True + + +def director(project_gdb="", Sequential=True, table_names=[]): + try: + # Test if passed workspace exists, if not sys.exit() + if not arcpy.Exists(project_gdb): + sys.exit()(f"{os.path.basename(project_gdb)} is missing!!") + + import dismap_tools + from create_species_year_image_name_table_worker import worker + + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + project_folder = os.path.dirname(project_gdb) + scratch_folder = os.path.join(project_folder, "Scratch") + del project_folder + + # scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + # csv_data_folder = rf"{project_folder}\CSV_Data" + # arcpy.env.workspace = project_gdb + # arcpy.env.scratchWorkspace = scratch_workspace + # del project_folder, scratch_workspace + + preprocessing( + project_gdb=project_gdb, table_names=table_names, clear_folder=True + ) + + # Sequential Processing + if Sequential: + arcpy.AddMessage("Sequential Processing") + for i in range(0, len(table_names)): + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + try: + worker(region_gdb=region_gdb) + except: # noqa: E722 + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del region_gdb, table_name + del i + else: + pass + + # Non-Sequential Processing + if not Sequential: + arcpy.AddMessage("Non-Sequential Processing") + # Imports + import multiprocessing + from time import gmtime, localtime, sleep, strftime, time + + arcpy.AddMessage("Start multiprocessing using the ArcGIS Pro pythonw.exe.") + # Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS + # get_install_path() uses a registry query to figure out 64bit python exe if available + multiprocessing.set_executable(os.path.join(sys.exec_prefix, "pythonw.exe")) + # Get CPU count and then take 2 away for other process + _processes = multiprocessing.cpu_count() - 2 + _processes = ( + _processes if len(table_names) >= _processes else len(table_names) + ) + arcpy.AddMessage( + f"Creating the multiprocessing Pool with {_processes} processes" + ) + # Create a pool of workers, keep one cpu free for surfing the net. + # Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) + with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: + arcpy.AddMessage("\tPrepare arguments for processing") + # Use apply_async so we can handle exceptions gracefully + jobs = {} + for i in range(0, len(table_names)): + try: + arcpy.AddMessage(f"Processing: {table_names[i]}") + table_name = table_names[i] + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") + jobs[table_name] = pool.apply_async(worker, [region_gdb]) + del table_name, region_gdb + except: # noqa: E722 + pool.terminate() + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + del i + all_finished = False + # Set a start time so that we can see how log things take + start_time = time() + result_completed = {} + while True: + all_finished = True + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + arcpy.AddMessage( + f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage("Have the workers finished?") + arcpy.AddMessage("Have the workers finished?") + finish_time = strftime("%a %b %d %I:%M %p", localtime()) + time_elapsed = "Elapsed Time {0} (H:M:S)".format( + strftime("%H:%M:%S", gmtime(elapse_time)) + ) + arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") + finish_time = f"{finish_time}.\n\t{time_elapsed}" + del time_elapsed + for table_name, result in jobs.items(): + if result.ready(): + if table_name not in result_completed: + result_completed[table_name] = finish_time + try: + # wait for and get the result from the task + result.get() + except SystemExit: + pool.terminate() + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + pass + arcpy.AddMessage( + f"Process {table_name}\n\tFinished on {result_completed[table_name]}" + ) + else: + all_finished = False + arcpy.AddMessage(f"Process {table_name} is running. . .") + del table_name, result + del elapse_time, end_time, finish_time + if all_finished: + break + sleep(_processes * 7.5) + del result_completed + del start_time + del all_finished + arcpy.AddMessage("\tClose the process pool") + # close the process pool + pool.close() + # wait for all tasks to complete and processes to close + arcpy.AddMessage( + "\tWait for all tasks to complete and processes to close" + ) + pool.join() + # Just in case + pool.terminate() + del pool + del jobs + del _processes + del time, multiprocessing, localtime, strftime, sleep, gmtime + arcpy.AddMessage("\tDone with multiprocessing Pool") + + # Post-Processing + arcpy.AddMessage("Post-Processing Begins") + arcpy.AddMessage("Processing Results") + datasets = list() + walk = arcpy.da.Walk(scratch_folder, datatype=["Table", "FeatureClass"]) + for dirpath, dirnames, filenames in walk: + for filename in filenames: + if filename.endswith("LayerSpeciesYearImageName"): + datasets.append(os.path.join(dirpath, filename)) + else: + pass + del filename + del dirpath, dirnames, filenames + del walk + for dataset in datasets: + datasets_short_path = f".. {'/'.join(dataset.split(os.sep)[-4:])}" + dataset_name = os.path.basename(dataset) + region_gdb = os.path.dirname(dataset) + arcpy.AddMessage(f"\tDataset: '{dataset_name}'") + arcpy.AddMessage(f"\t\tPath: '{datasets_short_path}'") + arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") + arcpy.AddMessage( + f"\tCopying the {dataset_name} Table to the project GDB Table" + ) + arcpy.management.Copy( + rf"{region_gdb}\{dataset_name}", rf"{project_gdb}\{dataset_name}" + ) + arcpy.AddMessage( + "\tCopy: {0} {1}\n".format( + dataset_name, arcpy.GetMessages(0).replace("\n", "\n\t") + ) + ) + + arcpy.AddMessage( + "\t\tUpdating field values to replace None with empty string" + ) + fields = [ + f.name + for f in arcpy.ListFields(rf"{project_gdb}\{dataset_name}") + if f.type == "String" + ] + # Create update cursor for feature class + with arcpy.da.UpdateCursor( + rf"{project_gdb}\{dataset_name}", fields + ) as cursor: + for row in cursor: + # arcpy.AddMessage(row) + for field_value in row: + # arcpy.AddMessage(field_value) + if field_value is None: + row[row.index(field_value)] = "" + cursor.updateRow(row) + del field_value + del row + del fields, cursor + + del region_gdb, dataset_name, datasets_short_path + del dataset + del datasets + + arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") + arcpy.management.Compact(project_gdb) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + + # Declared Variables assigned in function + del scratch_folder + # Imports + del dismap_tools, worker + # Function Parameters + del project_gdb, Sequential, table_names + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def script_tool(project_gdb=""): + try: + # Imports + from time import gmtime, localtime, strftime, time + + import dismap_tools + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + # Set varaibales + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" + del project_folder + + # Clear Scratch Folder + ClearScratchFolder = False + if ClearScratchFolder: + # if clear_folder: + _scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" + dismap_tools.clear_folder(folder=_scratch_folder) + del _scratch_folder + else: + pass + del ClearScratchFolder + # del clear_folder + + # Create project scratch workspace, if missing + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + if not arcpy.Exists(scratch_folder): + os.makedirs(scratch_folder) + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + arcpy.management.CreateFileGDB(rf"{scratch_folder}", "scratch") + del scratch_folder + + # Set basic arcpy.env variables + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + try: + # table_names = ["AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW",] + Test = False + if Test: + director( + project_gdb=project_gdb, + Sequential=True, + table_names=["GMEX_IDW", "HI_IDW", "WC_ANN_IDW", "WC_TRI_IDW"], + ) + # director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "HI_IDW"]) + elif not Test: + pass + # director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "EBS_IDW", "ENBS_IDW", "GOA_IDW", "NBS_IDW",]) + # director(project_gdb=project_gdb, Sequential=False, table_names=["HI_IDW", "WC_ANN_IDW", "WC_TRI_IDW",]) + # director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW",]) + # director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "AI_IDW", + "EBS_IDW", + "ENBS_IDW", + "GMEX_IDW", + "GOA_IDW", + "HI_IDW", + "NBS_IDW", + "NEUS_FAL_IDW", + "NEUS_SPR_IDW", + "SEUS_FAL_IDW", + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + "WC_ANN_IDW", + "WC_TRI_IDW", + ], + ) + # director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_FAL_IDW", "NEUS_SPR_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) + + else: + pass + del Test + except: # noqa: E722 + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + + # Clear Scratch Folder + ClearScratchFolder = False + if ClearScratchFolder: + # if clear_folder: + _scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" + dismap_tools.clear_folder(folder=_scratch_folder) + del _scratch_folder + else: + pass + del ClearScratchFolder + # del clear_folder + + # Declared Variables + del dismap_tools + # Function Parameters + del project_gdb + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + hours, rem = divmod(end_time - start_time, 3600) + minutes, seconds = divmod(rem, 60) + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage( + f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}" + ) + arcpy.AddMessage( + f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)" + ) + arcpy.AddMessage(f"{'-' * 80}") + del hours, rem, minutes, seconds + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + sys.exit() + return False + else: + return True + + +if __name__ == "__main__": + try: + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + project_gdb = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb", + ) + else: + pass + + script_tool(project_gdb) + + arcpy.SetParameterAsText(1, "Result") + del project_gdb + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_species_year_image_name_table_worker.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_species_year_image_name_table_worker.py similarity index 69% rename from ArcGIS-Analysis-Python/src/dismap_tools/create_species_year_image_name_table_worker.py rename to ArcGIS-Analysis-Python/Scripts/dismap_tools/create_species_year_image_name_table_worker.py index 0628606..962f97a 100644 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_species_year_image_name_table_worker.py +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/create_species_year_image_name_table_worker.py @@ -9,12 +9,23 @@ # Copyright: (c) john.f.kennedy 2024 # Licence: #------------------------------------------------------------------------------- -import os, sys # built-ins first +import inspect +import os +import sys import traceback -import inspect +import arcpy # third-parties second -import arcpy # third-parties second + +def trace(): + import sys # noqa: E401 + import traceback + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + filename = sys.path[0] + os.sep + "test.py" + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror def print_table(table=""): try: @@ -30,7 +41,7 @@ def print_table(table=""): del row del desc, fields, oid del table - except: + except: # noqa: E722 arcpy.AddError(arcpy.GetMessages(2)) traceback.print_exc() sys.exit() @@ -42,9 +53,9 @@ def worker(region_gdb=""): arcpy.AddError(f"{os.path.basename(region_gdb)} is missing!!") sys.exit() - from arcpy import metadata as md # Import the dismap module to access tools import dismap_tools + from arcpy import metadata as md # Set History and Metadata logs, set serverity and message level arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History @@ -91,8 +102,8 @@ def worker(region_gdb=""): # ********************************************************************** # Start: Create new LayerSpeciesYearImageName table - arcpy.AddMessage(f"\nDatasets Table\n" ) - datasets_table = rf"{region_gdb}\Datasets" + arcpy.AddMessage("\nDatasets Table\n" ) + datasets_table = rf"{region_gdb}\\Datasets" datasets_table_fields = [f.name for f in arcpy.ListFields(datasets_table) if f.type not in ['Geometry', 'OID']] print_table(datasets_table) #region = [row[0] for row in arcpy.da.SearchCursor(datasets_table, "Region", where_clause = f"TableName = '{table_name}'")][0] @@ -103,7 +114,7 @@ def worker(region_gdb=""): # ********************************************************************** # Start: Create new LayerSpeciesYearImageName table - arcpy.AddMessage(f"\nRegion IDW Table\n" ) + arcpy.AddMessage("\nRegion IDW Table\n" ) region_table_fields = [f.name for f in arcpy.ListFields(region_table) if f.type not in ['Geometry', 'OID']] # Get a record count to see if data is present; we don't want to add data getcount = arcpy.management.GetCount(region_table)[0] @@ -116,7 +127,7 @@ def worker(region_gdb=""): # ********************************************************************** # Start: Create new LayerSpeciesYearImageName table - arcpy.AddMessage(f"\nImage Name Table\n" ) + arcpy.AddMessage("\nImage Name Table\n" ) layer_species_year_image_name_fields = [f.name for f in arcpy.ListFields(layer_species_year_image_name) if f.type not in ['Geometry', 'OID']] arcpy.AddMessage(f"Image Name Fields:\n\t{', '.join(layer_species_year_image_name_fields)}") print_table(layer_species_year_image_name) @@ -126,7 +137,7 @@ def worker(region_gdb=""): # ********************************************************************** # Start: Get information from the species filter table to create a # species filter dictionary - arcpy.AddMessage(f"\nCreating the Species_Filter dictionary\n" ) + arcpy.AddMessage("\nCreating the Species_Filter dictionary\n" ) species_filter_table = os.path.join(region_gdb, "Species_Filter") species_filter_table_fields = [f.name for f in arcpy.ListFields(species_filter_table) if f.type not in ['Geometry', 'OID']] @@ -163,7 +174,7 @@ def worker(region_gdb=""): # Image Name Table # DatasetCode, Region, Season, SummaryProduct, FilterRegion, FilterSubRegion, Species, CommonName, SpeciesCommonName, CommonNameSpecies, TaxonomicGroup, ManagementBody, ManagementPlan, DistributionProjectName, CoreSpecies, Variable, Value, Dimensions, ImageName - arcpy.AddMessage(f"\nDefining the case fields\n") + arcpy.AddMessage("\nDefining the case fields\n") case_fields = [f for f in layer_species_year_image_name_fields if f in region_table_fields] arcpy.AddMessage(f"Case Fields:\n\t{', '.join(case_fields)}") @@ -420,183 +431,31 @@ def worker(region_gdb=""): arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") traceback.print_exc() sys.exit() - except: + except: # noqa: E722 arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") traceback.print_exc() sys.exit() - else: + else: # noqa: E722 # While in development, leave here. For test, move to finally rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def preprocessing(project_gdb="", table_names="", clear_folder=True): - try: - import dismap_tools - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic arcpy.env variables - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - # Set varaibales - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - - # Clear Scratch Folder - #ClearScratchFolder = True - #if ClearScratchFolder: - if clear_folder: - dismap_tools.clear_folder(folder=scratch_folder) - else: - pass - #del ClearScratchFolder - del clear_folder - - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - del project_folder, scratch_workspace - - if not table_names: - table_names = [row[0] for row in arcpy.da.SearchCursor(f"{project_gdb}\Datasets", - "TableName", - where_clause = "TableName LIKE '%_IDW'")] - else: - pass - - for table_name in table_names: - arcpy.AddMessage(f"Pre-Processing: {table_name}") - - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - - # Create Scratch Workspace for Region - if not arcpy.Exists(region_scratch_workspace): - os.makedirs(rf"{scratch_folder}\{table_name}") - if not arcpy.Exists(region_scratch_workspace): - arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") - del region_scratch_workspace - - arcpy.AddMessage(f"Creating File GDB: {table_name}") - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - # Process: Make Table View (Make Table View) (management) - datasets = rf'{project_gdb}\Datasets' - arcpy.AddMessage(f"\t{os.path.basename(datasets)} has {arcpy.management.GetCount(datasets)[0]} records") - - table_name_view = "Dataset Table View" - arcpy.management.MakeTableView(in_table = datasets, - out_view = table_name_view, - where_clause = f"TableName = '{table_name}'" - ) - arcpy.AddMessage(f"\tThe table {table_name_view} has {arcpy.management.GetCount(table_name_view)[0]} records") - arcpy.management.CopyRows(table_name_view, rf"{region_gdb}\Datasets") - arcpy.AddMessage("\tCopy Rows: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - filter_region = [row[0] for row in arcpy.da.SearchCursor(rf"{region_gdb}\Datasets", "FilterRegion")][0].replace("'", "''") - filter_subregion = [row[0] for row in arcpy.da.SearchCursor(rf"{region_gdb}\Datasets", "FilterSubRegion")][0].replace("'", "''") - - arcpy.management.Delete(table_name_view) - del table_name_view - - region_table = rf"{project_gdb}\{table_name}" - arcpy.AddMessage(f"\t{os.path.basename(region_table)} has {arcpy.management.GetCount(region_table)[0]} records") - # Process: Make Table View (Make Table View) (management) - table_name_view = "IDW Table View" - arcpy.management.MakeTableView(in_table = region_table, - out_view = table_name_view, - where_clause = "DistributionProjectName = 'NMFS/Rutgers IDW Interpolation'" - ) - # Process: Copy Rows (Copy Rows) (management) - arcpy.AddMessage(f"\t{table_name_view} has {arcpy.management.GetCount(table_name_view)[0]} records") - arcpy.management.CopyRows(in_rows = table_name_view, out_table = rf"{region_gdb}\{table_name}") - arcpy.AddMessage("\tCopy Rows: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.management.Delete(table_name_view) - del table_name_view - - # Process: Make Table View (Make Table View) (management) - #arcpy.AddMessage(filter_subregion) - species_filter = rf"{project_gdb}\Species_Filter" - arcpy.AddMessage(f"\t{os.path.basename(species_filter)} has {arcpy.management.GetCount(species_filter)[0]} records") - table_name_view = "Species Filter Table View" - arcpy.management.MakeTableView(in_table = species_filter, - out_view = table_name_view, - #where_clause = f"FilterSubRegion = '{filter_subregion}'", - where_clause = f"FilterSubRegion = '{filter_subregion}' AND DistributionProjectName = 'NMFS/Rutgers IDW Interpolation'", - workspace=region_gdb, - field_info="OBJECTID OBJECTID VISIBLE NONE;Species Species VISIBLE NONE;CommonName CommonName VISIBLE NONE;TaxonomicGroup TaxonomicGroup VISIBLE NONE;FilterRegion FilterRegion VISIBLE NONE;FilterSubRegion FilterSubRegion VISIBLE NONE;ManagementBody ManagementBody VISIBLE NONE;ManagementPlan ManagementPlan VISIBLE NONE;DistributionProjectName DistributionProjectName VISIBLE NONE" - ) - - arcpy.AddMessage(f"\t{table_name_view} has {arcpy.management.GetCount(table_name_view)[0]} records") - arcpy.management.CopyRows(in_rows = table_name_view, out_table = rf"{region_gdb}\Species_Filter") - arcpy.AddMessage("\tCopy Rows: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.management.Delete(table_name_view) - del table_name_view - #print(filter_region, filter_subregion) - # - del region_table, species_filter - del datasets, filter_region, filter_subregion - # Leave so we can block the above code - # Declared Variables - del table_name - - # Declared Variables - del scratch_folder, region_gdb - # Imports - del dismap_tools - # Function Parameters - del project_gdb, table_names - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk + if rk: + arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##") + del rk return True finally: pass def script_tool(project_gdb=""): try: - import dismap_tools from time import gmtime, localtime, strftime, time + + from create_species_year_image_name_table_director import preprocessing + # Set a start time so that we can see how log things take start_time = time() arcpy.AddMessage(f"{'-' * 80}") arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") arcpy.AddMessage(f"Python Version: {sys.version}") arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") @@ -619,11 +478,11 @@ def script_tool(project_gdb=""): # Set varaibales project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" + scratch_folder = os.path.join(project_folder, "Scratch") del project_folder for table_name in table_names: - region_gdb = rf"{scratch_folder}\{table_name}.gdb" + region_gdb = os.path.join(scratch_folder, f"{table_name}.gdb") try: pass @@ -640,9 +499,10 @@ def script_tool(project_gdb=""): # Declared Varaiables del scratch_folder # Imports - del dismap_tools + # Function Parameters del project_gdb + # Elapsed time end_time = time() elapse_time = end_time - start_time @@ -658,48 +518,47 @@ def script_tool(project_gdb=""): del elapse_time, end_time, start_time del gmtime, localtime, strftime, time - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() + #Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + #Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk return True - finally: - pass if __name__ == '__main__': try: project_gdb = arcpy.GetParameterAsText(0) if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" + project_gdb = os.path.join(os.path.expanduser('~'), "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026\\February 1 2026.gdb") else: pass + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file + + except arcpy.ExecuteError: + #Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + #Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/custom_xml_pipeline.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/custom_xml_pipeline.py new file mode 100644 index 0000000..657aa02 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/custom_xml_pipeline.py @@ -0,0 +1,191 @@ +"""NOAA InPort 79319 Metadata Pipeline via OWSLib. + +Uses the Open Geospatial Consortium (OGC) OWSLib library to parse legacy +ISO 19139 streams and natively constructs an ArcGIS database schema via lxml. +""" + +import os +import sys +import arcpy +import requests +from arcpy import metadata as md +from lxml import etree +from lxml.builder import ElementMaker + +try: + from owslib.iso import MD_Metadata +except ImportError: + print("❌ OWSLib is required. Please run: pip install OWSLib") + sys.exit(1) + +# Define standard XML namespaces for deep XPath querying +NS = { + "gmi": "http://www.isotc211.org/2005/gmi", + "gmd": "http://www.isotc211.org/2005/gmd", + "gco": "http://www.isotc211.org/2005/gco" +} + + +def map_iso_role(role_string: str) -> str: + """Maps ISO/OWSLib role strings to ArcGIS integer domains.""" + mapping = { + "pointOfContact": "007", + "author": "011", + "publisher": "010", + "originator": "006", + "distributor": "005", + "owner": "003", + "custodian": "002", + "principalInvestigator": "004" + } + return mapping.get(role_string, "007") + + +def process_metadata_pipeline(gdb_table: str, final_xml_out: str) -> None: + """Parses ISO 19139 via OWSLib and commits native XML to ArcGIS.""" + + # Targeting the standardized ISO 19115 (19139 Schema) WAF Endpoint + iso_url = "https://www.fisheries.noaa.gov/inportserve/waf/noaa/nmfs/ost/iso19115/xml/79319.xml" + + # Ensure target output directory exists + output_dir = os.path.dirname(final_xml_out) + if not os.path.exists(output_dir): + os.makedirs(output_dir) + + scratch_folder = arcpy.env.scratchFolder + raw_xml_tmp = os.path.join(scratch_folder, "raw_inport_iso.xml") + arcgis_xml_tmp = os.path.join(scratch_folder, "arcgis_native_build.xml") + + print("📡 Pulling ISO 19139 payload stream via OWSLib...") + try: + response = requests.get(iso_url, headers={"User-Agent": "Mozilla/5.0"}, timeout=30) + response.raise_for_status() + with open(raw_xml_tmp, "wb") as f: + f.write(response.content) + except requests.RequestException as req_err: + print(f"❌ Network transfer failed: {req_err}") + sys.exit(1) + + try: + # 1. Parse via OGC standard library + print("⚙️ Parsing complex contacts and extents via OWSLib...") + source_tree = etree.parse(raw_xml_tmp) + iso_md = MD_Metadata(source_tree) + + # 2. Extract Process Steps via lxml XPath to ensure zero provenance loss + process_steps = source_tree.xpath( + "//gmd:LI_ProcessStep/gmd:description/gco:CharacterString/text()", + namespaces=NS + ) + + # Safely extract the primary identification block from the list + ident = None + if hasattr(iso_md, "identification") and isinstance(iso_md.identification, list) and len(iso_md.identification) > 0: + ident = iso_md.identification[0] + + # Extract core text variables with safe fallbacks + title_val = getattr(ident, "title", None) or "DisMAP Survey Info" + abstract_val = getattr(ident, "abstract", None) or "" + purpose_val = getattr(ident, "purpose", None) or "" + + # 3. Construct ArcGIS Native XML Object natively in memory + E = ElementMaker() + + data_id = E.dataIdInfo( + E.idCitation(E.resTitle(title_val)), + E.idAbs(abstract_val), + E.idPurp(purpose_val) + ) + + # Aggregate Contacts from both the dataset level and metadata root level + contacts = [] + if ident and hasattr(ident, "contact") and ident.contact: + contacts.extend(ident.contact) + if hasattr(iso_md, "contact") and iso_md.contact: + contacts.extend(iso_md.contact) + + # Flawless Contact Matrix Mapping + for contact in contacts: + poc = E.idPoC() + if hasattr(contact, "organization") and contact.organization: + poc.append(E.rpOrgName(contact.organization)) + if hasattr(contact, "name") and contact.name: + poc.append(E.rpIndName(contact.name)) + if hasattr(contact, "email") and contact.email: + poc.append(E.cntAddress(E.eMailAdd(contact.email))) + if hasattr(contact, "role") and contact.role: + poc.append(E.role(E.RoleCd(value=map_iso_role(contact.role)))) + + # Only append if we successfully parsed a name or organization + if len(poc) > 0: + data_id.append(poc) + + # --- BUG FIX: Safely cast the bounding box to a list for iteration --- + if ident and hasattr(ident, "bbox") and ident.bbox: + # OWSLib returns a single object if there is only one bounding box + bbox_list = ident.bbox if isinstance(ident.bbox, list) else [ident.bbox] + + for box in bbox_list: + data_id.append( + E.geoBox( + E.westBL(str(getattr(box, "minx", ""))), + E.eastBL(str(getattr(box, "maxx", ""))), + E.southBL(str(getattr(box, "miny", ""))), + E.northBL(str(getattr(box, "maxy", ""))), + esriExtentType="search" + ) + ) + + # Lineage and Process Quality + dq_info = E.dqInfo() + lineage = E.dataLineage() + if iso_md.dataquality and hasattr(iso_md.dataquality, "lineage") and iso_md.dataquality.lineage: + lineage.append(E.statement(iso_md.dataquality.lineage)) + + for step in process_steps: + if step and step.strip(): + lineage.append(E.prcStep(E.stepDesc(step.strip()))) + + if len(lineage) > 0: + dq_info.append(lineage) + + # Final Assembly + arcgis_root = E.metadata( + E.Esri(E.ArcGISFormat("1.0"), E.SyncOnce("FALSE")), + E.mdFileID(getattr(iso_md, "identifier", None) or "gov.noaa.nmfs.inport:79319"), + data_id, + dq_info + ) + + with open(arcgis_xml_tmp, "wb") as out_f: + out_f.write(etree.tostring(arcgis_root, pretty_print=True, encoding="UTF-8")) + + # 4. Ingest directly to target database asset + print(f"📂 Binding parsed native XML payload onto: {gdb_table}") + arcgis_metadata = md.Metadata(gdb_table) + + arcgis_metadata.importMetadata(arcgis_xml_tmp, "ARCGIS_METADATA") + arcgis_metadata.save() + + # Output the clean, final document to system disk for scientist code review + arcgis_metadata.saveAsXML(final_xml_out) + print(f"🏆 Data conversion cycle complete: {final_xml_out}") + + except etree.LxmlError as xml_err: + print(f"❌ XML Parsing engine failure encountered: {xml_err}") + except Exception as db_err: + print(f"❌ Geodatabase tracking transaction rejected: {db_err}") + finally: + for cache_file in [raw_xml_tmp, arcgis_xml_tmp]: + if os.path.exists(cache_file): + os.remove(cache_file) + + +if __name__ == "__main__": + TARGET_ASSET = r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\February-1-2026\February-1-2026.gdb\DisMAP_Survey_Info" + FINAL_XML_EXPORT = r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\February-1-2026\Metadata_Export\Final_ArcGIS_Metadata_79319.xml" + + if arcpy.Exists(TARGET_ASSET): + process_metadata_pipeline(TARGET_ASSET, FINAL_XML_EXPORT) + else: + print(f"❌ Error: Missing destination table at target: {TARGET_ASSET}") \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_dismap_metadata_processing.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_dismap_metadata_processing.py new file mode 100644 index 0000000..be0d006 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_dismap_metadata_processing.py @@ -0,0 +1,4799 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: module1 +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 03/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import importlib +import inspect +import os # built-ins first +import sys +import traceback + +import arcpy # third-parties second + + +def new_function(): + try: + pass + # Declared Varaiables + # Imports + # Function Parameters + except KeyboardInterrupt: + raise SystemExit + except: + traceback.print_exc() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def date_code(version): + try: + from datetime import datetime + from time import strftime + + _date_code = "" + + if version.isdigit(): + # The version value is 'YYYYMMDD' format (20230501) + # and is converted to 'Month Day and Year' (i.e. May 1 2023) + _date_code = datetime.strptime(version, "%Y%m%d").strftime("%B %#d %Y") + elif not version.isdigit(): + # The version value is 'Month Day and Year' (i.e. May 1 2023) + # and is converted to 'YYYYMMDD' format (20230501) + _date_code = datetime.strptime(version, "%B %d %Y").strftime("%Y%m%d") + else: + _date_code = "error" + # Imports + del datetime, strftime + del version + + import copy + + __results = copy.deepcopy(_date_code) + del _date_code, copy + except KeyboardInterrupt: + raise SystemExit + except: + traceback.print_exc() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return __results + finally: + if "__results" in locals().keys(): + del __results + + +# # +# Function: unique_years +# Gets the unique years in a table +# @param string table: The name of the layer +# @return array: a sorted year array so we can go in order. +# # +def unique_years(table): + # print(table) + arcpy.management.SelectLayerByAttribute(table, "CLEAR_SELECTION") + arcpy.management.SelectLayerByAttribute(table, "NEW_SELECTION", "Year IS NOT NULL") + with arcpy.da.SearchCursor(table, ["Year"]) as cursor: + return sorted({row[0] for row in cursor}) + + +def xml_tree_merge(source, target): + import copy + + """Merge two xml trees A and B, so that each recursively found leaf element of B is added to A. If the element + already exists in A, it is replaced with B's version. Tree structure is created in A as required to reflect the + position of the leaf element in B. + Given and , a merge results in + (order not guaranteed) + """ + + def inner(aparent, bparent): + for bchild in bparent: + achild = aparent.xpath("./" + bchild.tag) + if not achild: + aparent.append(bchild) + elif bchild.getchildren(): + inner(achild[0], bchild) + + source_copy = copy.deepcopy(source) + inner(source_copy, target) + return source_copy + + +def dataset_title_dict(project_gdb=""): + try: + if "Scratch" in project_gdb: + project = os.path.basename(os.path.dirname(os.path.dirname(project_gdb))) + else: + project = os.path.basename(os.path.dirname(project_gdb)) + + project_folder = os.path.dirname(project_gdb) + crf_folder = rf"{project_folder}\CRFs" + _credits = "These data were produced by NMFS OST." + access_constraints = "***No Warranty*** The user assumes the entire risk related to its use of these data. NMFS is providing these data 'as is' and NMFS disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose. No warranty expressed or implied is made regarding the accuracy or utility of the data on any other system or for general or scientific purposes, nor shall the act of distribution constitute any such warranty. It is strongly recommended that careful attention be paid to the contents of the metadata file associated with these data to evaluate dataset limitations, restrictions or intended use. In no event will NMFS be liable to you or to any third party for any direct, indirect, incidental, consequential, special or exemplary damages or lost profit resulting from any use or misuse of these data." + + __datasets_dict = {} + + dataset_codes = { + row[0]: [row[1], row[2], row[3], row[4], row[5]] + for row in arcpy.da.SearchCursor( + rf"{project_gdb}\Datasets", + [ + "DatasetCode", + "PointFeatureType", + "DistributionProjectCode", + "FilterRegion", + "FilterSubRegion", + "Season", + ], + ) + } + for dataset_code in dataset_codes: + point_feature_type = ( + dataset_codes[dataset_code][0] if dataset_codes[dataset_code][0] else "" + ) + distribution_project_code = ( + dataset_codes[dataset_code][1] if dataset_codes[dataset_code][1] else "" + ) + filter_region = ( + dataset_codes[dataset_code][2] + if dataset_codes[dataset_code][2] + else dataset_code.replace("_", " ") + ) + filter_sub_region = ( + dataset_codes[dataset_code][3] + if dataset_codes[dataset_code][3] + else dataset_code.replace("_", " ") + ) + season = ( + dataset_codes[dataset_code][4] if dataset_codes[dataset_code][4] else "" + ) + + tags = ( + f"DisMAP; {filter_region}" + if filter_region == filter_sub_region + else f"DisMAP; {filter_region}; {filter_sub_region}" + ) + tags = f"{tags}; {season}" if season else f"{tags}" + tags = f"{tags}; distribution; seasonal distribution; fish; invertebrates; climate change; fishery-independent surveys; ecological dynamics; oceans; biosphere; earth science; species/population interactions; aquatic sciences; fisheries; range changes" + summary = "These data were created as part of the DisMAP project to enable visualization and analysis of changes in fish and invertebrate distributions" + + # print(f"Dateset Code: {dataset_code}") + if distribution_project_code: + if distribution_project_code == "IDW": + + # table_name = f"{dataset_code}_{distribution_project_code}_TABLE" + table_name = f"{dataset_code}_{distribution_project_code}" + table_name_s = f"{table_name}_{date_code(project)}" + table_name_st = f"{filter_sub_region} {season} Table {date_code(project)}".replace( + " ", " " + ) + + # print(f"\tProcessing: {table_name}") + + __datasets_dict[table_name] = { + "Dataset Service": table_name_s, + "Dataset Service Title": table_name_st, + "Tags": tags, + "Summary": summary, + "Description": f"This table represents the CSV Data files in ArcGIS format", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + del table_name, table_name_s, table_name_st + + table_name = f"{dataset_code}_{distribution_project_code}" + sample_locations_fc = ( + f"{table_name}_{point_feature_type.replace(' ', '_')}" + ) + sample_locations_fcs = f"{table_name}_{point_feature_type.replace(' ', '_')}_{date_code(project)}" + feature_service_title = f"{filter_sub_region} {season} {point_feature_type} {date_code(project)}" + sample_locations_fcst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + __datasets_dict[sample_locations_fc] = { + "Dataset Service": sample_locations_fcs, + "Dataset Service Title": sample_locations_fcst, + "Tags": tags, + "Summary": f"{summary}. These layers provide information on the spatial extent/boundaries of the bottom trawl surveys. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Description": f"This survey points layer provides information on both the locations where species are caught in several NOAA Fisheries surveys and the amount (i.e., biomass weight catch per unit effort, standardized to kg/ha) of each species that was caught at each location. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tSample Locations FC: {sample_locations_fc}") + # print(f"\tSample Locations FCS: {sample_locations_fcs}") + # print(f"\tSample Locations FST: {sample_locations_fcst}") + + del ( + table_name, + sample_locations_fc, + sample_locations_fcs, + sample_locations_fcst, + ) + + table_name = f"{dataset_code}" + sample_locations_fc = ( + f"{table_name}_{point_feature_type.replace(' ', '_')}" + ) + sample_locations_fcs = f"{table_name}_{point_feature_type.replace(' ', '_')}_{date_code(project)}" + feature_service_title = f"{filter_sub_region} {season} {point_feature_type} {date_code(project)}" + sample_locations_fcst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + __datasets_dict[sample_locations_fc] = { + "Dataset Service": sample_locations_fcs, + "Dataset Service Title": sample_locations_fcst, + "Tags": tags, + "Summary": f"{summary}. These layers provide information on the spatial extent/boundaries of the bottom trawl surveys. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Description": f"This survey points layer provides information on both the locations where species are caught in several NOAA Fisheries surveys and the amount (i.e., biomass weight catch per unit effort, standardized to kg/ha) of each species that was caught at each location. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tSample Locations FC: {sample_locations_fc}") + # print(f"\tSample Locations FCS: {sample_locations_fcs}") + # print(f"\tSample Locations FST: {sample_locations_fcst}") + + del ( + table_name, + sample_locations_fc, + sample_locations_fcs, + sample_locations_fcst, + ) + + elif distribution_project_code != "IDW": + + # table_name = f"{dataset_code}_TABLE" + table_name = f"{dataset_code}" + table_name_s = f"{table_name}_{date_code(project)}" + table_name_st = f"{filter_sub_region} {season} Table {date_code(project)}".replace( + " ", " " + ) + + # print(f"\tProcessing: {table_name}") + + __datasets_dict[table_name] = { + "Dataset Service": table_name_s, + "Dataset Service Title": table_name_st, + "Tags": tags, + "Summary": summary, + "Description": f"This table represents the CSV Data files in ArcGIS format", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + del table_name, table_name_s, table_name_st + + table_name = f"{dataset_code}" + grid_points_fc = ( + f"{table_name}_{point_feature_type.replace(' ', '_')}" + ) + grid_points_fcs = f"{table_name}_{point_feature_type.replace(' ', '_')}_{date_code(project)}" + feature_service_title = f"{filter_sub_region} {season} Sample Locations {date_code(project)}" + grid_points_fcst = f"{dataset_code.replace('_', ' ')} {point_feature_type} {date_code(project)}" + + __datasets_dict[grid_points_fc] = { + "Dataset Service": grid_points_fcs, + "Dataset Service Title": grid_points_fcst, + "Tags": tags, + "Summary": summary, + "Description": f"This grid points layer provides information on model output amount (i.e., biomass weight catch per unit effort, standardized to kg/ha) of each species that was modeled at each location. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tGRID Points FC: {grid_points_fc}") + # print(f"\tGRID Points FCS: {grid_points_fcs}") + # print(f"\tGRID Points FCST: {grid_points_fcst}") + + del table_name, grid_points_fc, grid_points_fcs, grid_points_fcst + + dataset_code = ( + f"{dataset_code}_{distribution_project_code}" + if distribution_project_code not in dataset_code + else dataset_code + ) + + # Bathymetry + bathymetry_r = f"{dataset_code}_Bathymetry" + bathymetry_rs = f"{dataset_code}_Bathymetry_{date_code(project)}" + feature_service_title = ( + f"{filter_sub_region} {season} Bathymetry {date_code(project)}" + ) + bathymetry_rst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {bathymetry_r}") + + __datasets_dict[bathymetry_r] = { + "Dataset Service": bathymetry_rs, + "Dataset Service Title": bathymetry_rst, + "Tags": tags, + "Summary": summary, + "Description": f"The bathymetry dataset represents the ocean depth at that grid cell.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tBathymetry R: {bathymetry_r}") + # print(f"\tBathymetry RS: {bathymetry_rs}") + # print(f"\tBathymetry RST: {bathymetry_rst}") + + del bathymetry_r, bathymetry_rs, bathymetry_rst + + # Boundary + boundary_fc = f"{dataset_code}_Boundary" + boundary_fcs = f"{dataset_code}_Boundary_{date_code(project)}" + feature_service_title = ( + f"{filter_sub_region} {season} Boundary {date_code(project)}" + ) + boundary_fcst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {boundary_fc}") + + __datasets_dict[boundary_fc] = { + "Dataset Service": boundary_fcs, + "Dataset Service Title": boundary_fcst, + "Tags": tags, + "Summary": summary, + "Description": f"These files contain the spatial boundaries of the NOAA Fisheries Bottom-trawl surveys. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Eastern Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tBoundary FC: {boundary_fc}") + # print(f"\tBoundary FCS: {boundary_fcs}") + # print(f"\tBoundary FCST: {boundary_fcst}") + + del boundary_fc, boundary_fcs, boundary_fcst + + # Boundary + boundary_line_fc = f"{dataset_code}_Boundary_Line" + boundary_line_fcs = f"{dataset_code}_Boundary_Line_{date_code(project)}" + feature_service_title = ( + f"{filter_sub_region} {season} Boundary Line {date_code(project)}" + ) + boundary_line_fcst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {boundary_line_fc}") + + __datasets_dict[boundary_line_fc] = { + "Dataset Service": boundary_line_fcs, + "Dataset Service Title": boundary_line_fcst, + "Tags": tags, + "Summary": summary, + "Description": f"These files contain the spatial boundaries of the NOAA Fisheries Bottom-trawl surveys. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Eastern Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tBoundary FC: {boundary_line_fc}") + # print(f"\tBoundary FCS: {boundary_line_fcs}") + # print(f"\tBoundary FCST: {boundary_line_fcst}") + + del boundary_line_fc, boundary_line_fcs, boundary_line_fcst + + # CRF + crf_r = f"{dataset_code}_CRF" + crf_rs = f"{dataset_code}_{date_code(project)}" + feature_service_title = f"{filter_sub_region} {season} {dataset_code[dataset_code.rfind('_')+1:]} {date_code(project)}" + crf_rst = f"{feature_service_title.replace(' ',' ')}" + # del feature_service_title + + # print(f"Processing: {crf_r}") + # print(f"\t{crf_rs}") + # print(f"\t{feature_service_title}") + # print(f"\t{crf_rst}") + + __datasets_dict[crf_r] = { + "Dataset Service": crf_rs, + "Dataset Service Title": crf_rst, + "Tags": tags, + "Summary": f"{summary}. These interpolated biomass layers provide information on the spatial distribution of species caught in the NOAA Fisheries fisheries-independent surveys. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Description": f"NOAA Fisheries and its partners conduct fisheries-independent surveys in 8 regions in the US (Northeast, Southeast, Gulf of Mexico, West Coast, Gulf of Alaska, Bering Sea, Aleutian Islands, Hawai’i Islands). These surveys are designed to collect information on the seasonal distribution, relative abundance, and biodiversity of fish and invertebrate species found in U.S. waters. Over 400 species of fish and invertebrates have been identified in these surveys.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tCRF R: {crf_r}") + # print(f"\tCRF RS: {crf_rs}") + # print(f"\tCRF RST: {crf_rst}") + + del crf_r, crf_rs, crf_rst + + # Extent Points + extent_points_fc = f"{dataset_code}_Extent_Points" + extent_points_fcs = f"{dataset_code}_Extent_Points_{date_code(project)}" + feature_service_title = ( + f"{filter_sub_region} {season} Extent Points {date_code(project)}" + ) + extent_points_fcst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {extent_points_fc}") + + __datasets_dict[extent_points_fc] = { + "Dataset Service": extent_points_fcs, + "Dataset Service Title": extent_points_fcst, + "Tags": tags, + "Summary": summary, + "Description": f"The Extent Points layer represents the extent of the model region.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tExtent Points FC: {extent_points_fc}") + # print(f"\tExtent Points FCS: {extent_points_fcs}") + # print(f"\tExtent Points FCST: {extent_points_fcst}") + + del extent_points_fc, extent_points_fcs, extent_points_fcst + + # Extent Points + points_fc = f"{dataset_code}_Points" + points_fcs = f"{dataset_code}_Points_{date_code(project)}" + feature_service_title = ( + f"{filter_sub_region} {season} Extent Points {date_code(project)}" + ) + points_fcst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {points_fc}") + + __datasets_dict[points_fc] = { + "Dataset Service": points_fcs, + "Dataset Service Title": points_fcst, + "Tags": tags, + "Summary": summary, + "Description": f"The Points layer represents the extent of the model region.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tExtent Points FC: {points_fc}") + # print(f"\tExtent Points FCS: {points_fcs}") + # print(f"\tExtent Points FCST: {points_fcst}") + + del points_fc, points_fcs, points_fcst + + fishnet_fc = f"{dataset_code}_Fishnet" + fishnet_fcs = f"{dataset_code}_Fishnet_{date_code(project)}" + feature_service_title = ( + f"{filter_sub_region} {season} Fishnet {date_code(project)}" + ) + fishnet_fcst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {fishnet_fc}") + + __datasets_dict[fishnet_fc] = { + "Dataset Service": fishnet_fcs, + "Dataset Service Title": fishnet_fcst, + "Tags": tags, + "Summary": summary, + "Description": f"The Fishnet is used to create the latitude and longitude rasters.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tFishnet FC: {fishnet_fc}") + # print(f"\tFishnet FCS: {fishnet_fcs}") + # print(f"\tFishnet FCST: {fishnet_fcst}") + + del fishnet_fc, fishnet_fcs, fishnet_fcst + + indicators_tb = f"{dataset_code}_Indicators" + indicators_tbs = f"{dataset_code}_Indicators_{date_code(project)}" + feature_service_title = f"{filter_sub_region} {season} Indicators Table {date_code(project)}" + indicators_tbst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {indicators_t}") + + __datasets_dict[indicators_tb] = { + "Dataset Service": indicators_tbs, + "Dataset Service Title": indicators_tbst, + "Tags": tags, + "Summary": f"{summary}. This table provides the key metrics used to evaluate a species distribution shift. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Description": f"These data contain the key distribution metrics of center of gravity, range limits, and depth for each species in the portal. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tIndicators T: {indicators_t}") + # print(f"\tIndicators TS: {indicators_ts}") + # print(f"\tIndicators TST: {indicators_tst}") + + del indicators_tb, indicators_tbs, indicators_tbst + + lat_long_fc = f"{dataset_code}_Lat_Long" + lat_long_fcs = f"{dataset_code}_Lat_Long_{date_code(project)}" + feature_service_title = ( + f"{filter_sub_region} {season} Lat Long {date_code(project)}" + ) + lat_long_fcst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {lat_long_fc}") + + __datasets_dict[lat_long_fc] = { + "Dataset Service": lat_long_fcs, + "Dataset Service Title": lat_long_fcst, + "Tags": tags, + "Summary": summary, + "Description": f"The lat_long layer is used to get the latitude & longitude values to create these rasters", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tLat Long FC: {lat_long_fc}") + # print(f"\tLat Long FCS: {lat_long_fcs}") + # print(f"\tLat Long FCST: {lat_long_fcst}") + + del lat_long_fc, lat_long_fcs, lat_long_fcst + + latitude_r = f"{dataset_code}_Latitude" + latitude_rs = f"{dataset_code}_Latitude_{date_code(project)}" + feature_service_title = ( + f"{filter_sub_region} {season} Latitude {date_code(project)}" + ) + latitude_rst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {latitude_r}") + + __datasets_dict[latitude_r] = { + "Dataset Service": latitude_rs, + "Dataset Service Title": latitude_rst, + "Tags": tags, + "Summary": summary, + "Description": f"The Latitude raster", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tLatitude R: {latitude_r}") + # print(f"\tLatitude RS: {latitude_rs}") + # print(f"\tLatitude RST: {latitude_rst}") + + del latitude_r, latitude_rs, latitude_rst + + layer_species_year_image_name_tb = ( + f"{dataset_code}_LayerSpeciesYearImageName" + ) + layer_species_year_image_name_tbs = ( + f"{dataset_code}_LayerSpeciesYearImageName_{date_code(project)}" + ) + feature_service_title = f"{filter_sub_region} {season} Layer Species Year Image Name Table {date_code(project)}" + layer_species_year_image_name_tbst = ( + f"{feature_service_title.replace(' ',' ')}" + ) + del feature_service_title + + # print(f"\tProcessing: {layer_species_year_image_name_tb}") + + __datasets_dict[layer_species_year_image_name_tb] = { + "Dataset Service": layer_species_year_image_name_tbs, + "Dataset Service Title": layer_species_year_image_name_tbst, + "Tags": tags, + "Summary": summary, + "Description": f"Layer Species Year Image Name Table", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tLayerSpeciesYearImageName T: {layer_species_year_image_name_tb}") + # print(f"\tLayerSpeciesYearImageName TS: {layer_species_year_image_name_tbs}") + # print(f"\tLayerSpeciesYearImageName TST: {layer_species_year_image_name_tbst}") + + del ( + layer_species_year_image_name_tb, + layer_species_year_image_name_tbs, + layer_species_year_image_name_tbst, + ) + + longitude_r = f"{dataset_code}_Longitude" + longitude_rs = f"{dataset_code}_Longitude_{date_code(project)}" + feature_service_title = ( + f"{filter_sub_region} {season} Longitude {date_code(project)}" + ) + longitude_rst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {longitude_r}") + + __datasets_dict[longitude_r] = { + "Dataset Service": longitude_rs, + "Dataset Service Title": longitude_rst, + "Tags": tags, + "Summary": summary, + "Description": f"The Longitude raster", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tLongitude R: {longitude_r}") + # print(f"\tLongitude RS: {longitude_rs}") + # print(f"\tLongitude RST: {longitude_rst}") + + del longitude_r, longitude_rs, longitude_rst + + mosaic_r = f"{dataset_code}_Mosaic" + mosaic_rs = f"{dataset_code}_Mosaic_{date_code(project)}" + feature_service_title = f"{filter_sub_region} {season} {dataset_code[dataset_code.rfind('_')+1:]} Mosaic {date_code(project)}" + mosaic_rst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {mosaic_r}") + + __datasets_dict[mosaic_r] = { + "Dataset Service": mosaic_rs, + "Dataset Service Title": mosaic_rst, + # "Tags" : _tags, + "Tags": tags, + "Summary": f"{summary}. These interpolated biomass layers provide information on the spatial distribution of species caught in the NOAA Fisheries fisheries-independent surveys. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Description": f"NOAA Fisheries and its partners conduct fisheries-independent surveys in 8 regions in the US (Northeast, Southeast, Gulf of Mexico, West Coast, Gulf of Alaska, Bering Sea, Aleutian Islands, Hawai’i Islands). These surveys are designed to collect information on the seasonal distribution, relative abundance, and biodiversity of fish and invertebrate species found in U.S. waters. Over 400 species of fish and invertebrates have been identified in these surveys.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tMosaic R: {mosaic_r}") + # print(f"\tMosaic RS: {mosaic_rs}") + # print(f"\tMosaic RST: {mosaic_rst}") + + del mosaic_r, mosaic_rs, mosaic_rst + + crf_r = f"{dataset_code}.crf" + crf_rs = f"{dataset_code}_CRF_{date_code(project)}" + feature_service_title = f"{filter_sub_region} {season} {dataset_code[dataset_code.rfind('_')+1:]} C {date_code(project)}" + crf_rst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {mosaic_r}") + + __datasets_dict[crf_r] = { + "Dataset Service": crf_rs, + "Dataset Service Title": crf_rst, + # "Tags" : _tags, + "Tags": tags, + "Summary": f"{summary}. These interpolated biomass layers provide information on the spatial distribution of species caught in the NOAA Fisheries fisheries-independent surveys. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Description": f"NOAA Fisheries and its partners conduct fisheries-independent surveys in 8 regions in the US (Northeast, Southeast, Gulf of Mexico, West Coast, Gulf of Alaska, Bering Sea, Aleutian Islands, Hawai’i Islands). These surveys are designed to collect information on the seasonal distribution, relative abundance, and biodiversity of fish and invertebrate species found in U.S. waters. Over 400 species of fish and invertebrates have been identified in these surveys.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tCFR R: {crf_r}") + # print(f"\tCFR RS: {crf_rs}") + # print(f"\tCFR RST: {crf_rst}") + + del crf_r, crf_rs, crf_rst + + raster_mask_r = f"{dataset_code}_Raster_Mask" + raster_mask_rs = f"{dataset_code}_Raster_Mask_{date_code(project)}" + feature_service_title = ( + f"{filter_sub_region} {season} Raster Mask {date_code(project)}" + ) + raster_mask_rst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {raster_mask_r}") + + __datasets_dict[raster_mask_r] = { + "Dataset Service": raster_mask_rs, + "Dataset Service Title": raster_mask_rst, + "Tags": tags, + "Summary": summary, + "Description": f"Raster Mask is used for image production", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tRaster_Mask R: {raster_mask_r}") + # print(f"\tRaster_Mask RS: {raster_mask_rs}") + # print(f"\tRaster_Mask RST: {raster_mask_rst}") + + del raster_mask_r, raster_mask_rs, raster_mask_rst + + region_fc = f"{dataset_code}_Region" + region_fcs = f"{dataset_code}_Region_{date_code(project)}" + feature_service_title = ( + f"{filter_sub_region} {season} Region {date_code(project)}" + ) + region_fcst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {region_fc}") + + __datasets_dict[region_fc] = { + "Dataset Service": region_fcs, + "Dataset Service Title": region_fcst, + "Tags": tags, + "Summary": summary, + "Description": f"These files contain the spatial boundaries of the NOAA Fisheries Bottom-trawl surveys. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tRegion FC: {region_fc}") + # print(f"\tRegion FCS: {region_fcs}") + # print(f"\tRegion FCST: {region_fcst}") + + del region_fc, region_fcs, region_fcst + + survey_area_fc = f"{dataset_code}_Survey_Area" + survey_area_fcs = f"{dataset_code}_Region_{date_code(project)}" + feature_service_title = ( + f"{filter_sub_region} {season} Region {date_code(project)}" + ) + survey_area_fcst = f"{feature_service_title.replace(' ',' ')}" + del feature_service_title + + # print(f"\tProcessing: {survey_area_fc}") + + __datasets_dict[survey_area_fc] = { + "Dataset Service": survey_area_fcs, + "Dataset Service Title": survey_area_fcst, + "Tags": tags, + "Summary": summary, + "Description": f"These files contain the spatial boundaries of the NOAA Fisheries Bottom-trawl surveys. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tRegion FC: {survey_area_fc}") + # print(f"\tRegion FCS: {survey_area_fcs}") + # print(f"\tRegion FCST: {survey_area_fcst}") + + del survey_area_fc, survey_area_fcs, survey_area_fcst + + del tags + + if not distribution_project_code: + + if "Datasets" == dataset_code: + + # print(f"\tProcessing: Datasets") + + datasets_tb = dataset_code + datasets_tbs = f"{dataset_code}_{date_code(project)}" + datasets_tbst = f"{dataset_code} {date_code(project)}" + + __datasets_dict[datasets_tb] = { + "Dataset Service": datasets_tbs, + "Dataset Service Title": datasets_tbst, + "Tags": "DisMAP, Datasets", + "Summary": summary, + "Description": "This table functions as a look-up table of vales", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + del datasets_tb, datasets_tbs, datasets_tbst + + elif "DisMAP_Regions" == dataset_code: + + # print(f"\tProcessing: DisMAP_Regions") + + regions_fc = dataset_code + regions_fcs = f"{dataset_code}_{date_code(project)}" + regions_fcst = f"DisMAP Regions {date_code(project)}" + + __datasets_dict[regions_fc] = { + "Dataset Service": regions_fcs, + "Dataset Service Title": regions_fcst, + "Tags": "DisMAP Regions", + "Summary": summary, + "Description": "These files contain the spatial boundaries of the NOAA Fisheries Bottom-trawl surveys. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Eastern Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + del regions_fc, regions_fcs, regions_fcst + + elif "Indicators" == dataset_code: + + # print(f"\tProcessing: Indicators") + + indicators_tb = f"{dataset_code}" + indicators_tbs = f"{dataset_code}_{date_code(project)}" + indicators_tbst = f"{dataset_code} {date_code(project)}" + + __datasets_dict[indicators_tb] = { + "Dataset Service": indicators_tbs, + "Dataset Service Title": indicators_tbst, + "Tags": "DisMAP, Indicators", + "Summary": f"{summary}. This table provides the key metrics used to evaluate a species distribution shift. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Description": f"These data contain the key distribution metrics of center of gravity, range limits, and depth for each species in the portal. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + del indicators_tb, indicators_tbs, indicators_tbst + + elif "LayerSpeciesYearImageName" == dataset_code: + + # print(f"\tProcessing: LayerSpeciesYearImageName") + + layer_species_year_image_name_tb = dataset_code + layer_species_year_image_name_tbs = ( + f"{dataset_code}_{date_code(project)}" + ) + layer_species_year_image_name_tbst = ( + f"Layer Species Year Image Name Table {date_code(project)}" + ) + + # print(f"\tProcessing: {layer_species_year_image_name_tb}") + + __datasets_dict[layer_species_year_image_name_tb] = { + "Dataset Service": layer_species_year_image_name_tbs, + "Dataset Service Title": layer_species_year_image_name_tbst, + "Tags": "DisMAP, Layer Species Year Image Name Table", + "Summary": summary, + "Description": "This table functions as a look-up table of values", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tLayerSpeciesYearImageName T: {layer_species_year_image_name_tb}") + # print(f"\tLayerSpeciesYearImageName TS: {layer_species_year_image_name_tbs}") + # print(f"\tLayerSpeciesYearImageName TST: {layer_species_year_image_name_tbst}") + + del ( + layer_species_year_image_name_tb, + layer_species_year_image_name_tbs, + layer_species_year_image_name_tbst, + ) + + elif "Species_Filter" == dataset_code: + + # print(f"\tProcessing: Species_Filter") + + species_filter_tb = dataset_code + species_filter_tbs = f"{dataset_code}_{date_code(project)}" + species_filter_tbst = f"Species Filter Table {date_code(project)}" + + __datasets_dict[species_filter_tb] = { + "Dataset Service": species_filter_tbs, + "Dataset Service Title": species_filter_tbst, + "Tags": "DisMAP, Species Filter Table", + "Summary": summary, + "Description": "This table functions as a look-up table of values", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tLayerSpeciesYearImageName T: {species_filter_tb}") + # print(f"\tLayerSpeciesYearImageName TS: {species_filter_tbs}") + # print(f"\tLayerSpeciesYearImageName TST: {species_filter_tbst}") + + del species_filter_tb, species_filter_tbs, species_filter_tbst + + elif "DisMAP_Survey_Info" == dataset_code: + + # print(f"\tProcessing: DisMAP_Survey_Info") + + tb = dataset_code + tbs = f"{dataset_code}_{date_code(project)}" + tbst = f"DisMAP Survey Info Table {date_code(project)}" + + __datasets_dict[tb] = { + "Dataset Service": tbs, + "Dataset Service Title": tbst, + "Tags": "DisMAP; DisMAP Survey Info Table", + "Summary": summary, + "Description": "This table functions as a look-up table of values", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # print(f"\tLayerSpeciesYearImageName T: {tb}") + # print(f"\tLayerSpeciesYearImageName TS: {tbs}") + # print(f"\tLayerSpeciesYearImageName TST: {tbst}") + + del tb, tbs, tbst + + else: + # print(f"\tProcessing: {dataset_code}") + + # table = dataset_code + # table_s = f"{dataset_code}_{date_code(project)}" + # table_st = f"{table_s.replace('_',' ')} {date_code(project)}" + # print(f"\tProcessing: {table_s}") + # __datasets_dict[table] = {"Dataset Service" : table_s, + # "Dataset Service Title" : table_st, + # "Tags" : f"DisMAP, {table}", + # "Summary" : summary, + # "Description" : "Unknown table", + # "Credits" : _credits, + # "Access Constraints" : access_constraints} + + # print(f"\tTable: {table}") + # print(f"\tTable TS: {table_s}") + # print(f"\tTable TST: {table_st}") + + # del table, table_s, table_st + + raise Exception(f"{dataset_code} is missing") + + else: + pass + + del summary + del point_feature_type, distribution_project_code + del filter_region, filter_sub_region, season + del dataset_code + + del _credits, access_constraints + + del dataset_codes + del project_folder, crf_folder + del project, project_gdb + except KeyboardInterrupt: + raise SystemExit + except: + traceback.print_exc() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return __datasets_dict + finally: + if "__datasets_dict" in locals().keys(): + del __datasets_dict + + +def import_basic_template_xml(dataset_path=""): + try: + # Import + from io import BytesIO, StringIO + + from arcpy import metadata as md + from lxml import etree + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + project_gdb = os.path.dirname(dataset_path) + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{project_folder}\Scratch" + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + import json + + json_path = rf"{project_folder}\root_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + root_dict = json.load(json_file) + del json_file + del json_path + del json + + ## #print("Creating the Metadata Dictionary. Please wait!!") + ## metadata_dictionary = dataset_title_dict(project_gdb) + ## #print("Creating the Metadata Dictionary. Completed") + + # print(dataset_path) + dataset_name = os.path.basename(dataset_path) + + print(f"Dataset: {dataset_name}") + + ## xml_file = ''' + ## + ## + ## + ## + ## Timothy J Haverland + ## + ## + ## tim.haverland@noaa.gov + ## + ## + ## https://www.fisheries.noaa.gov/about/office-science-and-technology + ## + ## + ## + ## + ## + ## + ## + ## + ## Melissa Ann Karp + ## + ## + ## melissa.karp@noaa.gov + ## + ## + ## https://www.fisheries.noaa.gov/about/office-science-and-technology + ## + ## + ## + ## + ## + ## + ## + ## + ## + ## + ## NMFS Office of Science and Technology + ## + ## + ## tim.haverland@noaa.gov + ## + ## + ## https://www.fisheries.noaa.gov/about/office-science-and-technology + ## + ## + ## + ## + ## + ## + ## + ## + ## + ## John F Kennedy + ## + ## + ## john.f.kennedy@noaa.gov + ## + ## + ## https://www.fisheries.noaa.gov/about/office-science-and-technology + ## + ## + ## + ## + ## + ## + ## ''' + + ## xml_file = ''' + ## + ## + ## John F Kennedy + ## + ## + ## john.f.kennedy@noaa.gov + ## + ## + ## https://www.fisheries.noaa.gov/about/office-science-and-technology + ## + ## + ## + ## + ## + ## + ## ''' + + ## # Parse the XML + ## dataset_md = md.Metadata(dataset_path) + ## #dataset_md.synchronize('ALWAYS') + ## #dataset_md.save() + ## in_md = md.Metadata(rf"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMap\ArcGIS-Analysis-Python\December 1 2024\Export\WC_TRI_IDW.xml") + ## dataset_md.copy(in_md) + ## #dataset_md.importMetadata(rf"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMap\ArcGIS-Analysis-Python\December 1 2024\Export\WC_TRI_IDW.xml", "ARCGIS_METADATA") + ## #dataset_md.importMetadata(xml_file, "ARCGIS_METADATA") + ## dataset_md.save() + ## dataset_md.synchronize("OVERWRITE") + ## dataset_md.save() + ## #dataset_md.reload() + ## #dataset_md.synchronize("ALWAYS") + ## #dataset_md.save() + ## #dataset_md.reload() + ## del in_md + ## del dataset_md + ## del xml_file + ## + ## tags = "DisMap;" + ## summary = "These data were created as part of the DisMAP project to enable visualization and analysis of changes in fish and invertebrate distributions" + ## description = "" + ## project_credits = "These data were produced by NMFS OST." + ## access_constraints = "***No Warranty*** The user assumes the entire risk related to its use of these data. NMFS is providing these data 'as is' and NMFS disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose. No warranty expressed or implied is made regarding the accuracy or utility of the data on any other system or for general or scientific purposes, nor shall the act of distribution constitute any such warranty. It is strongly recommended that careful attention be paid to the contents of the metadata file associated with these data to evaluate dataset limitations, restrictions or intended use. In no event will NMFS be liable to you or to any third party for any direct, indirect, incidental, consequential, special or exemplary damages or lost profit resulting from any use or misuse of these data." + ## + ## dataset_md = md.Metadata(dataset_path) + ## dataset_md.title = f"{dataset_name.replace('_', ' ')}" + ## dataset_md.tags = f"{tags}{dataset_name.replace('_', ' ')};" + ## dataset_md.summary = summary + ## dataset_md.description = f"{description}{dataset_name.replace('_', ' ')}" + ## dataset_md.credits = project_credits + ## dataset_md.accessConstraints = access_constraints + ## dataset_md.save() + ## dataset_md.synchronize("ALWAYS") + ## dataset_md.save() + ## del dataset_md + ## + ## del tags, summary, description, project_credits, access_constraints + + # Option #1 + # empty_md = md.Metadata() + # dataset_md = md.Metadata(dataset_path) + # dataset_md.copy(empty_md) + # dataset_md.save() + # del empty_md + # Option #2 + # empty_md = md.Metadata(xml_file) + # dataset_md = md.Metadata(dataset_path) + # dataset_md.copy(empty_md) + # dataset_md.save() + # del empty_md + # Option #3 + # + # dataset_md = md.Metadata(dataset_path) + # dataset_md.copy(in_md) + # dataset_md.save() + # del in_md + # Option #4 + dataset_md = md.Metadata(dataset_path) + dataset_md.importMetadata(rf"{project_folder}\metadata_template.xml") + dataset_md.save() + del dataset_md + + tags = "DisMap;" + summary = "These data were created as part of the DisMAP project to enable visualization and analysis of changes in fish and invertebrate distributions" + description = "" + project_credits = "These data were produced by NMFS OST." + access_constraints = "***No Warranty*** The user assumes the entire risk related to its use of these data. NMFS is providing these data 'as is' and NMFS disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose. No warranty expressed or implied is made regarding the accuracy or utility of the data on any other system or for general or scientific purposes, nor shall the act of distribution constitute any such warranty. It is strongly recommended that careful attention be paid to the contents of the metadata file associated with these data to evaluate dataset limitations, restrictions or intended use. In no event will NMFS be liable to you or to any third party for any direct, indirect, incidental, consequential, special or exemplary damages or lost profit resulting from any use or misuse of these data." + + dataset_md = md.Metadata(dataset_path) + dataset_md.title = f"{dataset_name.replace('_', ' ')}" + dataset_md.tags = f"{tags}{dataset_name.replace('_', ' ')};" + dataset_md.summary = summary + dataset_md.description = f"{description}{dataset_name.replace('_', ' ')}" + dataset_md.credits = project_credits + dataset_md.accessConstraints = access_constraints + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + dataset_md.reload() + export_folder = rf"{os.path.dirname(os.path.dirname(dataset_path))}\Export" + dataset_md.saveAsXML( + rf"{export_folder}\{os.path.basename(dataset_path)}.xml", + "REMOVE_ALL_SENSITIVE_INFO", + ) + # To parse from a string, use the fromstring() function instead. + _tree = etree.parse( + rf"{export_folder}\{os.path.basename(dataset_path)}.xml", + parser=etree.XMLParser(encoding="UTF-8", remove_blank_text=True), + ) + _root = _tree.getroot() + _root[:] = sorted(_root, key=lambda x: root_dict[x.tag]) + del _root + etree.indent(_tree, space="\t") + _tree.write( + rf"{export_folder}\{os.path.basename(dataset_path)}.xml", + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + del _tree + del export_folder + del dataset_md + + del tags, summary, description, project_credits, access_constraints + + # Parse the XML + dataset_md = md.Metadata(dataset_path) + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + target_tree = etree.parse(StringIO(dataset_md.xml), parser=parser) + # target_tree = etree.parse(xml_file, parser=parser) + target_root = target_tree.getroot() + target_root[:] = sorted(target_root, key=lambda x: root_dict[x.tag]) + etree.indent(target_tree, space="\t") + print( + etree.tostring( + target_tree, encoding="UTF-8", method="xml", pretty_print=True + ).decode() + ) + del parser, dataset_md + + del target_tree, target_root + + ## _tree = etree.parse(BytesIO(xml_file), etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## _root = _tree.getroot() + ## distributor = target_root.xpath(f"./distInfo/distributor") + ## if len(distributor) == 0: + ## target_root.xpath(f"./distInfo")[0].insert(distInfo_dict["distributor"], _root) + ## elif len(distributor) == 1: + ## distributor[0].getparent().replace(distributor[0], _root) + ## else: + ## pass + ## del _root, _tree, xml_file + ## #print(f"\n\t{etree.tostring(target_root.xpath(f'./distInfo/distributor')[0], encoding='UTF-8', method='xml', pretty_print=True).decode()}\n") + ## del distributor + + ## mdFileID = target_root.xpath(f"//mdFileID") + ## if mdFileID is not None and len(mdFileID) == 0: + ## _xml = 'gov.noaa.nmfs.inport:' + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## target_root.insert(root_dict['mdFileID'], _root) + ## del _root, _xml + ## elif mdFileID is not None and len(mdFileID) and len(mdFileID[0]) == 0: + ## mdFileID[0].text = "gov.noaa.nmfs.inport:" + ## elif mdFileID is not None and len(mdFileID) and len(mdFileID[0]) == 1: + ## pass + ## #print(etree.tostring(mdFileID[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del mdFileID + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## mdMaint = target_root.xpath(f"//mdMaint") + ## if mdMaint is not None and len(mdMaint) == 0: + ## _xml = '' + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## target_root.insert(root_dict['mdMaint'], _root) + ## del _root, _xml + ## elif mdMaint is not None and len(mdMaint) and len(mdMaint[0]) == 0: + ## target_root.xpath("./mdMaint/maintFreq/MaintFreqCd")[0].attrib["value"] = "009" + ## elif mdMaint is not None and len(mdMaint) and len(mdMaint[0]) == 1: + ## pass #print(etree.tostring(mdMaint[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## else: + ## pass + ## #print(etree.tostring(mdMaint[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del mdMaint + ## + ## # No changes needed below + ## #print(etree.tostring(target_tree, encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## etree.indent(target_root, space=' ') + ## dataset_md_xml = etree.tostring(target_tree, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True) + ## + ## SaveBackXml = False + ## if SaveBackXml: + ## dataset_md = md.Metadata(dataset_path) + ## dataset_md.xml = dataset_md_xml + ## dataset_md.save() + ## dataset_md.synchronize("ALWAYS") + ## dataset_md.save() + ## #dataset_md.reload() + ## del dataset_md + ## else: + ## pass + ## del SaveBackXml + ## del dataset_md_xml + + # Declared Variables + del root_dict + # del target_tree, target_root + # del metadata_dictionary, + del dataset_name + del project_gdb, project_folder, scratch_folder + # Imports + del md + del etree, StringIO, BytesIO + # Function Parameters + del dataset_path + except KeyboardInterrupt: + raise SystemExit + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + raise SystemExit + except arcpy.ExecuteError: + # traceback.print_exc() + arcpy.AddError(arcpy.GetMessages(2)) + raise SystemExit + except: + traceback.print_exc() + raise SystemExit + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def update_eainfo_xml_elements(dataset_path=""): + try: + # Imports + from io import BytesIO, StringIO + + # import copy + from arcpy import metadata as md + from lxml import etree + + # Project modules + # from src.project_tools import pretty_format_xml_file + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + project_gdb = os.path.dirname(dataset_path) + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{project_folder}\Scratch" + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + import json + + json_path = rf"{project_folder}\root_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + root_dict = json.load(json_file) + del json_file + del json_path + del json + + dataset_md = md.Metadata(dataset_path) + dataset_md.synchronize("ALWAYS") + dataset_md.save() + dataset_md.reload() + dataset_md_xml = dataset_md.xml + del dataset_md + + # Parse the XML + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + target_tree = etree.parse(StringIO(dataset_md_xml), parser=parser) + target_root = target_tree.getroot() + del parser, dataset_md_xml + + dataset_name = os.path.basename(dataset_path) + print(f"Processing Entity Attributes for dataset: '{dataset_name}'") + + # Root + mdTimeSt = target_root.find("./mdTimeSt") + # print(mdTimeSt) + if mdTimeSt is not None: + mdTimeSt.getparent().remove(mdTimeSt) + else: + pass + del mdTimeSt + + enttyp = target_root.find("enttyp") + if enttyp is not None: + enttypd = enttyp.find("enttypd") + enttypds = enttyp.find("enttypds") + if enttypd is None: + _xml = "A collection of geographic features with the same geometry type." + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + enttyp.insert(0, _root) + del _root, _xml + else: + pass + if enttypds is None: + _xml = "Esri" + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + enttyp.insert(0, _root) + del _root, _xml + else: + pass + del enttypds, enttypd + else: + pass + del enttyp + + # Create a list of fields using the ListFields function + fields = [ + f + for f in arcpy.ListFields(dataset_path) + if f.type not in ["Geometry", "OID"] + and f.name not in ["Shape_Area", "Shape_Length"] + ] + for field in fields: + attributes = target_root.xpath(f".//attrlabl[text()='{field.name}']/..") + if attributes is not None and len(attributes) > 0: + for attribute in attributes: + # print(attribute) + # print(etree.tostring(attribute, encoding='UTF-8', method='xml', pretty_print=True).decode()) + attrdef = attribute.find("./attrdef/..") + if attrdef is None: + _xml = f"Definition for: {field.name}" + _root = etree.XML( + _xml, + etree.XMLParser(encoding="UTF-8", remove_blank_text=True), + ) + attribute.insert(7, _root) + del _root, _xml + else: + pass + attrdefs = attribute.find("./attrdefs/..") + if attrdefs is None: + _xml = "NMFS OST DisMAP 2025" + _root = etree.XML( + _xml, + etree.XMLParser(encoding="UTF-8", remove_blank_text=True), + ) + attribute.insert(8, _root) + del _root, _xml + else: + pass + attrdomv = attribute.find("./attrdomv/..") + if attrdomv is None: + _xml = "None" + _root = etree.XML( + _xml, + etree.XMLParser(encoding="UTF-8", remove_blank_text=True), + ) + attribute.insert(8, _root) + del _root, _xml + else: + pass + del attrdef, attrdefs, attrdomv + del attribute + else: + pass + del attributes + del field + + attributes = target_root.xpath(f".//attr") + for attribute in attributes: + # print(etree.tostring(attribute, encoding='UTF-8', method='xml', pretty_print=True).decode()) + del attribute + del attributes + del fields + + # Metadata + target_root[:] = sorted(target_root, key=lambda x: root_dict[x.tag]) + + # No changes needed below + # print(etree.tostring(target_tree, encoding='UTF-8', method='xml', pretty_print=True).decode()) + etree.indent(target_tree, space=" ") + dataset_md_xml = etree.tostring( + target_tree, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + + SaveBackXml = True + if SaveBackXml: + dataset_md = md.Metadata(dataset_path) + dataset_md.xml = dataset_md_xml + dataset_md.save() + dataset_md.synchronize("CREATED") + dataset_md.save() + # _target_tree = etree.parse(StringIO(dataset_md.xml), parser=etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + # _target_tree.write(rf"{export_folder}\{dataset_name}.xml", pretty_print=True) + # print(etree.tostring(_target_tree.find("./eainfo"), encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + # del _target_tree + del dataset_md + else: + pass + del SaveBackXml + del dataset_md_xml + + # Declared Varaiables + del dataset_name + del target_tree, target_root + del project_gdb, project_folder, scratch_folder, root_dict + # Imports + del md, etree, StringIO, BytesIO + # Function Parameters + del dataset_path + except KeyboardInterrupt: + raise SystemExit + except: + traceback.print_exc() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def insert_missing_elements(dataset_path): + try: + import copy + from io import BytesIO, StringIO + + from arcpy import metadata as md + from lxml import etree + + project_gdb = os.path.dirname(dataset_path) + project_folder = os.path.dirname(project_gdb) + project = os.path.basename(os.path.dirname(project_gdb)) + export_folder = rf"{project_folder}\Export" + scratch_folder = rf"{project_folder}\Scratch" + + import json + + json_path = rf"{project_folder}\root_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + root_dict = json.load(json_file) + json_path = rf"{project_folder}\esri_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + esri_dict = json.load(json_file) + json_path = rf"{project_folder}\dataIdInfo_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + dataIdInfo_dict = json.load(json_file) + json_path = rf"{project_folder}\contact_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + contact_dict = json.load(json_file) + json_path = rf"{project_folder}\dqInfo_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + dqInfo_dict = json.load(json_file) + json_path = rf"{project_folder}\distInfo_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + distInfo_dict = json.load(json_file) + # json_path = rf"{project_folder}\RoleCd_dict.json" + # with open(json_path, "r", encoding='utf-8') as json_file: + # RoleCd_dict = json.load(json_file) + # json_path = rf"{project_folder}\tpCat_dict.json" + # with open(json_path, "r", encoding='utf-8') as json_file: + # tpCat_dict = json.load(json_file) + del json_file + del json_path + del json + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + del scratch_folder + del project_folder + del project_gdb + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # Get contact information + contacts_xml = ( + rf"{os.environ['USERPROFILE']}\Documents\ArcGIS\Descriptions\contacts.xml" + ) + contacts_xml_tree = etree.parse( + contacts_xml, + parser=etree.XMLParser(encoding="UTF-8", remove_blank_text=True), + ) # To parse from a string, use the fromstring() function instead. + del contacts_xml + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # Get Prefered contact information + mdContact_rpIndName = contact_dict["mdContact"][0]["rpIndName"] + mdContact_eMailAdd = contact_dict["mdContact"][0]["eMailAdd"] + mdContact_role = contact_dict["mdContact"][0]["role"] + + citRespParty_rpIndName = contact_dict["citRespParty"][0]["rpIndName"] + citRespParty_eMailAdd = contact_dict["citRespParty"][0]["eMailAdd"] + citRespParty_role = contact_dict["citRespParty"][0]["role"] + + idPoC_rpIndName = contact_dict["idPoC"][0]["rpIndName"] + idPoC_eMailAdd = contact_dict["idPoC"][0]["eMailAdd"] + idPoC_role = contact_dict["idPoC"][0]["role"] + + distorCont_rpIndName = contact_dict["distorCont"][0]["rpIndName"] + distorCont_eMailAdd = contact_dict["distorCont"][0]["eMailAdd"] + distorCont_role = contact_dict["distorCont"][0]["role"] + + srcCitatn_rpIndName = contact_dict["srcCitatn"][0]["rpIndName"] + srcCitatn_eMailAdd = contact_dict["srcCitatn"][0]["eMailAdd"] + srcCitatn_role = contact_dict["srcCitatn"][0]["role"] + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # print(etree.tostring(target_root, encoding='UTF-8', method='xml', pretty_print=True).decode()) + + dataset_md = md.Metadata(dataset_path) + dataset_md.synchronize("ALWAYS") + dataset_md.save() + dataset_md.reload() + dataset_md_xml = dataset_md.xml + del dataset_md + + # Parse the XML + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + target_tree = etree.parse(StringIO(dataset_md_xml), parser=parser) + target_root = target_tree.getroot() + del parser, dataset_md_xml + + CreaDate = target_root.xpath(f"//Esri/CreaDate")[0].text + CreaTime = target_root.xpath(f"//Esri/CreaTime")[0].text + # print(CreaDate, CreaTime) + CreaDateTime = f"{CreaDate[:4]}-{CreaDate[4:6]}-{CreaDate[6:]}T{CreaTime[:2]}:{CreaTime[2:4]}:{CreaTime[4:6]}" + # print(f"\tCreaDateTime: {CreaDateTime}") + # del CreaDateTime + del CreaDate, CreaTime + ModDate = target_root.xpath(f"//Esri/ModDate")[0].text + ModTime = target_root.xpath(f"//Esri/ModTime")[0].text + # print(ModDate, ModTime) + ModDateTime = f"{ModDate[:4]}-{ModDate[4:6]}-{ModDate[6:]}T{ModTime[:2]}:{ModTime[2:4]}:{ModTime[4:6]}" + # print(f"\tModDateTime: {ModDateTime}") + # del ModDateTime + del ModDate, ModTime + + dataset_name = os.path.basename(dataset_path) + print(f"Processing/Updating elements for dataset: '{dataset_name}'") + + xml_file = b""" + + + ISO 19139 Metadata Implementation Specification GML3.2 + ISO19139 + + + + + + + feature class name + feature class name + NMFS OST DisMAP + + + + + + + + + + + external + 810ad1c47a347c4bf5c88f2ea5077cd5d7a1bdcb + Timothy J Haverland + NMFS Office of Science and Technology + GIS App Developer + + + 1315 East West Highway + Silver Spring + MD + 20910-3282 + tim.haverland@noaa.gov + + + 301-427-8137 + 301-713-4137 + + 0700 - 1800 EST/EDT + + https://www.fisheries.noaa.gov/about/office-science-and-technology + REST Service + NMFS Office of Science and Technology + NOAA Fisheries Office of Science and Technology + + + + + + Timothy J Haverland + True + + + + + + + + + Global Change Master Directory (GCMD) Science Keywords + + + + + + + https://www.fisheries.noaa.gov/inport/help/components/keywords + REST Service + GCMD + Global Change Master Directory (GCMD) Science Keywords + + + + + + + + + + + + + + Global Change Master Directory (GCMD) Location Keywords + + + + + + + https://www.fisheries.noaa.gov/inport/help/components/keywords + REST Service + GCMD + Global Change Master Directory (GCMD) Location Keywords + + + + + + + + + + + + + + Global Change Master Directory (GCMD) Temporal Data Resolution Keywords + + + + + + + https://www.fisheries.noaa.gov/inport/help/components/keywords + REST Service + GCMD + Global Change Master Directory (GCMD) Temporal Data Resolution Keywords + + + + + + + + + + + + + + Integrated Taxonomic Information System (ITIS) + + + + + + + https://www.itits.org + REST Service + ITIS + Integrated Taxonomic Information System (ITIS) + + + + + + + + + + + external + c66ffbb333c48d18d81856ec0e0c37ea752bff1a + Melissa Ann Karp + NMFS Office of Science and Technology + Fisheries Science Coordinator + + + 1315 East West Hwy + Silver Spring + MD + 20910-3282 + melissa.karp@noaa.gov + US + + + 301-427-8202 + 301-713-4137 + + 0700 - 1800 EST/EDT + + https://www.fisheries.noaa.gov/about/office-science-and-technology + REST Service + NMFS Office of Science and Technology + NOAA Fisheries Office of Science and Technology + + + + + + Melissa Ann Karp + True + + + + + + + + + + + + + Data License: CC0-1.0 + Data License URL: https://creativecommons.org/publicdomain/zero/1.0/ + Data License Statement: These data were produced by NOAA and are not subject to copyright protection in the United States. NOAA waives any potential copyright and related rights in these data worldwide through the Creative Commons Zero 1.0 Universal Public Domain Dedication (CC0-1.0). + + + + + + FISMA Low + + + <DIV STYLE="text-align:Left;"><DIV><DIV><P><SPAN>***No Warranty*** The user assumes the entire risk related to its use of these data. NMFS is providing these data 'as is' and NMFS disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose. No warranty expressed or implied is made regarding the accuracy or utility of the data on any other system or for general or scientific purposes, nor shall the act of distribution constitute any such warranty. It is strongly recommended that careful attention be paid to the contents of the metadata file associated with these data to evaluate dataset limitations, restrictions or intended use. In no event will NMFS be liable to you or to any third party for any direct, indirect, incidental, consequential, special or exemplary damages or lost profit resulting from any use or misuse of these data.</SPAN></P></DIV></DIV></DIV> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + dataset + + + + Based on a review from DisMAP Team all necessary features are present. + + + + Conceptual Consistency Report + + NMFS OST DisMAP + + + + + + + Based on a review from DisMAP Team all necessary features are present. + 1 + + + + + Based on a review from DisMAP Team all necessary features are present. + + + + Completeness Report + + NMFS OST DisMAP + + + + + + + Based on a review from DisMAP Team all necessary features are present. + 1 + + + + + + + Data for 'region' 'version' + + + + + Source Citation for: + + NMFS OST DisMAP + + https://www.fisheries.noaa.gov/about/office-science-and-technology + REST Service + NMFS Office of Science and Technology + NOAA Fisheries Office of Science and Technology + + + + + + + + + + + document + + + + external + c66ffbb333c48d18d81856ec0e0c37ea752bff1a + Melissa Ann Karp + NMFS Office of Science and Technology + Fisheries Science Coordinator + + + 1315 East West Hwy + Silver Spring + MD + 20910-3282 + melissa.karp@noaa.gov + US + + + 301-427-8202 + 301-713-4137 + + 0700 - 1800 EST/EDT + + https://www.fisheries.noaa.gov/about/office-science-and-technology + REST Service + NMFS Office of Science and Technology + NOAA Fisheries Office of Science and Technology + + + + + + Melissa Ann Karp + True + + + + + + + + Geoprocessing Steps for 'region' 'version date' + + + external + c66ffbb333c48d18d81856ec0e0c37ea752bff1a + Melissa Ann Karp + NMFS Office of Science and Technology + Fisheries Science Coordinator + + + 1315 East West Hwy + Silver Spring + MD + 20910-3282 + melissa.karp@noaa.gov + US + + + 301-427-8202 + 301-713-4137 + + 0700 - 1800 EST/EDT + + https://www.fisheries.noaa.gov/about/office-science-and-technology + REST Service + NMFS Office of Science and Technology + NOAA Fisheries Office of Science and Technology + + + + + + Melissa Ann Karp + True + + + + + + external + b212accd6134b5457de3ed1debca061419d927ce + John F Kennedy + NMFS Office of Science and Technology + GIS Specialist + + + 1315 East West Highway + Silver Spring + MD + 20910-3282 + US + john.f.kennedy@noaa.gov + + + 301-427-8149 + 301-713-4137 + + 0930 - 2030 EST/EDT + + https://www.fisheries.noaa.gov/about/office-science-and-technology + REST Service + NMFS Office of Science and Technology + NOAA Fisheries Office of Science and Technology + + + + + + John F Kennedy + True + + + + + + DisMAP + + + + + + + + ESRI REST Service + + Uncompressed + + + + + external + 579ce2e21b888ac8f6ac1dac30f04cddec7a0d7c + NMFS Office of Science and Technology + NMFS Office of Science and Technology + GIS App Developer + + + 1315 East West Highway + Silver Spring + MD + 20910-3282 + US + tim.haverland@noaa.gov + + + 301-427-8137 + 301-713-4137 + + 0700 - 1800 EST/EDT + + https://www.fisheries.noaa.gov/about/office-science-and-technology + REST Service + NMFS Office of Science and Technology + NOAA Fisheries Office of Science and Technology + + + + + + NMFS Office of Science and Technology (Distributor) + True + + + + + + + MB + 8 + + https://services2.arcgis.com/C8EMgrsFcRFL6LrL/arcgis/rest/services/.../FeatureServer + ESRI REST Service + NMFS Office of Science and Technology + Dataset Feature Service + + + + + + + + external + b212accd6134b5457de3ed1debca061419d927ce + John F Kennedy + NMFS Office of Science and Technology + GIS Specialist + + + 1315 East West Highway + Silver Spring + MD + 20910-3282 + US + john.f.kennedy@noaa.gov + + + 301-427-8149 + 301-713-4137 + + 0930 - 2030 EST/EDT + + https://www.fisheries.noaa.gov/about/office-science-and-technology + REST Service + NMFS Office of Science and Technology + NOAA Fisheries Office of Science and Technology + + + + + + John F Kennedy (Metadata Author) + True + + + + + <.> + """ + + source_tree = etree.parse( + BytesIO(xml_file), etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + source_root = source_tree.getroot() + + # Merge Target wtih Source + target_source_merge = xml_tree_merge(target_root, source_root) + # print(etree.tostring(target_source_merge, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + # Merge Source wtih Target + source_target_merge = xml_tree_merge(target_source_merge, target_root) + # print(etree.tostring(source_target_merge, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + del target_source_merge + del source_tree, source_root, xml_file + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + dataset_md_xml = etree.tostring( + source_target_merge, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=False, + ) + + SaveBackXml = False + if SaveBackXml: + dataset_md = md.Metadata(dataset_path) + dataset_md.xml = dataset_md_xml + dataset_md.save() + dataset_md.synchronize("CREATED") + dataset_md.save() + # dataset_md.reload() + # dataset_md_xml = dataset_md.xml + del dataset_md + # Parse the XML + # _target_tree = etree.parse(StringIO(dataset_md_xml), parser=etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + # del dataset_md_xml + # print(etree.tostring(_target_tree, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + # del _target_tree + else: + pass + del SaveBackXml + del dataset_md_xml + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + + dataset_md = md.Metadata(dataset_path) + dataset_md.synchronize("ALWAYS") + dataset_md.save() + dataset_md.reload() + dataset_md_xml = dataset_md.xml + del dataset_md + + # Parse the XML + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + target_tree = etree.parse(StringIO(dataset_md_xml), parser=parser) + target_root = target_tree.getroot() + del parser, dataset_md_xml + + ## target_root.xpath("./distInfo/distFormat/formatName")[0].set('Sync', "FALSE") + ## target_root.xpath("./dataIdInfo/envirDesc")[0].set('Sync', "TRUE") + + ## for key in root_dict: + ## #print(key) + ## elem = target_root.find(f"./{key}") + ## if elem is not None and len(elem) > 0: + ## #print(elem.tag) + ## pass + ## del elem + ## del key + ## + ## # Root + ## mdTimeSt = target_root.find("./mdTimeSt") + ## #print(mdTimeSt) + ## if mdTimeSt is not None: + ## mdTimeSt.getparent().remove(mdTimeSt) + ## else: + ## pass + ## del mdTimeSt + + ## # Metadata + ## target_root[:] = sorted(target_root, key=lambda x: root_dict[x.tag]) + ## # Esri + ## Esri = target_root.xpath("./Esri")[0] + ## Esri[:] = sorted(Esri, key=lambda x: esri_dict[x.tag]) + ## #print(etree.tostring(Esri, encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del Esri + ## # dataIdInfo + ## dataIdInfo = target_root.xpath("./dataIdInfo")[0] + ## dataIdInfo[:] = sorted(dataIdInfo, key=lambda x: dataIdInfo_dict[x.tag]) + ## #print(etree.tostring(dataIdInfo, encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del dataIdInfo + ## # dqInfo + ## dqInfo = target_root.xpath("./dqInfo")[0] + ## dqInfo[:] = sorted(dqInfo, key=lambda x: dqInfo_dict[x.tag]) + ## #print(etree.tostring(dqInfo, encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del dqInfo + ## # distInfo + ## distInfo = target_root.xpath("./distInfo")[0] + ## distInfo[:] = sorted(distInfo, key=lambda x: distInfo_dict[x.tag]) + ## #print(etree.tostring(distInfo, encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del distInfo + # mdContact + # mdLang + # mdHrLv + # refSysInfo + # spatRepInfo + # spdoinfo + # eainfo + + ## enttyp = target_root.find("enttyp") + ## if enttyp is not None: + ## enttypd = enttyp.find("enttypd") + ## enttypds = enttyp.find("enttypds") + ## if enttypd is None: + ## _xml = "A collection of geographic features with the same geometry type." + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## enttyp.insert(0, _root) + ## del _root, _xml + ## else: + ## pass + ## if enttypds is None: + ## _xml = "Esri" + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## enttyp.insert(0, _root) + ## del _root, _xml + ## else: + ## pass + ## del enttypds, enttypd + ## else: + ## pass + ## del enttyp + + # idCredit completed + # for idCredit in target_root.xpath("./dataIdInfo/idCredit"): + # #print(etree.tostring(idCredit, encoding='UTF-8', method='xml', pretty_print=True).decode()) + # #idCredit.text = "NOAA Fisheries. 2025.." + # del idCredit + # print(etree.tostring(target_root.xpath("./dataIdInfo/idCredit")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + + ## # resTitle completed + ## resTitle = target_root.xpath("./dataIdInfo/idCitation/resTitle")[0] + ## target_root.xpath("./dqInfo/dataLineage/dataSource/srcCitatn/resTitle")[0].text = resTitle.text + ## #print(f"\tresTitle: {resTitle.text}") + ## #resTitle.text = f"" + ## del resTitle + ## resAltTitle = target_root.xpath("./dataIdInfo/idCitation/resAltTitle")[0] + ## target_root.xpath("./dqInfo/dataLineage/dataSource/srcCitatn/resAltTitle")[0].text = resAltTitle.text + ## #print(f"\tresAltTitle: {resAltTitle.text}") + ## #resAltTitle.text = f"" + ## del resAltTitle + ## collTitle = target_root.xpath("./dataIdInfo/idCitation/collTitle")[0] + ## #print(f"\tcollTitle: {collTitle.text}") + ## collTitle.text = "NMFS OST DisMAP" + ## target_root.xpath("./dqInfo/dataLineage/dataSource/srcCitatn/collTitle")[0].text = collTitle.text + ## #print(f"\tcollTitle: {collTitle.text}") + ## del collTitle + + ## resConst = target_root.xpath("./dataIdInfo/resConst") + ## if len(resConst) == 1: + ## xml_file = b''' + ## + ## + ## + ## + ## + ## + ## + ## Data License: CC0-1.0 + ##Data License URL: https://creativecommons.org/publicdomain/zero/1.0/ + ##Data License Statement: These data were produced by NOAA and are not subject to copyright protection in the United States. NOAA waives any potential copyright and related rights in these data worldwide through the Creative Commons Zero 1.0 Universal Public Domain Dedication (CC0-1.0). + ## + ## + ## + ## + ## + ## + ## FISMA Low + ## + ## + ## <DIV STYLE="text-align:Left;"><DIV><DIV><P><SPAN>***No Warranty*** The user assumes the entire risk related to its use of these data. NMFS is providing these data 'as is' and NMFS disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose. No warranty expressed or implied is made regarding the accuracy or utility of the data on any other system or for general or scientific purposes, nor shall the act of distribution constitute any such warranty. It is strongly recommended that careful attention be paid to the contents of the metadata file associated with these data to evaluate dataset limitations, restrictions or intended use. In no event will NMFS be liable to you or to any third party for any direct, indirect, incidental, consequential, special or exemplary damages or lost profit resulting from any use or misuse of these data.</SPAN></P></DIV></DIV></DIV> + ## + ## ''' + ## _tree = etree.parse(BytesIO(xml_file), etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## _root = _tree.getroot() + ## resConst[0].getparent().replace(resConst[0], _root) + ## del _root, _tree, xml_file + ## else: + ## pass + ## del resConst + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # discKeys, themeKeys, placeKeys, tempKeys + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # searchKeys = target_root.xpath("./dataIdInfo/searchKeys") + # for searchKey in searchKeys: + # #print(etree.tostring(searchKey, encoding='UTF-8', method='xml', pretty_print=True).decode()) + # del searchKey + # del searchKeys + ## searchKeys = target_root.xpath("./dataIdInfo/searchKeys") + ## for searchKey in searchKeys: + ## #print(etree.tostring(searchKey, encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## for keyword in searchKey.xpath("./keyword"): + ## if isinstance(keyword.text, type(None)): + ## keyword.getparent().remove(keyword) + ## else: + ## pass #print(etree.tostring(keyword, encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del searchKey + ## del searchKeys + ## target_root.xpath("./dataIdInfo/searchKeys/keyword")[0].text = f"{species_range_dict[dataset_name]['LISTENTITY']}; ESA; range; NMFS" + ## + ## keywords = target_root.xpath("./dataIdInfo/discKeys/keyword") + ## if keywords is not None and len(keywords) and len(keywords[0]) == 0: + ## keyword = target_root.xpath("./dataIdInfo/discKeys/keyword")[0] + ## keyword.text = f"{species_range_dict[dataset_name]['SCIENAME']}" + ## del keyword + ## #elif keywords is not None and len(keywords) and len(keywords[0]) >= 1: + ## # pass + ## del keywords + ## createDate = target_root.xpath("./dataIdInfo/discKeys/thesaName/date/createDate") + ## if createDate is not None and len(createDate) and len(createDate[0]) == 0: + ## target_root.xpath("./dataIdInfo/discKeys/thesaName/date/createDate")[0].text = CreaDateTime + ## elif createDate is not None and len(createDate) and len(createDate[0]) == 1: + ## pass + ## else: + ## pass + ## del createDate + ## pubDate = target_root.xpath("./dataIdInfo/discKeys/thesaName/date/pubDate") + ## if pubDate is not None and len(pubDate) and len(pubDate[0]) == 0: + ## target_root.xpath("./dataIdInfo/discKeys/thesaName/date/pubDate")[0].text = CreaDateTime + ## elif pubDate is not None and len(pubDate) and len(pubDate[0]) == 1: + ## pass + ## else: + ## pass + ## del pubDate + ## reviseDate = target_root.xpath("./dataIdInfo/discKeys/thesaName/date/reviseDate") + ## if reviseDate is not None and len(reviseDate) and len(reviseDate[0]) == 0: + ## target_root.xpath("./dataIdInfo/discKeys/thesaName/date/reviseDate")[0].text = ModDateTime + ## elif reviseDate is not None and len(reviseDate) and len(reviseDate[0]) == 1: + ## pass + ## else: + ## pass + ## del reviseDate + ## resTitle = target_root.xpath("./dataIdInfo/discKeys/thesaName/resTitle") + ## if resTitle is not None and len(resTitle) and len(resTitle[0]) == 0: + ## target_root.xpath("./dataIdInfo/discKeys/thesaName/resTitle")[0].text = "Integrated Taxonomic Information System (ITIS)" + ## elif resTitle is not None and len(resTitle) and len(resTitle[0]) == 1: + ## pass + ## else: + ## pass + ## del resTitle + ## discKeys = target_root.xpath("./dataIdInfo/discKeys") + ## for i in range(0, len(discKeys)): + ## #print(etree.tostring(discKeys[i], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del i + ## del discKeys + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## # themeKeys + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## keywords = target_root.xpath("./dataIdInfo/themeKeys/keyword") + ## if keywords is not None and len(keywords) and len(keywords[0]) == 0: + ## new_item_name = target_root.find("./Esri/DataProperties/itemProps/itemName").text + ## keyword = target_root.xpath("./dataIdInfo/themeKeys/keyword")[0] + ## keyword.text = f"{species_range_dict[dataset_name]['COMNAME'].title()}; {species_range_dict[dataset_name]['SCIENAME']}; Endangered Species; NMFS" + ## del keyword, new_item_name + ## elif keywords is not None and len(keywords) and len(keywords[0]) >= 1: + ## pass + ## del keywords + ## createDate = target_root.xpath("./dataIdInfo/themeKeys/thesaName/date/createDate") + ## if createDate is not None and len(createDate) and len(createDate[0]) == 0: + ## target_root.xpath("./dataIdInfo/themeKeys/thesaName/date/createDate")[0].text = CreaDateTime + ## elif createDate is not None and len(createDate) and len(createDate[0]) == 1: + ## pass + ## else: + ## pass + ## del createDate + ## pubDate = target_root.xpath("./dataIdInfo/themeKeys/thesaName/date/pubDate") + ## if pubDate is not None and len(pubDate) and len(pubDate[0]) == 0: + ## target_root.xpath("./dataIdInfo/themeKeys/thesaName/date/pubDate")[0].text = CreaDateTime + ## elif pubDate is not None and len(pubDate) and len(pubDate[0]) == 1: + ## pass + ## else: + ## pass + ## del pubDate + ## reviseDate = target_root.xpath("./dataIdInfo/themeKeys/thesaName/date/reviseDate") + ## if reviseDate is not None and len(reviseDate) and len(reviseDate[0]) == 0: + ## target_root.xpath("./dataIdInfo/themeKeys/thesaName/date/reviseDate")[0].text = ModDateTime + ## elif reviseDate is not None and len(reviseDate) and len(reviseDate[0]) == 1: + ## pass + ## else: + ## pass + ## del reviseDate + ## resTitle = target_root.xpath("./dataIdInfo/themeKeys/thesaName/resTitle") + ## if resTitle is not None and len(resTitle) and len(resTitle[0]) == 0: + ## target_root.xpath("./dataIdInfo/themeKeys/thesaName/resTitle")[0].text = "Global Change Master Directory (GCMD) Science Keyword" + ## elif resTitle is not None and len(resTitle) and len(resTitle[0]) == 1: + ## pass + ## else: + ## pass + ## del resTitle + ## themeKeys = target_root.xpath("./dataIdInfo/themeKeys") + ## for i in range(0, len(themeKeys)): + ## #print(etree.tostring(themeKeys[i], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del i + ## del themeKeys + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## # placeKeys + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## keywords = target_root.xpath("./dataIdInfo/placeKeys/keyword") + ## if keywords is not None and len(keywords) and len(keywords[0]) == 0: + ## new_item_name = target_root.find("./Esri/DataProperties/itemProps/itemName").text + ## keyword = target_root.xpath("./dataIdInfo/placeKeys/keyword")[0] + ## keyword.text = f"Enter place/geography keywords for {new_item_name}, separated by a semicolon" + ## del keyword, new_item_name + ## elif keywords is not None and len(keywords) and len(keywords[0]) >= 1: + ## pass + ## del keywords + ## createDate = target_root.xpath("./dataIdInfo/placeKeys/thesaName/date/createDate") + ## if createDate is not None and len(createDate) and len(createDate[0]) == 0: + ## target_root.xpath("./dataIdInfo/placeKeys/thesaName/date/createDate")[0].text = CreaDateTime + ## elif createDate is not None and len(createDate) and len(createDate[0]) == 1: + ## pass + ## else: + ## pass + ## del createDate + ## pubDate = target_root.xpath("./dataIdInfo/placeKeys/thesaName/date/pubDate") + ## if pubDate is not None and len(pubDate) and len(pubDate[0]) == 0: + ## target_root.xpath("./dataIdInfo/placeKeys/thesaName/date/pubDate")[0].text = CreaDateTime + ## elif pubDate is not None and len(pubDate) and len(pubDate[0]) == 1: + ## pass + ## else: + ## pass + ## del pubDate + ## reviseDate = target_root.xpath("./dataIdInfo/placeKeys/thesaName/date/reviseDate") + ## if reviseDate is not None and len(reviseDate) and len(reviseDate[0]) == 0: + ## target_root.xpath("./dataIdInfo/placeKeys/thesaName/date/reviseDate")[0].text = ModDateTime + ## elif reviseDate is not None and len(reviseDate) and len(reviseDate[0]) == 1: + ## pass + ## else: + ## pass + ## del reviseDate + ## resTitle = target_root.xpath("./dataIdInfo/placeKeys/thesaName/resTitle") + ## if resTitle is not None and len(resTitle) and len(resTitle[0]) == 0: + ## target_root.xpath("./dataIdInfo/placeKeys/thesaName/resTitle")[0].text = "Global Change Master Directory (GCMD) Location Keywords" + ## elif resTitle is not None and len(resTitle) and len(resTitle[0]) == 1: + ## pass + ## else: + ## pass + ## del resTitle + ## placeKeys = target_root.xpath("./dataIdInfo/placeKeys") + ## for i in range(0, len(placeKeys)): + ## #print(etree.tostring(placeKeys[i], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del i + ## del placeKeys + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## # tempKeys + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## keywords = target_root.xpath("./dataIdInfo/tempKeys/keyword") + ## if keywords is not None and len(keywords) and len(keywords[0]) == 0: + ## new_item_name = target_root.find("./Esri/DataProperties/itemProps/itemName").text + ## keyword = target_root.xpath("./dataIdInfo/tempKeys/keyword")[0] + ## keyword.text = f"Enter temporal keywords (e.g. year, year range, season, etc.) for {new_item_name}, separated by a semicolon" + ## del keyword, new_item_name + ## elif keywords is not None and len(keywords) and len(keywords[0]) >= 1: + ## pass + ## del keywords + ## createDate = target_root.xpath("./dataIdInfo/tempKeys/thesaName/date/createDate") + ## if createDate is not None and len(createDate) and len(createDate[0]) == 0: + ## target_root.xpath("./dataIdInfo/tempKeys/thesaName/date/createDate")[0].text = CreaDateTime + ## elif createDate is not None and len(createDate) and len(createDate[0]) == 1: + ## pass + ## else: + ## pass + ## del createDate + ## pubDate = target_root.xpath("./dataIdInfo/tempKeys/thesaName/date/pubDate") + ## if pubDate is not None and len(pubDate) and len(pubDate[0]) == 0: + ## target_root.xpath("./dataIdInfo/tempKeys/thesaName/date/pubDate")[0].text = CreaDateTime + ## elif pubDate is not None and len(pubDate) and len(pubDate[0]) == 1: + ## pass + ## else: + ## pass + ## del pubDate + ## reviseDate = target_root.xpath("./dataIdInfo/tempKeys/thesaName/date/reviseDate") + ## if reviseDate is not None and len(reviseDate) and len(reviseDate[0]) == 0: + ## target_root.xpath("./dataIdInfo/tempKeys/thesaName/date/reviseDate")[0].text = ModDateTime + ## elif reviseDate is not None and len(reviseDate) and len(reviseDate[0]) == 1: + ## pass + ## else: + ## pass + ## del reviseDate + ## resTitle = target_root.xpath("./dataIdInfo/tempKeys/thesaName/resTitle") + ## if resTitle is not None and len(resTitle) and len(resTitle[0]) == 0: + ## target_root.xpath("./dataIdInfo/tempKeys/thesaName/resTitle")[0].text = "Global Change Master Directory (GCMD) Temporal Data Resolution Keywords" + ## elif resTitle is not None and len(resTitle) and len(resTitle[0]) == 1: + ## pass + ## else: + ## pass + ## del resTitle + ## tempKeys = target_root.xpath("./dataIdInfo/tempKeys") + ## for i in range(0, len(tempKeys)): + ## #print(etree.tostring(tempKeys[i], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del i + ## del tempKeys + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## # Data Extent + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## dataExt = target_root.xpath("./dataIdInfo/dataExt")[0] + ## exDesc = dataExt.xpath("//exDesc") + ## if len(exDesc) == 0: + ## _xml = "[Location extent description]. The data represents an approximate distribution of the listed entity based on the best available information from [date of first source] to [date of final species expert review]." + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## dataExt.insert(0, _root) + ## del _root, _xml + ## elif len(exDesc) == 1: + ## exDesc[0].text = "[Location extent description]. The data represents an approximate distribution of the listed entity based on the best available information from [date of first source] to [date of final species expert review]." + ## else: + ## pass + ## del exDesc + ## tempEle = dataExt.xpath("//tempEle") + ## if len(tempEle) == 0: + ## _xml = f' \ + ## {CreaDateTime}{ModDateTime} \ + ## {ModDateTime}' + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## dataExt.insert(2, _root) + ## del _root, _xml + ## elif len(tempEle) == 1: + ## _xml = f' \ + ## {CreaDateTime}{ModDateTime} \ + ## {ModDateTime}' + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## tempEle[0].getparent().replace(tempEle[0], _root) + ## del _root, _xml + ## del tempEle + ## del dataExt + # dataExt = target_root.xpath("./dataIdInfo/dataExt") + # for i in range(0, len(dataExt)): + # #print(etree.tostring(dataExt[i], encoding='UTF-8', method='xml', pretty_print=True).decode()) + # del i + # del dataExt + # dataExt = target_root.xpath("./dataIdInfo/dataExt") + # for i in range(1, len(dataExt)): + # dataExt[i].getparent().remove(dataExt[i]) + # del i + # del dataExt + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## #target_root.xpath("./dqInfo/dqScope/scpLvl/ScopeCd")[0].set('value', "005") + ## PresFormCd = target_root.xpath("./dataIdInfo/idCitation/presForm/PresFormCd")[0] + ## fgdcGeoform = target_root.xpath("./dataIdInfo/idCitation/presForm/fgdcGeoform")[0] + ## SpatRepTypCd = target_root.xpath("./dataIdInfo/spatRpType/SpatRepTypCd")[0] + ## PresFormCd.set('Sync', "TRUE") + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## # SpatRepTypCd "Empty" "001" (vector) "002" (raster/grid) "003" (tabular) + ## # PresFormCd "005" "003" "011" + ## # fgdcGeoform "vector data" "raster data" "tabular data" + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## datasetSet = target_root.xpath("./dqInfo/dqScope/scpLvlDesc/datasetSet")[0] + ## if SpatRepTypCd.get("value") == "001": + ## PresFormCd.set("value", "005") + ## fgdcGeoform.text = "vector digital data" + ## datasetSet.text = "Vector Digital Data" + ## elif SpatRepTypCd.get("value") == "002": + ## PresFormCd.set("value", "003") + ## fgdcGeoform.text = "raster digital data" + ## datasetSet.text = "Raster Digital Data" + ## elif SpatRepTypCd.get("value") == "003": + ## PresFormCd.set("value", "011") + ## fgdcGeoform.text = "tabular digital data" + ## datasetSet.text = "Tabular Digital Data" + ## else: + ## pass + ## #print("------" * 10) + ## #print(etree.tostring(SpatRepTypCd, encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## #print(etree.tostring(target_root.xpath("./dataIdInfo/idCitation/presForm")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## #print(etree.tostring(target_root.xpath("./dqInfo/dqScope")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## #print("------" * 10) + ## del datasetSet, SpatRepTypCd, fgdcGeoform, PresFormCd + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## formatName = target_root.xpath("./distInfo/distFormat/formatName")[0] + ## envirDesc = target_root.xpath("./dataIdInfo/envirDesc")[0] + ## envirDesc.set('Sync', "TRUE") + ## target_root.xpath("./distInfo/distFormat/fileDecmTech")[0].text = "Uncompressed" + ## # # 001 = Vector + ## #''' # 002 = Grid + ## # # 003 = Text Table + ## #''' + ## #format_name_text = "" + ## #try: + ## # GeoObjTypCd = target_root.xpath("./spatRepInfo/VectSpatRep/geometObjs/geoObjTyp/GeoObjTypCd")[0].get("value") + ## # if GeoObjTypCd == "002": + ## # format_name_text = "ESRI File Geodatabase" + ## # del GeoObjTypCd + ## #except: + ## # format_name_text = "ESRI Geodatabase Table" + ## formatName.text = "ESRI REST Service" + ## formatVer_text = str.rstrip(str.lstrip(envirDesc.text)) + ## formatVer = target_root.xpath("./distInfo/distFormat/formatVer")[0] + ## formatVer.text = str.rstrip(str.lstrip(formatVer_text)) + ## del formatVer_text + ## del envirDesc + ## del formatVer + ## del formatName + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## mdFileID = target_root.xpath(f"//mdFileID") + ## if mdFileID is not None and len(mdFileID) == 0: + ## _xml = 'gov.noaa.nmfs.inport:' + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## target_root.insert(root_dict['mdFileID'], _root) + ## del _root, _xml + ## elif mdFileID is not None and len(mdFileID) and len(mdFileID[0]) == 0: + ## mdFileID[0].text = "gov.noaa.nmfs.inport:" + ## elif mdFileID is not None and len(mdFileID) and len(mdFileID[0]) == 1: + ## pass + ## #print(etree.tostring(mdFileID[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del mdFileID + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## mdMaint = target_root.xpath(f"//mdMaint") + ## if mdMaint is not None and len(mdMaint) == 0: + ## _xml = '' + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## target_root.insert(root_dict['mdMaint'], _root) + ## del _root, _xml + ## elif mdMaint is not None and len(mdMaint) and len(mdMaint[0]) == 0: + ## target_root.xpath("./mdMaint/maintFreq/MaintFreqCd")[0].attrib["value"] = "009" + ## elif mdMaint is not None and len(mdMaint) and len(mdMaint[0]) == 1: + ## pass #print(etree.tostring(mdMaint[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## else: + ## pass + ## #print(etree.tostring(mdMaint[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del mdMaint + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## distorTran = target_root.xpath("//distorTran") + ## for _distorTran in distorTran: + ## _distorTran.tag = "distTranOps" + ## del _distorTran + ## del distorTran + + ## distTranOps = target_root.xpath("//distTranOps") + ## for i in range(0, len(distTranOps)): + ## if i == 0: + ## xml_file = b''' + ## MB + ## 0 + ## + ## https://services2.arcgis.com/C8EMgrsFcRFL6LrL/arcgis/rest/services/.../FeatureServer + ## ESRI REST Service + ## NMFS Office of Science and Technology + ## Dataset Feature Service + ## + ## + ## + ## + ## ''' + ## _tree = etree.parse(BytesIO(xml_file), etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## _root = _tree.getroot() + ## distTranOps[i].getparent().replace(distTranOps[i], _root) + ## del _root, _tree, xml_file + ## elif i > 0: + ## distTranOps[i].getparent().remove(distTranOps[i]) + ## else: + ## pass + ## del i + ## del distTranOps + # print(etree.tostring(target_root.xpath("./distInfo")[0], encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + # print(etree.tostring(target_root.xpath("./Esri/DataProperties/itemProps")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## new_item_name = target_root.find("./Esri/DataProperties/itemProps/itemName").text + ## new_item_name = new_item_name.replace("IDW_Sample_Locations", "Sample_Locations") if "Sample_Locations" in new_item_name else new_item_name + ## onLineSrcs = target_root.findall("./distInfo/distTranOps/onLineSrc") + ## for onLineSrc in onLineSrcs: + ## if onLineSrc.find('./protocol').text == "ESRI REST Service": + ## old_linkage_element = onLineSrc.find('./linkage') + ## old_linkage = old_linkage_element.text + ## #print(old_linkage, flush=True) + ## old_item_name = old_linkage[old_linkage.find("/services/")+len("/services/"):old_linkage.find("/FeatureServer")] + ## new_linkage = old_linkage.replace(old_item_name, f"{new_item_name}_{date_code(project)}") + ## #print(new_linkage, flush=True) + ## old_linkage_element.text = new_linkage + ## #print(old_linkage_element.text, flush=True) + ## del old_linkage_element + ## del old_item_name, old_linkage, new_linkage + ## else: + ## pass + ## del onLineSrc + ## del onLineSrcs, new_item_name + ## #print(etree.tostring(target_root.xpath("./distInfo")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + + ## xml_file = b''' + ## + ## external + ## 579ce2e21b888ac8f6ac1dac30f04cddec7a0d7c + ## NMFS Office of Science and Technology + ## NMFS Office of Science and Technology + ## GIS App Developer + ## + ## + ## 1315 East West Highway + ## Silver Spring + ## MD + ## 20910-3282 + ## US + ## tim.haverland@noaa.gov + ## + ## + ## 301-427-8137 + ## 301-713-4137 + ## + ## 0700 - 1800 EST/EDT + ## + ## https://www.fisheries.noaa.gov/about/office-science-and-technology + ## REST Service + ## NMFS Office of Science and Technology + ## NOAA Fisheries Office of Science and Technology + ## + ## + ## + ## + ## + ## NMFS Office of Science and Technology (Distributor) + ## True + ## + ## + ## + ## + ## + ## ''' + ## _tree = etree.parse(BytesIO(xml_file), etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## _root = _tree.getroot() + ## distributor = target_root.xpath(f"./distInfo/distributor")[0] + ## distributor.getparent().replace(distributor, _root) + ## del _root, _tree, xml_file + ## #print(f"\n\t{etree.tostring(target_root.xpath(f'./distInfo/distributor')[0], encoding='UTF-8', method='xml', pretty_print=True).decode()}\n") + ## del distributor + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # statement + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## statement = target_root.xpath("./dqInfo/dataLineage/statement") + ## if statement is not None and len(statement) == 0: + ## pass # Need to insert statement + ## elif statement is not None and len(statement) and len(statement[0]) == 0: + ## target_root.xpath("./dqInfo/dataLineage/statement")[0].text = "Need to update datalienage statement" + ## elif statement is not None and len(statement) and len(statement[0]) == 1: + ## pass + ## elif statement is not None and len(statement) and len(statement[0]) >= 1: + ## pass + ## else: + ## pass + ## #print(f"\n\t{etree.tostring(statement[0], encoding='UTF-8', method='xml', pretty_print=True).decode()}\n") + ## del statement + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## # srcDesc + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## srcDesc = target_root.xpath("./dqInfo/dataLineage/dataSource/srcDesc") + ## if srcDesc is not None and len(srcDesc) == 0: + ## pass # Need to insert srcDesc + ## elif srcDesc is not None and len(srcDesc) and len(srcDesc[0]) == 0: + ## target_root.xpath("./dqInfo/dataLineage/dataSource/srcDesc")[0].text = "Need to update srcDesc" + ## elif srcDesc is not None and len(srcDesc) and len(srcDesc[0]) == 1: + ## pass + ## elif srcDesc is not None and len(srcDesc) and len(srcDesc[0]) >= 1: + ## pass + ## else: + ## pass + ## #print(f"\n\t{etree.tostring(srcDesc[0], encoding='UTF-8', method='xml', pretty_print=True).decode()}\n") + ## del srcDesc + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # prcStep + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## stepProcs = target_root.xpath("./dqInfo/dataLineage/prcStep/stepProc") + ## for stepProc in stepProcs: + ## rpIndName = stepProc.find("rpIndName") + ## if rpIndName is None: + ## stepProc.getparent().remove(stepProc) + ## else: + ## pass + ## del rpIndName + ## #print(f"{etree.tostring(stepProc, encoding='UTF-8', method='xml', pretty_print=True).decode()}") + ## del stepProc + ## del stepProcs + + ## _report = target_root.xpath(f"./dqInfo/report[@type='DQConcConsis']") + ## if len(_report) == 1: + ## _xml = ''' + ## Based on a review from DisMAP Team all necessary features are present. + ## + ## + ## + ## Conceptual Consistency Report + ## + ## NMFS OST DisMAP + ## + ## + ## + ## + ## + ## + ## Based on a review from DisMAP Team all necessary features are present. + ## 1 + ## + ## + ## ''' + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## #print(f"{etree.tostring(_root, encoding='UTF-8', method='xml', pretty_print=True).decode()}") + ## #raise SystemExit + ## _report[0].getparent().replace(_report[0], _root) + ## del _root, _xml + ## else: + ## pass + ## del _report + ## + ## _report = target_root.xpath(f"./dqInfo/report[@type='DQCompOm']") + ## if len(_report) == 1: + ## _xml = ''' + ## Based on a review from DisMAP Team all necessary features are present. + ## + ## + ## + ## Completeness Report + ## + ## NMFS OST DisMAP + ## + ## + ## + ## + ## + ## + ## Based on a review from DisMAP Team all necessary features are present. + ## 1 + ## + ## + ## ''' + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## _report[0].getparent().replace(_report[0], _root) + ## del _root, _xml + ## else: + ## pass + ## del _report + + ## prcStep = target_root.xpath("./dqInfo/dataLineage/prcStep") + ## #print(len(prcStep)) + ## if prcStep is not None and len(prcStep) == 0: + ## pass + ## #print("prcStep missing") + ## elif prcStep is not None and len(prcStep) and len(prcStep[0]) == 0: + ## #print("found empty element prcStep. Now adding content.") + ## target_root.xpath("./dqInfo/dataLineage/prcStep")[0].text = "Update Metadata 2025" + ## elif prcStep is not None and len(prcStep) and len(prcStep[0]) >= 1: + ## for i in range(0, len(prcStep)): + ## stepDesc = prcStep[i].xpath("./stepDesc")[0] + ## if stepDesc.text == "pre-Update Metadata 2025": + ## prcStep[i].xpath("./stepDateTm")[0].text = CreaDateTime + ## elif stepDesc.text == "Update Metadata 2025": + ## prcStep[i].xpath("./stepDateTm")[0].text = ModDateTime + ## elif stepDesc.text not in ["pre-Update Metadata 2025", "Update Metadata 2025"]: + ## prcStep[i].xpath("./stepDateTm")[0].text = CreaDateTime + ## del stepDesc + ## del i + ## else: + ## pass + ## del prcStep + + # srcDesc = target_root.xpath("./dqInfo/dataLineage/dataSource/srcDesc") + # for _srcDesc in srcDesc: + # #print(f"\t{etree.tostring(_srcDesc, encoding='UTF-8', method='xml', pretty_print=True).decode()}") + # del _srcDesc + # del srcDesc + # print(etree.tostring(reports[0].getparent(), encoding='UTF-8', method='xml', pretty_print=True).decode()) + # del dataSources + # dataLineage = target_root.xpath("./dqInfo/dataLineage") + # for i in range(0, len(dataLineage)): + # #print(etree.tostring(dataLineage[i], encoding='UTF-8', method='xml', pretty_print=True).decode()) + # del i + # del dataLineage + # distInfo = target_root.xpath("./distInfo")[0] + # print(etree.tostring(distInfo, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + # del distInfo + + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## # Reorder Elements + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## # Metadata + ## target_root[:] = sorted(target_root, key=lambda x: root_dict[x.tag]) + ## # Esri + ## Esri = target_root.xpath("./Esri")[0] + ## Esri[:] = sorted(Esri, key=lambda x: esri_dict[x.tag]) + ## #print(etree.tostring(Esri, encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del Esri + ## # dataIdInfo + ## dataIdInfo = target_root.xpath("./dataIdInfo")[0] + ## dataIdInfo[:] = sorted(dataIdInfo, key=lambda x: dataIdInfo_dict[x.tag]) + ## #print(etree.tostring(dataIdInfo, encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del dataIdInfo + ## # dqInfo + ## dqInfo = target_root.xpath("./dqInfo")[0] + ## dqInfo[:] = sorted(dqInfo, key=lambda x: dqInfo_dict[x.tag]) + ## #print(etree.tostring(dqInfo, encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del dqInfo + ## # distInfo + ## distInfo = target_root.xpath("./distInfo")[0] + ## distInfo[:] = sorted(distInfo, key=lambda x: distInfo_dict[x.tag]) + ## #print(etree.tostring(distInfo, encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## del distInfo + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # print(etree.tostring(target_tree, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + etree.indent(target_tree, space=" ") + dataset_md_xml = etree.tostring( + target_tree, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + + SaveBackXml = False + if SaveBackXml: + dataset_md = md.Metadata(dataset_path) + dataset_md.xml = dataset_md_xml + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + # _target_tree = etree.parse(StringIO(dataset_md.xml), parser=etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + # _target_tree.write(rf"{export_folder}\{dataset_name}.xml", pretty_print=True) + # print(etree.tostring(_target_tree, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + # del _target_tree + del dataset_md + else: + pass + del SaveBackXml + del dataset_md_xml + + # Declared Variables + del project + del contacts_xml_tree + del source_target_merge + del export_folder + del mdContact_rpIndName, mdContact_eMailAdd, mdContact_role + del citRespParty_rpIndName, citRespParty_eMailAdd, citRespParty_role + del idPoC_rpIndName, idPoC_eMailAdd, idPoC_role + del distorCont_rpIndName, distorCont_eMailAdd, distorCont_role + del srcCitatn_rpIndName, srcCitatn_eMailAdd, srcCitatn_role + del dataset_name + del CreaDateTime, ModDateTime + del contact_dict + # del RoleCd_dict, tpCat_dict, + del dataIdInfo_dict, dqInfo_dict, distInfo_dict, esri_dict, root_dict + # Imports + del etree, md, BytesIO, StringIO, copy + # Declared variables + del target_root, target_tree + # Function Parameters + del dataset_path + + except KeyboardInterrupt: + raise SystemExit + except SystemExit: + raise SystemExit + except: + traceback.print_exc() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def add_update_dates(dataset_path=""): + try: + # Imports + import copy + from io import BytesIO, StringIO + + from arcpy import metadata as md + from lxml import etree + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + # print(dataset_path) + dataset_name = os.path.basename(dataset_path) + print(f"Processing Add/Update Dates for dataset: '{dataset_name}'") + # print(f"\tDataset Location: {os.path.basename(os.path.dirname(dataset_path))}") + + dataset_md = md.Metadata(dataset_path) + dataset_md.synchronize("ALWAYS") + dataset_md.save() + dataset_md.reload() + dataset_md_xml = dataset_md.xml + del dataset_md + + # Parse the XML + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + target_tree = etree.parse(StringIO(dataset_md_xml), parser=parser) + target_root = target_tree.getroot() + del parser, dataset_md_xml + + CreaDate = target_root.xpath(f"//Esri/CreaDate")[0].text + CreaTime = target_root.xpath(f"//Esri/CreaTime")[0].text + # print(CreaDate, CreaTime) + CreaDateTime = f"{CreaDate[:4]}-{CreaDate[4:6]}-{CreaDate[6:]}T{CreaTime[:2]}:{CreaTime[2:4]}:{CreaTime[4:6]}" + # print(f"\tCreaDateTime: {CreaDateTime}") + # del CreaDateTime + del CreaDate, CreaTime + ModDate = target_root.xpath(f"//Esri/ModDate")[0].text + ModTime = target_root.xpath(f"//Esri/ModTime")[0].text + # print(ModDate, ModTime) + ModDateTime = f"{ModDate[:4]}-{ModDate[4:6]}-{ModDate[6:]}T{ModTime[:2]}:{ModTime[2:4]}:{ModTime[4:6]}" + # print(f"\tModDateTime: {ModDateTime}") + # del ModDateTime + del ModDate, ModTime + + dates = target_tree.xpath(f"//date") + count = 0 + count_dates = len(dates) + for date in dates: + # _date = copy.deepcopy(date) + count += 1 + + createDate = date.xpath(f"./createDate") + # print(f"Element list: '{createDate}'") + # print(f"Element count: '{len(createDate)}'") + # print(len(createDate[0].text)) + # print(type(createDate[0].text)) + if not len(createDate): + _xml = f"{CreaDateTime}" + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + date.insert(0, _root) + del _root, _xml + elif len(createDate) and createDate[0].text is not None: + pass + # print(f"createDate exists and has content '{createDate[0].text}'") + # print(etree.tostring(createDate[0], encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + elif len(createDate) and createDate[0].text is None: + # print(f"createDate exists and but does not have content.") + createDate[0].text = CreaDateTime + date.insert(0, createDate[0]) + del createDate + + pubDate = date.xpath(f"./pubDate") + if not len(pubDate): + _xml = f"{CreaDateTime}" + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + date.insert(0, _root) + del _root, _xml + if len(pubDate) and pubDate[0].text is not None: + pass + # print(f"pubDate exists and has content '{pubDate[0].text}'") + # print(etree.tostring(pubDate[0], encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + elif len(pubDate) and pubDate[0].text is None: + # print(f"pubDate exists and but does not have content.") + pubDate[0].text = CreaDateTime + date.insert(1, pubDate[0]) + del pubDate + + reviseDate = date.xpath(f"./reviseDate") + if not len(reviseDate): + _xml = f"{ModDateTime}" + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + date.insert(0, _root) + del _root, _xml + if len(reviseDate) and reviseDate[0].text is not None: + pass + # print(f"reviseDate exists and has content '{reviseDate[0].text}'") + # print(etree.tostring(reviseDate[0], encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + elif len(reviseDate) and reviseDate[0].text is None: + # print(f"reviseDate exists and but does not have content.") + reviseDate[0].text = ModDateTime + date.insert(2, reviseDate[0]) + del reviseDate + + ## if len(createDate) == 0: + ## _xml = f"{CreaDateTime}" + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## date.insert(0, _root) + ## del _root, _xml + ## elif len(createDate) == 1: + ## if createDate[0].text: + ## createDate[0].text = createDate[0].text + ## elif not createDate[0].text: + ## createDate[0].text = CreaDateTime + ## else: + ## pass + ## else: + ## pass + # print(etree.tostring(createDate[0], encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + ## pubDate = date.xpath(f"./date/pubDate") + ## if len(pubDate) == 0: + ## _xml = f"{CreaDateTime}" + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## date.insert(0, _root) + ## del _root, _xml + ## elif len(pubDate) == 1: + ## if pubDate[0].text: + ## pubDate[0].text = pubDate[0].text + ## elif not pubDate[0].text: + ## pubDate[0].text = CreaDateTime + ## else: + ## pass + ## else: + ## pass + ## del pubDate + ## + ## try: + ## revisedDate = date.xpath(f"./date/revisedDate")[0] + ## revisedDate.tag = "reviseDate" + ## del revisedDate + ## except: + ## pass + ## + ## reviseDate = date.xpath(f"./date/reviseDate") + ## if len(reviseDate) == 0: + ## _xml = f"{CreaDateTime}" + ## _root = etree.XML(_xml, etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + ## date.insert(0, _root) + ## del _root, _xml + ## elif len(reviseDate) == 1: + ## if reviseDate[0].text: + ## reviseDate[0].text = reviseDate[0].text + ## elif not reviseDate[0].text: + ## reviseDate[0].text = ModDateTime + ## else: + ## pass + ## else: + ## pass + ## del reviseDate + + ## date.getparent().replace(date, _date) + + # print(etree.tostring(date, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + + del date + del count, count_dates + del dates + + dates = target_root.xpath(f"//date") + count = 0 + count_dates = len(dates) + for date in dates: + count += 1 + # print(f"\tDate: {count} of {count_dates}") + # print(f"\t\tCreaDateTime: {CreaDateTime}") + # print(f"\t\tModDateTime: {ModDateTime}") + # print(date.getroottree().getpath(date)) + # print(etree.tostring(date, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + del date + del count, count_dates + del dates + + # No changes needed below + # print(etree.tostring(target_tree, encoding='UTF-8', method='xml', pretty_print=True).decode()) + etree.indent(target_root, space=" ") + dataset_md_xml = etree.tostring( + target_tree, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + + SaveBackXml = True + if SaveBackXml: + dataset_md = md.Metadata(dataset_path) + dataset_md.xml = dataset_md_xml + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + # dataset_md.reload() + del dataset_md + else: + pass + del SaveBackXml + del dataset_md_xml + + del dataset_name, target_tree, target_root + + # Declared Variables + del CreaDateTime, ModDateTime + # Imports + del etree, StringIO, BytesIO, copy, md + # Function Parameters + del dataset_path + + except KeyboardInterrupt: + raise SystemExit + except Exception: + traceback.print_exc() + except: + traceback.print_exc() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def basic_metadata_report(dataset_path=""): + try: + # Imports + import copy + from io import BytesIO, StringIO + + from arcpy import metadata as md + from lxml import etree + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + project_gdb = os.path.dirname(dataset_path) + project_folder = os.path.dirname(project_gdb) + project = os.path.basename(os.path.dirname(project_gdb)) + export_folder = rf"{project_folder}\Export" + scratch_folder = rf"{project_folder}\Scratch" + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + del scratch_folder + del project_folder + del project_gdb + + # print(dataset_path) + dataset_name = os.path.basename(dataset_path) + print(f"Reporting on Basic XML Metadata for dataset: '{dataset_name}'") + # print(f"\tDataset Location: {os.path.basename(os.path.dirname(dataset_path))}") + + dataset_md = md.Metadata(dataset_path) + # dataset_md.synchronize("ALWAYS") + # dataset_md.save() + # dataset_md.reload() + dataset_md_xml = dataset_md.xml + del dataset_md + + # Parse the XML + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + target_tree = etree.parse(StringIO(dataset_md_xml), parser=parser) + target_root = target_tree.getroot() + del parser, dataset_md_xml + + dataset_md = md.Metadata(dataset_path) + print(f"\tTitle: {dataset_md.title}") + print(f"\tSearch Keys: {dataset_md.tags}") + print(f"\tSummary: {dataset_md.summary}") + print(f"\tDescription: {dataset_md.description}") + print(f"\tCredits: {dataset_md.credits}") + print(f"\tUse Limits: {dataset_md.accessConstraints}") + del dataset_md + + # No changes needed below + # print(etree.tostring(target_tree, encoding='UTF-8', method='xml', pretty_print=True).decode()) + etree.indent(target_root, space=" ") + dataset_md_xml = etree.tostring( + target_tree, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + + SaveBackXml = True + if SaveBackXml: + dataset_md = md.Metadata(dataset_path) + dataset_md.xml = dataset_md_xml + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + # dataset_md.reload() + del dataset_md + else: + pass + del SaveBackXml + del dataset_md_xml + + # Declared Varaiables + del project, export_folder + del dataset_name + del target_tree, target_root + # Imports + del etree, StringIO, BytesIO, copy, md + # Function Parameters + del dataset_path + except KeyboardInterrupt: + raise SystemExit + except: + traceback.print_exc() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def metadata_esri_report(dataset_path=""): + try: + # Imports + import copy + from io import BytesIO, StringIO + + from arcpy import metadata as md + from lxml import etree + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + # print(dataset_path) + dataset_name = os.path.basename(dataset_path) + print(f"Reporting on Esri XML for dataset: '{dataset_name}'") + # print(f"\tDataset Location: {os.path.basename(os.path.dirname(dataset_path))}") + + dataset_md = md.Metadata(dataset_path) + # dataset_md.synchronize("ALWAYS") + # dataset_md.save() + # dataset_md.reload() + dataset_md_xml = dataset_md.xml + del dataset_md + + # Parse the XML + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + target_tree = etree.parse(StringIO(dataset_md_xml), parser=parser) + target_root = target_tree.getroot() + del parser, dataset_md_xml + + if target_root.find("Esri") is not None: + Esri = target_root.xpath("./Esri")[0] + _xml = """ + ISO 19139 Metadata Implementation Specification GML3.2 + ISO19139 + + + + """ + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + # Merge Target wtih Source + target_source_merge = xml_tree_merge(Esri, _root) + # print(etree.tostring(target_source_merge, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + # Merge Source wtih Target + source_target_merge = xml_tree_merge(target_source_merge, Esri) + # print(etree.tostring(source_target_merge, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + Esri.getparent().replace(Esri, source_target_merge) + del target_source_merge, source_target_merge + del _root, _xml + # print(etree.tostring(target_root.find("Esri"), encoding='UTF-8', method='xml', pretty_print=True).decode()) + del Esri + else: + pass + + # No changes needed below + # print(etree.tostring(target_tree, encoding='UTF-8', method='xml', pretty_print=True).decode()) + etree.indent(target_root, space=" ") + dataset_md_xml = etree.tostring( + target_tree, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + + SaveBackXml = True + if SaveBackXml: + dataset_md = md.Metadata(dataset_path) + dataset_md.xml = dataset_md_xml + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + # dataset_md.reload() + del dataset_md + else: + pass + del SaveBackXml + del dataset_md_xml + + # Declared Varaiables + del dataset_name + del target_tree, target_root + # Imports + del etree, StringIO, BytesIO, copy, md + # Function Parameters + del dataset_path + except KeyboardInterrupt: + raise SystemExit + except: + traceback.print_exc() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def metadata_dataidinfo_report(dataset_path=""): + try: + # Imports + import copy + from io import BytesIO, StringIO + + from arcpy import metadata as md + from lxml import etree + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + import json + + json_path = rf"{project_folder}\dataIdInfo_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + dataIdInfo_dict = json.load(json_file) + del json_file + del json_path + json_path = rf"{project_folder}\root_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + root_dict = json.load(json_file) + del json_file + del json_path + del json + + # print(dataset_path) + dataset_name = os.path.basename(dataset_path) + print(f"Reporting on dataIdInfo XML for dataset: '{dataset_name}'") + # print(f"\tDataset Location: {os.path.basename(os.path.dirname(dataset_path))}") + + dataset_md = md.Metadata(dataset_path) + dataset_md.synchronize("ALWAYS") + dataset_md.save() + dataset_md.reload() + dataset_md_xml = dataset_md.xml + del dataset_md + + # Parse the XML + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + target_tree = etree.parse(StringIO(dataset_md_xml), parser=parser) + target_root = target_tree.getroot() + del parser, dataset_md_xml + + # target_root[:] = sorted(target_root, key=lambda x: root_dict[x.tag]) + # for child in target_root: + # #print(child.tag) + # #print(etree.tostring(child, encoding='UTF-8', method='xml', pretty_print=True).decode()) + # del child + # Esri + # dataIdInfo + # dqInfo + # distInfo + # mdContact + # mdLang + # mdChar + # mdDateSt + # mdHrLv + # mdHrLvName + # mdFileID + # mdMaint + # refSysInfo + # spatRepInfo + # spdoinfo + # eainfo + + refSysInfo = target_root.xpath("./refSysInfo") + if len(refSysInfo) == 0: + pass # print("missing") + elif len(refSysInfo) == 1: + pass # print(etree.tostring(target_root.xpath("./refSysInfo")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + elif len(refSysInfo) > 1: + pass # print("too many") + else: + pass + del refSysInfo + + dqInfo = target_root.xpath("./dqInfo") + if len(dqInfo) == 0: + _xml = """ + + + + + + dataset + + + + """ + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + target_root.insert(root_dict["dqInfo"], _root) + del _root, _xml + else: + pass + del dqInfo + + mdHrLv = target_root.xpath("./mdHrLv") + if len(mdHrLv) == 0: + _xml = """ + + + """ + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + target_root.insert(root_dict["mdHrLv"], _root) + del _root, _xml + else: + pass + del mdHrLv + + mdHrLvName = target_root.xpath("./mdHrLvName") + if len(mdHrLvName) == 0: + _xml = """dataset""" + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + target_root.insert(root_dict["mdHrLvName"], _root) + del _root, _xml + else: + pass + del mdHrLvName + + fgdcGeoform = target_root.xpath("./dataIdInfo/idCitation/presForm/fgdcGeoform") + if len(fgdcGeoform) == 0: + _xml = """document""" + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + target_root.xpath("./dataIdInfo/idCitation/presForm")[0].insert( + dataIdInfo_dict["fgdcGeoform"], _root + ) + del _root, _xml + else: + pass + del fgdcGeoform + + # print(etree.tostring(target_root.xpath("./distInfo")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + + distInfo = target_root.xpath("./distInfo") + if len(distInfo) == 0: + _xml = """ + + ESRI REST Service + + Uncompressed + + + + """ + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + target_root.xpath("./dataIdInfo/idCitation/presForm")[0].insert( + dataIdInfo_dict["fgdcGeoform"], _root + ) + del _root, _xml + elif len(distInfo) == 1: + formatVer = distInfo[0].xpath("./distFormat/formatVer") + if len(formatVer) == 0: + _xml = """""" + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + target_root.xpath("./distInfo/distFormat")[0].insert(1, _root) + del _root, _xml + elif len(formatVer) == 1: + pass + elif len(formatVer) > 1: + for i in range(1, len(formatVer)): + formatVer[i].getparent().remove(formatVer[i]) + del i + else: + pass + del formatVer + + fileDecmTech = distInfo[0].xpath("./distFormat/fileDecmTech") + if len(fileDecmTech) == 0: + _xml = """""" + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + target_root.xpath("./distInfo/distFormat")[0].insert(2, _root) + del _root, _xml + elif len(fileDecmTech) == 1: + pass + elif len(fileDecmTech) > 1: + for i in range(1, len(fileDecmTech)): + fileDecmTech[i].getparent().remove(fileDecmTech[i]) + del i + else: + pass + del fileDecmTech + + formatInfo = distInfo[0].xpath("./distFormat/formatInfo") + if len(formatInfo) == 0: + _xml = """""" + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + target_root.xpath("./distInfo/distFormat")[0].insert(2, _root) + del _root, _xml + elif len(formatInfo) == 1: + pass + elif len(formatInfo) > 1: + for i in range(1, len(formatInfo)): + formatInfo[i].getparent().remove(formatInfo[i]) + del i + else: + pass + del formatInfo + else: + pass + del distInfo + + # print(etree.tostring(target_root.xpath("./mdHrLv")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + # print(etree.tostring(target_root.xpath("./mdHrLvName")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + # print(etree.tostring(target_root.xpath("./dqInfo/dqScope")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + # print(etree.tostring(target_root.xpath("./dataIdInfo/idCitation/presForm")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + # print(etree.tostring(target_root.xpath("./distInfo")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + + # raise Exception + mdHrLvName = target_root.xpath("./mdHrLvName") + if len(mdHrLvName) == 0: + _xml = """dataset""" + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + target_root.insert(root_dict["mdHrLvName"], _root) + del _root, _xml + else: + pass + del mdHrLvName + + target_root.xpath("./dataIdInfo/envirDesc")[0].set("Sync", "TRUE") + # target_root.xpath("./dqInfo/dqScope/scpLvl/ScopeCd")[0].set('value', "005") + # target_root.xpath("./dqInfo/dqScope/scpLvl/ScopeCd")[0].set('Sync', "TRUE") + mdHrLvName = target_root.xpath("./mdHrLvName")[0] + ScopeCd = target_root.xpath("./dqInfo/dqScope/scpLvl/ScopeCd")[0] + PresFormCd = target_root.xpath("./dataIdInfo/idCitation/presForm/PresFormCd")[0] + fgdcGeoform = target_root.xpath("./dataIdInfo/idCitation/presForm/fgdcGeoform")[ + 0 + ] + SpatRepTypCd = target_root.xpath("./dataIdInfo/spatRpType/SpatRepTypCd")[0] + PresFormCd.set("Sync", "TRUE") + # print("------" * 10) + # print(etree.tostring(SpatRepTypCd, encoding='UTF-8', method='xml', pretty_print=True).decode()) + # print(etree.tostring(target_root.xpath("./dataIdInfo/idCitation/presForm")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + # print(etree.tostring(target_root.xpath("./dqInfo/dqScope")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + # print("------" * 10) + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # SpatRepTypCd "Empty" "001" (vector) "002" (raster/grid) "003" (tabular) + # ScopeCd "005" "005" "007" + # PresFormCd "005" "003" "011" + # fgdcGeoform "vector data" "raster data" "tabular data" + # mdHrLvName "vector data" "raster data" "tabular data" + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + datasetSet = target_root.xpath("./dqInfo/dqScope/scpLvlDesc/datasetSet") + if len(datasetSet) == 0: + _xml = '' + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + target_root.xpath("./dqInfo/dqScope")[0].insert(1, _root) + del _root, _xml + else: + pass + datasetSet = target_root.xpath("./dqInfo/dqScope/scpLvlDesc/datasetSet")[0] + if SpatRepTypCd.get("value") == "001": + ScopeCd.set("value", "005") + PresFormCd.set("value", "005") + fgdcGeoform.text = "vector digital data" + datasetSet.text = "Vector Digital Data" + mdHrLvName.text = "Vector Digital Data" + elif SpatRepTypCd.get("value") == "002": + ScopeCd.set("value", "005") + PresFormCd.set("value", "003") + fgdcGeoform.text = "raster digital data" + datasetSet.text = "Raster Digital Data" + mdHrLvName.text = "Raster Digital Data" + elif SpatRepTypCd.get("value") == "003": + ScopeCd.set("value", "007") + PresFormCd.set("value", "011") + fgdcGeoform.text = "tabular digital data" + datasetSet.text = "Tabular Digital Data" + mdHrLvName.text = "Tabular Digital Data" + else: + pass + # print("------" * 10) + # print(etree.tostring(SpatRepTypCd, encoding='UTF-8', method='xml', pretty_print=True).decode()) + # print(etree.tostring(target_root.xpath("./dataIdInfo/idCitation/presForm")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + # print(etree.tostring(target_root.xpath("./dqInfo/dqScope")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + # print("------" * 10) + del datasetSet, SpatRepTypCd, fgdcGeoform, PresFormCd, ScopeCd, mdHrLvName + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + formatName = target_root.xpath("./distInfo/distFormat/formatName")[0] + envirDesc = target_root.xpath("./dataIdInfo/envirDesc")[0] + envirDesc.set("Sync", "TRUE") + target_root.xpath("./distInfo/distFormat/fileDecmTech")[0].text = "Uncompressed" + formatName.text = "ESRI REST Service" + formatVer_text = str.rstrip(str.lstrip(envirDesc.text)) + formatVer = target_root.xpath("./distInfo/distFormat/formatVer")[0] + formatVer.text = str.rstrip(str.lstrip(formatVer_text)) + del formatVer_text + del envirDesc + del formatVer + del formatName + + xml_file = b""" + external + c66ffbb333c48d18d81856ec0e0c37ea752bff1a + Melissa Ann Karp + NMFS Office of Science and Technology + Fisheries Science Coordinator + + + 1315 East West Hwy + Silver Spring + MD + 20910-3282 + melissa.karp@noaa.gov + US + + + 301-427-8202 + 301-713-4137 + + 0700 - 1800 EST/EDT + + https://www.fisheries.noaa.gov/about/office-science-and-technology + REST Service + NMFS Office of Science and Technology + NOAA Fisheries Office of Science and Technology + + + + + + Melissa Ann Karp + True + + + + + """ + _tree = etree.parse( + BytesIO(xml_file), etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + _root = _tree.getroot() + idPoC = target_root.xpath(f"./dataIdInfo/idPoC") + if len(idPoC) == 0: + target_root.xpath(f"./dataIdInfo")[0].insert( + dataIdInfo_dict["idPoC"], _root + ) + elif len(idPoC) == 1: + idPoC[0].getparent().replace(idPoC[0], _root) + else: + pass + del _root, _tree, xml_file + # print(f"\n\t{etree.tostring(target_root.xpath(f'./dataIdInfo/idPoC')[0], encoding='UTF-8', method='xml', pretty_print=True).decode()}\n") + del idPoC + + xml_file = b""" + external + 579ce2e21b888ac8f6ac1dac30f04cddec7a0d7c + NMFS Office of Science and Technology + NMFS Office of Science and Technology + GIS App Developer + + + 1315 East West Highway + Silver Spring + MD + 20910-3282 + US + tim.haverland@noaa.gov + + + 301-427-8137 + 301-713-4137 + + 0700 - 1800 EST/EDT + + https://www.fisheries.noaa.gov/about/office-science-and-technology + REST Service + NMFS Office of Science and Technology + NOAA Fisheries Office of Science and Technology + + + + + + NMFS Office of Science and Technology (Distributor) + True + + + + + """ + _tree = etree.parse( + BytesIO(xml_file), etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + _root = _tree.getroot() + citRespParty = target_root.xpath(f"./dataIdInfo/idCitation/citRespParty") + if len(citRespParty) == 0: + target_root.xpath(f"./dataIdInfo/idCitation")[0].insert( + dataIdInfo_dict["citRespParty"], _root + ) + elif len(citRespParty) == 1: + citRespParty[0].getparent().replace(citRespParty[0], _root) + else: + pass + del _root, _tree, xml_file + # print(f"\n\t{etree.tostring(target_root.xpath(f'./dataIdInfo/idCitation/citRespParty')[0], encoding='UTF-8', method='xml', pretty_print=True).decode()}\n") + del citRespParty + + resConst = target_root.xpath("./dataIdInfo/resConst") + if len(resConst) == 1: + xml_file = b""" + + + + + + + + Data License: CC0-1.0 +Data License URL: https://creativecommons.org/publicdomain/zero/1.0/ +Data License Statement: These data were produced by NOAA and are not subject to copyright protection in the United States. NOAA waives any potential copyright and related rights in these data worldwide through the Creative Commons Zero 1.0 Universal Public Domain Dedication (CC0-1.0). + + + + + + + FISMA Low + + + <DIV STYLE="text-align:Left;"><DIV><DIV><P><SPAN>***No Warranty*** The user assumes the entire risk related to its use of these data. NMFS is providing these data 'as is' and NMFS disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose. No warranty expressed or implied is made regarding the accuracy or utility of the data on any other system or for general or scientific purposes, nor shall the act of distribution constitute any such warranty. It is strongly recommended that careful attention be paid to the contents of the metadata file associated with these data to evaluate dataset limitations, restrictions or intended use. In no event will NMFS be liable to you or to any third party for any direct, indirect, incidental, consequential, special or exemplary damages or lost profit resulting from any use or misuse of these data.</SPAN></P></DIV></DIV></DIV> + + """ + _tree = etree.parse( + BytesIO(xml_file), + etree.XMLParser(encoding="UTF-8", remove_blank_text=True), + ) + _root = _tree.getroot() + resConst[0].getparent().replace(resConst[0], _root) + del _root, _tree, xml_file + else: + pass + del resConst + + dataIdInfo = target_root.xpath("./dataIdInfo") + for data_Id_Info in dataIdInfo: + data_Id_Info[:] = sorted(data_Id_Info, key=lambda x: dataIdInfo_dict[x.tag]) + # print(etree.tostring(data_Id_Info, encoding='UTF-8', method='xml', pretty_print=True).decode()) + del data_Id_Info + del dataIdInfo + + # No changes needed below + # print(etree.tostring(target_tree, encoding='UTF-8', method='xml', pretty_print=True).decode()) + etree.indent(target_root, space=" ") + dataset_md_xml = etree.tostring( + target_tree, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + + SaveBackXml = True + if SaveBackXml: + dataset_md = md.Metadata(dataset_path) + dataset_md.xml = dataset_md_xml + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + # dataset_md.reload() + del dataset_md + else: + pass + del SaveBackXml + del dataset_md_xml + + # Declared Varaiables + del dataset_name + del dataIdInfo_dict, root_dict + del target_tree, target_root + # Imports + del etree, StringIO, BytesIO, copy, md + # Function Parameters + del dataset_path + except KeyboardInterrupt: + raise SystemExit + except: + traceback.print_exc() + raise SystemExit + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def metadata_dq_info_report(dataset_path=""): + try: + # Imports + import copy + from io import BytesIO, StringIO + + from arcpy import metadata as md + from lxml import etree + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + import json + + json_path = rf"{project_folder}\dqInfo_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + dqInfo_dict = json.load(json_file) + del json_file + del json_path + del json + + export_folder = rf"{os.path.dirname(os.path.dirname(dataset_path))}\Export" + + # print(dataset_path) + dataset_name = os.path.basename(dataset_path) + print(f"Reporting on dqInfo XML for dataset: '{dataset_name}'") + # print(f"\tDataset Location: {os.path.basename(os.path.dirname(dataset_path))}") + + dataset_md = md.Metadata(dataset_path) + # dataset_md.synchronize("ALWAYS") + # dataset_md.save() + # dataset_md.reload() + dataset_md_xml = dataset_md.xml + del dataset_md + + # Parse the XML + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + target_tree = etree.parse(StringIO(dataset_md_xml), parser=parser) + target_root = target_tree.getroot() + del parser, dataset_md_xml + + # dqInfo + dqInfo = target_root.xpath("./dqInfo")[0] + dqInfo[:] = sorted(dqInfo, key=lambda x: dqInfo_dict[x.tag]) + # print(etree.tostring(dqInfo, encoding='UTF-8', method='xml', pretty_print=True).decode()) + + # target_root[:] = sorted(target_root, key=lambda x: dqInfo_dict[x.tag]) + # for child in target_root: + # #print(child.tag) + # #print(etree.tostring(child, encoding='UTF-8', method='xml', pretty_print=True).decode()) + # del child + # Esri + # dataIdInfo + # dqInfo + # distInfo + # mdContact + # mdLang + # mdChar + # mdDateSt + # mdHrLv + # mdHrLvName + # mdFileID + # mdMaint + # refSysInfo + # spatRepInfo + # spdoinfo + # eainfo + + _report = target_root.xpath(f"./dqInfo/report[@type='DQConcConsis']") + if len(_report) == 1: + _xml = """ + Based on a review from DisMAP Team all necessary features are present. + + + + Conceptual Consistency Report + + NMFS OST DisMAP + + + + + + + Based on a review from DisMAP Team all necessary features are present. + 1 + + + """ + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + # print(f"{etree.tostring(_root, encoding='UTF-8', method='xml', pretty_print=True).decode()}") + # raise SystemExit + _report[0].getparent().replace(_report[0], _root) + del _root, _xml + else: + pass + del _report + + _report = target_root.xpath(f"./dqInfo/report[@type='DQCompOm']") + if len(_report) == 1: + _xml = """ + Based on a review from DisMAP Team all necessary features are present. + + + + Completeness Report + + NMFS OST DisMAP + + + + + + + Based on a review from DisMAP Team all necessary features are present. + 1 + + + """ + _root = etree.XML( + _xml, etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + _report[0].getparent().replace(_report[0], _root) + del _root, _xml + else: + pass + del _report + + dqInfo = target_root.xpath("./dqInfo") + # print(len(dqInfo)) + for dq_Info in dqInfo: + dq_Info[:] = sorted(dq_Info, key=lambda x: dqInfo_dict[x.tag]) + # print(etree.tostring(dq_Info, encoding='UTF-8', method='xml', pretty_print=True).decode()) + del dq_Info + del dqInfo + + # print(len(target_root.xpath("./dqInfo"))) + for i in range(1, len(target_root.xpath("./dqInfo"))): + dq_Info = target_root.xpath("./dqInfo")[ + i + ] # .write(rf"{export_folder}\{os.path.basename(dataset_path)} dqInfo.xml", encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True) + # Writing to a new file + file = open( + rf"{export_folder}\{os.path.basename(dataset_path)} dqInfo.xml", "w" + ) + file.write( + etree.tostring( + dq_Info, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ).decode() + ) + file.close() + del file + dq_Info.getparent().remove(dq_Info) + del dq_Info + del i + + # No changes needed below + # print(etree.tostring(target_tree, encoding='UTF-8', method='xml', pretty_print=True).decode()) + etree.indent(target_root, space=" ") + dataset_md_xml = etree.tostring( + target_tree, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + + SaveBackXml = True + if SaveBackXml: + dataset_md = md.Metadata(dataset_path) + dataset_md.xml = dataset_md_xml + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + # dataset_md.reload() + del dataset_md + else: + pass + del SaveBackXml + del dataset_md_xml + + # Declared Varaiables + del export_folder + del dataset_name + del dqInfo_dict + del target_tree, target_root + # Imports + del etree, StringIO, BytesIO, copy, md + # Function Parameters + del dataset_path + except KeyboardInterrupt: + raise SystemExit + except: + traceback.print_exc() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def metadata_dist_info_report(dataset_path=""): + try: + # Imports + import copy + from io import BytesIO, StringIO + + from arcpy import metadata as md + from lxml import etree + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + import json + + json_path = rf"{project_folder}\distInfo_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + distInfo_dict = json.load(json_file) + del json_file + del json_path + del json + + project = os.path.basename(os.path.dirname(os.path.dirname(dataset_path))) + export_folder = rf"{os.path.dirname(os.path.dirname(dataset_path))}\Export" + + # print(dataset_path) + dataset_name = os.path.basename(dataset_path) + print(f"Reporting on distInfo XML for dataset: '{dataset_name}'") + # print(f"\tDataset Location: {os.path.basename(os.path.dirname(dataset_path))}") + + dataset_md = md.Metadata(dataset_path) + # dataset_md.synchronize("ALWAYS") + # dataset_md.save() + # dataset_md.reload() + dataset_md_xml = dataset_md.xml + del dataset_md + + # Parse the XML + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + target_tree = etree.parse(StringIO(dataset_md_xml), parser=parser) + target_root = target_tree.getroot() + del parser, dataset_md_xml + + # target_root[:] = sorted(target_root, key=lambda x: distInfo_dict[x.tag]) + # for child in target_root: + # #print(child.tag) + # #print(etree.tostring(child, encoding='UTF-8', method='xml', pretty_print=True).decode()) + # del child + # Esri + # dataIdInfo + # dqInfo + # distInfo + # mdContact + # mdLang + # mdChar + # mdDateSt + # mdHrLv + # mdHrLvName + # mdFileID + # mdMaint + # refSysInfo + # spatRepInfo + # spdoinfo + # eainfo + + distorTran = target_root.xpath("//distorTran") + for _distorTran in distorTran: + _distorTran.tag = "distTranOps" + del _distorTran + del distorTran + + ## target_root.xpath("./distInfo/distFormat/formatName")[0].set('Sync', "FALSE") + ## target_root.xpath("./dataIdInfo/envirDesc")[0].set('Sync', "TRUE") + ## #target_root.xpath("./dqInfo/dqScope/scpLvl/ScopeCd")[0].set('value', "005") + ## PresFormCd = target_root.xpath("./dataIdInfo/idCitation/presForm/PresFormCd")[0] + ## fgdcGeoform = target_root.xpath("./dataIdInfo/idCitation/presForm/fgdcGeoform")[0] + ## SpatRepTypCd = target_root.xpath("./dataIdInfo/spatRpType/SpatRepTypCd")[0] + ## PresFormCd.set('Sync', "TRUE") + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## # SpatRepTypCd "Empty" "001" (vector) "002" (raster/grid) "003" (tabular) + ## # PresFormCd "005" "003" "011" + ## # fgdcGeoform "vector data" "raster data" "tabular data" + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## datasetSet = target_root.xpath("./dqInfo/dqScope/scpLvlDesc/datasetSet")[0] + ## if SpatRepTypCd.get("value") == "001": + ## PresFormCd.set("value", "005") + ## fgdcGeoform.text = "vector digital data" + ## datasetSet.text = "Vector Digital Data" + ## elif SpatRepTypCd.get("value") == "002": + ## PresFormCd.set("value", "003") + ## fgdcGeoform.text = "raster digital data" + ## datasetSet.text = "Raster Digital Data" + ## elif SpatRepTypCd.get("value") == "003": + ## PresFormCd.set("value", "011") + ## fgdcGeoform.text = "tabular digital data" + ## datasetSet.text = "Tabular Digital Data" + ## else: + ## pass + ## #print("------" * 10) + ## #print(etree.tostring(SpatRepTypCd, encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## #print(etree.tostring(target_root.xpath("./dataIdInfo/idCitation/presForm")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## #print(etree.tostring(target_root.xpath("./dqInfo/dqScope")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + ## #print("------" * 10) + ## del datasetSet, SpatRepTypCd, fgdcGeoform, PresFormCd + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + ## formatName = target_root.xpath("./distInfo/distFormat/formatName")[0] + ## envirDesc = target_root.xpath("./dataIdInfo/envirDesc")[0] + ## envirDesc.set('Sync', "TRUE") + ## target_root.xpath("./distInfo/distFormat/fileDecmTech")[0].text = "Uncompressed" + ## formatName.text = "ESRI REST Service" + ## formatVer_text = str.rstrip(str.lstrip(envirDesc.text)) + ## formatVer = target_root.xpath("./distInfo/distFormat/formatVer")[0] + ## formatVer.text = str.rstrip(str.lstrip(formatVer_text)) + ## del formatVer_text + ## del envirDesc + ## del formatVer + ## del formatName + + xml_file = b""" + + external + 579ce2e21b888ac8f6ac1dac30f04cddec7a0d7c + NMFS Office of Science and Technology + NMFS Office of Science and Technology + GIS App Developer + + + 1315 East West Highway + Silver Spring + MD + 20910-3282 + US + tim.haverland@noaa.gov + + + 301-427-8137 + 301-713-4137 + + 0700 - 1800 EST/EDT + + https://www.fisheries.noaa.gov/about/office-science-and-technology + REST Service + NMFS Office of Science and Technology + NOAA Fisheries Office of Science and Technology + + + + + + NMFS Office of Science and Technology (Distributor) + True + + + + + + """ + _tree = etree.parse( + BytesIO(xml_file), etree.XMLParser(encoding="UTF-8", remove_blank_text=True) + ) + _root = _tree.getroot() + distributor = target_root.xpath(f"./distInfo/distributor") + if len(distributor) == 0: + target_root.xpath(f"./distInfo")[0].insert( + distInfo_dict["distributor"], _root + ) + elif len(distributor) == 1: + distributor[0].getparent().replace(distributor[0], _root) + else: + pass + del _root, _tree, xml_file + # print(f"\n\t{etree.tostring(target_root.xpath(f'./distInfo/distributor')[0], encoding='UTF-8', method='xml', pretty_print=True).decode()}\n") + del distributor + + ## new_item_name = target_root.find("./Esri/DataProperties/itemProps/itemName").text + ## new_item_name = new_item_name.replace("IDW_Sample_Locations", "Sample_Locations") if "Sample_Locations" in new_item_name else new_item_name + ## onLineSrcs = target_root.findall("./distInfo/distTranOps/onLineSrc") + ## for onLineSrc in onLineSrcs: + ## if onLineSrc.find('./protocol').text == "ESRI REST Service": + ## old_linkage_element = onLineSrc.find('./linkage') + ## old_linkage = old_linkage_element.text + ## #print(old_linkage, flush=True) + ## old_item_name = old_linkage[old_linkage.find("/services/")+len("/services/"):old_linkage.find("/FeatureServer")] + ## new_linkage = old_linkage.replace(old_item_name, f"{new_item_name}_{date_code(project)}") + ## #print(new_linkage, flush=True) + ## old_linkage_element.text = new_linkage + ## #print(old_linkage_element.text, flush=True) + ## del old_linkage_element + ## del old_item_name, old_linkage, new_linkage + ## else: + ## pass + ## del onLineSrc + ## del onLineSrcs, new_item_name + ## #print(etree.tostring(target_root.xpath("./distInfo")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + + new_item_name = target_root.find( + "./Esri/DataProperties/itemProps/itemName" + ).text + if "Sample_Locations" in new_item_name: + _new_item_name = ( + new_item_name.replace("IDW_Sample_Locations", "Sample_Locations") + if "Sample_Locations" in new_item_name + else new_item_name + ) + onLineSrcs = target_root.findall("./distInfo/distTranOps/onLineSrc") + for onLineSrc in onLineSrcs: + onLineSrc.find("./protocol").text = "ESRI REST Service" + old_linkage_element = onLineSrc.find("./linkage") + old_linkage = old_linkage_element.text + # print(old_linkage, flush=True) + old_item_name = old_linkage[old_linkage.find("/services/") + len("/services/") : old_linkage.find("/FeatureServer")] + + if old_item_name != f"{_new_item_name}_{date_code(project)}": + # print('remove') + onLineSrc.getparent().remove(onLineSrc) + else: + pass + + # print(old_item_name, f"{_new_item_name}_{date_code(project)}") + # new_linkage = old_linkage.replace(old_item_name, f"{_new_item_name}_{date_code(project)}") + # print(new_linkage, flush=True) + # old_linkage_element.text = new_linkage + # print(old_linkage_element.text, flush=True) + del old_linkage_element + del old_item_name, old_linkage # , new_linkage + # print(etree.tostring(onLineSrc, encoding='UTF-8', method='xml', pretty_print=True).decode()) + # if onLineSrc.find('./protocol').text == "ESRI REST Service": + # old_linkage_element = onLineSrc.find('./linkage') + # old_linkage = old_linkage_element.text + # #print(old_linkage, flush=True) + # old_item_name = old_linkage[old_linkage.find("/services/")+len("/services/"):old_linkage.find("/FeatureServer")] + # new_linkage = old_linkage.replace(old_item_name, f"{new_item_name}_{date_code(project)}") + # #print(new_linkage, flush=True) + # old_linkage_element.text = new_linkage + # #print(old_linkage_element.text, flush=True) + # del old_linkage_element + # del old_item_name, old_linkage, new_linkage + # else: + # pass + del onLineSrc + # print(_new_item_name) + del onLineSrcs, _new_item_name + else: + pass + # print(etree.tostring(target_root.xpath("./distInfo")[0], encoding='UTF-8', method='xml', pretty_print=True).decode()) + # print(new_item_name) + del new_item_name + + distInfo = target_root.xpath("./distInfo") + # print(len(distInfo)) + for dist_Info in distInfo: + dist_Info[:] = sorted(dist_Info, key=lambda x: distInfo_dict[x.tag]) + # print(etree.tostring(dist_Info, encoding='UTF-8', method='xml', pretty_print=True).decode()) + del dist_Info + del distInfo + + # No changes needed below + # print(etree.tostring(target_tree, encoding='UTF-8', method='xml', pretty_print=True).decode()) + etree.indent(target_root, space=" ") + dataset_md_xml = etree.tostring( + target_tree, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + + SaveBackXml = True + if SaveBackXml: + dataset_md = md.Metadata(dataset_path) + dataset_md.xml = dataset_md_xml + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + # dataset_md.reload() + del dataset_md + else: + pass + del SaveBackXml + del dataset_md_xml + + # Declared Varaiables + del export_folder, project + del dataset_name + del distInfo_dict + del target_tree, target_root + # Imports + del etree, StringIO, BytesIO, copy, md + # Function Parameters + del dataset_path + except KeyboardInterrupt: + raise SystemExit + except: + traceback.print_exc() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def main(project_gdb=""): + try: + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + print(f"{'-' * 80}") + print(f"Python Script: {os.path.basename(__file__)}") + print( + f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}" + ) + print(f"Python Version: {sys.version}") + print(f"Environment: {os.path.basename(sys.exec_prefix)}") + print(f"{'-' * 80}\n") + + # Imports + from io import BytesIO, StringIO + + # import copy + # import arcpy + from arcpy import metadata as md + from lxml import etree + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + # Test if passed workspace exists, if not raise SystemExit + if not arcpy.Exists(project_gdb): + print(f"{os.path.basename(project_gdb)} is missing!!") + print(f"{project_gdb}") + + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{project_folder}\Scratch" + # print(project_folder) + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + # metadata_dictionary = dataset_title_dict(project_gdb) + # for key in metadata_dictionary: + # print(key, metadata_dictionary[key]) + # del key + + datasets = list() + walk = arcpy.da.Walk(arcpy.env.workspace) + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + + del scratch_folder, project_folder + + print( + f"Processing: {os.path.basename(arcpy.env.workspace)} in the '{inspect.stack()[0][3]}' function" + ) + + # Points + # for dataset_path in sorted([ds for ds in datasets if ds.endswith("AI_Sample_Locations") or ds.endswith("AI_IDW_Sample_Locations")]): + # for dataset_path in sorted([ds for ds in datasets if ds.endswith("_Sample_Locations")]): + # for dataset_path in sorted([ds for ds in datasets if ds.endswith("EBS_Sample_Locations") or ds.endswith("EBS_IDW_Sample_Locations")]): + # Polylines + # for dataset_path in sorted([ds for ds in datasets if ds.endswith("AI_Boundary") or ds.endswith("AI_IDW_Boundary")]): + # Polygons + # for dataset_path in sorted([ds for ds in datasets if ds.endswith("AI_Region") or ds.endswith("AI_IDW_Region")]): + # Table + # for dataset_path in sorted([ds for ds in datasets if ds.endswith("AI_Indicators") or ds.endswith("AI_IDW_Indicators")]): + # for dataset_path in sorted([ds for ds in datasets if ds.endswith("Indicators")]): + # Raster + # for dataset_path in sorted([ds for ds in datasets if ds.endswith("AI_Bathymetry") or ds.endswith("AI_IDW_Bathymetry")]): + # for dataset_path in sorted([ds for ds in datasets if ds.endswith("AI_Raster_Mask") or ds.endswith("AI_IDW_Raster_Mask")]): + # for dataset_path in sorted([ds for ds in datasets if ds.endswith("AI_Raster_Mosaic") or ds.endswith("AI_IDW_Mosaic")]): + # for dataset_path in sorted([ds for ds in datasets if any (ds.endswith(d) for d in ["Datasets", "AI_IDW_Extent_Points", "AI_IDW_Latitude", "AI_IDW_Raster_Mask"])]): + # for dataset_path in sorted([ds for ds in datasets if "AI_IDW" in os.path.basename(ds)]): + # for dataset_path in sorted([ds for ds in datasets if "EBS_IDW" in os.path.basename(ds)]): + # for dataset_path in sorted([ds for ds in datasets if any (ds.endswith(d) for d in ["Species_Filer", "EBS_IDW_Extent_Points", "EBS_IDW_Latitude", "EBS_IDW_Raster_Mask"])]): + # for dataset_path in sorted([ds for ds in datasets if any (ds.endswith(d) for d in ['SpeciesPersistenceIndicatorNetWTCPUE', 'SpeciesPersistenceIndicatorPercentileWTCPUE', 'Species_Filter', 'DisMAP_Survey_Info'])]): + for dataset_path in sorted( + [ds for ds in datasets if any(ds.endswith(d) for d in ["Species_Filter"])] + ): + + # ALL + # for dataset_path in sorted(datasets): + # dataset_name = os.path.basename(dataset_path) + # print(f"Dataset: '{dataset_name}'\n\tType: '{arcpy.Describe(dataset_path).datasetType}'") + # del dataset_name + + ImportBasicTemplateXml = True + if ImportBasicTemplateXml: + import_basic_template_xml(dataset_path) + else: + pass + del ImportBasicTemplateXml + + BasicMetadataReport = False # Just a report + if BasicMetadataReport: + basic_metadata_report(dataset_path) + else: + pass + del BasicMetadataReport + + MetadataEsriReport = False + if MetadataEsriReport: + metadata_esri_report(dataset_path) + else: + pass + del MetadataEsriReport + + MetadataDataIdInfoReport = False + if MetadataDataIdInfoReport: + metadata_dataidinfo_report(dataset_path) + else: + pass + del MetadataDataIdInfoReport + + MetadataDqInfoReport = False + if MetadataDqInfoReport: + metadata_dq_info_report(dataset_path) + else: + pass + del MetadataDqInfoReport + + MetadataDistInfoReport = False + if MetadataDistInfoReport: + metadata_dist_info_report(dataset_path) + else: + pass + del MetadataDistInfoReport + + UpdateEaInfoXmlElements = False + if UpdateEaInfoXmlElements: + update_eainfo_xml_elements(dataset_path) + else: + pass + del UpdateEaInfoXmlElements + + AddUpdateDates = False + if AddUpdateDates: + add_update_dates(dataset_path) + else: + pass + del AddUpdateDates + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # A keeper. Adds entity attribute details, if missing + InsertMissingElements = False + if InsertMissingElements: + insert_missing_elements(dataset_path) + else: + pass + del InsertMissingElements + + AddUpdateContacts = False + if AddUpdateContacts: + add_update_contacts(dataset_path=dataset_path) + else: + pass + del AddUpdateContacts + + CreateFeatureClassLayers = False + if CreateFeatureClassLayers: + create_feature_class_layers(dataset_path=dataset_path) + else: + pass + del CreateFeatureClassLayers + + PrintTargetTree = False + if PrintTargetTree: + dataset_md = md.Metadata(dataset_path) + # dataset_md.synchronize("ALWAYS") + # dataset_md.save() + # dataset_md.reload() + # Parse the XML + export_folder = ( + rf"{os.path.dirname(os.path.dirname(dataset_path))}\Export" + ) + # print(export_folder) + # _target_tree = etree.parse(StringIO(dataset_md.xml), parser=etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + # etree.indent(_target_tree, " ") + # _target_tree.write(rf"{export_folder}\{os.path.basename(dataset_path)}.xml", encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True) + # print(etree.tostring(_target_tree, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) + # del _target_tree + dataset_md.saveAsXML( + rf"{export_folder}\{os.path.basename(dataset_path)}.xml", "TEMPLATE" + ) + del export_folder + del dataset_md + else: + pass + del PrintTargetTree + del dataset_path + + CompactGDB = False + if CompactGDB: + print(f"Compact GDB") + arcpy.management.Compact(project_gdb) + print("\t" + arcpy.GetMessages().replace("\n", "\n\t") + "\n") + else: + pass + del CompactGDB + + # Declared Varaiables + del datasets + # Imports + del etree, StringIO, BytesIO, md + # Function Parameters + del project_gdb + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + print(f"\n{'-' * 80}") + print( + f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}" + ) + print( + "Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) + ) + print(f"{'-' * 80}") + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + except KeyboardInterrupt: + raise SystemExit + except Exception: + raise SystemExit + except: + traceback.print_exc() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +if __name__ == "__main__": + try: + # Append the location of this scrip to the System Path + sys.path.append(os.path.dirname(os.path.dirname(__file__))) + # Imports + base_project_folder = rf"{os.path.dirname(os.path.dirname(__file__))}" + # project_name = "April 1 2023" + # project_name = "July 1 2024" + project_name = "December 1 2024" + # project_name = "June 1 2025" + project_folder = rf"{base_project_folder}\{project_name}" + project_gdb = os.path.join(project_folder, f"{project_name}.gdb") + + main(project_gdb=project_gdb) + + # Declared Variables + # del collective_title + del project_gdb, project_name, project_folder, base_project_folder + # Imports + except: + traceback.print_exc() + else: + pass + finally: + pass +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_dismap_metadata_processing.zip b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_dismap_metadata_processing.zip new file mode 100644 index 0000000..add74d7 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_dismap_metadata_processing.zip differ diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_dismap_tiff_image_archive.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_dismap_tiff_image_archive.py new file mode 100644 index 0000000..2e56a83 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_dismap_tiff_image_archive.py @@ -0,0 +1,181 @@ +# --------------------------------------------------------------------------------------- +# Name: module1 +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 22/12/2025 +# Copyright: (c) john.f.kennedy 2025 +# Licence: +# --------------------------------------------------------------------------------------- +import inspect +import os +import sys +import traceback +import zipfile + +import arcpy + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + filename = sys.path[0] + os.sep + "test.py" + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror + + +def zip_folder(folder_path="", archive_folder=""): + """ + Creates a zip archive of a given folder and its contents. + + Args: + folder_path (str): The path to the folder to be archived. + """ + try: + output_zip_path = rf"{archive_folder}\{os.path.basename(folder_path)}.zip" + # arcpy.AddMessage(output_zip_path) + arcpy.AddMessage(f"\t\t\t\t../{'/'.join(output_zip_path.split(os.sep)[-3:])}") + + with zipfile.ZipFile(output_zip_path, "w", zipfile.ZIP_DEFLATED) as zipf: + for root, dirs, files in os.walk(folder_path): + for file in files: + file_path = os.path.join(root, file) + # Calculate the relative path within the zip archive + arcname = os.path.relpath(file_path, folder_path) + # arcpy.AddMessage(arcname) + zipf.write(file_path, arcname) + for dir_name in dirs: + # Add empty directories to the archive + dir_path = os.path.join(root, dir_name) + arcname = os.path.relpath(dir_path, folder_path) + # arcpy.AddMessage(arcname) + # Ensure directory entries end with a slash in the archive + if not arcname.endswith("/"): + arcname += "/" + zipf.writestr(zipfile.ZipInfo(arcname), "") + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + sys.exit() + return False + else: + return True + + +def main(base_folder="", versions="", archive_folder=""): + try: + import dismap_tools + + arcpy.AddMessage( + f"Home Folder: {os.path.basename(base_folder)} in '{inspect.stack()[0][3]}'" + ) + arcpy.AddMessage( + f"Versions: {', '.join(versions)} in '{inspect.stack()[0][3]}'" + ) + + for version in versions: + image_folder = rf"{base_folder}\{version}\Images" + _archive_folder = os.path.join( + archive_folder, + f"DisMAP_{dismap_tools.date_code(version)}", + "results\\raster", + ) + # arcpy.AddMessage(f"\tImage Folder: {os.path.basename(image_folder)} in '{inspect.stack()[0][3]}'") + arcpy.AddMessage(f"\tImage Folder: {os.path.basename(image_folder)}") + arcpy.AddMessage(f"\t\tArchive Folder: {os.path.basename(_archive_folder)}") + + for entry in os.scandir(image_folder): + if entry.is_dir(): + arcpy.AddMessage( + f"\t\t\tInput Folder: {os.path.basename(entry.path)}" + ) + zip_folder(entry.path, _archive_folder) + else: + pass + del entry + del image_folder, version, _archive_folder + + # Delete Declared Varibales + # Delete Functions Parameters + del base_folder, versions, archive_folder + # Imports + del dismap_tools + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +if __name__ == "__main__": + try: + base_folder = arcpy.GetParameterAsText(0) + versions = arcpy.GetParameterAsText(1) + archive_folder = arcpy.GetParameterAsText(2) + + if not base_folder: + base_folder = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMap\ArcGIS-Analysis-Python" + else: + arcpy.AddMessage(f"Home Folder: {os.path.basename(base_folder)}") + + if not versions: + # versions = ["April 1 2023", "July 1 2024", "August 1 2025",] + # versions = ["April 1 2023"] + versions = ["February 1 2026"] + else: + arcpy.AddMessage(f"Versions: {', '.join(versions)}") + + if not archive_folder: + archive_folder = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMap\\ArcGIS-Analysis-Python\\NCEI Archive", + ) + else: + arcpy.AddMessage(f"Home Folder: {os.path.basename(base_folder)}") + + result = main( + base_folder=base_folder, versions=versions, archive_folder=archive_folder + ) + + if result: + arcpy.SetParameterAsText(3, result) + del result + + # Clean-up declared variables + del base_folder, versions, archive_folder + + except: # noqa: E722 + traceback.print_exc() + else: + pass + finally: + sys.exit() +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_dismap_vector_archive.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_dismap_vector_archive.py new file mode 100644 index 0000000..3708ea4 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_dismap_vector_archive.py @@ -0,0 +1,310 @@ +# --------------------------------------------------------------------------------------- +# Name: module1 +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 22/12/2025 +# Copyright: (c) john.f.kennedy 2025 +# Licence: +# --------------------------------------------------------------------------------------- +import inspect +import os +import zipfile + +import arcpy + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + filename = sys.path[0] + os.sep + "test.py" + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror + + +def dis_map_archive_folders(home_folder="", versions="", archive_folder=""): + try: + import dismap_tools + + arcpy.env.overwriteOutput = True + + # arcpy.AddMessage(f"Home Folder: {os.path.basename(home_folder)} in '{inspect.stack()[0][3]}'") + # arcpy.AddMessage(f"Versions: {', '.join(versions)} in '{inspect.stack()[0][3]}'") + + for version in versions: + project_gdb = rf"{home_folder}\{version}\{version}.gdb" + _archive_folder = os.path.join( + archive_folder, f"DisMAP_{dismap_tools.date_code(version)}" + ) + # archive_gdb = rf"{_archive_folder}\DisMAP_{dismap_tools.date_code(version)}.gpkg" + + archive_folders = [ + "initial", + "results/vector-tabular/metadata", + "results/raster", + ] + + # arcpy.AddMessage(f"\tProject GDB: {os.path.basename(project_gdb)} in '{inspect.stack()[0][3]}'") + # arcpy.AddMessage(f"\tProject GDB: {project_gdb}") + # arcpy.AddMessage(f"\t\tArchive Folder: {_archive_folder}") + for archiveFolder in archive_folders: + archiveFolder_path = os.path.abspath( + os.path.join( + archive_folder, + f"DisMAP_{dismap_tools.date_code(version)}", + archiveFolder, + ) + ) + # arcpy.AddMessage(f"\t\t\tFolder: {archiveFolder_path}") + if not os.path.isdir(archiveFolder_path): + os.makedirs(archiveFolder_path) + else: + pass + pass + + del archiveFolder_path, archiveFolder + del archive_folders + + del project_gdb, _archive_folder + del version + + # Delete Declared Varibales + # Delete Functions Parameters + del home_folder, versions, archive_folder + # Imports + del dismap_tools + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def zip_folder(folder_path="", archive_folder=""): + """ + Creates a zip archive of a given folder and its contents. + + Args: + folder_path (str): The path to the folder to be archived. + """ + output_zip_path = rf"{archive_folder}\{os.path.basename(folder_path)}.zip" + + with zipfile.ZipFile(output_zip_path, "w", zipfile.ZIP_DEFLATED) as zipf: + for root, dirs, files in os.walk(folder_path): + for file in files: + file_path = os.path.join(root, file) + # Calculate the relative path within the zip archive + arcname = os.path.relpath(file_path, folder_path) + # arcpy.AddMessage(arcname) + zipf.write(file_path, arcname) + for dir_name in dirs: + # Add empty directories to the archive + dir_path = os.path.join(root, dir_name) + arcname = os.path.relpath(dir_path, folder_path) + # arcpy.AddMessage(arcname) + # Ensure directory entries end with a slash in the archive + if not arcname.endswith("/"): + arcname += "/" + zipf.writestr(zipfile.ZipInfo(arcname), "") + + +def main(home_folder="", versions="", archive_folder=""): + try: + import dismap_tools + from arcpy import metadata as md + + arcpy.env.overwriteOutput = True + + dis_map_archive_folders( + home_folder=home_folder, versions=versions, archive_folder=archive_folder + ) + + # archive_folders = ["initial", "results/vector-tabular/metadata", "results/raster"] + # archiveFolder_path = os.path.abspath(os.path.join(archive_folder, f"DisMAP_{dismap_tools.date_code(version)}", archiveFolder)) + + arcpy.AddMessage( + f"Home Folder: {os.path.basename(home_folder)} in '{inspect.stack()[0][3]}'" + ) + arcpy.AddMessage( + f"Versions: {', '.join(versions)} in '{inspect.stack()[0][3]}'" + ) + + for version in versions: + project_gdb = rf"{home_folder}\{version}\{version}.gdb" + _archive_folder = os.path.abspath( + os.path.join( + archive_folder, + f"DisMAP_{dismap_tools.date_code(version)}", + "results/vector-tabular", + ) + ) + archive_gdb = os.path.abspath( + rf"{_archive_folder}\DisMAP_{dismap_tools.date_code(version)}.gpkg" + ) + + # arcpy.AddMessage(f"\tProject GDB: {os.path.basename(project_gdb)} in '{inspect.stack()[0][3]}'") + arcpy.AddMessage(f"\tProject GDB: {os.path.basename(project_gdb)}") + arcpy.AddMessage(f"\t\tArchive Folder: {os.path.basename(_archive_folder)}") + + arcpy.env.workspace = project_gdb + + arcpy.management.CreateSQLiteDatabase( + out_database_name=archive_gdb, spatial_type="GEOPACKAGE" + ) + + archive_tbs = [ + "DisMAP_Survey_Info", + "Indicators", + "SpeciesPersistenceIndicatorPercentileBin", + "SpeciesPersistenceIndicatorTrend", + "Species_Filter", + ] + # fc_md.exportMetadata("C:\\Users\\john.f.kennedy\\Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\NCEI Archive\fc_md.xml", "ISO19139_GML32", 'REMOVE_ALL_SENSITIVE_INFO') + for tb in sorted( + [ + tb + for tb in arcpy.ListTables("*") + if tb in archive_tbs or tb.endswith("_IDW") + ] + ): + arcpy.AddMessage(f"\t\t\tTable: {tb}") + arcpy.management.Copy(rf"{project_gdb}\{tb}", rf"{archive_gdb}\{tb}") + tb_md = md.Metadata(rf"{project_gdb}\{tb}") + tb_md.exportMetadata( + os.path.abspath( + os.path.join( + archive_folder, + f"DisMAP_{dismap_tools.date_code(version)}", + f"results/vector-tabular/metadata/{tb}.xml", + ) + ), + "ISO19139", + "REMOVE_ALL_SENSITIVE_INFO", + ) + del tb_md + + del tb + del archive_tbs + + archive_fcs = [ + "Regions", + "Sample_Locations", + ] + + for fc in sorted( + [ + fc + for fc in arcpy.ListFeatureClasses("*") + if any(fc.endswith(f"{f}") for f in archive_fcs) + ] + ): + arcpy.AddMessage(f"\t\t\tFeature Class: {fc}") + arcpy.management.Copy(rf"{project_gdb}\{fc}", rf"{archive_gdb}\{fc}") + fc_md = md.Metadata(rf"{project_gdb}\{fc}") + fc_md.exportMetadata( + os.path.abspath( + os.path.join( + archive_folder, + f"DisMAP_{dismap_tools.date_code(version)}", + f"results/vector-tabular/metadata/{fc}.xml", + ) + ), + "ISO19139", + "REMOVE_ALL_SENSITIVE_INFO", + ) + del fc_md + + del fc + + del project_gdb, _archive_folder, archive_gdb + del version + + # Delete Declared Varibales + # Delete Functions Parameters + del home_folder, versions, archive_folder + # Imports + del dismap_tools, md + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +if __name__ == "__main__": + try: + home_folder = arcpy.GetParameterAsText(0) + versions = arcpy.GetParameterAsText(1) + archive_folder = arcpy.GetParameterAsText(2) + + if not home_folder: + home_folder = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMap\ArcGIS-Analysis-Python" + else: + arcpy.AddMessage(f"Home Folder: {os.path.basename(home_folder)}") + + if not versions: + versions = [ + "April 1 2023", + "July 1 2024", + "August 1 2025", + ] + # versions = ["July 1 2024", "August 1 2025",] + else: + arcpy.AddMessage(f"Versions: {', '.join(versions)}") + + if not archive_folder: + archive_folder = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMap\ArcGIS-Analysis-Python\NCEI Archive" + else: + arcpy.AddMessage(f"Home Folder: {os.path.basename(home_folder)}") + + result = main( + home_folder=home_folder, versions=versions, archive_folder=archive_folder + ) + + if result: + arcpy.SetParameterAsText(3, result) + else: + pass + del result + + # Clean-up declared variables + del home_folder, versions, archive_folder + + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + else: + pass + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/src/dismap_tools_dev/dev_export_arcgis_metadata.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_export_arcgis_metadata.py similarity index 74% rename from ArcGIS-Analysis-Python/src/dismap_tools_dev/dev_export_arcgis_metadata.py rename to ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_export_arcgis_metadata.py index 86a4184..ed9b19e 100644 --- a/ArcGIS-Analysis-Python/src/dismap_tools_dev/dev_export_arcgis_metadata.py +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_export_arcgis_metadata.py @@ -15,18 +15,21 @@ See the License for the specific language governing permissions and limitations under the License. """ + +import inspect # Python Built-in's modules are loaded first -import os, sys -import traceback, inspect +import os +import sys +import traceback + def export_metadata(project_gdb="", metadata_workspace=""): try: # Imports # Third-party modules are loaded second import arcpy - from arcpy import metadata as md import dev_create_folders - + from arcpy import metadata as md # Project modules from src.project_tools import pretty_format_xml_file @@ -37,7 +40,7 @@ def export_metadata(project_gdb="", metadata_workspace=""): # Define variables project_folder = os.path.dirname(project_gdb) scratch_folder = rf"{project_folder}\Scratch" - scratch_gdb = rf"{scratch_folder}\scratch.gdb" + scratch_gdb = rf"{scratch_folder}\scratch.gdb" # Set the workspace environment to local file geodatabase arcpy.env.workspace = project_gdb @@ -60,7 +63,9 @@ def export_metadata(project_gdb="", metadata_workspace=""): fc_path = rf"{project_gdb}\{fc}" - export_xml_metadata_path = rf"{project_folder}\{metadata_workspace}\{fc}.xml" + export_xml_metadata_path = ( + rf"{project_folder}\{metadata_workspace}\{fc}.xml" + ) dataset_md = md.Metadata(fc_path) dataset_md.synchronize("ALWAYS") @@ -68,7 +73,7 @@ def export_metadata(project_gdb="", metadata_workspace=""): dataset_md.save() dataset_md.reload() dataset_md.saveAsXML(export_xml_metadata_path, "REMOVE_ALL_SENSITIVE_INFO") - #if dataset_md.thumbnailUri: + # if dataset_md.thumbnailUri: # arcpy.management.Copy(dataset_md.thumbnailUri, rf"{metadata_workspace}\{fc} Thumbnail.jpg") # arcpy.management.Copy(dataset_md.thumbnailUri, rf"{metadata_workspace}\{fc} Browse Graphic.jpg") @@ -77,7 +82,7 @@ def export_metadata(project_gdb="", metadata_workspace=""): if os.path.isfile(export_xml_metadata_path): pretty_format_xml_file(export_xml_metadata_path) else: - print(F"Problem with '{os.path.basename(export_xml_metadata_path)}'") + print(f"Problem with '{os.path.basename(export_xml_metadata_path)}'") del export_xml_metadata_path del fc, fc_path @@ -100,21 +105,29 @@ def export_metadata(project_gdb="", metadata_workspace=""): # Imports del arcpy # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: print(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk return True finally: pass + def main(project_gdb="", metadata_workspace=""): try: from time import gmtime, localtime, strftime, time + # Set a start time so that we can see how log things take start_time = time() print(f"{'-' * 80}") print(f"Python Script: {os.path.basename(__file__)}") print(f"Location: {os.path.dirname(__file__)}") - print(f"Python Version: {sys.version} Environment: {os.path.basename(sys.exec_prefix)}") + print( + f"Python Version: {sys.version} Environment: {os.path.basename(sys.exec_prefix)}" + ) print(f"{'-' * 80}\n") export_metadata(project_gdb=project_gdb, metadata_workspace=metadata_workspace) @@ -126,10 +139,14 @@ def main(project_gdb="", metadata_workspace=""): # Elapsed time end_time = time() - elapse_time = end_time - start_time + elapse_time = end_time - start_time print(f"\n{'-' * 80}") - print(f"Python script: {os.path.basename(__file__)} successfully completed {strftime('%a %b %d %I:%M %p', localtime())}") - print(u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time)))) + print( + f"Python script: {os.path.basename(__file__)} successfully completed {strftime('%a %b %d %I:%M %p', localtime())}" + ) + print( + "Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) + ) print(f"{'-' * 80}") del elapse_time, end_time, start_time del gmtime, localtime, strftime, time @@ -138,31 +155,36 @@ def main(project_gdb="", metadata_workspace=""): traceback.print_exc() else: # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: print(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk return True finally: pass -if __name__ == '__main__': + +if __name__ == "__main__": try: # Imports from datetime import date # Append the location of this scrip to the System Path - #sys.path.append(os.path.dirname(__file__)) + # sys.path.append(os.path.dirname(__file__)) sys.path.append(os.path.dirname(os.path.dirname(__file__))) today = date.today() date_string = today.strftime("%Y-%m-%d") - project_folder = rf"{os.path.dirname(os.path.dirname(__file__))}" - project_name = "National Mapper" - #project_name = "NMFS_ESA_Range" - project_gdb = rf"{project_folder}\{project_name}.gdb" + project_folder = rf"{os.path.dirname(os.path.dirname(__file__))}" + project_name = "National Mapper" + # project_name = "NMFS_ESA_Range" + project_gdb = os.path.join(project_folder, f"{project_name}.gdb") metadata_workspace = f"Export" - #metadata_workspace = f"Export {date_string}" - #metadata_workspace = f"Export 2025-01-27" + # metadata_workspace = f"Export {date_string}" + # metadata_workspace = f"Export 2025-01-27" main(project_gdb=project_gdb, metadata_workspace=metadata_workspace) @@ -177,4 +199,5 @@ def main(project_gdb="", metadata_workspace=""): else: pass finally: - pass \ No newline at end of file + pass +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_transform_metadata.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_transform_metadata.py new file mode 100644 index 0000000..d65595c --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dev_transform_metadata.py @@ -0,0 +1,59 @@ +#--------------------------------------------------------------------------------------- +# Name: module1 +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 21/05/2026 +# Copyright: (c) john.f.kennedy 2026 +# Licence: +#--------------------------------------------------------------------------------------- + +import os +#import arcpy +from arcpy import metadata as md + +def transform_metadata(input_xml, xslt_path, output_xml): + """ + Uses ArcGIS Pro's metadata engine to apply a custom XSLT stylesheet + to an XML metadata document. + """ + print(f"Initializing Metadata Engine for: {os.path.basename(input_xml)}") + + # Instantiate the metadata object pointing to your source XML + source_metadata = md.Metadata(input_xml) + + # Apply the custom XSLT stylesheet and export the transformed content + # saveAsUsingCustomXSLT is the native Pro method replacing older ArcMap conversion tools + source_metadata.saveAsUsingCustomXSLT( + outputPath=output_xml, + customStylesheetPath=xslt_path + ) + + print(f"Success! Transformed metadata saved to: {output_xml}") + +if __name__ == "__main__": + from lxml import etree + #from io import StringIO + + #xml_file = r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\Initial-Data\DisMAP_Contacts_20250801.xml" + xml_file = r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\Initial-Data\DisMAP_Contacts_20260201.xml" + + tree = etree.parse(xml_file, parser=etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) + + #print(etree.tostring(target_tree, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True)) + + tree.write(xml_file, + pretty_print=True, + xml_declaration=True, + encoding="UTF-8") + +## # Define paths (Adjust these to match your workspace) +## WORKING_DIR = r"C:\DataSci\DisMAP_Project" +## +## INPUT_FILE = os.path.join(WORKING_DIR, "DisMAP_Contacts_20250801.xml") +## XSLT_FILE = os.path.join(WORKING_DIR, "disMAP_transform.xslt") +## OUTPUT_FILE = os.path.join(WORKING_DIR, "DisMAP_Contacts_Transformed.xml") +## +## # Execute +## transform_metadata(INPUT_FILE, XSLT_FILE, OUTPUT_FILE) \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/dismap_base_project_setup.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_base_project_setup.py similarity index 74% rename from ArcGIS-Analysis-Python/src/dismap_tools/dismap_base_project_setup.py rename to ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_base_project_setup.py index ee5a8df..047f941 100644 --- a/ArcGIS-Analysis-Python/src/dismap_tools/dismap_base_project_setup.py +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_base_project_setup.py @@ -14,23 +14,28 @@ import arcpy # third-parties second # noqa: F401 + def trace(): - import sys, traceback # noqa: E401 + import sys # noqa: E401 + import traceback + tb = sys.exc_info()[2] tbinfo = traceback.format_tb(tb)[0] line = tbinfo.split(", ")[1] filename = sys.path[0] + os.sep + "test.py" - synerror = traceback.format_exc().splitlines()[-1] + synerror = traceback.print_exc().splitlines()[-1] return line, filename, synerror + def script_tool(base_project_folder="", base_project_folders=""): try: from time import gmtime, localtime, strftime, time + # Set a start time so that we can see how log things take start_time = time() arcpy.AddMessage(f"{'-' * 80}") arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - #arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") + # arcpy.AddMessage(f"Location: ../{'/'.join(__file__.split(os.sep)[-4:])}") arcpy.AddMessage(f"Python Version: {sys.version}") arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") arcpy.AddMessage(f"{'-' * 80}\n") @@ -39,12 +44,14 @@ def script_tool(base_project_folder="", base_project_folders=""): arcpy.env.workspace = base_project_folder - #for folder in arcpy.ListWorkspaces("*", "Folder"): + # for folder in arcpy.ListWorkspaces("*", "Folder"): # arcpy.AddMessage(os.path.basename(folder)) # del folder for project_folder in base_project_folders.split(";"): - project_folder_path = os.path.abspath(os.path.join(base_project_folder, f"{project_folder}")) + project_folder_path = os.path.abspath( + os.path.join(base_project_folder, f"{project_folder}") + ) if not os.path.isdir(project_folder_path): os.makedirs(project_folder_path) else: @@ -61,24 +68,28 @@ def script_tool(base_project_folder="", base_project_folders=""): # Elapsed time end_time = time() - elapse_time = end_time - start_time + elapse_time = end_time - start_time arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}") - arcpy.AddMessage(u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time)))) + arcpy.AddMessage( + f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}" + ) + arcpy.AddMessage( + "Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) + ) arcpy.AddMessage(f"{'-' * 80}") del elapse_time, end_time, start_time del gmtime, localtime, strftime, time except arcpy.ExecuteError: - #Return Geoprocessing tool specific errors + # Return Geoprocessing tool specific errors line, filename, err = trace() arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") for msg in range(0, arcpy.GetMessageCount()): if arcpy.GetSeverity(msg) == 2: arcpy.AddReturnMessage(msg) return False - except:# noqa: E722 - #Gets non-tool errors + except: # noqa: E722 + # Gets non-tool errors line, filename, err = trace() arcpy.AddError("Python error on " + line + " of " + filename) arcpy.AddError(err) @@ -86,9 +97,10 @@ def script_tool(base_project_folder="", base_project_folders=""): else: return True -if __name__ == '__main__': + +if __name__ == "__main__": try: - base_project_folder = arcpy.GetParameterAsText(0) + base_project_folder = arcpy.GetParameterAsText(0) base_project_folders = arcpy.GetParameterAsText(1) if not base_project_folder: @@ -97,7 +109,7 @@ def script_tool(base_project_folder="", base_project_folders=""): pass if not base_project_folders: - base_project_folders = "Bathymetry;Initial Data" + base_project_folders = "Bathymetry;Dataset Shapefiles;Initial Data" else: pass @@ -107,9 +119,10 @@ def script_tool(base_project_folder="", base_project_folders=""): del base_project_folder, base_project_folders except: # noqa: E722 - #Gets non-tool errors + # Gets non-tool errors line, filename, err = trace() arcpy.AddError("Python error on " + line + " of " + filename) arcpy.AddError(err) else: - pass \ No newline at end of file + pass +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_metadata_processing.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_metadata_processing.py new file mode 100644 index 0000000..f9d02ee --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_metadata_processing.py @@ -0,0 +1,2936 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: module1 +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 03/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import importlib +import inspect +import os +import sys +import traceback + +import arcpy # third-parties second + +sys.path.append(os.path.dirname(__file__)) + + +def line_info(msg): + f = inspect.currentframe() + i = inspect.getframeinfo(f.f_back) + return f"Script: {os.path.basename(i.filename)}\n\tNear Line: {i.lineno}\n\tFunction: {i.function}\n\tMessage: {msg}" + + +def create_basic_template_xml_files(project_folder=""): + try: + # Import + from arcpy import metadata as md + from dismap_tools import dataset_title_dict, parse_xml_file_format_and_save + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + +## base_project_folder = rf"{os.path.dirname(base_project_file)}" +## base_project_file = rf"{base_project_folder}\DisMAP.aprx" +## project_folder = rf"{base_project_folder}\{project}" + project = os.path.basename(project_folder) + project_gdb = os.path.join(project_folder, f"{project}.gdb") + metadata_folder = os.path.join(project_folder, "Template Metadata") + crfs_folder = os.path.join(project_folder, "CRFs") + scratch_folder = os.path.join(project_folder, "Scratch") + + metadata_dictionary = dataset_title_dict(project_gdb) + + workspaces = [project_gdb, crfs_folder] + + for workspace in workspaces: + + arcpy.env.workspace = workspace + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + datasets = list() + + walk = arcpy.da.Walk(workspace) + + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + + for dataset_path in sorted(datasets): + # print(dataset_path) + dataset_name = os.path.basename(dataset_path) + + print(f"Dataset Name: {dataset_name}") + + if "Datasets" == dataset_name: + + print(f"\tDataset Table") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + datasets_table_template = ( + rf"{metadata_folder}\datasets_table_template.xml" + ) + dataset_md.saveAsXML( + datasets_table_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(datasets_table_template) + del datasets_table_template + + del dataset_md + + elif "Species_Filter" == dataset_name: + + print(f"\tSpecies Filter Table") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + species_filter_table_template = ( + rf"{metadata_folder}\species_filter_table_template.xml" + ) + dataset_md.saveAsXML( + species_filter_table_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(species_filter_table_template) + del species_filter_table_template + + del dataset_md + + elif "Indicators" in dataset_name: + + print(f"\tIndicators") + + if dataset_name == "Indicators": + dataset_name = f"{dataset_name}_Table" + else: + pass + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + indicators_template = rf"{metadata_folder}\indicators_template.xml" + dataset_md.saveAsXML( + indicators_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(indicators_template) + del indicators_template + + del dataset_md + + elif "LayerSpeciesYearImageName" in dataset_name: + + print(f"\tLayer Species Year Image Name") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + layer_species_year_image_name_template = ( + rf"{metadata_folder}\layer_species_year_image_name_template.xml" + ) + dataset_md.saveAsXML( + layer_species_year_image_name_template, + "REMOVE_ALL_SENSITIVE_INFO", + ) + parse_xml_file_format_and_save(layer_species_year_image_name_template) + del layer_species_year_image_name_template + + del dataset_md + + elif dataset_name.endswith("Boundary"): + + print(f"\tBoundary") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + boundary_template = rf"{metadata_folder}\boundary_template.xml" + dataset_md.saveAsXML(boundary_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(boundary_template) + del boundary_template + + del dataset_md + + elif dataset_name.endswith("Extent_Points"): + + print(f"\tExtent_Points") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + extent_points_template = ( + rf"{metadata_folder}\extent_points_template.xml" + ) + dataset_md.saveAsXML( + extent_points_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(extent_points_template) + del extent_points_template + + del dataset_md + + elif dataset_name.endswith("Fishnet"): + + print(f"\tFishnet") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + fishnet_template = rf"{metadata_folder}\fishnet_template.xml" + dataset_md.saveAsXML(fishnet_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(fishnet_template) + del fishnet_template + + del dataset_md + + elif dataset_name.endswith("Lat_Long"): + + print(f"\tLat_Long") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + lat_long_template = rf"{metadata_folder}\lat_long_template.xml" + dataset_md.saveAsXML(lat_long_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(lat_long_template) + del lat_long_template + + del dataset_md + + elif dataset_name.endswith("Region"): + + print(f"\tRegion") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + region_template = rf"{metadata_folder}\region_template.xml" + dataset_md.saveAsXML(region_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(region_template) + del region_template + + del dataset_md + + elif dataset_name.endswith("Sample_Locations"): + + print(f"\tSample_Locations") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + sample_locations_template = ( + rf"{metadata_folder}\sample_locations_template.xml" + ) + dataset_md.saveAsXML( + sample_locations_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(sample_locations_template) + del sample_locations_template + + del dataset_md + + elif dataset_name.endswith("GRID_Points"): + + print(f"\tGRID_Points") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + grid_points_template = ( + rf"{metadata_folder}\grid_points_template.xml" + ) + dataset_md.saveAsXML( + grid_points_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(grid_points_template) + del grid_points_template + + del dataset_md + + elif "DisMAP_Regions" == dataset_name: + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + dismap_regions_template = ( + rf"{metadata_folder}\dismap_regions_template.xml" + ) + dataset_md.saveAsXML( + dismap_regions_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(dismap_regions_template) + del dismap_regions_template + + del dataset_md + + elif dataset_name.endswith("Bathymetry"): + + print("\tBathymetry") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + bathymetry_template = rf"{metadata_folder}\bathymetry_template.xml" + dataset_md.saveAsXML( + bathymetry_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(bathymetry_template) + del bathymetry_template + + del dataset_md + + elif dataset_name.endswith("Latitude"): + + print(f"\tLatitude") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + latitude_template = rf"{metadata_folder}\latitude_template.xml" + dataset_md.saveAsXML(latitude_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(latitude_template) + del latitude_template + + del dataset_md + + elif dataset_name.endswith("Longitude"): + + print(f"\tLongitude") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + longitude_template = rf"{metadata_folder}\longitude_template.xml" + dataset_md.saveAsXML( + longitude_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(longitude_template) + del longitude_template + + del dataset_md + + elif dataset_name.endswith("Raster_Mask"): + + print(f"\tRaster_Mask") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + raster_mask_template = ( + rf"{metadata_folder}\raster_mask_template.xml" + ) + dataset_md.saveAsXML( + raster_mask_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(raster_mask_template) + del raster_mask_template + + del dataset_md + + elif dataset_name.endswith("Mosaic"): + + print(f"\tMosaic") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + mosaic_template = rf"{metadata_folder}\mosaic_template.xml" + dataset_md.saveAsXML(mosaic_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(mosaic_template) + del mosaic_template + + del dataset_md + + elif dataset_name.endswith(".crf"): + + print(f"\tCRF") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Dataset Service Title"] + dataset_md.tags = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Tags"] + dataset_md.summary = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Summary"] + dataset_md.description = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Description"] + dataset_md.credits = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Access Constraints"] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + crf_template = rf"{metadata_folder}\crf_template.xml" + dataset_md.saveAsXML(crf_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(crf_template) + del crf_template + + del dataset_md + + else: + print(f"\tRegion Table") + + if dataset_name.endswith("IDW"): + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[f"{dataset_name}"][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[f"{dataset_name}"]["Tags"] + dataset_md.summary = metadata_dictionary[f"{dataset_name}"][ + "Summary" + ] + dataset_md.description = metadata_dictionary[f"{dataset_name}"][ + "Description" + ] + dataset_md.credits = metadata_dictionary[f"{dataset_name}"][ + "Credits" + ] + dataset_md.accessConstraints = metadata_dictionary[ + f"{dataset_name}" + ]["Access Constraints"] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + idw_region_table_template = ( + rf"{metadata_folder}\idw_region_table_template.xml" + ) + dataset_md.saveAsXML( + idw_region_table_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(idw_region_table_template) + del idw_region_table_template + + del dataset_md + + elif dataset_name.endswith("GLMME"): + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[f"{dataset_name}"][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[f"{dataset_name}"]["Tags"] + dataset_md.summary = metadata_dictionary[f"{dataset_name}"][ + "Summary" + ] + dataset_md.description = metadata_dictionary[f"{dataset_name}"][ + "Description" + ] + dataset_md.credits = metadata_dictionary[f"{dataset_name}"][ + "Credits" + ] + dataset_md.accessConstraints = metadata_dictionary[ + f"{dataset_name}" + ]["Access Constraints"] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + glmme_region_table_template = ( + rf"{metadata_folder}\glmme_region_table_template.xml" + ) + dataset_md.saveAsXML( + glmme_region_table_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(glmme_region_table_template) + del glmme_region_table_template + + del dataset_md + + else: + pass + + del dataset_name, dataset_path + + del workspace + + del datasets + + # Declared Variables set in function + del project_gdb, base_project_folder, metadata_folder + del project_folder, scratch_folder, crfs_folder + del metadata_dictionary, workspaces + + # Imports + del dismap, dataset_title_dict, parse_xml_file_format_and_save + del md + + # Function Parameters + del base_project_file, project + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + # arcpy.AddMessage("\nScript finished successfully.") + return True + + +def import_basic_template_xml_files(base_project_file="", project=""): + try: + # Import + import dismap + from arcpy import metadata as md + + importlib.reload(dismap) + from dismap import (dataset_title_dict, parse_xml_file_format_and_save, + unique_years) + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel(2) + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + base_project_folder = rf"{os.path.dirname(base_project_file)}" + project_folder = rf"{base_project_folder}\{project}" + project_gdb = rf"{project_folder}\{project}.gdb" + current_md_folder = rf"{project_folder}\Current Metadata" + inport_md_folder = rf"{project_folder}\InPort Metadata" + crfs_folder = rf"{project_folder}\CRFs" + scratch_folder = rf"{project_folder}\Scratch" + + # print("Creating the Metadata Dictionary. Please wait!!") + metadata_dictionary = dataset_title_dict(project_gdb) + # print("Creating the Metadata Dictionary. Completed") + + workspaces = [project_gdb, crfs_folder] + # workspaces = [crfs_folder] + + for workspace in workspaces: + + arcpy.env.workspace = workspace + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + datasets = list() + + walk = arcpy.da.Walk(workspace) + + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + + for dataset_path in sorted(datasets): + # print(dataset_path) + dataset_name = os.path.basename(dataset_path) + + print(f"Dataset Name: {dataset_name}") + + if "Datasets" == dataset_name: + + print(f"\tDataset Table") + + datasets_table_template = ( + rf"{current_md_folder}\Table\datasets_table_template.xml" + ) + template_md = md.Metadata(datasets_table_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + # dataset_md.importMetadata(datasets_table_template) + dataset_md.save() + # dataset_md.synchronize("SELECTIVE") + + del empty_md, template_md, datasets_table_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Table\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif "Species_Filter" == dataset_name: + + print(f"\tSpecies Filter Table") + + species_filter_table_template = ( + rf"{current_md_folder}\Table\species_filter_table_template.xml" + ) + template_md = md.Metadata(species_filter_table_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, species_filter_table_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Table\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif "Indicators" in dataset_name: + + print(f"\tIndicators") + + if dataset_name == "Indicators": + indicators_template = ( + rf"{current_md_folder}\Table\indicators_template.xml" + ) + else: + indicators_template = ( + rf"{current_md_folder}\Table\region_indicators_template.xml" + ) + + template_md = md.Metadata(indicators_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, indicators_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + # print(metadata_dictionary[dataset_name]["Tags"]) + # print(_tags) + + if dataset_name == "Indicators": + dataset_name = f"{dataset_name}_Table" + else: + pass + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Table\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + elif "LayerSpeciesYearImageName" in dataset_name: + + print(f"\tLayer Species Year Image Name") + + layer_species_year_image_name_template = rf"{current_md_folder}\Table\layer_species_year_image_name_template.xml" + template_md = md.Metadata(layer_species_year_image_name_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, layer_species_year_image_name_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Table\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + elif dataset_name.endswith("Boundary"): + + print(f"\tBoundary") + + boundary_template = ( + rf"{current_md_folder}\Boundary\boundary_template.xml" + ) + template_md = md.Metadata(boundary_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, boundary_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Boundary\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Boundary\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Extent_Points"): + + print(f"\tExtent_Points") + + extent_points_template = ( + rf"{current_md_folder}\Extent_Points\extent_points_template.xml" + ) + template_md = md.Metadata(extent_points_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, extent_points_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Extent_Points\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Extent_Points\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Fishnet"): + + print(f"\tFishnet") + + fishnet_template = ( + rf"{current_md_folder}\Fishnet\fishnet_template.xml" + ) + template_md = md.Metadata(fishnet_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, fishnet_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Fishnet\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Fishnet\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Lat_Long"): + + print(f"\tLat_Long") + + lat_long_template = ( + rf"{current_md_folder}\Lat_Long\lat_long_template.xml" + ) + template_md = md.Metadata(lat_long_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, lat_long_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Lat_Long\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Lat_Long\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Region"): + + print(f"\tRegion") + + region_template = rf"{current_md_folder}\Region\region_template.xml" + template_md = md.Metadata(region_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, region_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Region\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Region\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Sample_Locations"): + + print(f"\tSample_Locations") + + sample_locations_template = rf"{current_md_folder}\Sample_Locations\sample_locations_template.xml" + template_md = md.Metadata(sample_locations_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, sample_locations_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = ( + rf"{current_md_folder}\Sample_Locations\{dataset_name}.xml" + ) + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Sample_Locations\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + elif dataset_name.endswith("GRID_Points"): + + print(f"\tGRID_Points") + + grid_points_template = ( + rf"{current_md_folder}\GRID_Points\grid_points_template.xml" + ) + template_md = md.Metadata(grid_points_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, grid_points_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\GRID_Points\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\GRID_Points\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + elif "DisMAP_Regions" == dataset_name: + + print(f"\tDisMAP_Regions") + + dismap_regions_template = ( + rf"{current_md_folder}\Region\dismap_regions_template.xml" + ) + template_md = md.Metadata(dismap_regions_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, dismap_regions_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Region\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Region\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Bathymetry"): + + print("\tBathymetry") + + bathymetry_template = ( + rf"{current_md_folder}\Bathymetry\bathymetry_template.xml" + ) + template_md = md.Metadata(bathymetry_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, bathymetry_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Bathymetry\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Bathymetry\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Latitude"): + + print(f"\tLatitude") + + latitude_template = ( + rf"{current_md_folder}\Latitude\latitude_template.xml" + ) + template_md = md.Metadata(latitude_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, latitude_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Latitude\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Latitude\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Longitude"): + + print(f"\tLongitude") + + longitude_template = ( + rf"{current_md_folder}\Longitude\longitude_template.xml" + ) + template_md = md.Metadata(longitude_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, longitude_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Longitude\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Longitude\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Raster_Mask"): + + print(f"\tRaster_Mask") + + raster_mask_template = ( + rf"{current_md_folder}\Raster_Mask\raster_mask_template.xml" + ) + template_md = md.Metadata(raster_mask_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, raster_mask_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Raster_Mask\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Raster_Mask\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Mosaic"): + + print(f"\tMosaic") + + mosaic_template = rf"{current_md_folder}\Mosaic\mosaic_template.xml" + template_md = md.Metadata(mosaic_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, mosaic_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Mosaic\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Mosaic\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + elif dataset_name.endswith(".crf"): + + print(f"\tCRF") + # print(dataset_name) + # print(dataset_path) + # dataset_path = dataset_path.replace(crfs_folder, project_gdb).replace(".crf", "_Mosaic") + # print(dataset_path) + + crf_template = rf"{current_md_folder}\CRF\crf_template.xml" + template_md = md.Metadata(crf_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, crf_template + + # Max-Min Year range table + years_md = unique_years( # This line is causing an error because unique_years expects a feature class or table, not a path to a CRF. + dataset_path.replace(crfs_folder, project_gdb).replace( + ".crf", "_Mosaic" + ) + ) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Dataset Service Title"] + dataset_md.tags = ( + metadata_dictionary[dataset_name.replace(".crf", "_CRF")][ + "Tags" + ] + + _tags + ) + dataset_md.summary = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Summary"] + dataset_md.description = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Description"] + dataset_md.credits = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Access Constraints"] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\CRF\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\CRF\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + else: + print(f"\tRegion Table") + + if dataset_name.endswith("IDW"): + + idw_region_table_template = ( + rf"{current_md_folder}\Table\idw_region_table_template.xml" + ) + template_md = md.Metadata(idw_region_table_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, idw_region_table_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[f"{dataset_name}"][ + "Dataset Service Title" + ] + dataset_md.tags = ( + metadata_dictionary[f"{dataset_name}"]["Tags"] + _tags + ) + dataset_md.summary = metadata_dictionary[f"{dataset_name}"][ + "Summary" + ] + dataset_md.description = metadata_dictionary[f"{dataset_name}"][ + "Description" + ] + dataset_md.credits = metadata_dictionary[f"{dataset_name}"][ + "Credits" + ] + dataset_md.accessConstraints = metadata_dictionary[ + f"{dataset_name}" + ]["Access Constraints"] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Table\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT( + target_file_path, custom_xslt_path + ) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + elif dataset_name.endswith("GLMME"): + + glmme_region_table_template = rf"{current_md_folder}\Table\glmme_region_table_template.xml" + template_md = md.Metadata(glmme_region_table_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, glmme_region_table_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[f"{dataset_name}"][ + "Dataset Service Title" + ] + dataset_md.tags = ( + metadata_dictionary[f"{dataset_name}"]["Tags"] + _tags + ) + dataset_md.summary = metadata_dictionary[f"{dataset_name}"][ + "Summary" + ] + dataset_md.description = metadata_dictionary[f"{dataset_name}"][ + "Description" + ] + dataset_md.credits = metadata_dictionary[f"{dataset_name}"][ + "Credits" + ] + dataset_md.accessConstraints = metadata_dictionary[ + f"{dataset_name}" + ]["Access Constraints"] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Table\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT( + target_file_path, custom_xslt_path + ) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + else: + pass + + del dataset_name, dataset_path + + del workspace + + del datasets + + # Declared Variables set in function + del project_gdb, base_project_folder, current_md_folder, inport_md_folder + del project_folder, scratch_folder, crfs_folder + del metadata_dictionary, workspaces + + # Imports + del dismap, dataset_title_dict, parse_xml_file_format_and_save, unique_years + del md + + # Function Parameters + del base_project_file, project + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + # arcpy.AddMessage("\nScript finished successfully.") + return True + + +def create_thumbnails(base_project_file="", project=""): + try: + # Import + import dismap + from arcpy import metadata as md + + importlib.reload(dismap) + from dismap import parse_xml_file_format_and_save + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel(2) + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + base_project_folder = rf"{os.path.dirname(base_project_file)}" + base_project_file = rf"{base_project_folder}\DisMAP.aprx" + project_folder = rf"{base_project_folder}\{project}" + project_gdb = rf"{project_folder}\{project}.gdb" + metadata_folder = rf"{project_folder}\Export Metadata" + crfs_folder = rf"{project_folder}\CRFs" + scratch_folder = rf"{project_folder}\Scratch" + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + aprx = arcpy.mp.ArcGISProject(base_project_file) + home_folder = aprx.homeFolder + + workspaces = [project_gdb, crfs_folder] + + for workspace in workspaces: + + arcpy.env.workspace = workspace + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + datasets = list() + + walk = arcpy.da.Walk(workspace) + + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + + for dataset_path in sorted(datasets): + # print(dataset_path) + dataset_name = os.path.basename(dataset_path) + + print(f"Dataset Name: {dataset_name}") + + if "Datasets" == dataset_name: + + print(f"\tDataset Table") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif "Species_Filter" == dataset_name: + + print(f"\tSpecies Filter Table") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif "Indicators" in dataset_name: + + print(f"\tIndicators") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif "LayerSpeciesYearImageName" in dataset_name: + + print(f"\tLayer Species Year Image Name") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Boundary"): + + print(f"\tBoundary") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Boundary\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Extent_Points"): + + print(f"\tExtent_Points") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Extent_Points\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Fishnet"): + + print(f"\tFishnet") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Fishnet\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Lat_Long"): + + print(f"\tLat_Long") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Lat_Long\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Region"): + + print(f"\tRegion") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Region\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Sample_Locations"): + + print(f"\tSample_Locations") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Sample_Locations\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("GRID_Points"): + + print(f"\tGRID_Points") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\GRID_Points\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif "DisMAP_Regions" == dataset_name: + + print(f"\tDisMAP_Regions") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Region\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Bathymetry"): + + print("\tBathymetry") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Bathymetry\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Latitude"): + + print(f"\tLatitude") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Latitude\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Longitude"): + + print(f"\tLongitude") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Longitude\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Raster_Mask"): + + print(f"\tRaster_Mask") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Raster_Mask\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Mosaic"): + + print(f"\tMosaic") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Mosaic\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith(".crf"): + + print(f"\tCRF") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\CRF\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + else: + pass + print(f"\tRegion Table") + + if dataset_name.endswith("IDW"): + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("GLMME"): + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + else: + pass + + del dataset_name, dataset_path + + del workspace, datasets + + del workspaces + + # Declared Variables set in function for aprx + del home_folder + # Save aprx one more time and then delete + aprx.save() + del aprx + + # Declared Variables set in function + del project_gdb, base_project_folder, metadata_folder, crfs_folder + del project_folder, scratch_folder + + # Imports + del dismap, parse_xml_file_format_and_save + del md + + # Function Parameters + del base_project_file, project + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + # arcpy.AddMessage("\nScript finished successfully.") + return True + + +def export_to_inport_xml_files(base_project_file="", project=""): + try: + if not base_project_file or not project: + raise SystemExit("parameters are missing") + + # Import + import dismap + from arcpy import metadata as md + + importlib.reload(dismap) + from dismap import parse_xml_file_format_and_save + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel(2) + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + base_project_folder = rf"{os.path.dirname(base_project_file)}" + project_folder = rf"{base_project_folder}\{project}" + project_gdb = rf"{project_folder}\{project}.gdb" + metadata_folder = rf"{project_folder}\InPort Metadata" + crfs_folder = rf"{project_folder}\CRFs" + scratch_folder = rf"{project_folder}\Scratch" + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + datasets = [ + rf"{project_gdb}\Species_Filter", + rf"{project_gdb}\Indicators", + rf"{project_gdb}\DisMAP_Regions", + rf"{project_gdb}\GMEX_IDW_Sample_Locations", + rf"{project_gdb}\GMEX_IDW_Mosaic", + rf"{crfs_folder}\GMEX_IDW.crf", + ] + + for dataset_path in sorted(datasets): + print(dataset_path) + + dataset_name = os.path.basename(dataset_path) + + print(f"Dataset Name: {dataset_name}") + + target_file_path = rf"{metadata_folder}\{dataset_name}.xml" + custom_xslt_path = rf"{metadata_folder}\ArcGIS2InPort.xsl" + + dataset_md = md.Metadata(dataset_path) + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + del dataset_md + + try: + parse_xml_file_format_and_save(target_file_path) + except Exception: + raise Exception + + del target_file_path, custom_xslt_path + + del dataset_name, dataset_path + + del datasets + + # Declared Variables set in function + del project_gdb, base_project_folder, metadata_folder + del project_folder, scratch_folder, crfs_folder + + # Imports + del dismap, parse_xml_file_format_and_save + del md + + # Function Parameters + del base_project_file, project + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + # arcpy.AddMessage("\nScript finished successfully.") + return True + + +def create_maps(base_project_file="", project="", dataset=""): + try: + # Import + import dismap + from arcpy import metadata as md + + importlib.reload(dismap) + from dismap import parse_xml_file_format_and_save + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel(2) + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + base_project_folder = rf"{os.path.dirname(base_project_file)}" + base_project_file = rf"{base_project_folder}\DisMAP.aprx" + project_folder = rf"{base_project_folder}\{project}" + project_gdb = rf"{project_folder}\{project}.gdb" + metadata_folder = rf"{project_folder}\Export Metadata" + crfs_folder = rf"{project_folder}\CRFs" + scratch_folder = rf"{project_folder}\Scratch" + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + aprx = arcpy.mp.ArcGISProject(base_project_file) + + dataset_name = os.path.basename(dataset) + + print(f"Dataset Name: {dataset_name}") + + if dataset_name not in [cm.name for cm in aprx.listMaps()]: + print(f"Creating Map: {dataset_name}") + aprx.createMap(f"{dataset_name}", "Map") + aprx.save() + else: + pass + + current_map = aprx.listMaps(f"{dataset_name}")[0] + print(f"Current Map: {current_map.name}") + + if dataset_name not in [ + lyr.name for lyr in current_map.listLayers(f"{dataset_name}") + ]: + print(f"Adding {dataset_name} to Map") + + map_layer = arcpy.management.MakeFeatureLayer(dataset, f"{dataset_name}") + + # arcpy.management.Delete(rf"{project_folder}\Layers\{dataset_name}.lyrx") + # os.remove(rf"{project_folder}\Layers\{dataset_name}.lyrx") + + map_layer_file = arcpy.management.SaveToLayerFile( + map_layer, rf"{project_folder}\Layers\{dataset_name}.lyrx" + ) + del map_layer_file + + map_layer_file = arcpy.mp.LayerFile( + rf"{project_folder}\Layers\{dataset_name}.lyrx" + ) + + arcpy.management.Delete(map_layer) + del map_layer + + current_map.addLayer(map_layer_file) + del map_layer_file + + aprx.save() + else: + pass + + # aprx_basemaps = aprx.listBasemaps() + # basemap = 'GEBCO Basemap/Contours (NOAA NCEI Visualization)' + basemap = "Terrain with Labels" + + current_map.addBasemap(basemap) + del basemap + + # Set Reference Scale + current_map.referenceScale = 50000000 + + # Clear Selection + current_map.clearSelection() + + current_map_cim = current_map.getDefinition("V3") + current_map_cim.enableWraparound = True + current_map.setDefinition(current_map_cim) + + # Return the layer's CIM definition + cim_lyr = lyr.getDefinition("V3") + + # Modify the color, width and dash template for the SolidStroke layer + symLvl1 = cim_lyr.renderer.symbol.symbol.symbolLayers[0] + symLvl1.color.values = [0, 0, 0, 100] + symLvl1.width = 1 + + # Push the changes back to the layer object + lyr.setDefinition(cim_lyr) + del symLvl1, cim_lyr + + aprx.save() + + height = ( + arcpy.Describe(dataset).extent.YMax - arcpy.Describe(dataset).extent.YMin + ) + width = ( + arcpy.Describe(dataset).extent.XMax - arcpy.Describe(dataset).extent.XMin + ) + + # map_width, map_height + map_width, map_height = 8.5, 11 + + if height > width: + page_height = map_height + page_width = map_width + elif height < width: + page_height = map_width + page_width = map_height + else: + page_width = map_width + page_height = map_height + + del map_width, map_height + del height, width + + if dataset_name not in [cl.name for cl in aprx.listLayouts()]: + print(f"Creating Layout: {dataset_name}") + aprx.createLayout(page_width, page_height, "INCH", f"{dataset_name}") + aprx.save() + else: + print(f"Layout: {dataset_name} exists") + + # Set the default map camera to the extent of the park boundary before opening the new view + # default camera only affects newly opened views + lyr = current_map.listLayers(f"{dataset_name}")[-1] + + # + arcpy.management.SelectLayerByAttribute( + lyr, "NEW_SELECTION", "DatasetCode in ('ENBS', 'HI', 'NEUS_SPR')" + ) + + mv = current_map.openView() + mv.panToExtent(mv.getLayerExtent(lyr, True, True)) + mv.zoomToAllLayers() + del mv + + arcpy.management.SelectLayerByAttribute(lyr, "CLEAR_SELECTION") + + av = aprx.activeView + av.exportToPNG( + rf"{project_folder}\Layers\{dataset_name}.png", + width=288, + height=192, + resolution=96, + color_mode="24-BIT_TRUE_COLOR", + embed_color_profile=True, + ) + av.exportToJPEG( + rf"{project_folder}\Layers\{dataset_name}.jpg", + width=288, + height=192, + resolution=96, + jpeg_color_mode="24-BIT_TRUE_COLOR", + embed_color_profile=True, + ) + del av + + # print(current_map.referenceScale) + + # export the newly opened active view to PDF, then delete the new map + # mv = aprx.activeView + # mv.exportToPDF(r"C:\Temp\RangerStations.pdf", width=700, height=500, resolution=96) + # aprx.deleteItem(current_map) + + # mv = aprx.activeView + # mv = current_map.defaultView + # mv.zoomToAllLayers() + # print(mv.camera.getExtent()) + # arcpy.management.Delete(rf"{project_folder}\Layers\{dataset_name}.png") + # arcpy.management.Delete(rf"{project_folder}\Layers\{dataset_name}.jpg") + + # os.remove(rf"{project_folder}\Layers\{dataset_name}.png") + # os.remove(rf"{project_folder}\Layers\{dataset_name}.jpg") + + # mv.exportToPNG(rf"{project_folder}\Layers\{dataset_name}.png", width=288, height=192, resolution = 96, color_mode="24-BIT_TRUE_COLOR", embed_color_profile=True) + # mv.exportToJPEG(rf"{project_folder}\Layers\{dataset_name}.jpg", width=288, height=192, resolution = 96, jpeg_color_mode="24-BIT_TRUE_COLOR", embed_color_profile=True) + # del mv + + # Export the resulting imported layout and changes to JPEG + # print(f"Exporting '{current_layout.name}'") + # current_map.exportToJPEG(rf"{project_folder}\Layouts\{current_layout.name}.jpg", page_width, page_height) + # current_map.exportToPNG(rf"{project_folder}\Layouts\{current_layout.name}.png", page_width, page_height) + + # fc_md = md.Metadata(dataset) + # fc_md.thumbnailUri = rf"{project_folder}\Layouts\{dataset_name}.png" + # fc_md.thumbnailUri = rf"{project_folder}\Layouts\{dataset_name}.jpg" + # fc_md.save() + # del fc_md + + aprx.save() + + # # from arcpy import metadata as md + # # + # # fc_md = md.Metadata(dataset) + # # fc_md.thumbnailUri = rf"{project_folder}\Layers\{dataset_name}.png" + # # fc_md.save() + # # del fc_md + # # del md + + ## aprx.save() + ## + ## current_layout = [cl for cl in aprx.listLayouts() if cl.name == dataset_name][0] + ## print(f"Current Layout: {current_layout.name}") + ## + ## current_layout.openView() + ## + ## # Remove all map frames + ## for mf in current_layout.listElements("MapFrame_Element"): current_layout.deleteElement(mf); del mf + ## + ## # print(f'Layout Name: {current_layout.name}') + ## # print(f' Width x height: {current_layout.pageWidth} x {current_layout.pageHeight} units are {current_layout.pageUnits}') + ## # print(f' MapFrame count: {str(len(current_layout.listElements("MapFrame_Element")))}') + ## # for mf in current_layout.listElements("MapFrame_Element"): + ## # if len(current_layout.listElements("MapFrame_Element")) > 0: + ## # print(f' MapFrame name: {mf.name}') + ## # print(f' Total element count: {str(len(current_layout.listElements()))} \n') + ## + ## + ## print(f"Create a new map frame using a point geometry") + ## #Create a new map frame using a point geometry + ## #mf1 = current_layout.createMapFrame(arcpy.Point(0.01,0.01), current_map, 'New MF - Point') + ## mf1 = current_layout.createMapFrame(arcpy.Point(0.0,0.0), current_map, 'New MF - Point') + ## #mf1.elementWidth = 10 + ## #mf1.elementHeight = 7.5 + ## #mf1.elementWidth = page_width - 0.01 + ## #mf1.elementHeight = page_height - 0.01 + ## mf1.elementWidth = page_width + ## mf1.elementHeight = page_height + + ## lyr = current_map.listLayers(f"{dataset_name}")[0] + ## + ## #Zoom to ALL selected features and export to PDF + ## #arcpy.SelectLayerByAttribute_management(lyr, 'NEW_SELECTION') + ## #mf1.zoomToAllLayers(True) + ## #arcpy.SelectLayerByAttribute_management(lyr, 'CLEAR_SELECTION') + ## + ## #Set the map frame extent to the extent of a layer + ## #mf1.camera.setExtent(mf1.getLayerExtent(lyr, False, True)) + ## #mf1.camera.scale = mf1.camera.scale * 1.1 #add a slight buffer + ## + ## del lyr + + ## print(f"Create a new bookmark set to the map frame's default extent") + ## #Create a new bookmark set to the map frame's default extent + ## bkmk = mf1.createBookmark('Default Extent', "The map's default extent") + ## bkmk.updateThumbnail() + ## del mf1 + ## del bkmk + + # Create point text element using a system style item + # txtStyleItem = aprx.listStyleItems('ArcGIS 2D', 'TEXT', 'Title (Serif)')[0] + # ptTxt = aprx.createTextElement(current_layout, arcpy.Point(5.5, 4.25), 'POINT', f'{dataset_name}', 10, style_item=txtStyleItem) + # del txtStyleItem + + # Change the anchor position and reposition the text to center + # ptTxt.setAnchor('Center_Point') + # ptTxt.elementPositionX = page_width / 2.0 + # ptTxt.elementPositionY = page_height - 0.25 + # del ptTxt + + # print(f"Using CIM to update border") + # current_layout_cim = current_layout.getDefinition('V3') + # for elm in current_layout_cim.elements: + # if type(elm).__name__ == 'CIMMapFrame': + # if elm.graphicFrame.borderSymbol.symbol.symbolLayers: + # sym = elm.graphicFrame.borderSymbol.symbol.symbolLayers[0] + # sym.width = 5 + # sym.color.values = [255, 0, 0, 100] + # else: + # arcpy.AddWarning(elm.name + ' has NO symbol layers') + # current_layout.setDefinition(current_layout_cim) + # del current_layout_cim, elm, sym + + ## ExportLayout = True + ## if ExportLayout: + ## #Export the resulting imported layout and changes to JPEG + ## print(f"Exporting '{current_layout.name}'") + ## current_layout.exportToJPEG(rf"{project_folder}\Layouts\{current_layout.name}.jpg") + ## current_layout.exportToPNG(rf"{project_folder}\Layouts\{current_layout.name}.png") + ## del ExportLayout + + ## #Export the resulting imported layout and changes to JPEG + ## print(f"Exporting '{current_layout.name}'") + ## current_map.exportToJPEG(rf"{project_folder}\Layouts\{current_layout.name}.jpg", page_width, page_height) + ## current_map.exportToPNG(rf"{project_folder}\Layouts\{current_layout.name}.png", page_width, page_height) + ## + ## fc_md = md.Metadata(dataset) + ## fc_md.thumbnailUri = rf"{project_folder}\Layouts\{current_layout.name}.png" + ## #fc_md.thumbnailUri = rf"{project_folder}\Layouts\{current_layout.name}.jpg" + ## fc_md.save() + ## del fc_md + ## + ## aprx.save() + + # aprx.deleteItem(current_map) + # aprx.deleteItem(current_layout) + + del current_map + # , current_layout + # del page_width, page_height + del dataset_name, dataset + + aprx.save() + + print(f"\nCurrent Maps & Layouts") + + current_maps = aprx.listMaps() + # current_layouts = aprx.listLayouts() + + if current_maps: + print(f"\nCurrent Maps\n") + for current_map in current_maps: + print(f"\tProject Map: {current_map.name}") + del current_map + else: + arcpy.AddWarning("No maps in Project") + + ## if current_layouts: + ## print(f"\nCurrent Layouts\n") + ## for current_layout in current_layouts: + ## print(f"\tProject Layout: {current_layout.name}") + ## del current_layout + ## else: + ## arcpy.AddWarning("No layouts in Project") + + # del current_layouts + del current_maps + + # Declared Variables set in function for aprx + + # Save aprx one more time and then delete + aprx.save() + del aprx + + # Declared Variables set in function + del project_gdb, base_project_folder, metadata_folder, crfs_folder + del project_folder, scratch_folder + + # Imports + del dismap, parse_xml_file_format_and_save + del md + + # Function Parameters + del base_project_file, project + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + # arcpy.AddMessage("\nScript finished successfully.") + return True + + +def script_tool(project_folder=""): + try: + + CreateBasicTemplateXMLFiles = True + if CreateBasicTemplateXMLFiles: + create_basic_template_xml_files(project_folder) + del CreateBasicTemplateXMLFiles + +## ImportBasicTemplateXmlFiles = False +## if ImportBasicTemplateXmlFiles: +## import_basic_template_xml_files(base_project_file, project) +## del ImportBasicTemplateXmlFiles +## +## CreateThumbnails = False +## if CreateThumbnails: +## create_thumbnails(base_project_file, project) +## del CreateThumbnails +## +## CreateMaps = False +## if CreateMaps: +## create_maps( +## base_project_file, project, dataset=rf"{project_gdb}\DisMAP_Regions" +## ) +## del CreateMaps +## +## ExportToInportXmlFiles = False +## if ExportToInportXmlFiles: +## export_to_inport_xml_files(base_project_file, project) +## del ExportToInportXmlFiles + + # Variable created in function + + # Function parameters + del project_folder + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:") + traceback.print_exc() + + else: + arcpy.AddMessage("\nScript finished successfully.\n") + finally: + arcpy.AddMessage(f"\n{'--End' * 10}--") + + +if __name__ == '__main__': + try: + + project_folder = arcpy.GetParameterAsText(0) + + if not project_folder: + release = "February-1-2026" + #release = "August-1-2025" + project_folder = os.path.join(os.path.expanduser('~'), f"Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\{release}") + else: + pass + + script_tool(project_folder) + + arcpy.SetParameterAsText(1, "Result") + + del project_folder + + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + except Exception: + traceback.print_exc() + + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_metadata_processing.~py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_metadata_processing.~py new file mode 100644 index 0000000..de8e01d --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_metadata_processing.~py @@ -0,0 +1,2936 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: module1 +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 03/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import importlib +import inspect +import os +import sys +import traceback + +import arcpy # third-parties second + +sys.path.append(os.path.dirname(__file__)) + + +def line_info(msg): + f = inspect.currentframe() + i = inspect.getframeinfo(f.f_back) + return f"Script: {os.path.basename(i.filename)}\n\tNear Line: {i.lineno}\n\tFunction: {i.function}\n\tMessage: {msg}" + + +def create_basic_template_xml_files(project_folder=""): + try: + # Import + from arcpy import metadata as md + from dismap_tools import dataset_title_dict, parse_xml_file_format_and_save + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + +## base_project_folder = rf"{os.path.dirname(base_project_file)}" +## base_project_file = rf"{base_project_folder}\DisMAP.aprx" +## project_folder = rf"{base_project_folder}\{project}" + project = os.path.basename(project_folder) + project_gdb = os.path.join(project_folder, f"{project}.gdb") + metadata_folder = os.path.join(project_folder, "Template Metadata") + crfs_folder = os.path.join(project_folder, "CRFs") + scratch_folder = os.path.join(project_folder, "Scratch") + + metadata_dictionary = dataset_title_dict(project_gdb) + + workspaces = [project_gdb, crfs_folder] + + for workspace in workspaces: + + arcpy.env.workspace = workspace + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + datasets = list() + + walk = arcpy.da.Walk(workspace) + + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + + for dataset_path in sorted(datasets): + # print(dataset_path) + dataset_name = os.path.basename(dataset_path) + + print(f"Dataset Name: {dataset_name}") + + if "Datasets" == dataset_name: + + print(f"\tDataset Table") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + datasets_table_template = ( + rf"{metadata_folder}\datasets_table_template.xml" + ) + dataset_md.saveAsXML( + datasets_table_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(datasets_table_template) + del datasets_table_template + + del dataset_md + + elif "Species_Filter" == dataset_name: + + print(f"\tSpecies Filter Table") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + species_filter_table_template = ( + rf"{metadata_folder}\species_filter_table_template.xml" + ) + dataset_md.saveAsXML( + species_filter_table_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(species_filter_table_template) + del species_filter_table_template + + del dataset_md + + elif "Indicators" in dataset_name: + + print(f"\tIndicators") + + if dataset_name == "Indicators": + dataset_name = f"{dataset_name}_Table" + else: + pass + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + indicators_template = rf"{metadata_folder}\indicators_template.xml" + dataset_md.saveAsXML( + indicators_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(indicators_template) + del indicators_template + + del dataset_md + + elif "LayerSpeciesYearImageName" in dataset_name: + + print(f"\tLayer Species Year Image Name") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + layer_species_year_image_name_template = ( + rf"{metadata_folder}\layer_species_year_image_name_template.xml" + ) + dataset_md.saveAsXML( + layer_species_year_image_name_template, + "REMOVE_ALL_SENSITIVE_INFO", + ) + parse_xml_file_format_and_save(layer_species_year_image_name_template) + del layer_species_year_image_name_template + + del dataset_md + + elif dataset_name.endswith("Boundary"): + + print(f"\tBoundary") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + boundary_template = rf"{metadata_folder}\boundary_template.xml" + dataset_md.saveAsXML(boundary_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(boundary_template) + del boundary_template + + del dataset_md + + elif dataset_name.endswith("Extent_Points"): + + print(f"\tExtent_Points") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + extent_points_template = ( + rf"{metadata_folder}\extent_points_template.xml" + ) + dataset_md.saveAsXML( + extent_points_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(extent_points_template) + del extent_points_template + + del dataset_md + + elif dataset_name.endswith("Fishnet"): + + print(f"\tFishnet") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + fishnet_template = rf"{metadata_folder}\fishnet_template.xml" + dataset_md.saveAsXML(fishnet_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(fishnet_template) + del fishnet_template + + del dataset_md + + elif dataset_name.endswith("Lat_Long"): + + print(f"\tLat_Long") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + lat_long_template = rf"{metadata_folder}\lat_long_template.xml" + dataset_md.saveAsXML(lat_long_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(lat_long_template) + del lat_long_template + + del dataset_md + + elif dataset_name.endswith("Region"): + + print(f"\tRegion") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + region_template = rf"{metadata_folder}\region_template.xml" + dataset_md.saveAsXML(region_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(region_template) + del region_template + + del dataset_md + + elif dataset_name.endswith("Sample_Locations"): + + print(f"\tSample_Locations") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + sample_locations_template = ( + rf"{metadata_folder}\sample_locations_template.xml" + ) + dataset_md.saveAsXML( + sample_locations_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(sample_locations_template) + del sample_locations_template + + del dataset_md + + elif dataset_name.endswith("GRID_Points"): + + print(f"\tGRID_Points") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + grid_points_template = ( + rf"{metadata_folder}\grid_points_template.xml" + ) + dataset_md.saveAsXML( + grid_points_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(grid_points_template) + del grid_points_template + + del dataset_md + + elif "DisMAP_Regions" == dataset_name: + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + dismap_regions_template = ( + rf"{metadata_folder}\dismap_regions_template.xml" + ) + dataset_md.saveAsXML( + dismap_regions_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(dismap_regions_template) + del dismap_regions_template + + del dataset_md + + elif dataset_name.endswith("Bathymetry"): + + print(f"\tBathymetry") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + bathymetry_template = rf"{metadata_folder}\bathymetry_template.xml" + dataset_md.saveAsXML( + bathymetry_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(bathymetry_template) + del bathymetry_template + + del dataset_md + + elif dataset_name.endswith("Latitude"): + + print(f"\tLatitude") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + latitude_template = rf"{metadata_folder}\latitude_template.xml" + dataset_md.saveAsXML(latitude_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(latitude_template) + del latitude_template + + del dataset_md + + elif dataset_name.endswith("Longitude"): + + print(f"\tLongitude") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + longitude_template = rf"{metadata_folder}\longitude_template.xml" + dataset_md.saveAsXML( + longitude_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(longitude_template) + del longitude_template + + del dataset_md + + elif dataset_name.endswith("Raster_Mask"): + + print(f"\tRaster_Mask") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + raster_mask_template = ( + rf"{metadata_folder}\raster_mask_template.xml" + ) + dataset_md.saveAsXML( + raster_mask_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(raster_mask_template) + del raster_mask_template + + del dataset_md + + elif dataset_name.endswith("Mosaic"): + + print(f"\tMosaic") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + mosaic_template = rf"{metadata_folder}\mosaic_template.xml" + dataset_md.saveAsXML(mosaic_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(mosaic_template) + del mosaic_template + + del dataset_md + + elif dataset_name.endswith(".crf"): + + print(f"\tCRF") + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Dataset Service Title"] + dataset_md.tags = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Tags"] + dataset_md.summary = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Summary"] + dataset_md.description = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Description"] + dataset_md.credits = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Access Constraints"] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + crf_template = rf"{metadata_folder}\crf_template.xml" + dataset_md.saveAsXML(crf_template, "REMOVE_ALL_SENSITIVE_INFO") + parse_xml_file_format_and_save(crf_template) + del crf_template + + del dataset_md + + else: + print(f"\tRegion Table") + + if dataset_name.endswith("IDW"): + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[f"{dataset_name}"][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[f"{dataset_name}"]["Tags"] + dataset_md.summary = metadata_dictionary[f"{dataset_name}"][ + "Summary" + ] + dataset_md.description = metadata_dictionary[f"{dataset_name}"][ + "Description" + ] + dataset_md.credits = metadata_dictionary[f"{dataset_name}"][ + "Credits" + ] + dataset_md.accessConstraints = metadata_dictionary[ + f"{dataset_name}" + ]["Access Constraints"] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + idw_region_table_template = ( + rf"{metadata_folder}\idw_region_table_template.xml" + ) + dataset_md.saveAsXML( + idw_region_table_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(idw_region_table_template) + del idw_region_table_template + + del dataset_md + + elif dataset_name.endswith("GLMME"): + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + del empty_md + + dataset_md.title = metadata_dictionary[f"{dataset_name}"][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[f"{dataset_name}"]["Tags"] + dataset_md.summary = metadata_dictionary[f"{dataset_name}"][ + "Summary" + ] + dataset_md.description = metadata_dictionary[f"{dataset_name}"][ + "Description" + ] + dataset_md.credits = metadata_dictionary[f"{dataset_name}"][ + "Credits" + ] + dataset_md.accessConstraints = metadata_dictionary[ + f"{dataset_name}" + ]["Access Constraints"] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + glmme_region_table_template = ( + rf"{metadata_folder}\glmme_region_table_template.xml" + ) + dataset_md.saveAsXML( + glmme_region_table_template, "REMOVE_ALL_SENSITIVE_INFO" + ) + parse_xml_file_format_and_save(glmme_region_table_template) + del glmme_region_table_template + + del dataset_md + + else: + pass + + del dataset_name, dataset_path + + del workspace + + del datasets + + # Declared Variables set in function + del project_gdb, base_project_folder, metadata_folder + del project_folder, scratch_folder, crfs_folder + del metadata_dictionary, workspaces + + # Imports + del dismap, dataset_title_dict, parse_xml_file_format_and_save + del md + + # Function Parameters + del base_project_file, project + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + # arcpy.AddMessage("\nScript finished successfully.") + return True + + +def import_basic_template_xml_files(base_project_file="", project=""): + try: + # Import + import dismap + from arcpy import metadata as md + + importlib.reload(dismap) + from dismap import (dataset_title_dict, parse_xml_file_format_and_save, + unique_years) + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel(2) + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + base_project_folder = rf"{os.path.dirname(base_project_file)}" + project_folder = rf"{base_project_folder}\{project}" + project_gdb = rf"{project_folder}\{project}.gdb" + current_md_folder = rf"{project_folder}\Current Metadata" + inport_md_folder = rf"{project_folder}\InPort Metadata" + crfs_folder = rf"{project_folder}\CRFs" + scratch_folder = rf"{project_folder}\Scratch" + + # print("Creating the Metadata Dictionary. Please wait!!") + metadata_dictionary = dataset_title_dict(project_gdb) + # print("Creating the Metadata Dictionary. Completed") + + workspaces = [project_gdb, crfs_folder] + # workspaces = [crfs_folder] + + for workspace in workspaces: + + arcpy.env.workspace = workspace + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + datasets = list() + + walk = arcpy.da.Walk(workspace) + + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + + for dataset_path in sorted(datasets): + # print(dataset_path) + dataset_name = os.path.basename(dataset_path) + + print(f"Dataset Name: {dataset_name}") + + if "Datasets" == dataset_name: + + print(f"\tDataset Table") + + datasets_table_template = ( + rf"{current_md_folder}\Table\datasets_table_template.xml" + ) + template_md = md.Metadata(datasets_table_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + # dataset_md.importMetadata(datasets_table_template) + dataset_md.save() + # dataset_md.synchronize("SELECTIVE") + + del empty_md, template_md, datasets_table_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Table\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif "Species_Filter" == dataset_name: + + print(f"\tSpecies Filter Table") + + species_filter_table_template = ( + rf"{current_md_folder}\Table\species_filter_table_template.xml" + ) + template_md = md.Metadata(species_filter_table_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, species_filter_table_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Table\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif "Indicators" in dataset_name: + + print(f"\tIndicators") + + if dataset_name == "Indicators": + indicators_template = ( + rf"{current_md_folder}\Table\indicators_template.xml" + ) + else: + indicators_template = ( + rf"{current_md_folder}\Table\region_indicators_template.xml" + ) + + template_md = md.Metadata(indicators_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, indicators_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + # print(metadata_dictionary[dataset_name]["Tags"]) + # print(_tags) + + if dataset_name == "Indicators": + dataset_name = f"{dataset_name}_Table" + else: + pass + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Table\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + elif "LayerSpeciesYearImageName" in dataset_name: + + print(f"\tLayer Species Year Image Name") + + layer_species_year_image_name_template = rf"{current_md_folder}\Table\layer_species_year_image_name_template.xml" + template_md = md.Metadata(layer_species_year_image_name_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, layer_species_year_image_name_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Table\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + elif dataset_name.endswith("Boundary"): + + print(f"\tBoundary") + + boundary_template = ( + rf"{current_md_folder}\Boundary\boundary_template.xml" + ) + template_md = md.Metadata(boundary_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, boundary_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Boundary\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Boundary\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Extent_Points"): + + print(f"\tExtent_Points") + + extent_points_template = ( + rf"{current_md_folder}\Extent_Points\extent_points_template.xml" + ) + template_md = md.Metadata(extent_points_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, extent_points_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Extent_Points\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Extent_Points\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Fishnet"): + + print(f"\tFishnet") + + fishnet_template = ( + rf"{current_md_folder}\Fishnet\fishnet_template.xml" + ) + template_md = md.Metadata(fishnet_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, fishnet_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Fishnet\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Fishnet\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Lat_Long"): + + print(f"\tLat_Long") + + lat_long_template = ( + rf"{current_md_folder}\Lat_Long\lat_long_template.xml" + ) + template_md = md.Metadata(lat_long_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, lat_long_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Lat_Long\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Lat_Long\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Region"): + + print(f"\tRegion") + + region_template = rf"{current_md_folder}\Region\region_template.xml" + template_md = md.Metadata(region_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, region_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Region\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Region\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Sample_Locations"): + + print(f"\tSample_Locations") + + sample_locations_template = rf"{current_md_folder}\Sample_Locations\sample_locations_template.xml" + template_md = md.Metadata(sample_locations_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, sample_locations_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = ( + rf"{current_md_folder}\Sample_Locations\{dataset_name}.xml" + ) + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Sample_Locations\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + elif dataset_name.endswith("GRID_Points"): + + print(f"\tGRID_Points") + + grid_points_template = ( + rf"{current_md_folder}\GRID_Points\grid_points_template.xml" + ) + template_md = md.Metadata(grid_points_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, grid_points_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\GRID_Points\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\GRID_Points\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + elif "DisMAP_Regions" == dataset_name: + + print(f"\tDisMAP_Regions") + + dismap_regions_template = ( + rf"{current_md_folder}\Region\dismap_regions_template.xml" + ) + template_md = md.Metadata(dismap_regions_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, dismap_regions_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Region\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Region\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Bathymetry"): + + print(f"\tBathymetry") + + bathymetry_template = ( + rf"{current_md_folder}\Bathymetry\bathymetry_template.xml" + ) + template_md = md.Metadata(bathymetry_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, bathymetry_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Bathymetry\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Bathymetry\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Latitude"): + + print(f"\tLatitude") + + latitude_template = ( + rf"{current_md_folder}\Latitude\latitude_template.xml" + ) + template_md = md.Metadata(latitude_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, latitude_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Latitude\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Latitude\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Longitude"): + + print(f"\tLongitude") + + longitude_template = ( + rf"{current_md_folder}\Longitude\longitude_template.xml" + ) + template_md = md.Metadata(longitude_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, longitude_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Longitude\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Longitude\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Raster_Mask"): + + print(f"\tRaster_Mask") + + raster_mask_template = ( + rf"{current_md_folder}\Raster_Mask\raster_mask_template.xml" + ) + template_md = md.Metadata(raster_mask_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, raster_mask_template + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Raster_Mask\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Raster_Mask\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md + + elif dataset_name.endswith("Mosaic"): + + print(f"\tMosaic") + + mosaic_template = rf"{current_md_folder}\Mosaic\mosaic_template.xml" + template_md = md.Metadata(mosaic_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, mosaic_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[dataset_name][ + "Dataset Service Title" + ] + dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags + dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name][ + "Description" + ] + dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[dataset_name][ + "Access Constraints" + ] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Mosaic\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\Mosaic\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + elif dataset_name.endswith(".crf"): + + print(f"\tCRF") + # print(dataset_name) + # print(dataset_path) + # dataset_path = dataset_path.replace(crfs_folder, project_gdb).replace(".crf", "_Mosaic") + # print(dataset_path) + + crf_template = rf"{current_md_folder}\CRF\crf_template.xml" + template_md = md.Metadata(crf_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, crf_template + + # Max-Min Year range table + years_md = unique_years( # This line is causing an error because unique_years expects a feature class or table, not a path to a CRF. + dataset_path.replace(crfs_folder, project_gdb).replace( + ".crf", "_Mosaic" + ) + ) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Dataset Service Title"] + dataset_md.tags = ( + metadata_dictionary[dataset_name.replace(".crf", "_CRF")][ + "Tags" + ] + + _tags + ) + dataset_md.summary = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Summary"] + dataset_md.description = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Description"] + dataset_md.credits = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Credits"] + dataset_md.accessConstraints = metadata_dictionary[ + dataset_name.replace(".crf", "_CRF") + ]["Access Constraints"] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\CRF\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = rf"{inport_md_folder}\CRF\{dataset_name}.xml" + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + else: + print(f"\tRegion Table") + + if dataset_name.endswith("IDW"): + + idw_region_table_template = ( + rf"{current_md_folder}\Table\idw_region_table_template.xml" + ) + template_md = md.Metadata(idw_region_table_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, idw_region_table_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[f"{dataset_name}"][ + "Dataset Service Title" + ] + dataset_md.tags = ( + metadata_dictionary[f"{dataset_name}"]["Tags"] + _tags + ) + dataset_md.summary = metadata_dictionary[f"{dataset_name}"][ + "Summary" + ] + dataset_md.description = metadata_dictionary[f"{dataset_name}"][ + "Description" + ] + dataset_md.credits = metadata_dictionary[f"{dataset_name}"][ + "Credits" + ] + dataset_md.accessConstraints = metadata_dictionary[ + f"{dataset_name}" + ]["Access Constraints"] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Table\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT( + target_file_path, custom_xslt_path + ) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + elif dataset_name.endswith("GLMME"): + + glmme_region_table_template = rf"{current_md_folder}\Table\glmme_region_table_template.xml" + template_md = md.Metadata(glmme_region_table_template) + + dataset_md = md.Metadata(dataset_path) + empty_md = md.Metadata() + dataset_md.copy(empty_md) + dataset_md.save() + dataset_md.copy(template_md) + dataset_md.save() + del empty_md, template_md, glmme_region_table_template + + # Max-Min Year range table + years_md = unique_years(dataset_path) + _tags = f", {min(years_md)} to {max(years_md)}" + del years_md + + dataset_md.title = metadata_dictionary[f"{dataset_name}"][ + "Dataset Service Title" + ] + dataset_md.tags = ( + metadata_dictionary[f"{dataset_name}"]["Tags"] + _tags + ) + dataset_md.summary = metadata_dictionary[f"{dataset_name}"][ + "Summary" + ] + dataset_md.description = metadata_dictionary[f"{dataset_name}"][ + "Description" + ] + dataset_md.credits = metadata_dictionary[f"{dataset_name}"][ + "Credits" + ] + dataset_md.accessConstraints = metadata_dictionary[ + f"{dataset_name}" + ]["Access Constraints"] + dataset_md.save() + + dataset_md.synchronize("ALWAYS") + + out_xml = rf"{current_md_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + target_file_path = ( + rf"{inport_md_folder}\Table\{dataset_name}.xml" + ) + custom_xslt_path = rf"{inport_md_folder}\ArcGIS2InPort.xsl" + + dataset_md.saveAsUsingCustomXSLT( + target_file_path, custom_xslt_path + ) + parse_xml_file_format_and_save(target_file_path) + + del target_file_path, custom_xslt_path + + del dataset_md, _tags + + else: + pass + + del dataset_name, dataset_path + + del workspace + + del datasets + + # Declared Variables set in function + del project_gdb, base_project_folder, current_md_folder, inport_md_folder + del project_folder, scratch_folder, crfs_folder + del metadata_dictionary, workspaces + + # Imports + del dismap, dataset_title_dict, parse_xml_file_format_and_save, unique_years + del md + + # Function Parameters + del base_project_file, project + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + # arcpy.AddMessage("\nScript finished successfully.") + return True + + +def create_thumbnails(base_project_file="", project=""): + try: + # Import + import dismap + from arcpy import metadata as md + + importlib.reload(dismap) + from dismap import parse_xml_file_format_and_save + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel(2) + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + base_project_folder = rf"{os.path.dirname(base_project_file)}" + base_project_file = rf"{base_project_folder}\DisMAP.aprx" + project_folder = rf"{base_project_folder}\{project}" + project_gdb = rf"{project_folder}\{project}.gdb" + metadata_folder = rf"{project_folder}\Export Metadata" + crfs_folder = rf"{project_folder}\CRFs" + scratch_folder = rf"{project_folder}\Scratch" + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + aprx = arcpy.mp.ArcGISProject(base_project_file) + home_folder = aprx.homeFolder + + workspaces = [project_gdb, crfs_folder] + + for workspace in workspaces: + + arcpy.env.workspace = workspace + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + datasets = list() + + walk = arcpy.da.Walk(workspace) + + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + + for dataset_path in sorted(datasets): + # print(dataset_path) + dataset_name = os.path.basename(dataset_path) + + print(f"Dataset Name: {dataset_name}") + + if "Datasets" == dataset_name: + + print(f"\tDataset Table") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif "Species_Filter" == dataset_name: + + print(f"\tSpecies Filter Table") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif "Indicators" in dataset_name: + + print(f"\tIndicators") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif "LayerSpeciesYearImageName" in dataset_name: + + print(f"\tLayer Species Year Image Name") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Boundary"): + + print(f"\tBoundary") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Boundary\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Extent_Points"): + + print(f"\tExtent_Points") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Extent_Points\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Fishnet"): + + print(f"\tFishnet") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Fishnet\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Lat_Long"): + + print(f"\tLat_Long") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Lat_Long\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Region"): + + print(f"\tRegion") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Region\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Sample_Locations"): + + print(f"\tSample_Locations") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Sample_Locations\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("GRID_Points"): + + print(f"\tGRID_Points") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\GRID_Points\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif "DisMAP_Regions" == dataset_name: + + print(f"\tDisMAP_Regions") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Region\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Bathymetry"): + + print(f"\tBathymetry") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Bathymetry\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Latitude"): + + print(f"\tLatitude") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Latitude\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Longitude"): + + print(f"\tLongitude") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Longitude\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Raster_Mask"): + + print(f"\tRaster_Mask") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Raster_Mask\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("Mosaic"): + + print(f"\tMosaic") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Mosaic\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith(".crf"): + + print(f"\tCRF") + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\CRF\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + else: + pass + print(f"\tRegion Table") + + if dataset_name.endswith("IDW"): + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + elif dataset_name.endswith("GLMME"): + + dataset_md = md.Metadata(dataset_path) + + out_xml = rf"{metadata_folder}\Table\{dataset_name}.xml" + dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save(out_xml) + del out_xml + + del dataset_md + + else: + pass + + del dataset_name, dataset_path + + del workspace, datasets + + del workspaces + + # Declared Variables set in function for aprx + del home_folder + # Save aprx one more time and then delete + aprx.save() + del aprx + + # Declared Variables set in function + del project_gdb, base_project_folder, metadata_folder, crfs_folder + del project_folder, scratch_folder + + # Imports + del dismap, parse_xml_file_format_and_save + del md + + # Function Parameters + del base_project_file, project + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + # arcpy.AddMessage("\nScript finished successfully.") + return True + + +def export_to_inport_xml_files(base_project_file="", project=""): + try: + if not base_project_file or not project: + raise SystemExit("parameters are missing") + + # Import + import dismap + from arcpy import metadata as md + + importlib.reload(dismap) + from dismap import parse_xml_file_format_and_save + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel(2) + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + base_project_folder = rf"{os.path.dirname(base_project_file)}" + project_folder = rf"{base_project_folder}\{project}" + project_gdb = rf"{project_folder}\{project}.gdb" + metadata_folder = rf"{project_folder}\InPort Metadata" + crfs_folder = rf"{project_folder}\CRFs" + scratch_folder = rf"{project_folder}\Scratch" + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + datasets = [ + rf"{project_gdb}\Species_Filter", + rf"{project_gdb}\Indicators", + rf"{project_gdb}\DisMAP_Regions", + rf"{project_gdb}\GMEX_IDW_Sample_Locations", + rf"{project_gdb}\GMEX_IDW_Mosaic", + rf"{crfs_folder}\GMEX_IDW.crf", + ] + + for dataset_path in sorted(datasets): + print(dataset_path) + + dataset_name = os.path.basename(dataset_path) + + print(f"Dataset Name: {dataset_name}") + + target_file_path = rf"{metadata_folder}\{dataset_name}.xml" + custom_xslt_path = rf"{metadata_folder}\ArcGIS2InPort.xsl" + + dataset_md = md.Metadata(dataset_path) + dataset_md.saveAsUsingCustomXSLT(target_file_path, custom_xslt_path) + del dataset_md + + try: + parse_xml_file_format_and_save(target_file_path) + except Exception: + raise Exception + + del target_file_path, custom_xslt_path + + del dataset_name, dataset_path + + del datasets + + # Declared Variables set in function + del project_gdb, base_project_folder, metadata_folder + del project_folder, scratch_folder, crfs_folder + + # Imports + del dismap, parse_xml_file_format_and_save + del md + + # Function Parameters + del base_project_file, project + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + # arcpy.AddMessage("\nScript finished successfully.") + return True + + +def create_maps(base_project_file="", project="", dataset=""): + try: + # Import + import dismap + from arcpy import metadata as md + + importlib.reload(dismap) + from dismap import parse_xml_file_format_and_save + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel(2) + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + base_project_folder = rf"{os.path.dirname(base_project_file)}" + base_project_file = rf"{base_project_folder}\DisMAP.aprx" + project_folder = rf"{base_project_folder}\{project}" + project_gdb = rf"{project_folder}\{project}.gdb" + metadata_folder = rf"{project_folder}\Export Metadata" + crfs_folder = rf"{project_folder}\CRFs" + scratch_folder = rf"{project_folder}\Scratch" + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" + + aprx = arcpy.mp.ArcGISProject(base_project_file) + + dataset_name = os.path.basename(dataset) + + print(f"Dataset Name: {dataset_name}") + + if dataset_name not in [cm.name for cm in aprx.listMaps()]: + print(f"Creating Map: {dataset_name}") + aprx.createMap(f"{dataset_name}", "Map") + aprx.save() + else: + pass + + current_map = aprx.listMaps(f"{dataset_name}")[0] + print(f"Current Map: {current_map.name}") + + if dataset_name not in [ + lyr.name for lyr in current_map.listLayers(f"{dataset_name}") + ]: + print(f"Adding {dataset_name} to Map") + + map_layer = arcpy.management.MakeFeatureLayer(dataset, f"{dataset_name}") + + # arcpy.management.Delete(rf"{project_folder}\Layers\{dataset_name}.lyrx") + # os.remove(rf"{project_folder}\Layers\{dataset_name}.lyrx") + + map_layer_file = arcpy.management.SaveToLayerFile( + map_layer, rf"{project_folder}\Layers\{dataset_name}.lyrx" + ) + del map_layer_file + + map_layer_file = arcpy.mp.LayerFile( + rf"{project_folder}\Layers\{dataset_name}.lyrx" + ) + + arcpy.management.Delete(map_layer) + del map_layer + + current_map.addLayer(map_layer_file) + del map_layer_file + + aprx.save() + else: + pass + + # aprx_basemaps = aprx.listBasemaps() + # basemap = 'GEBCO Basemap/Contours (NOAA NCEI Visualization)' + basemap = "Terrain with Labels" + + current_map.addBasemap(basemap) + del basemap + + # Set Reference Scale + current_map.referenceScale = 50000000 + + # Clear Selection + current_map.clearSelection() + + current_map_cim = current_map.getDefinition("V3") + current_map_cim.enableWraparound = True + current_map.setDefinition(current_map_cim) + + # Return the layer's CIM definition + cim_lyr = lyr.getDefinition("V3") + + # Modify the color, width and dash template for the SolidStroke layer + symLvl1 = cim_lyr.renderer.symbol.symbol.symbolLayers[0] + symLvl1.color.values = [0, 0, 0, 100] + symLvl1.width = 1 + + # Push the changes back to the layer object + lyr.setDefinition(cim_lyr) + del symLvl1, cim_lyr + + aprx.save() + + height = ( + arcpy.Describe(dataset).extent.YMax - arcpy.Describe(dataset).extent.YMin + ) + width = ( + arcpy.Describe(dataset).extent.XMax - arcpy.Describe(dataset).extent.XMin + ) + + # map_width, map_height + map_width, map_height = 8.5, 11 + + if height > width: + page_height = map_height + page_width = map_width + elif height < width: + page_height = map_width + page_width = map_height + else: + page_width = map_width + page_height = map_height + + del map_width, map_height + del height, width + + if dataset_name not in [cl.name for cl in aprx.listLayouts()]: + print(f"Creating Layout: {dataset_name}") + aprx.createLayout(page_width, page_height, "INCH", f"{dataset_name}") + aprx.save() + else: + print(f"Layout: {dataset_name} exists") + + # Set the default map camera to the extent of the park boundary before opening the new view + # default camera only affects newly opened views + lyr = current_map.listLayers(f"{dataset_name}")[-1] + + # + arcpy.management.SelectLayerByAttribute( + lyr, "NEW_SELECTION", "DatasetCode in ('ENBS', 'HI', 'NEUS_SPR')" + ) + + mv = current_map.openView() + mv.panToExtent(mv.getLayerExtent(lyr, True, True)) + mv.zoomToAllLayers() + del mv + + arcpy.management.SelectLayerByAttribute(lyr, "CLEAR_SELECTION") + + av = aprx.activeView + av.exportToPNG( + rf"{project_folder}\Layers\{dataset_name}.png", + width=288, + height=192, + resolution=96, + color_mode="24-BIT_TRUE_COLOR", + embed_color_profile=True, + ) + av.exportToJPEG( + rf"{project_folder}\Layers\{dataset_name}.jpg", + width=288, + height=192, + resolution=96, + jpeg_color_mode="24-BIT_TRUE_COLOR", + embed_color_profile=True, + ) + del av + + # print(current_map.referenceScale) + + # export the newly opened active view to PDF, then delete the new map + # mv = aprx.activeView + # mv.exportToPDF(r"C:\Temp\RangerStations.pdf", width=700, height=500, resolution=96) + # aprx.deleteItem(current_map) + + # mv = aprx.activeView + # mv = current_map.defaultView + # mv.zoomToAllLayers() + # print(mv.camera.getExtent()) + # arcpy.management.Delete(rf"{project_folder}\Layers\{dataset_name}.png") + # arcpy.management.Delete(rf"{project_folder}\Layers\{dataset_name}.jpg") + + # os.remove(rf"{project_folder}\Layers\{dataset_name}.png") + # os.remove(rf"{project_folder}\Layers\{dataset_name}.jpg") + + # mv.exportToPNG(rf"{project_folder}\Layers\{dataset_name}.png", width=288, height=192, resolution = 96, color_mode="24-BIT_TRUE_COLOR", embed_color_profile=True) + # mv.exportToJPEG(rf"{project_folder}\Layers\{dataset_name}.jpg", width=288, height=192, resolution = 96, jpeg_color_mode="24-BIT_TRUE_COLOR", embed_color_profile=True) + # del mv + + # Export the resulting imported layout and changes to JPEG + # print(f"Exporting '{current_layout.name}'") + # current_map.exportToJPEG(rf"{project_folder}\Layouts\{current_layout.name}.jpg", page_width, page_height) + # current_map.exportToPNG(rf"{project_folder}\Layouts\{current_layout.name}.png", page_width, page_height) + + # fc_md = md.Metadata(dataset) + # fc_md.thumbnailUri = rf"{project_folder}\Layouts\{dataset_name}.png" + # fc_md.thumbnailUri = rf"{project_folder}\Layouts\{dataset_name}.jpg" + # fc_md.save() + # del fc_md + + aprx.save() + + # # from arcpy import metadata as md + # # + # # fc_md = md.Metadata(dataset) + # # fc_md.thumbnailUri = rf"{project_folder}\Layers\{dataset_name}.png" + # # fc_md.save() + # # del fc_md + # # del md + + ## aprx.save() + ## + ## current_layout = [cl for cl in aprx.listLayouts() if cl.name == dataset_name][0] + ## print(f"Current Layout: {current_layout.name}") + ## + ## current_layout.openView() + ## + ## # Remove all map frames + ## for mf in current_layout.listElements("MapFrame_Element"): current_layout.deleteElement(mf); del mf + ## + ## # print(f'Layout Name: {current_layout.name}') + ## # print(f' Width x height: {current_layout.pageWidth} x {current_layout.pageHeight} units are {current_layout.pageUnits}') + ## # print(f' MapFrame count: {str(len(current_layout.listElements("MapFrame_Element")))}') + ## # for mf in current_layout.listElements("MapFrame_Element"): + ## # if len(current_layout.listElements("MapFrame_Element")) > 0: + ## # print(f' MapFrame name: {mf.name}') + ## # print(f' Total element count: {str(len(current_layout.listElements()))} \n') + ## + ## + ## print(f"Create a new map frame using a point geometry") + ## #Create a new map frame using a point geometry + ## #mf1 = current_layout.createMapFrame(arcpy.Point(0.01,0.01), current_map, 'New MF - Point') + ## mf1 = current_layout.createMapFrame(arcpy.Point(0.0,0.0), current_map, 'New MF - Point') + ## #mf1.elementWidth = 10 + ## #mf1.elementHeight = 7.5 + ## #mf1.elementWidth = page_width - 0.01 + ## #mf1.elementHeight = page_height - 0.01 + ## mf1.elementWidth = page_width + ## mf1.elementHeight = page_height + + ## lyr = current_map.listLayers(f"{dataset_name}")[0] + ## + ## #Zoom to ALL selected features and export to PDF + ## #arcpy.SelectLayerByAttribute_management(lyr, 'NEW_SELECTION') + ## #mf1.zoomToAllLayers(True) + ## #arcpy.SelectLayerByAttribute_management(lyr, 'CLEAR_SELECTION') + ## + ## #Set the map frame extent to the extent of a layer + ## #mf1.camera.setExtent(mf1.getLayerExtent(lyr, False, True)) + ## #mf1.camera.scale = mf1.camera.scale * 1.1 #add a slight buffer + ## + ## del lyr + + ## print(f"Create a new bookmark set to the map frame's default extent") + ## #Create a new bookmark set to the map frame's default extent + ## bkmk = mf1.createBookmark('Default Extent', "The map's default extent") + ## bkmk.updateThumbnail() + ## del mf1 + ## del bkmk + + # Create point text element using a system style item + # txtStyleItem = aprx.listStyleItems('ArcGIS 2D', 'TEXT', 'Title (Serif)')[0] + # ptTxt = aprx.createTextElement(current_layout, arcpy.Point(5.5, 4.25), 'POINT', f'{dataset_name}', 10, style_item=txtStyleItem) + # del txtStyleItem + + # Change the anchor position and reposition the text to center + # ptTxt.setAnchor('Center_Point') + # ptTxt.elementPositionX = page_width / 2.0 + # ptTxt.elementPositionY = page_height - 0.25 + # del ptTxt + + # print(f"Using CIM to update border") + # current_layout_cim = current_layout.getDefinition('V3') + # for elm in current_layout_cim.elements: + # if type(elm).__name__ == 'CIMMapFrame': + # if elm.graphicFrame.borderSymbol.symbol.symbolLayers: + # sym = elm.graphicFrame.borderSymbol.symbol.symbolLayers[0] + # sym.width = 5 + # sym.color.values = [255, 0, 0, 100] + # else: + # arcpy.AddWarning(elm.name + ' has NO symbol layers') + # current_layout.setDefinition(current_layout_cim) + # del current_layout_cim, elm, sym + + ## ExportLayout = True + ## if ExportLayout: + ## #Export the resulting imported layout and changes to JPEG + ## print(f"Exporting '{current_layout.name}'") + ## current_layout.exportToJPEG(rf"{project_folder}\Layouts\{current_layout.name}.jpg") + ## current_layout.exportToPNG(rf"{project_folder}\Layouts\{current_layout.name}.png") + ## del ExportLayout + + ## #Export the resulting imported layout and changes to JPEG + ## print(f"Exporting '{current_layout.name}'") + ## current_map.exportToJPEG(rf"{project_folder}\Layouts\{current_layout.name}.jpg", page_width, page_height) + ## current_map.exportToPNG(rf"{project_folder}\Layouts\{current_layout.name}.png", page_width, page_height) + ## + ## fc_md = md.Metadata(dataset) + ## fc_md.thumbnailUri = rf"{project_folder}\Layouts\{current_layout.name}.png" + ## #fc_md.thumbnailUri = rf"{project_folder}\Layouts\{current_layout.name}.jpg" + ## fc_md.save() + ## del fc_md + ## + ## aprx.save() + + # aprx.deleteItem(current_map) + # aprx.deleteItem(current_layout) + + del current_map + # , current_layout + # del page_width, page_height + del dataset_name, dataset + + aprx.save() + + print(f"\nCurrent Maps & Layouts") + + current_maps = aprx.listMaps() + # current_layouts = aprx.listLayouts() + + if current_maps: + print(f"\nCurrent Maps\n") + for current_map in current_maps: + print(f"\tProject Map: {current_map.name}") + del current_map + else: + arcpy.AddWarning("No maps in Project") + + ## if current_layouts: + ## print(f"\nCurrent Layouts\n") + ## for current_layout in current_layouts: + ## print(f"\tProject Layout: {current_layout.name}") + ## del current_layout + ## else: + ## arcpy.AddWarning("No layouts in Project") + + # del current_layouts + del current_maps + + # Declared Variables set in function for aprx + + # Save aprx one more time and then delete + aprx.save() + del aprx + + # Declared Variables set in function + del project_gdb, base_project_folder, metadata_folder, crfs_folder + del project_folder, scratch_folder + + # Imports + del dismap, parse_xml_file_format_and_save + del md + + # Function Parameters + del base_project_file, project + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + # arcpy.AddMessage("\nScript finished successfully.") + return True + + +def script_tool(project_folder=""): + try: + + CreateBasicTemplateXMLFiles = True + if CreateBasicTemplateXMLFiles: + create_basic_template_xml_files(project_folder) + del CreateBasicTemplateXMLFiles + +## ImportBasicTemplateXmlFiles = False +## if ImportBasicTemplateXmlFiles: +## import_basic_template_xml_files(base_project_file, project) +## del ImportBasicTemplateXmlFiles +## +## CreateThumbnails = False +## if CreateThumbnails: +## create_thumbnails(base_project_file, project) +## del CreateThumbnails +## +## CreateMaps = False +## if CreateMaps: +## create_maps( +## base_project_file, project, dataset=rf"{project_gdb}\DisMAP_Regions" +## ) +## del CreateMaps +## +## ExportToInportXmlFiles = False +## if ExportToInportXmlFiles: +## export_to_inport_xml_files(base_project_file, project) +## del ExportToInportXmlFiles + + # Variable created in function + + # Function parameters + del project_folder + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:") + traceback.print_exc() + + else: + arcpy.AddMessage("\nScript finished successfully.\n") + finally: + arcpy.AddMessage(f"\n{'--End' * 10}--") + + +if __name__ == '__main__': + try: + + project_folder = arcpy.GetParameterAsText(0) + + if not project_folder: + release = "February-1-2026" + #release = "August-1-2025" + project_folder = os.path.join(os.path.expanduser('~'), f"Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\{release}") + else: + pass + + script_tool(project_folder) + + arcpy.SetParameterAsText(1, "Result") + + del project_folder + + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + except Exception: + traceback.print_exc() + + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_project_setup.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_project_setup.py new file mode 100644 index 0000000..6eec726 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_project_setup.py @@ -0,0 +1,186 @@ +""" +Script documentation +- Tool parameters are accessed using arcpy.GetParameter() or + arcpy.GetParameterAsText() +- Update derived parameter values using arcpy.SetParameter() or + arcpy.SetParameterAsText() +""" + +import inspect +import os +import traceback + +import arcpy + + +def script_tool(new_project_folder, project_folders): + """Script code goes below""" + try: + arcpy.env.overwriteOutput = True + + try: + aprx = arcpy.mp.ArcGISProject("CURRENT") + os.chdir(aprx.homeFolder) + arcpy.env.workspace = aprx.defaultGeodatabase + #del aprx + except Exception: + #print(e) + aprx = arcpy.mp.ArcGISProject(os.path.join(os.path.expanduser('~'), "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\DisMAP.aprx")) + os.chdir(aprx.homeFolder) + arcpy.env.workspace = aprx.defaultGeodatabase + #del aprx + + + if not arcpy.Exists(os.path.join(aprx.homeFolder, new_project_folder)): + arcpy.AddMessage(f"Creating Home Folder: '{os.path.basename(aprx.homeFolder)}'") + arcpy.management.CreateFolder(aprx.homeFolder, new_project_folder) + arcpy.AddMessage(arcpy.GetMessages()) + else: + arcpy.AddMessage(f"Home Folder: '{os.path.basename(os.path.join(aprx.homeFolder, new_project_folder))}' Exists") + + + if not arcpy.Exists(os.path.join(aprx.homeFolder, new_project_folder, f"{new_project_folder}.gdb")): + arcpy.AddMessage( + f"Creating Project GDB: '{new_project_folder}.gdb'" + ) + arcpy.management.CreateFileGDB(os.path.join(aprx.homeFolder, new_project_folder), f"{new_project_folder}" + ) + arcpy.AddMessage(arcpy.GetMessages()) + else: + arcpy.AddMessage(f"Project GDB: '{new_project_folder}.gdb' exists") + + if not arcpy.Exists(os.path.join(aprx.homeFolder, new_project_folder, "Scratch")): + arcpy.AddMessage("Creating the Scratch Folder") + arcpy.management.CreateFolder(os.path.join(aprx.homeFolder, new_project_folder), "Scratch") + arcpy.AddMessage(arcpy.GetMessages()) + else: + arcpy.AddMessage(f"Scratch Folder for: {new_project_folder} exists") + + if not arcpy.Exists(os.path.join(aprx.homeFolder, new_project_folder, "Scratch", "scratch.gdb")): + arcpy.AddMessage("Creating the Scratch GDB") + arcpy.management.CreateFileGDB(os.path.join(aprx.homeFolder, new_project_folder, "Scratch"), "scratch") + arcpy.AddMessage(arcpy.GetMessages()) + else: + arcpy.AddMessage("Scratch GDB Exists") + + for _project_folder in project_folders.split(";"): + if not arcpy.Exists( + rf"{aprx.homeFolder}\{new_project_folder}\{_project_folder}" + ): + arcpy.AddMessage(f"Creating Folder: {_project_folder}") + arcpy.management.CreateFolder( + rf"{aprx.homeFolder}\{new_project_folder}", _project_folder + ) + arcpy.AddMessage(arcpy.GetMessages()) + else: + arcpy.AddMessage(f"Folder: '{_project_folder}' Exists") + del _project_folder + if not arcpy.Exists(os.path.join(aprx.homeFolder, new_project_folder, f"{new_project_folder}.aprx")): + aprx.saveACopy(os.path.join(aprx.homeFolder, new_project_folder, f"{new_project_folder}.aprx") + ) + arcpy.AddMessage(arcpy.GetMessages()) + else: + pass + + _aprx = arcpy.mp.ArcGISProject(os.path.join(aprx.homeFolder, new_project_folder, + f"{new_project_folder}.aprx") + ) + # Remove maps + _maps = _aprx.listMaps() + if len(_maps) > 0: + for _map in _maps: + arcpy.AddMessage(_map.name) + #aprx.deleteItem(_map) + del _map + del _maps + _aprx.save() + + databases = [] + databases.append( + { + "databasePath": rf"{aprx.homeFolder}\{new_project_folder}\{new_project_folder}.gdb", + "isDefaultDatabase": True, + } + ) + _aprx.updateDatabases(databases) + arcpy.AddMessage(f"Databases: {databases}") + del databases + _aprx.save() + + toolboxes = [] + toolboxes.append( + {"toolboxPath": rf"{aprx.homeFolder}\DisMAP.atbx", "isDefaultToolbox": True} + ) + _aprx.updateToolboxes(toolboxes) + arcpy.AddMessage(f"Toolboxes: {toolboxes}") + del toolboxes + _aprx.save() + del _aprx + + # Declared variables + del aprx + # Function parameters + del new_project_folder, project_folders + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + arcpy.AddMessage("\nScript finished successfully.") + return True + finally: + arcpy.AddMessage(f"\n{'--End' * 10}--") + + +if __name__ == "__main__": + try: + new_project_folder = arcpy.GetParameterAsText(0) + project_folders = arcpy.GetParameterAsText(1) + + if not new_project_folder: + # new_project_folder = "August-1-2025" + # new_project_folder = "February-1-2026" + new_project_folder = "June-1-2026" + else: + pass + + if not project_folders: + project_folders = ( + "CRFs;CSV_Data;Dataset_Shapefiles;Images;Layers;Metadata_ArcGIS;Metadata_Export;Metadata_Gemini;Metadata_InPort;Publish" + ) + else: + pass + + script_tool(new_project_folder, project_folders) + + arcpy.SetParameterAsText(3, "Result") + + del new_project_folder, project_folders + + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + except Exception: + traceback.print_exc() + + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_tools.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_tools.py new file mode 100644 index 0000000..06c1a0f --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_tools.py @@ -0,0 +1,3542 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: py +# Purpose: Common DisMAP functions +# +# Author: john.f.kennedy +# +# Created: 12/01/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +# built-ins first +import inspect +import os +import sys +import traceback + +import arcpy # third-parties second + +def parse_xml_file_format_and_save(csv_data_folder="", xml_file="", sort=False): + try: + + import json + + print(csv_data_folder) + + json_path = os.path.join(csv_data_folder, "root_dict.json") + # print(csv_data_folder) + with open(json_path, "r", encoding='utf-8') as json_file: + root_dict = json.load(json_file) + del json_file + del json_path + del json + + ## root_dict = {"Esri" : 0, "dataIdInfo" : 1, "mdChar" : 2, + ## "mdContact" : 3, "mdDateSt" : 4, "mdFileID" : 5, + ## "mdLang" : 6, "mdMaint" : 7, "mdHrLv" : 8, + ## "mdHrLvName" : 9, "refSysInfo" : 10, "spatRepInfo" : 11, + ## "spdoinfo" : 12, "dqInfo" : 13, "distInfo" : 14, + ## "eainfo" : 15, "contInfo" : 16, "spref" : 17, + ## "spatRepInfo" : 18, "dataSetFn" : 19, "Binary" : 100,} + + from lxml import etree + + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) # pyright: ignore[reportAttributeAccessIssue] + tree = etree.parse( # pyright: ignore[reportAttributeAccessIssue] + xml_file, parser=parser + ) # To parse from a string, use the fromstring() function instead. + del parser + + if sort: + root = tree.getroot() + for child in root.xpath("."): + child[:] = sorted(child, key=lambda x: root_dict[x.tag]) + del child + del root + del sort + etree.indent(tree, space=" ") # pyright: ignore[reportAttributeAccessIssue] + tree.write( + xml_file, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + del tree + del xml_file, etree + del root_dict + del csv_data_folder + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + traceback.print_exc() + raise SystemExit + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + traceback.print_exc() + raise SystemExit + except OSError as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + traceback.print_exc() + raise SystemExit + except FileNotFoundError as e: + arcpy.AddError(f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}") + traceback.print_exc() + raise SystemExit + else: + return True + + +def print_xml_file(xml_file="", sort=False): + try: + root_dict = { + "Esri": 0, + "dataIdInfo": 1, + "mdChar": 2, + "mdContact": 3, + "mdDateSt": 4, + "mdFileID": 5, + "mdLang": 6, + "mdMaint": 7, + "mdHrLv": 8, + "mdHrLvName": 9, + "refSysInfo": 10, + "spatRepInfo": 11, + "spdoinfo": 12, + "dqInfo": 13, + "distInfo": 14, + "eainfo": 15, + "contInfo": 16, + "spref": 17, + "spatRepInfo": 18, + "dataSetFn": 19, + "Binary": 100, + } + + from lxml import etree + + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) # pyright: ignore[reportAttributeAccessIssue] + tree = etree.parse( # pyright: ignore[reportAttributeAccessIssue] + xml_file, parser=parser + ) + + etree.indent(tree, space=" ") # pyright: ignore[reportAttributeAccessIssue] + tree.write( + xml_file, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + +## etree.indent(tree, space=" ") # pyright: ignore[reportAttributeAccessIssue] +## arcpy.AddMessage( +## etree.tostring( # pyright: ignore[reportAttributeAccessIssue] +## tree, +## encoding="UTF-8", +## method="xml", +## xml_declaration=True, +## pretty_print=True, +## ).decode() +## ) + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + return True + finally: + pass + + +def add_fields(csv_data_folder="", in_table=""): + try: + # Import this Python module + # import dev_dismap_tools + # importlib.reload(dev_dismap_tools) + + table = os.path.basename(in_table) + project_gdb = os.path.dirname(in_table) + + _field_definitions = field_definitions(csv_data_folder, "") + + # set workspace environment + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = r"Scratch\\scratch.gdb" + arcpy.SetLogMetadata(True) + + if "_IDW_Region" in table: + table = "IDW_Data" + elif "GFDL_Region" in table: + table = "GFDL_Data" + elif "GLMME_Region" in table: + table = "GLMME_Data" + elif "Indicators" in table: + table = "Indicators" + else: + table = table + + fields = table_definitions(csv_data_folder, table) + + field_definition_list = [] + for field in fields: + field_definition_list.append( + [ + _field_definitions[field]["field_name"], + _field_definitions[field]["field_type"], + _field_definitions[field]["field_aliasName"], + _field_definitions[field]["field_length"], + ] + ) + arcpy.AddMessage(f"Adding Fields to Table: {table}") + arcpy.management.AddFields( + in_table=in_table, field_description=field_definition_list, template="" + ) + arcpy.AddMessage("\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + return True + finally: + pass + + +def alter_fields(csv_data_folder="", in_table=""): + try: + project_gdb = os.path.dirname(in_table) + + arcpy.env.workspace = project_gdb + arcpy.SetLogMetadata(True) + + if arcpy.Exists(in_table): + arcpy.AddMessage( + f"Altering Field Aliases for Table: {os.path.basename(in_table)}" + ) + # arcpy.AddMessage(f"{table}") + + fields = [ + f + for f in arcpy.ListFields(in_table) + if f.type not in ["Geometry", "OID"] + and f.name not in ["Shape_Area", "Shape_Length"] + ] + _field_definitions = field_definitions(csv_data_folder, "") + + for field in fields: + field_name = field.name + arcpy.AddMessage(f"\tAltering Field: {field_name} {field.type}") + + if field_name in _field_definitions: + + arcpy.AddMessage( + f"\t\tAltering Field: {field_name} to: {_field_definitions[field_name]['field_aliasName']}" + ) + + try: + arcpy.management.AlterField( + in_table=in_table, + field=_field_definitions[field_name]["field_name"], + new_field_name=_field_definitions[field_name]["field_name"], + new_field_alias=_field_definitions[field_name][ + "field_aliasName" + ], + field_length=_field_definitions[field_name]["field_length"], + field_is_nullable="NULLABLE", + clear_field_alias="DO_NOT_CLEAR", + ) + arcpy.AddMessage( + "\t\t\t{0}\n".format( + arcpy.GetMessages().replace("\n", "\n\t\t\t") + ) + ) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + + elif field_name not in _field_definitions: + arcpy.AddWarning( + f"###--->>> Field: {field_name} is not in fieldDefinitions <<<---###" + ) + else: + pass + else: + arcpy.AddWarning( + f"###--->>> Alter fields: {os.path.basename(in_table)} not found <<<---###" + ) + + del _field_definitions, project_gdb, in_table + + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + return True + finally: + pass + + +def backup_gdb(project_gdb=""): + try: + + arcpy.AddMessage("Making a backup") + arcpy.management.Copy(project_gdb, project_gdb.replace(".gdb", f"_Backup.gdb")) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + + arcpy.AddMessage("Compacting the backup") + arcpy.management.Compact(project_gdb.replace(".gdb", f"_Backup.gdb")) + arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + return True + finally: + pass + + +def basic_metadata(csv_data_folder="", in_table=""): + # Deprecated + try: + + table = os.path.basename(in_table) + project_gdb = os.path.dirname(in_table) + + # set workspace environment + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.env.scratchWorkspace = rf"Scratch\\scratch.gdb" + arcpy.env.workspace = project_gdb + arcpy.SetLogMetadata(True) + + if arcpy.Exists(table): + arcpy.AddMessage(f"Adding metadata to: {table}") + + if table.endswith(".crf"): + table = table.replace(".crf", "_Mosaic") + + metadata_dictionary = metadata_dictionary_json(csv_data_folder, "") + + # from arcpy import metadata as md + # # https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm + # dataset_md = md.Metadata(in_table) + # dataset_md.synchronize("ALWAYS", 0) + # dataset_md.save() + # dataset_md.reload() + + # dataset_md.synchronize("NOT_CREATED", 0) + # dataset_md.title = metadata_dictionary[table]["md_title"] + # dataset_md.tags = metadata_dictionary[table]["md_tags"] + # dataset_md.summary = metadata_dictionary[table]["md_summary"] + # dataset_md.description = metadata_dictionary[table]["md_description"] + # dataset_md.credits = metadata_dictionary[table]["md_credits"] + # dataset_md.accessConstraints = metadata_dictionary[table]["md_access_constraints"] + # dataset_md.save() + # dataset_md.reload() + + # arcpy.AddMessage(metadata_dictionary[table]["md_title"]) + # arcpy.AddMessage(metadata_dictionary[table]["md_tags"]) + # arcpy.AddMessage(metadata_dictionary[table]["md_summary"]) + # arcpy.AddMessage(metadata_dictionary[table]["md_description"]) + # arcpy.AddMessage(metadata_dictionary[table]["md_credits"]) + # arcpy.AddMessage(metadata_dictionary[table]["md_access_constraints"]) + + arcpy.AddMessage(f"Adding metadata to: {table} completed") + + # del dataset_md, md + + else: + arcpy.AddWarning(f"Adding Metadata: {table} not found") + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + return True + finally: + pass + + +def check_datasets(datasets=[]): + try: + + def formatDateTime(dateTime): + from datetime import datetime, timezone + + d = datetime.strptime(dateTime, "%Y-%m-%dT%H:%M:%S.%f") + d = d.replace(tzinfo=timezone.utc) + d = d.astimezone() + return d.strftime("%b %d %Y %I:%M:%S %p") + + for dataset in datasets: + # Create a Describe object from the feature class + # + desc = arcpy.da.Describe(dataset) + # Print some feature class properties + # baseName + # catalogPath + # children + # childrenExpanded + # Examine children and print their name and dataType + # + # arcpy.AddMessage("Children:") + # for child in desc.children: + # arcpy.AddMessage("\t%s = %s" % (child.name, child.dataType)) + # dataElementType + # dataType + # extension + # file + # fullPropsRetrieved + # metadataRetrieved + + arcpy.AddMessage(f"Dataset Name: {desc['name']}") + arcpy.AddMessage(f"\tDataset Path: {desc['path']}") + arcpy.AddMessage(f"\tDataset Type: {desc['dataType']}") + + if desc["dataType"] == "FeatureClass": + # arcpy.AddMessage(f"\tFeature Type: {desc['featureType']}") + arcpy.AddMessage(f"\tData Type: {desc['dataType']}") + # arcpy.AddMessage(f"\tDataset Type: {desc['datasetType']}") + arcpy.AddMessage(f"\tShape Type: {desc['shapeType']}") + arcpy.AddMessage( + f"\tDate Created: {formatDateTime(desc['dateCreated'])}" + ) + arcpy.AddMessage( + f"\tDate Accessed: {formatDateTime(desc['dateAccessed'])}" + ) + arcpy.AddMessage( + f"\tDate Modified: {formatDateTime(desc['dateModified'])}" + ) + arcpy.AddMessage( + f"\tSize: {round(desc['size'] * 0.000001, 2)} MB" + ) + arcpy.AddMessage( + f"\tSpatial Reference: {desc['spatialReference'].name}" + ) + # arcpy.AddMessage(f"Spatial Index: {str(desc.hasSpatialIndex)}") + # arcpy.AddMessage(f"Has M: {desc.hasM}") + # arcpy.AddMessage(f"Has Z: {desc.hasZ}") + # arcpy.AddMessage(f"Shape Field Name: {desc.shapeFieldName}") + # arcpy.AddMessage(f"Split Model: {str(desc.hasSpatialIndex)}") + # arcpy.AddMessage(desc["fields"]) + fields = [f.name for f in desc["fields"]] + oid = desc["OIDFieldName"] + # Use SQL TOP to sort field values + arcpy.AddMessage(f"\t{', '.join(fields)}") + for row in arcpy.da.SearchCursor(dataset, fields, f"{oid} <= 5"): + arcpy.AddMessage(f"\t{row}") + + ## fields = [f.name for f in desc["fields"]] + ## oid_field_name = desc["OIDFieldName"] + ## # Use SQL TOP to sort field values + ## arcpy.AddMessage(f"\t{', '.join(fields)}") + ## oids = [oid for oid in arcpy.da.SearchCursor(dataset, f"{oid_field_name}")] + ## from random import sample + ## random_indices = sample(oids, 5) + ## del sample + ## for row in arcpy.da.SearchCursor(dataset, fields, f"{oid_field_name} in {random_indices}"): + ## arcpy.AddMessage(f"\t{row}") + ## del row + ## del oids, random_indices, oid_field_name, fields + + elif desc["dataType"] == "RasterDataset": + arcpy.AddMessage(f"\tData Type: {desc['dataType']}") + arcpy.AddMessage( + f"\tCell Size: {desc['meanCellHeight']} x {desc['meanCellWidth']}" + ) + arcpy.AddMessage(f"\tExtent: {desc['extent']}") + arcpy.AddMessage( + f"\tHeight & Width: {desc['height']} x {desc['width']}" + ) + arcpy.AddMessage( + f"\tSpatial Reference: {desc['spatialReference'].name}" + ) + + # for key in sorted(desc): + # value = str(desc[key]) + # arcpy.AddMessage(f"Key: '{key:<30}' Value: '{value:<25}'") + # del value, key + + elif desc["dataType"] == "Table": + arcpy.AddMessage(f"\tData Type: {desc['dataType']}") + arcpy.AddMessage( + f"\tDate Created: {formatDateTime(desc['dateCreated'])}" + ) + arcpy.AddMessage( + f"\tDate Accessed: {formatDateTime(desc['dateAccessed'])}" + ) + arcpy.AddMessage( + f"\tDate Modified: {formatDateTime(desc['dateModified'])}" + ) + arcpy.AddMessage( + f"\tSize: {round(desc['size'] * 0.000001, 2)} MB" + ) + # arcpy.AddMessage(desc["fields"]) + fields = [f.name for f in desc["fields"]] + oid = desc["OIDFieldName"] + # Use SQL TOP to sort field values + arcpy.AddMessage(f"\t{', '.join(fields)}") + for row in arcpy.da.SearchCursor(dataset, fields, f"{oid} <= 5"): + arcpy.AddMessage(f"\t{row}") + del row + del oid, fields + + elif desc["dataType"] == "MosaicDataset": + arcpy.AddMessage(f"\t DSID: {desc['DSID']}") + arcpy.AddMessage(f"\t JPEGQuality: {desc['JPEGQuality']}") + arcpy.AddMessage(f"\t LERCTolerance: {desc['LERCTolerance']}") + arcpy.AddMessage(f"\t MExtent: {desc['MExtent']}") + arcpy.AddMessage(f"\t OIDFieldName: {desc['OIDFieldName']}") + arcpy.AddMessage(f"\t ZExtent: {desc['ZExtent']}") + arcpy.AddMessage( + f"\t allowedCompressionMethods: {desc['allowedCompressionMethods']}" + ) + arcpy.AddMessage(f"\t allowedFields: {desc['allowedFields']}") + arcpy.AddMessage( + f"\t allowedMensurationCapabilities: {desc['allowedMensurationCapabilities']}" + ) + arcpy.AddMessage( + f"\t allowedMosaicMethods: {desc['allowedMosaicMethods']}" + ) + arcpy.AddMessage(f"\t bandCount: {desc['bandCount']}") + arcpy.AddMessage(f"\t baseName: {desc['baseName']}") + arcpy.AddMessage(f"\t blendWidth: {desc['blendWidth']}") + arcpy.AddMessage(f"\t blendWidthUnits: {desc['blendWidthUnits']}") + arcpy.AddMessage(f"\t catalogPath: {desc['catalogPath']}") + arcpy.AddMessage( + f"\t cellSizeToleranceFactor: {desc['cellSizeToleranceFactor']}" + ) + arcpy.AddMessage(f"\t children: {desc['children']}") + arcpy.AddMessage(f"\t childrenExpanded: {desc['childrenExpanded']}") + arcpy.AddMessage(f"\t childrenNames: {desc['childrenNames']}") + arcpy.AddMessage(f"\t clipToBoundary: {desc['clipToBoundary']}") + arcpy.AddMessage(f"\t compressionType: {desc['compressionType']}") + arcpy.AddMessage(f"\t dataElementType: {desc['dataElementType']}") + arcpy.AddMessage(f"\t dataType: {desc['dataType']}") + arcpy.AddMessage(f"\t datasetType: {desc['datasetType']}") + arcpy.AddMessage( + f"\t defaultCompressionMethod: {desc['defaultCompressionMethod']}" + ) + arcpy.AddMessage( + f"\t defaultMensurationCapability: {desc['defaultMensurationCapability']}" + ) + arcpy.AddMessage( + f"\t defaultMosaicMethod: {desc['defaultMosaicMethod']}" + ) + arcpy.AddMessage( + f"\t defaultResamplingMethod: {desc['defaultResamplingMethod']}" + ) + arcpy.AddMessage(f"\t defaultSubtypeCode: {desc['defaultSubtypeCode']}") + arcpy.AddMessage(f"\t endTimeField: {desc['endTimeField']}") + arcpy.AddMessage(f"\t extent: {desc['extent']}") + arcpy.AddMessage(f"\t featureType: {desc['featureType']}") + arcpy.AddMessage(f"\t fields: {desc['fields']}") + arcpy.AddMessage(f"\t file: {desc['file']}") + arcpy.AddMessage( + f"\t footprintMayContainNoData: {desc['footprintMayContainNoData']}" + ) + arcpy.AddMessage(f"\t format: {desc['format']}") + arcpy.AddMessage(f"\t fullPropsRetrieved: {desc['fullPropsRetrieved']}") + arcpy.AddMessage(f"\t hasOID: {desc['hasOID']}") + arcpy.AddMessage(f"\t hasSpatialIndex: {desc['hasSpatialIndex']}") + arcpy.AddMessage(f"\t indexes: {desc['indexes']}") + arcpy.AddMessage(f"\t isInteger: {desc['isInteger']}") + arcpy.AddMessage(f"\t isTimeInUTC: {desc['isTimeInUTC']}") + arcpy.AddMessage( + f"\t maxDownloadImageCount: {desc['maxDownloadImageCount']}" + ) + arcpy.AddMessage( + f"\t maxDownloadSizeLimit: {desc['maxDownloadSizeLimit']}" + ) + arcpy.AddMessage( + f"\t maxRastersPerMosaic: {desc['maxRastersPerMosaic']}" + ) + arcpy.AddMessage(f"\t maxRecordsReturned: {desc['maxRecordsReturned']}") + arcpy.AddMessage(f"\t maxRequestSizeX: {desc['maxRequestSizeX']}") + arcpy.AddMessage(f"\t maxRequestSizeY: {desc['maxRequestSizeY']}") + arcpy.AddMessage( + f"\t minimumPixelContribution: {desc['minimumPixelContribution']}" + ) + arcpy.AddMessage(f"\t mosaicOperator: {desc['mosaicOperator']}") + arcpy.AddMessage(f"\t name: {desc['name']}") + arcpy.AddMessage(f"\t orderField: {desc['orderField']}") + arcpy.AddMessage(f"\t path: {desc['path']}") + arcpy.AddMessage(f"\t permanent: {desc['permanent']}") + arcpy.AddMessage(f"\t rasterFieldName: {desc['rasterFieldName']}") + arcpy.AddMessage( + f"\t rasterMetadataLevel: {desc['rasterMetadataLevel']}" + ) + arcpy.AddMessage(f"\t shapeFieldName: {desc['shapeFieldName']}") + arcpy.AddMessage(f"\t shapeType: {desc['shapeType']}") + arcpy.AddMessage(f"\t sortAscending: {desc['sortAscending']}") + arcpy.AddMessage(f"\t spatialReference: {desc['spatialReference']}") + arcpy.AddMessage(f"\t startTimeField: {desc['startTimeField']}") + arcpy.AddMessage(f"\t supportsBigInteger: {desc['supportsBigInteger']}") + arcpy.AddMessage( + f"\t supportsBigObjectID: {desc['supportsBigObjectID']}" + ) + arcpy.AddMessage(f"\t supportsDateOnly: {desc['supportsDateOnly']}") + arcpy.AddMessage(f"\t supportsTimeOnly: {desc['supportsTimeOnly']}") + arcpy.AddMessage( + f"\t supportsTimestampOffset: {desc['supportsTimestampOffset']}" + ) + arcpy.AddMessage(f"\t timeValueFormat: {desc['timeValueFormat']}") + arcpy.AddMessage(f"\t useTime: {desc['useTime']}") + arcpy.AddMessage(f"\t viewpointSpacingX: {desc['viewpointSpacingX']}") + arcpy.AddMessage(f"\t viewpointSpacingY: {desc['viewpointSpacingY']}") + arcpy.AddMessage(f"\t workspace: {desc['workspace']}") + + # arcpy.AddMessage(desc["fields"]) + fields = [f.name for f in desc["fields"]] + oid = desc["OIDFieldName"] + # Use SQL TOP to sort field values + arcpy.AddMessage(f"\t{', '.join(fields)}") + for row in arcpy.da.SearchCursor(dataset, fields, f"{oid} <= 5"): + arcpy.AddMessage(f"\t{row}") + + elif desc["dataType"]: # This condition seems to be missing a specific check, it will always be true if dataType exists. + arcpy.AddWarning(desc["dataType"]) + + else: + arcpy.AddWarning("No data to describe!!") + + del desc, dataset + + del formatDateTime, datasets + + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + traceback.print_exc() + sys.exit() + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + return True + finally: + pass + + +def check_transformation(ds, cs): + dsc_in = arcpy.Describe(ds) + insr = dsc_in.spatialReference + + # if output coordinate system is set and is different than the input coordinate system + if cs and (cs.name != insr.name): + translist = arcpy.ListTransformations(insr, cs, dsc_in.extent) + trans = translist[0] if translist else "" + # arcpy.AddMessage(f"\t{trans}\n") + # for trans in translist: + # arcpy.AddMessage(f"\t{trans}") + return trans + + +def clear_folder(folder=""): + try: + import shutil + + for filename in os.listdir(folder): + file_path = os.path.join(folder, filename) + if os.path.isfile(file_path) or os.path.islink(file_path): + arcpy.AddMessage(f"Removing: {os.path.basename(file_path)}") + os.unlink(file_path) + elif os.path.isdir(file_path): + arcpy.AddMessage(f"Removing: {os.path.basename(file_path)}") + shutil.rmtree(file_path) + else: + pass + + + except arcpy.ExecuteError: + # Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + return False + except: # noqa: E722 + # Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + return False + else: + return True + + +def compare_metadata_xml(file1="", file2=""): + """This requires the use of the clone ArcGIS Pro env and the installation of xmldiff.""" + # https://buildmedia.readthedocs.org/media/pdf/xmldiff/latest/xmldiff.pdf + try: + # Test if passed workspace exists, if not raise Exception + if not os.path.exists(rf"{file1}") or not os.path.exists(rf"{file2}"): + raise Exception( + f"{os.path.basename(file1)} or {os.path.basename(file2)} is missing!!" + ) + + from lxml import etree + from xmldiff import formatting, main + + # Examples + # diff = main.diff_files(file1, file2, formatter=formatting.XMLFormatter()) + # diff = main.diff_files(file1, file2, formatter=formatting.XMLFormatter(normalize=formatting.WS_BOTH, pretty_print=True)) + # The DiffFormatter creates a script of steps to take to make file2 like file1 + __diff = main.diff_files(file1, file2, formatter=formatting.DiffFormatter()) + # If there are differences + if __diff: + __diff = main.diff_files(file1, file2, formatter=formatting.XMLFormatter()) + return __diff + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + return __diff + finally: + pass + + +def convertSeconds(seconds): + try: + _min, _sec = divmod(seconds, 60) + _hour, _min = divmod(_min, 60) + return f"{int(_hour)}:{int(_min)}:{_sec:.3f}" + except Exception: + arcpy.AddError(f"Error in convertSeconds: {e}") + traceback.print_exc() + + +##def calculate_core_species(table): +## try: +## +## region_gdb = os.path.dirname(table) +## +## arcpy.env.workspace = region_gdb +## arcpy.env.scratchWorkspace = region_gdb +## arcpy.env.parallelProcessingFactor = "100%" +## arcpy.env.overwriteOutput = True +## arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History +## arcpy.SetLogMetadata(True) +## arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. +## # 1—If a tool produces a warning or an error, it will throw an exception. +## # 2—If a tool produces an error, it will throw an exception. This is the default. +## arcpy.SetMessageLevels(["NORMAL"]) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION +## del region_gdb +## +## # def unique_years(table): +## # with arcpy.da.SearchCursor(table, ["Year"]) as cursor: +## # return sorted({row[0] for row in cursor}) +## +## def unique_values(table, field): +## with arcpy.da.SearchCursor(table, [field]) as cursor: +## return sorted({row[0] for row in cursor}) # Uses list comprehension +## +## # Get unique list of years from the table +## all_years = unique_values(table, "Year") +## +## PrintListOfYears = False +## if PrintListOfYears: +## # Print list of years +## arcpy.AddMessage(f"--> Years: {', '.join([str(y) for y in all_years])}") +## +## # Get minimum year (first year) and maximum year (last year) +## min_year, max_year = min(all_years), max(all_years) +## +## # Print min year +## arcpy.AddMessage(f"--> Min Year: {min_year} and Max Year: {max_year}") +## +## del min_year, max_year +## +## del PrintListOfYears +## +## arcpy.AddMessage(f"\t Creating {os.path.basename(table)} Table View") +## +## species_table_view = arcpy.management.MakeTableView(table, f"{os.path.basename(table)} Table View") +## +## unique_species = unique_values(species_table_view, "Species") +## +## for unique_specie in unique_species: +## arcpy.AddMessage(f"\t\t Unique Species: {unique_specie}") +## +## # Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script +## # The following inputs are layers or table views: "ai_csv" +## arcpy.management.SelectLayerByAttribute(in_layer_or_view=species_table_view, selection_type="NEW_SELECTION", where_clause=f"Species = '{unique_specie}' AND WTCPUE > 0.0 AND DistributionProjectName = 'NMFS/Rutgers IDW Interpolation'") +## +## all_specie_years = unique_values(species_table_view, "Year") +## +## # arcpy.AddMessage(f"\t\t\t Years: {', '.join([str(y) for y in all_specie_years])}") +## +## # arcpy.AddMessage(f"\t\t Select Species ({unique_specie}) by attribute") +## +## arcpy.management.SelectLayerByAttribute(in_layer_or_view=species_table_view, selection_type="NEW_SELECTION", where_clause=f"Species = '{unique_specie}'") +## +## # arcpy.AddMessage(f"\t Set CoreSpecies to Yes or No") +## +## if all_years == all_specie_years: +## arcpy.AddMessage(f"\t\t\t {unique_specie} is a Core Species") +## arcpy.management.CalculateField(in_table=species_table_view, field="CoreSpecies", expression="'Yes'", expression_type="PYTHON", code_block="") +## else: +## arcpy.AddMessage(f"\t\t\t @@@@ {unique_specie} is not a Core Species @@@@") +## arcpy.management.CalculateField(in_table=species_table_view, field="CoreSpecies", expression="'No'", expression_type="PYTHON", code_block="") +## +## arcpy.management.SelectLayerByAttribute(species_table_view, "CLEAR_SELECTION") +## del unique_specie, all_specie_years +## +## arcpy.management.Delete(f"{os.path.basename(table)} Table View") +## del species_table_view, unique_species, all_years +## del unique_values +## del table +## +## except KeyboardInterrupt: +## raise SystemExit +## except arcpy.ExecuteWarning: +## arcpy.AddWarning(arcpy.GetMessages(1)) +## except arcpy.ExecuteError: +## arcpy.AddError(arcpy.GetMessages(2)) +## traceback.print_exc() +## raise SystemExit +## except Exception: +## arcpy.AddError(arcpy.GetMessages(2)) +## traceback.print_exc() +## raise SystemExit +## except: # noqa: E722 +## arcpy.AddError(arcpy.GetMessages(2)) +## traceback.print_exc() +## raise SystemExit +## else: +## # While in development, leave here. For test, move to finally +## rk = [key for key in locals().keys() if not key.startswith('__')] +## if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk +## return True +## finally: +## pass + + +def dataset_title_dict(project_gdb=""): + try: + project_folder = os.path.dirname(project_gdb) + project = os.path.basename(project_folder) + csv_data_folder = os.path.join(project_folder, "CSV_Data") + #print([f.name for f in arcpy.ListFields(os.path.join(csv_data_folder, "Datasets.csv"))]) + + crf_folder = rf"{project_folder}\CRFs" + _credits = "These data were produced by NMFS OST." + access_constraints = "***No Warranty*** The user assumes the entire risk related to its use of these data. NMFS is providing these data 'as is' and NMFS disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose. No warranty expressed or implied is made regarding the accuracy or utility of the data on any other system or for general or scientific purposes, nor shall the act of distribution constitute any such warranty. It is strongly recommended that careful attention be paid to the contents of the metadata file associated with these data to evaluate dataset limitations, restrictions or intended use. In no event will NMFS be liable to you or to any third party for any direct, indirect, incidental, consequential, special or exemplary damages or lost profit resulting from any use or misuse of these data." + + __datasets_dict = {} + + #for row in arcpy.da.SearchCursor(os.path.join(csv_data_folder, "Datasets.csv"), ["PointFeatureType","DistributionProjectCode","Region","Season",]): + # print(row) + + dataset_codes = {row[0]: [row[1], row[2], row[3], row[4]] + for row in arcpy.da.SearchCursor(os.path.join(csv_data_folder, "Datasets.csv"), + ["DatasetCode","PointFeatureType","DistributionProjectCode","Region","Season",],) + } + # for dataset_code in dataset_codes: + # dataset_codes[dataset_code] = [s for s in dataset_codes[dataset_code] if s.strip()] + # #print(f"Dataset Code: {dataset_code}\n\t{dataset_codes[dataset_code]}") + + for dataset_code in dataset_codes: + point_feature_type = ( + dataset_codes[dataset_code][0] if dataset_codes[dataset_code][0] else "" + ) + distribution_project_code = ( + dataset_codes[dataset_code][1] if dataset_codes[dataset_code][1] else "" + ) + region = ( + dataset_codes[dataset_code][2] + if dataset_codes[dataset_code][2] + else dataset_code.replace("_", " ") + ) + season = ( + dataset_codes[dataset_code][3] if dataset_codes[dataset_code][3] else "" + ) + + tags = f"DisMap, {region}, {season}" if season else f"DisMap, {region}" + # tags = f"{tags}, distribution, seasonal distribution, fish, invertebrates, climate change, fishery-independent surveys, ecological dynamics, oceans, biosphere, earth science, species/population interactions, aquatic sciences, fisheries, range changes" + summary = "These data were created as part of the DisMAP project to enable visualization and analysis of changes in fish and invertebrate distributions" + + # arcpy.AddMessage(f"Dateset Code: {dataset_code}") + + if distribution_project_code == "IDW": + table_name = f"{dataset_code}_{distribution_project_code}" + table_name_s = f"{table_name}_{date_code(project)}" + table_name_st = f"{region} {season} Table {date_code(project)}".replace( + " ", " " + ) + + # arcpy.AddMessage(f"\tProcessing: {table_name}") + + __datasets_dict[table_name] = { + "Dataset Service": table_name_s, + "Dataset Service Title": table_name_st, + "Tags": tags, + "Summary": summary, + "Description": "This table represents the CSV Data files in ArcGIS format", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + del table_name, table_name_s, table_name_st + + table_name = f"{dataset_code}_{distribution_project_code}" + sample_locations_fc = ( + f"{table_name}_{point_feature_type.replace(' ', '_')}" + ) + sample_locations_fcs = f"{table_name.replace('_IDW', '')}_{point_feature_type.replace(' ', '_')}_{date_code(project)}" + feature_service_title = f"{region} {season} {point_feature_type} {date_code(project)}".replace( + " ", " " + ) + sample_locations_fcst = f"{feature_service_title}" + del feature_service_title + + __datasets_dict[sample_locations_fc] = { + "Dataset Service": sample_locations_fcs, + "Dataset Service Title": sample_locations_fcst, + "Tags": tags, + "Summary": f"{summary}. These layers provide information on the spatial extent/boundaries of the bottom trawl surveys. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Description": f"This survey points layer provides information on both the locations where species are caught in several NOAA Fisheries surveys and the amount (i.e., biomass weight catch per unit effort, standardized to kg/ha) of each species that was caught at each location. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tSample Locations FC: {sample_locations_fc}") + # arcpy.AddMessage(f"\tSample Locations FCS: {sample_locations_fcs}") + # arcpy.AddMessage(f"\tSample Locations FST: {sample_locations_fcst}") + + del ( + table_name, + sample_locations_fc, + sample_locations_fcs, + sample_locations_fcst, + ) + + dataset_code = ( + f"{dataset_code}_{distribution_project_code}" + if distribution_project_code not in dataset_code + else dataset_code + ) + + # Bathymetry + bathymetry_r = f"{dataset_code}_Bathymetry" + bathymetry_rs = f"{dataset_code}_Bathymetry_{date_code(project)}" + feature_service_title = ( + f"{region} {season} Bathymetry {date_code(project)}".replace( + " ", " " + ) + ) + bathymetry_rst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {bathymetry_r}") + + __datasets_dict[bathymetry_r] = { + "Dataset Service": bathymetry_rs, + "Dataset Service Title": bathymetry_rst, + "Tags": tags, + "Summary": summary, + "Description": "The bathymetry dataset represents the ocean depth at that grid cell.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tBathymetry R: {bathymetry_r}") + # arcpy.AddMessage(f"\tBathymetry RS: {bathymetry_rs}") + # arcpy.AddMessage(f"\tBathymetry RST: {bathymetry_rst}") + + del bathymetry_r, bathymetry_rs, bathymetry_rst + + # Boundary + boundary_fc = f"{dataset_code}_Boundary" + boundary_fcs = f"{dataset_code}_Boundary_{date_code(project)}" + feature_service_title = ( + f"{region} {season} Boundary {date_code(project)}".replace( + " ", " " + ) + ) + boundary_fcst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {boundary_fc}") + + __datasets_dict[boundary_fc] = { + "Dataset Service": boundary_fcs, + "Dataset Service Title": boundary_fcst, + "Tags": tags, + "Summary": summary, + "Description": "These files contain the spatial boundaries of the NOAA Fisheries Bottom-trawl surveys. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Eastern Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tBoundary FC: {boundary_fc}") + # arcpy.AddMessage(f"\tBoundary FCS: {boundary_fcs}") + # arcpy.AddMessage(f"\tBoundary FCST: {boundary_fcst}") + + del boundary_fc, boundary_fcs, boundary_fcst + + # Boundary Line + boundary_line_fc = f"{dataset_code}_Boundary_Line" + boundary_line_fcs = f"{dataset_code}_Boundary_Line_{date_code(project)}" + feature_service_title = ( + f"{region} {season} Boundary Line {date_code(project)}".replace( + " ", " " + ) + ) + boundary_line_fcst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {boundary_line_fc}") + + __datasets_dict[boundary_line_fc] = { + "Dataset Service": boundary_line_fcs, + "Dataset Service Title": boundary_line_fcst, + "Tags": tags, + "Summary": summary, + "Description": "These files contain the spatial boundaries of the NOAA Fisheries Bottom-trawl surveys. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Eastern Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tBoundary FC: {boundary_line_fc}") + # arcpy.AddMessage(f"\tBoundary FCS: {boundary_line_fcs}") + # arcpy.AddMessage(f"\tBoundary FCST: {boundary_line_fcst}") + + del boundary_line_fc, boundary_line_fcs, boundary_line_fcst + + # Extent Points + extent_points_fc = f"{dataset_code}_Extent_Points" + extent_points_fcs = f"{dataset_code}_Extent_Points_{date_code(project)}" + feature_service_title = ( + f"{region} {season} Extent Points {date_code(project)}".replace( + " ", " " + ) + ) + extent_points_fcst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {extent_points_fc}") + __datasets_dict[extent_points_fc] = { + "Dataset Service": extent_points_fcs, + "Dataset Service Title": extent_points_fcst, + "Tags": tags, + "Summary": summary, + "Description": f"The Extent Points layer represents the extent of the model region.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + # arcpy.AddMessage(f"\tExtent Points FC: {extent_points_fc}") + # arcpy.AddMessage(f"\tExtent Points FCS: {extent_points_fcs}") + # arcpy.AddMessage(f"\tExtent Points FCST: {extent_points_fcst}") + del extent_points_fc, extent_points_fcs, extent_points_fcst + + fishnet_fc = f"{dataset_code}_Fishnet" + fishnet_fcs = f"{dataset_code}_Fishnet_{date_code(project)}" + feature_service_title = ( + f"{region} {season} Fishnet {date_code(project)}".replace(" ", " ") + ) + fishnet_fcst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {fishnet_fc}") + + __datasets_dict[fishnet_fc] = { + "Dataset Service": fishnet_fcs, + "Dataset Service Title": fishnet_fcst, + "Tags": tags, + "Summary": summary, + "Description": f"The Fishnet is used to create the latitude and longitude rasters.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tFishnet FC: {fishnet_fc}") + # arcpy.AddMessage(f"\tFishnet FCS: {fishnet_fcs}") + # arcpy.AddMessage(f"\tFishnet FCST: {fishnet_fcst}") + + del fishnet_fc, fishnet_fcs, fishnet_fcst + + indicators_tb = f"{dataset_code}_Indicators" + indicators_tbs = f"{dataset_code}_Indicators_{date_code(project)}" + feature_service_title = ( + f"{region} {season} Indicators Table {date_code(project)}".replace( + " ", " " + ) + ) + indicators_tbst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {indicators_tb}") + + __datasets_dict[indicators_tb] = { + "Dataset Service": indicators_tbs, + "Dataset Service Title": indicators_tbst, + "Tags": tags, + "Summary": f"{summary}. This table provides the key metrics used to evaluate a species distribution shift. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Description": f"These data contain the key distribution metrics of center of gravity, range limits, and depth for each species in the portal. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tIndicators T: {indicators_tb}") + # arcpy.AddMessage(f"\tIndicators TS: {indicators_tbs}") + # arcpy.AddMessage(f"\tIndicators TST: {indicators_tbst}") + + del indicators_tb, indicators_tbs, indicators_tbst + + lat_long_fc = f"{dataset_code}_Lat_Long" + lat_long_fcs = f"{dataset_code}_Lat_Long_{date_code(project)}" + feature_service_title = ( + f"{region} {season} Lat Long {date_code(project)}".replace( + " ", " " + ) + ) + lat_long_fcst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {lat_long_fc}") + + __datasets_dict[lat_long_fc] = { + "Dataset Service": lat_long_fcs, + "Dataset Service Title": lat_long_fcst, + "Tags": tags, + "Summary": summary, + "Description": f"The lat_long layer is used to get the latitude & longitude values to create these rasters", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tLat Long FC: {lat_long_fc}") + # arcpy.AddMessage(f"\tLat Long FCS: {lat_long_fcs}") + # arcpy.AddMessage(f"\tLat Long FCST: {lat_long_fcst}") + + del lat_long_fc, lat_long_fcs, lat_long_fcst + + latitude_r = f"{dataset_code}_Latitude" + latitude_rs = f"{dataset_code}_Latitude_{date_code(project)}" + feature_service_title = ( + f"{region} {season} Latitude {date_code(project)}".replace( + " ", " " + ) + ) + latitude_rst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {latitude_r}") + + __datasets_dict[latitude_r] = { + "Dataset Service": latitude_rs, + "Dataset Service Title": latitude_rst, + "Tags": tags, + "Summary": summary, + "Description": f"The Latitude raster", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tLatitude R: {latitude_r}") + # arcpy.AddMessage(f"\tLatitude RS: {latitude_rs}") + # arcpy.AddMessage(f"\tLatitude RST: {latitude_rst}") + + del latitude_r, latitude_rs, latitude_rst + + layer_species_year_image_name_tb = ( + f"{dataset_code}_LayerSpeciesYearImageName" + ) + layer_species_year_image_name_tbs = ( + f"{dataset_code}_LayerSpeciesYearImageName_{date_code(project)}" + ) + feature_service_title = f"{region} {season} Layer Species Year Image Name Table {date_code(project)}" + layer_species_year_image_name_tbst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {layer_species_year_image_name_tb}") + + __datasets_dict[layer_species_year_image_name_tb] = { + "Dataset Service": layer_species_year_image_name_tbs, + "Dataset Service Title": layer_species_year_image_name_tbst, + "Tags": tags, + "Summary": summary, + "Description": f"Layer Species Year Image Name Table", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName T: {layer_species_year_image_name_tb}") + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName TS: {layer_species_year_image_name_tbs}") + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName TST: {layer_species_year_image_name_tbst}") + + del ( + layer_species_year_image_name_tb, + layer_species_year_image_name_tbs, + layer_species_year_image_name_tbst, + ) + + longitude_r = f"{dataset_code}_Longitude" + longitude_rs = f"{dataset_code}_Longitude_{date_code(project)}" + feature_service_title = ( + f"{region} {season} Longitude {date_code(project)}".replace( + " ", " " + ) + ) + longitude_rst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {longitude_r}") + + __datasets_dict[longitude_r] = { + "Dataset Service": longitude_rs, + "Dataset Service Title": longitude_rst, + "Tags": tags, + "Summary": summary, + "Description": f"The Longitude raster", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tLongitude R: {longitude_r}") + # arcpy.AddMessage(f"\tLongitude RS: {longitude_rs}") + # arcpy.AddMessage(f"\tLongitude RST: {longitude_rst}") + + del longitude_r, longitude_rs, longitude_rst + + mosaic_r = f"{dataset_code}_Mosaic" + mosaic_rs = f"{dataset_code}_Mosaic_{date_code(project)}" + feature_service_title = f"{region} {season} {dataset_code[dataset_code.rfind('_')+1:]} Mosaic {date_code(project)}".replace( + " ", " " + ) + mosaic_rst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {mosaic_r}") + + __datasets_dict[mosaic_r] = { + "Dataset Service": mosaic_rs, + "Dataset Service Title": mosaic_rst, + "Tags": tags, + "Summary": f"{summary}. These interpolated biomass layers provide information on the spatial distribution of species caught in the NOAA Fisheries fisheries-independent surveys. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Description": f"NOAA Fisheries and its partners conduct fisheries-independent surveys in 8 regions in the US (Northeast, Southeast, Gulf of Mexico, West Coast, Gulf of Alaska, Bering Sea, Aleutian Islands, Hawai’i Islands). These surveys are designed to collect information on the seasonal distribution, relative abundance, and biodiversity of fish and invertebrate species found in U.S. waters. Over 400 species of fish and invertebrates have been identified in these surveys.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tMosaic R: {mosaic_r}") + # arcpy.AddMessage(f"\tMosaic RS: {mosaic_rs}") + # arcpy.AddMessage(f"\tMosaic RST: {mosaic_rst}") + + del mosaic_r, mosaic_rs, mosaic_rst + + crf_r = f"{dataset_code}.crf" + crf_rs = f"{dataset_code}_{date_code(project)}" + feature_service_title = f"{region} {season} {dataset_code[dataset_code.rfind('_')+1:]} {date_code(project)}".replace( + " ", " " + ) + crf_rst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {crf_r}") + + __datasets_dict[crf_r] = { + "Dataset Service": crf_rs, + "Dataset Service Title": crf_rst, + "Tags": tags, + "Summary": f"{summary}. These interpolated biomass layers provide information on the spatial distribution of species caught in the NOAA Fisheries fisheries-independent surveys. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Description": f"NOAA Fisheries and its partners conduct fisheries-independent surveys in 8 regions in the US (Northeast, Southeast, Gulf of Mexico, West Coast, Gulf of Alaska, Bering Sea, Aleutian Islands, Hawai’i Islands). These surveys are designed to collect information on the seasonal distribution, relative abundance, and biodiversity of fish and invertebrate species found in U.S. waters. Over 400 species of fish and invertebrates have been identified in these surveys.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tCFR R: {crf_r}") + # arcpy.AddMessage(f"\tCFR RS: {crf_rs}") + # arcpy.AddMessage(f"\tCFR RST: {crf_rst}") + + del crf_r, crf_rs, crf_rst + + raster_mask_r = f"{dataset_code}_Raster_Mask" + raster_mask_rs = f"{dataset_code}_Raster_Mask_{date_code(project)}" + feature_service_title = ( + f"{region} {season} Raster Mask {date_code(project)}".replace( + " ", " " + ) + ) + raster_mask_rst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {raster_mask_r}") + + __datasets_dict[raster_mask_r] = { + "Dataset Service": raster_mask_rs, + "Dataset Service Title": raster_mask_rst, + "Tags": tags, + "Summary": summary, + "Description": f"Raster Mask is used for image production", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tRaster_Mask R: {raster_mask_r}") + # arcpy.AddMessage(f"\tRaster_Mask RS: {raster_mask_rs}") + # arcpy.AddMessage(f"\tRaster_Mask RST: {raster_mask_rst}") + + del raster_mask_r, raster_mask_rs, raster_mask_rst + + region_fc = f"{dataset_code}_Region" + region_fcs = f"{dataset_code}_Region_{date_code(project)}" + feature_service_title = ( + f"{region} {season} Region {date_code(project)}".replace(" ", " ") + ) + region_fcst = f"{feature_service_title}" + del feature_service_title + + # arcpy.AddMessage(f"\tProcessing: {region_fc}") + + __datasets_dict[region_fc] = { + "Dataset Service": region_fcs, + "Dataset Service Title": region_fcst, + "Tags": tags, + "Summary": summary, + "Description": f"These files contain the spatial boundaries of the NOAA Fisheries Bottom-trawl surveys. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tRegion FC: {region_fc}") + # arcpy.AddMessage(f"\tRegion FCS: {region_fcs}") + # arcpy.AddMessage(f"\tRegion FCST: {region_fcst}") + + del region_fc, region_fcs, region_fcst + del tags + else: + pass + + if "Datasets" == dataset_code: + + # arcpy.AddMessage(f"\tProcessing: {dataset_code}") + + datasets_tb = dataset_code + datasets_tbs = f"{dataset_code}_{date_code(project)}" + datasets_tbst = f"{dataset_code} {date_code(project)}" + + __datasets_dict[datasets_tb] = { + "Dataset Service": datasets_tbs, + "Dataset Service Title": datasets_tbst, + "Tags": "DisMAP, Datasets", + "Summary": summary, + "Description": "This table functions as a look-up table of values", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"{__datasets_dict[datasets_tb]}") + del datasets_tb, datasets_tbs, datasets_tbst + else: + pass + + if "DisMAP_Regions" == dataset_code: + + # arcpy.AddMessage(f"\tProcessing: {dataset_code}") + + regions_fc = dataset_code + regions_fcs = f"{dataset_code}_{date_code(project)}" + regions_fcst = f"DisMAP Regions {date_code(project)}" + + __datasets_dict[regions_fc] = { + "Dataset Service": regions_fcs, + "Dataset Service Title": regions_fcst, + "Tags": "DisMAP Regions", + "Summary": summary, + "Description": "These files contain the spatial boundaries of the NOAA Fisheries Bottom-trawl surveys. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Eastern Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + del regions_fc, regions_fcs, regions_fcst + + else: + pass + if "Indicators" == dataset_code: + + # arcpy.AddMessage(f"\tProcessing: {dataset_code}") + + indicators_tb = f"{dataset_code}" + indicators_tbs = f"{dataset_code}_{date_code(project)}" + indicators_tbst = f"{dataset_code} {date_code(project)}" + + __datasets_dict[indicators_tb] = { + "Dataset Service": indicators_tbs, + "Dataset Service Title": indicators_tbst, + "Tags": "DisMAP, Indicators", + "Summary": f"{summary}. This table provides the key metrics used to evaluate a species distribution shift. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", + "Description": f"These data contain the key distribution metrics of center of gravity, range limits, and depth for each species in the portal. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + del indicators_tb, indicators_tbs, indicators_tbst + else: + pass + + if "Species_Filter" == dataset_code: + + # arcpy.AddMessage(f"\tProcessing: {dataset_code}") + + species_filter_tb = dataset_code + species_filter_tbs = f"{dataset_code}_{date_code(project)}" + species_filter_tbst = f"Species Filter Table {date_code(project)}" + + __datasets_dict[species_filter_tb] = { + "Dataset Service": species_filter_tbs, + "Dataset Service Title": species_filter_tbst, + "Tags": "DisMAP, Species Filter Table", + "Summary": summary, + "Description": "This table functions as a look-up table of values", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName T: {species_filter_tb}") + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName TS: {species_filter_tbs}") + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName TST: {species_filter_tbst}") + + del species_filter_tb, species_filter_tbs, species_filter_tbst + + else: + pass + if "DisMAP_Survey_Info" == dataset_code: + + # arcpy.AddMessage(f"\tProcessing: {dataset_code}") + + tb = dataset_code + tbs = f"{dataset_code}_{date_code(project)}" + tbst = f"DisMAP Survey Info Table {date_code(project)}" + + __datasets_dict[tb] = { + "Dataset Service": tbs, + "Dataset Service Title": tbst, + "Tags": "DisMAP; DisMAP Survey Info Table", + "Summary": summary, + "Description": "This table functions as a look-up table of values", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName T: {tb}") + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName TS: {tbs}") + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName TST: {tbst}") + + del tb, tbs, tbst + + else: + pass + + if "SpatialGroup_SpeciesPersistenceIndicator" == dataset_code: + + # arcpy.AddMessage(f"\tProcessing: {dataset_code} DisMAP_Survey_Info") + + tb = dataset_code + tbs = f"{dataset_code}_{date_code(project)}" + tbst = f"Spatial Group Species Persistence Indicator Table {date_code(project)}" + + __datasets_dict[tb] = { + "Dataset Service": tbs, + "Dataset Service Title": tbst, + "Tags": "DisMAP; Spatial Group Species Persistence Indicator Table", + "Summary": summary, + "Description": "This table functions as a look-up table of values", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName T: {tb}") + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName TS: {tbs}") + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName TST: {tbst}") + + del tb, tbs, tbst + + else: + pass + + + if "SpeciesPersistenceIndicatorPercentileBin" == dataset_code: + + # arcpy.AddMessage(f"\tProcessing: {dataset_code} DisMAP_Survey_Info") + + tb = dataset_code + tbs = f"{dataset_code}_{date_code(project)}" + tbst = f"Species Persistence Indicator Percentile Bin Table {date_code(project)}" + + __datasets_dict[tb] = { + "Dataset Service": tbs, + "Dataset Service Title": tbst, + "Tags": "DisMAP; Species Persistence Indicator Percentile Bin Table", + "Summary": summary, + "Description": "This table functions as a look-up table of values", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName T: {tb}") + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName TS: {tbs}") + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName TST: {tbst}") + + del tb, tbs, tbst + + else: + pass + + if "SpeciesPersistenceIndicatorTrend" == dataset_code: + + # arcpy.AddMessage(f"\tProcessing: {dataset_code}") + + tb = dataset_code + tbs = f"{dataset_code}_{date_code(project)}" + tbst = f"Species Persistence Indicator Trend Table {date_code(project)}" + + __datasets_dict[tb] = { + "Dataset Service": tbs, + "Dataset Service Title": tbst, + "Tags": "DisMAP; Species Persistence Indicator Trend Table", + "Summary": summary, + "Description": "This table functions as a look-up table of values", + "Credits": _credits, + "Access Constraints": access_constraints, + } + + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName T: {tb}") + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName TS: {tbs}") + # arcpy.AddMessage(f"\tLayerSpeciesYearImageName TST: {tbst}") + + del tb, tbs, tbst + + else: + pass + # arcpy.AddMessage(f"\tProcessing: {dataset_code}") + # table = dataset_code + # table_s = f"{dataset_code}_{date_code(project)}" + # table_st = f"{table_s.replace('_',' ')} {date_code(project)}" + # arcpy.AddMessage(f"\tProcessing: {table_s}") + # __datasets_dict[table] = {"Dataset Service" : table_s, + # "Dataset Service Title" : table_st, + # "Tags" : f"DisMAP, {table}", + # "Summary" : summary, + # "Description" : "Unknown table", + # "Credits" : _credits, + # "Access Constraints" : access_constraints} + # arcpy.AddMessage(f"\tTable: {table}") + # arcpy.AddMessage(f"\tTable TS: {table_s}") + # arcpy.AddMessage(f"\tTable TST: {table_st}") + # del table, table_s, table_st + # arcpy.AddWarning(f"{dataset_code} is missing") + + del summary + del point_feature_type, distribution_project_code, region, season + del dataset_code + + del _credits, access_constraints + + del dataset_codes + del project_folder, crf_folder + del project, project_gdb + + except KeyboardInterrupt: + raise SystemExit + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + raise SystemExit + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + raise SystemExit + except SystemExit: + raise SystemExit + else: + return __datasets_dict + finally: + pass + + +def date_code(version): + try: + from datetime import datetime + from time import strftime + + _date_code = "" + + if version.isdigit(): + # The version value is 'YYYYMMDD' format (20230501) + # and is converted to 'Month Day and Year' (i.e. May 1 2023) + # print(f"Is Digit: {version}") + _date_code = datetime.strptime(version, "%Y%m%d").strftime("%B %#d %Y") + # print(_date_code) + elif not version.isdigit(): + version = version.replace("-", " ") + # The version value is 'Month Day and Year' (i.e. May 1 2023) + # and is converted to 'YYYYMMDD' format (20230501) + # print(f"Is Not Digit: {version}") + _date_code = datetime.strptime(version, "%B %d %Y").strftime("%Y%m%d") + # print(_date_code) + else: + _date_code = "error" + # Imports + del datetime, strftime + del version + + import copy + __results = copy.deepcopy(_date_code) + del _date_code, copy + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + else: + #arcpy.AddMessage("\nScript finished successfully.") + return __results + finally: + pass + #arcpy.AddMessage(f"\n{'--End' * 10}--") + + +def dTypesCSV(csv_data_folder="", table=""): + try: + ## if "IDW" in table: + ## table = "IDW_Data" + ## elif "GLMME" in table: + ## table = "GLMME_Data" + ## elif "GFDL" in table: + ## table = "GFDL_Data" + ## elif "Indicators" in table: + ## table = "Indicators" + ## + ## ## elif "DisMAP_Regions" in table: + ## ## table = "DisMAP_Regions" + ## ## + ## ## elif "Datasets" in table: + ## ## table = "Datasets" + ## ## + ## ## elif "Datasets" in table: + ## ## table = "Datasets" + ## ## + ## ## elif "Datasets" in table: + ## ## table = "Datasets" + ## + ## else: + ## table = table + + _table_definitions = table_definitions(csv_data_folder, "") + for key in _table_definitions: + #print(key, _table_definitions[key]) + del key + + fields = _table_definitions[table.replace(".csv", "")] + + field_csv_dtypes = { + k.replace(" ", "_"): "str" + for k in _table_definitions[table.replace(".csv", "")] + } + + del fields, _table_definitions + del csv_data_folder, table + + # Import + import copy + + __results = copy.deepcopy(field_csv_dtypes) + del field_csv_dtypes, copy + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:") + traceback.print_exc() + else: + return __results + finally: + if "__results" in locals().keys(): + del __results + + +def dTypesGDB(csv_data_folder="", table=""): + try: + ## if "IDW" in table: + ## table = "IDW_Data" + ## elif "GLMME" in table: + ## table = "GLMME_Data" + ## elif "GFDL" in table: + ## table = "GFDL_Data" + ## else: + ## pass + + _field_definitions = field_definitions(csv_data_folder, "") + _table_definitions = table_definitions(csv_data_folder, "") + + fields = _table_definitions[table.replace(".csv", "")] + + field_gdb_dtypes = [] + for field in fields: + field_definition = _field_definitions[field] + # arcpy.AddMessage(field_definition["field_type"]) + # fd = field_definition[:-2] + # del fd[2], field_definition + if ( + field_definition["field_type"] == "TEXT" + or field_definition["field_type"] == "String" + ): + field_dtype = f"U{field_definition['field_length']}" + elif ( + field_definition["field_type"] == "SHORT" + or field_definition["field_type"] == "Integer" + ): + # np.dtype('u4') == dtype('uint32') + # field_dtype = f"U4" + field_dtype = f"u4" + elif ( + field_definition["field_type"] == "DOUBLE" + or field_definition["field_type"] == "Double" + ): + # np.dtype('d') == dtype('float64'), np.dtype('f') == dtype('float32'), np.dtype('f8') == dtype('float64') + field_dtype = f"d" + elif ( + field_definition["field_type"] == "DATE" + or field_definition["field_type"] == "Date" + ): + field_dtype = f"M8[us]" + else: + field_dtype = "" + field_gdb_dtypes.append((f"{field}", f"{field_dtype}")) + del field_definition, field, field_dtype + del fields + + del _field_definitions, _table_definitions + + del table, csv_data_folder + + import copy + + __results = copy.deepcopy(field_gdb_dtypes) + del field_gdb_dtypes, copy + + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + return __results + finally: + if "__results" in locals().keys(): + del __results + + +def export_metadata(csv_data_folder="", in_table=""): + # Deprecated + try: + table = os.path.basename(in_table) + ws = os.path.dirname(in_table) + project_folder = os.path.dirname(ws) + # csv_data_folder = os.path.join(project_folder, "CSV_Data") + project = os.path.basename(project_folder) + version = project[7:] + del in_table, project_folder, project, version, csv_data_folder + + ws_type = arcpy.Describe(ws).workspaceType + + if ws_type == "LocalDatabase": + os.chdir(os.path.dirname(ws)) + elif ws_type == "FileSystem": + os.chdir(ws) + elif ws_type == "RemoteDatabase": + pass + else: + pass + del ws_type + + cwd = os.getcwd() + + # ArcPy Environments + # Set the overwriteOutput to True + arcpy.env.overwriteOutput = True + # Use all of the cores on the machine. + arcpy.env.parallelProcessingFactor = "100%" + # Set the scratch workspace + arcpy.env.scratchWorkspace = rf"Scratch\\scratch.gdb" + # Set the workspace to the workspace + arcpy.env.workspace = ws + + # Set Log Metadata to False in order to not record all geoprocessing + # steps in metadata + arcpy.SetLogMetadata(True) + + arcpy.AddMessage(f"Dataset: {table}") + + # Process: Export Metadata + arcpy.AddMessage(f"\tExporting Metadata Object for Dataset: {table}") + + # https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm + from arcpy import metadata as md + + dataset_md = md.Metadata(table) + dataset_md.synchronize("ALWAYS") + dataset_md.save() + dataset_md.reload() + + arcpy.AddMessage( + f"\t\tStep 1: Saving the metadata file for: {table} as an EXACT_COPY" + ) + out_xml = os.path.join(cwd, "Export Metadata", f"{table} Step 1 EXACT_COPY.xml") + dataset_md.saveAsXML(out_xml, "EXACT_COPY") + pretty_format_xml_file(out_xml) + del out_xml + + arcpy.AddMessage( + f"\t\tStep 2: Saving the metadata file for: {table} as a TEMPLATE" + ) + out_xml = os.path.join(cwd, "Export Metadata", f"{table} Step 2 TEMPLATE.xml") + dataset_md.saveAsXML(out_xml, "TEMPLATE") + pretty_format_xml_file(out_xml) + del out_xml + + del dataset_md, md + + # Declared variable + del ws, table, cwd + + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + + +def field_definitions(csv_data_folder="", field=""): + try: + import copy + import json + + # Read a File + with open( + os.path.join(csv_data_folder, "field_definitions.json"), "r" + ) as json_file: + try: + _field_definitions = json.load(json_file) + except: # noqa: E722 + arcpy.AddError(f"CSV Data: {csv_data_folder}") + arcpy.AddError(f"Field Defs: {json_file.name}") + sys.exit(0) + del json_file + + if not field: # if "" + # Returns a dictionaty of field definitions + __results = copy.deepcopy(_field_definitions) + elif field: # If a field was passed, then return + if field in _field_definitions: + __results = copy.deepcopy(_field_definitions[field]) + else: + __results = False + else: + pass + del _field_definitions + # Imports copy + del json, copy + # Function parameters + del csv_data_folder, field + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + return __results + finally: + if "__results" in locals().keys(): + del __results + + +def get_encoding_index_col(csv_file): + from pathlib import Path + + import chardet + import pandas as pd + + # Open the file in binary mode + with open(csv_file, "rb") as f: + # Read the file's content + data = f.read() + # Detect the encoding using chardet.detect() + encoding_result = chardet.detect(data) + # Retrieve the encoding information + encoding = encoding_result["encoding"] + # Print the detected encoding + # arcpy.AddMessage("Detected Encoding:", encoding) + + path = Path(csv_file) + path.write_text(path.read_text(encoding=encoding), encoding="utf8") + del path + + dtypes = {} + # Read the CSV file into a DataFrame + df = pd.read_csv( + csv_file, + encoding=encoding, + delimiter=",", + ) + # Analyze the data types and lengths + for column in df.columns: + dtypes[column] = df[column].dtype + del column + first_column = list(dtypes.keys())[0] + index_column = 0 if first_column == "Unnamed: 0" else None + # Declared Variables + del df, dtypes, first_column + + # Import + del chardet, pd, Path + + return encoding, index_column + + +def get_transformation(gsr_wkt="", psr_wkt=""): + gsr = arcpy.SpatialReference() + gsr.loadFromString(gsr_wkt) + # arcpy.AddMessage(f"\tGSR: {gsr.name}") + + psr = arcpy.SpatialReference() + psr.loadFromString(psr_wkt) + # arcpy.AddMessage(f"\tPSR: {psr.name}") + + transformslist = arcpy.ListTransformations(gsr, psr) + transform = transformslist[0] if transformslist else "" + # arcpy.AddMessage(f"\t\tTransformation: {transform}\n") + # for transform in transformslist: + # arcpy.AddMessage(f"\t{transform}") + return transform + + +def import_metadata(csv_data_folder="", dataset=""): + try: + # arcpy.AddMessage(csv_data_folder) + # arcpy.AddMessage(dataset) + if len(csv_data_folder) == 0 or len(dataset) == 0: + arcpy.AddError( + f"{os.path.basename(csv_data_folder)} or {os.path.basename(dataset)} is empty" + ) + raise Exception + else: + pass + # Import + from arcpy import metadata as md + + # arcpy.AddMessage(f"{csv_data_folder}") + # arcpy.AddMessage(f"{dataset}") + + dataset_name = os.path.basename(dataset).replace(".crf", "_CRF") if dataset.endswith(".crf") else os.path.basename(dataset) + project_gdb = os.path.dirname(dataset) + + # arcpy.AddMessage(f"{dataset_name}") + # arcpy.AddMessage(f"{project_gdb}") + + # if dataset_name.endswith(".crf"): + # dataset_name = dataset_name.replace(".crf", "_CRF") + # #_project = os.path.basename(os.path.dirname(os.path.dirname(dataset))) + # #project_gdb = rf"{os.path.dirname(os.path.dirname(dataset))}\{_project}.gdb" + # #del _project + # else: + # pass + # #project_gdb = os.path.dirname(dataset) + + # arcpy.AddMessage(f"{'-' * 10}") + # arcpy.AddError(project_gdb) + # arcpy.AddError(csv_data_folder) + # arcpy.AddError(dataset) + # arcpy.AddMessage(f"{'-' * 10}") + # raise SystemExit + + # arcpy.AddMessage(csv_data_folder) + + project_folder = os.path.dirname(csv_data_folder) + metadata_folder = os.path.join(project_folder, "Metadata_Export") + #metadata_folder = os.path.join(project_folder, "Gemini_Metadata") + + # ArcPy Environments + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = os.path.join( + os.path.dirname(project_gdb), "Scratch\\scratch.gdb" + ) + arcpy.SetLogMetadata(True) + + try: + arcpy.AddMessage("Create Metadata Dictionary") + metadata_dictionary = dataset_title_dict(project_gdb) + if metadata_dictionary: + pass + #for key in metadata_dictionary: + # arcpy.AddMessage(f"{key}, {metadata_dictionary[key]}") + # del key + elif not metadata_dictionary: + arcpy.AddWarning("Metadata Dictionary is empty") + else: + pass + except: # noqa: E722 + traceback.print_exc() + sys.exit() + arcpy.AddMessage(f"Metadata for: {dataset_name} dataset") + + # arcpy.AddMessage(f"\tDataset Service: {datasets_dict[dataset]['Dataset Service']}") + # arcpy.AddMessage(f"\tDataset Service Title: {datasets_dict[dataset]['Dataset Service Title']}") + + # Assign the Metadata object's content to a target item + dataset_md = md.Metadata(dataset) +## # resource_citation_contacts = rf"{metadata_folder}\resource_citation_contacts.xml" +## resource_citation_contacts = rf"{metadata_folder}\contacts.xml" +## # arcpy.AddMessage(resource_citation_contacts) +## dataset_md.importMetadata(resource_citation_contacts) +## dataset_md.save() +## dataset_md.synchronize("ALWAYS") # This line is redundant, already synchronized above +## dataset_md.save() +## del resource_citation_contacts # , poc_template_md + + # Create a new Metadata object and add some content to it + # https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm + dataset_md.title = metadata_dictionary[dataset_name.replace(".csv", "")]["Dataset Service Title"] + dataset_md.tags = metadata_dictionary[dataset_name.replace(".csv", "")]["Tags"] + dataset_md.summary = metadata_dictionary[dataset_name.replace(".csv", "")]["Summary"] + dataset_md.description = metadata_dictionary[dataset_name.replace(".csv", "")]["Description"] + # dataset_md.credits = metadata_dictionary[dataset_name.replace(".csv", "")]["Credits"] + # dataset_md.accessConstraints = metadata_dictionary[dataset_name.replace(".csv", "")]["Access Constraints"] + dataset_md.save() + dataset_md.synchronize("ALWAYS") # This line is redundant, already synchronized above + dataset_md.save() + #dataset_md.reload() + out_xml = rf"{metadata_folder}\{dataset_md.title}.xml" + dataset_md.saveAsXML(out_xml, "REMOVE_ALL_SENSITIVE_INFO") + # dataset_md.saveAsXML(out_xml, "REMOVE_MACHINE_NAMES") + #dataset_md.saveAsXML(out_xml) + parse_xml_file_format_and_save( + csv_data_folder=csv_data_folder, xml_file=out_xml, sort=True + ) + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + raise SystemExit + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError("Traceback:\n") + traceback.print_exc() + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}\n{arcpy.GetMessages()}" + ) + + raise SystemExit + else: + return True + + +def metadata_dictionary_json(csv_data_folder="", dataset_name=""): + try: + import json + + # Read a File + with open(rf"{csv_data_folder}\metadata_dictionary.json", "r") as json_file: + metadata_dictionary = json.load(json_file) + + if not dataset_name: + __results = metadata_dictionary + elif dataset_name: + __results = metadata_dictionary[dataset_name] + else: + __results = None + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except SystemExit: + sys.exit() + except: # noqa: E722 + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + return __results + finally: + if "__results" in locals().keys(): + del __results + + +def pretty_format_xml_file(metadata=""): + try: + # xml.etree.ElementTree Imports + # arcpy.AddMessage(f"###--->>> Converting metadata file: {os.path.basename(metadata)} to pretty format") + if os.path.isfile(metadata): + tree = ET.ElementTree(file=metadata) + root = tree.getroot() + tree = ET.ElementTree(root) + ET.indent(tree, space="\t", level=0) + xmlstr = ET.tostring(root, encoding="UTF-8").decode("UTF-8") + xmlstr = xmlstr.replace(' Sync="TRUE">\n', ' Sync="TRUE">') + xmlstr = xmlstr.replace(' Sync="FALSE">\n', ' Sync="FALSE">') + xmlstr = xmlstr.replace(' value="eng">\n', ' value="eng">') + xmlstr = xmlstr.replace(' value="US">\n', ' value="US">') + xmlstr = xmlstr.replace(' value="001">\n', ' value="001">') + xmlstr = xmlstr.replace(' value="002">\n', ' value="002">') + xmlstr = xmlstr.replace(' value="003">\n', ' value="003">') + xmlstr = xmlstr.replace(' value="004">\n', ' value="004">') + xmlstr = xmlstr.replace(' value="005">\n', ' value="005">') + xmlstr = xmlstr.replace(' value="006">\n', ' value="006">') + xmlstr = xmlstr.replace(' value="007">\n', ' value="007">') + xmlstr = xmlstr.replace(' value="008">\n', ' value="008">') + xmlstr = xmlstr.replace(' value="009">\n', ' value="009">') + xmlstr = xmlstr.replace(' value="010">\n', ' value="010">') + xmlstr = xmlstr.replace(' value="011">\n', ' value="011">') + xmlstr = xmlstr.replace(' value="012">\n', ' value="012">') + xmlstr = xmlstr.replace(' value="013">\n', ' value="013">') + xmlstr = xmlstr.replace(' value="014">\n', ' value="014">') + xmlstr = xmlstr.replace(' value="015">\n', ' value="015">') + xmlstr = xmlstr.replace(' code="0">\n', ' code="0">') + xmlstr = xmlstr.replace( + '\n', + '', + ) + xmlstr = xmlstr.replace('\n', '') + + xmlstr = xmlstr.replace("", '') + xmlstr = xmlstr.replace("", '') + xmlstr = xmlstr.replace("", '') + + xmlstr = xmlstr.replace('Sync="FALSE"', 'Sync="TRUE"') + + try: + with open(metadata, "w") as f: + f.write(xmlstr) + except: # noqa: E722 + arcpy.AddError( + f"The metadata file: {os.path.basename(metadata)} can not be overwritten!!" + ) + else: + arcpy.AddWarning( + f"\t###--->>> {os.path.basename(metadata)} is missing!! <<<---###" + ) + arcpy.AddWarning(f"\t###--->>> {metadata} <<<---###") + # Declared variable + del metadata, ET + + except KeyboardInterrupt: + raise SystemExit + except arcpy.ExecuteWarning: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + raise SystemExit + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + raise SystemExit + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + raise SystemExit + except: # noqa: E722 + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + raise SystemExit + else: + return True + finally: + pass + + +def pretty_format_xml_files(metadata_folder=""): + try: + arcpy.env.overwriteOutput = True + arcpy.env.workspace = metadata_folder + + xml_files = [rf"{metadata_folder}\{xml}" for xml in arcpy.ListFiles("*.xml")] + for xml_file in xml_files: + arcpy.AddMessage(os.path.basename(xml_file)) + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + return __results + finally: + if "__results" in locals().keys(): + del __results + + +def table_definitions(csv_data_folder="", dataset_name=""): + try: + # arcpy.AddMessage(dataset_name) + # arcpy.AddMessage(csv_data_folder) + import json + + # Read a File + with open( + os.path.join(csv_data_folder, "table_definitions.json"), "r" + ) as json_file: + _table_definitions = json.load(json_file) + + if not dataset_name or dataset_name == "": + import copy + # Return a dictionary of all values + __results = copy.deepcopy(_table_definitions) + elif dataset_name: + arcpy.AddMessage(f"IN: {dataset_name}") + ## if "_IDW" in dataset_name: + ## dataset_name = "IDW_Data" + ## elif "_GLMME" in dataset_name: + ## dataset_name = "GLMME_Data" + ## elif "_GFDL" in dataset_name: + ## dataset_name = "GFDL_Data" + ## else: + ## dataset_name = dataset_name + ## # arcpy.AddMessage(f"OUT: {dataset_name}") + __results = copy.deepcopy(_table_definitions[dataset_name]) + else: + arcpy.AddError("something wrong") + raise SystemExit + + except KeyboardInterrupt: + sys.exit() + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + sys.exit() + else: + return __results + finally: + if "__results" in locals().keys(): + del __results + + +# # +# Function: unique_years +# Gets the unique years in a table +# @param string table: The name of the layer +# @return array: a sorted year array so we can go in order. +# # +def unique_values(table, field): + # arcpy.AddMessage(table) + with arcpy.da.SearchCursor(table, [field]) as cursor: + return sorted({row[0] for row in cursor}) # Uses list comprehension + + +# # +# Function: unique_years +# Gets the unique years in a table +# @param string table: The name of the layer +# @return array: a sorted year array so we can go in order. +# # +def unique_years(table): + # arcpy.AddMessage(table) + arcpy.management.SelectLayerByAttribute(table, "CLEAR_SELECTION") + arcpy.management.SelectLayerByAttribute(table, "NEW_SELECTION", "Year IS NOT NULL") + with arcpy.da.SearchCursor(table, ["Year"]) as cursor: + return sorted({row[0] for row in cursor}) + + +def test_bed_1(project_gdb=""): + ## raise SystemExit(traceback.print_exc()) + ## finally: + ## if "results" in locals().keys(): del results + try: + + base_project_folder = os.path.dirname(os.path.dirname(__file__)) + + #print(project_gdb) + + # Test if passed workspace exists, if not raise SystemExit + if not arcpy.Exists(rf"{project_gdb}"): + raise SystemExit(f"{os.path.basename(project_gdb)} is missing!!") + else: + pass + + ## # Write to File + ## with open('fieldDefinitions.json', 'w') as json_file: + ## json.dump(fieldDefinitions(), json_file, indent=4) + ## del json_file + ## + ## # Write to File + ## with open('tableDefinitions.json', 'w') as json_file: + ## json.dump(tableDefinitions(), json_file, indent=4) + ## del json_file + + ## # Read a File + ## with open('fieldDefinitions.json', 'r') as json_file: + ## field_definitions = json.load(json_file) + ## for field_definition in field_definitions: + ## arcpy.AddMessage(f'Field: {field_definition}') + ## for key in field_definitions[field_definition]: + ## arcpy.AddMessage(f"\t{key:<17} : {field_definitions[field_definition][key]}") + ## del field_definition + ## #del _field_definitions + ## del json_file + + ## # Read a File + ## with open('tableDefinitions.json', 'r') as json_file: + ## table_definitions = json.load(json_file) + ## for table_definition in table_definitions: + ## arcpy.AddMessage(f"Table: {table_definition}") + ## table_fields = table_definitions[table_definition] + ## for table_field in table_fields: + ## #arcpy.AddMessage(f"\tField Name: {field}") + ## arcpy.AddMessage(f"\tField Name: {table_field:<17}") + ## for key in field_definitions[table_field]: + ## arcpy.AddMessage(f"\t\t{key:<17} : {field_definitions[table_field][key]}") + ## del key + ## del table_field + ## del table_fields + ## del table_definition + ## del _table_definitions + ## del json_file + ## del _field_definitions + ## + ## # Read a File + ## with open('fieldDefinitions.json', 'r') as json_file: + ## field_definitions = json.load(json_file) + ## del json_file + ## + ## # Read a File + ## with open('tableDefinitions.json', 'r') as json_file: + ## table_definitions = json.load(json_file) + ## del json_file + ## + ## # arcpy.AddMessage(field_definitions["Species"]["field_name"]) + ## arcpy.AddMessage(table_definitions["Datasets"]) + ## + ## del _field_definitions + ## del _table_definitions + + project_name = os.path.basename(os.path.splitext(project_gdb)[0]) + arcpy.AddMessage(project_name) + arcpy.AddMessage(date_code(project_name)) + + # # # ###--->>> + + ## tables = ["Datasets", "DisMAP_Regions", "AI_IDW"] + ## for table in tables: + ## field_csv_dtypes = dTypesCSV(csv_data_folder, table) + ## + ## arcpy.AddMessage(table) + ## for field_csv_dtype in field_csv_dtypes: + ## arcpy.AddMessage(f"\t{field_csv_dtype}"); del field_csv_dtype + ## del field_csv_dtypes + ## + ## field_gdb_dtypes = dTypesGDB(csv_data_folder, table) + ## for field_gdb_dtype in field_gdb_dtypes: + ## arcpy.AddMessage(f"\t{field_gdb_dtype}"); del field_gdb_dtype + ## del field_gdb_dtypes + ## + ## del table + ## del tables + + ## _field_definitions = fieldDefinitions(csv_data_folder, "") + ## for field in field_definitions: + ## arcpy.AddMessage(field) + ## arcpy.AddMessage(f"\t{field_definitions[field]}") + ## del field + ## del _field_definitions + + ## # First Test + ## _table_definitions = table_definitions(csv_data_folder, "") + ## #arcpy.AddMessage(table_definitions) + ## for table in table_definitions: + ## arcpy.AddMessage(table) + ## arcpy.AddMessage(f"\t{table_definitions[table]}"); + ## del table + ## del _table_definitions + + ## # Second Test + ## table_definition = tableDefinitions(csv_data_folder, "") + ## arcpy.AddMessage(table_definition); del table_definition + ## + ## #table = "DataSets" + ## #arcpy.AddMessage(table_definitions[table]) + ## #arcpy.AddMessage(f"\t"); del table + + ## # Third Test + ## tables = ["Datasets", "DisMAP_Regions", "AI_IDW",] + ## for table in tables: + ## table_definition = tableDefinitions(csv_data_folder, table) + ## arcpy.AddMessage(f"Table: {table}:\n\t{', '.join(table_definition)}"); del table_definition + ## del table + ## del tables + + ## field = "DMSLat" + ## _field_definitions = fieldDefinitions(csv_data_folder, field) + ## if field_definitions: + ## for field in field_definitions: + ## arcpy.AddMessage(field) + ## #arcpy.AddMessage(f"\t{field_definitions[field]}") + ## del field + ## else: + ## arcpy.AddMessage(f"Field: {field} is not in fieldDefinitions") + ## del _field_definitions, field + + ## import dev_dismap_tools + ## + ## csv_file=r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\April 1 2023\CSV_Data\Datasets.csv" + ## #csv_file=r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\April 1 2023\CSV_Data\Species_Filter.csv" + ## + ## table = os.path.basename(csv_file).replace(".csv", "") + ## csv_data_folder = os.path.dirname(csv_file) + ## project_folder = os.path.dirname(csv_data_folder) + ## project = os.path.basename(project_folder) + ## #version = project[7:] + ## + ## arcpy.AddMessage(f"\tProject GDB: DisMAP {project}.gdb") + ## gdb = os.path.join(project_folder, f"{project}.gdb") + ## + ## arcpy.env.overwriteOutput = True + ## arcpy.env.parallelProcessingFactor = "100%" + ## arcpy.env.scratchWorkspace = rf"Scratch\\scratch.gdb" + ## arcpy.env.workspace = gdb + ## arcpy.SetLogMetadata(True) + ## + ## field_csv_dtypes = dTypesCSV(csv_data_folder, table) + ## field_gdb_dtypes = dTypesGDB(csv_data_folder, table) + ## + ## arcpy.AddMessage(f"\tCreating Table: {table}") + ## arcpy.management.CreateTable(gdb, f"{table}", "", "", table.replace("_", " ")) + ## + ## in_table = os.path.join(gdb, table) + ## + ## #add_fields(in_table) + ## #alterFields(in_table) + ## basic_metadata(in_table) + ## export_metadata(in_table) + ## + ## del csv_file, table, project_folder, project, gdb + ## del field_csv_dtypes, field_gdb_dtypes + ## del dev_dismap_tools, in_table + +## # ###--->>> +## dataset = r'{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\CRFs\NBS_IDW.crf' +## import_metadata(csv_data_folder, dataset) +## # ###--->>> + + ## # ###--->>> + ## # Update Dataset Metadata Dictionary + ## datasets_dict = dataset_title_dict(project_gdb) + ## + ## # Write to File + ## with open(rf"{csv_data_folder}\metadata_dictionary.json", "w") as json_file: + ## json.dump(datasets_dict, json_file, indent=4) + ## del json_file + ## + ## # Read a File + ## with open(rf"{csv_data_folder}\metadata_dictionary.json", "r") as json_file: + ## datasets_dict = json.load(json_file) + ## del json_file + ## + ## for dataset in sorted(datasets_dict): + ## arcpy.AddMessage(f"Table: {dataset}") + ## arcpy.AddMessage(f"\tDataset Service: {datasets_dict[dataset]['Dataset Service']}") + ## arcpy.AddMessage(f"\tDataset Service Title: {datasets_dict[dataset]['Dataset Service Title']}") + ## arcpy.AddMessage(F"\tTags: {datasets_dict[dataset]['Tags']}") + ## arcpy.AddMessage(F"\tSummary: {datasets_dict[dataset]['Summary']}") + ## arcpy.AddMessage(F"\tDescription: {datasets_dict[dataset]['Description']}") + ## #arcpy.AddMessage(F"\tCredits: {datasets_dict[dataset]['Credits']}") + ## #arcpy.AddMessage(F"\tAccess Constraints: {datasets_dict[dataset]['Access Constraints']}") + ## arcpy.AddMessage(f"{'-'*80}") + ## + ## # dataset_md.synchronize("NOT_CREATED", 0) + ## # dataset_md.title = metadata_dictionary[table]["md_title"] + ## # dataset_md.tags = metadata_dictionary[table]["md_tags"] + ## # dataset_md.summary = metadata_dictionary[table]["md_summary"] + ## # dataset_md.description = metadata_dictionary[table]["md_description"] + ## # dataset_md.credits = metadata_dictionary[table]["md_credits"] + ## # dataset_md.accessConstraints = metadata_dictionary[table]["md_access_constraints"] + ## + ## del dataset + ## del datasets_dict + ## + ## # ###--->>> + + ## # ###--->>> + ## dataset = r'{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\May 1 2024.gdb\Datasets' + ## import_metadata(csv_data_folder, dataset) + ## del dataset + + ## # ###--->>> + + ## # ###--->>> + ## from arcpy import metadata as md + ## + ## arcpy.env.overwriteOutput = True + ## arcpy.env.workspace = rf"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\DisMAP.gdb" + ## + ## arcpy.management.CreateFeatureclass(arcpy.env.workspace, "temp_fc", "POLYGON") + ## dataset = rf"{arcpy.env.workspace}\temp_fc" + ## dataset_xml = r'{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\temp_fc.xml' + ## new_md_xml = r'{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\new_md.xml' + ## + ## dataset_md = md.Metadata(dataset) + ## dataset_md.saveAsXML(dataset_xml.replace(".xml", " no sync.xml")) + ## pretty_format_xml_file(dataset_xml.replace(".xml", " no sync.xml")) + ## + ## new_md.saveAsXML(new_md_xml) + ## pretty_format_xml_file(new_md_xml) + ## #if not dataset_md.isReadOnly: + ## dataset_md.copy(new_md) + ## dataset_md.synchronize("ACCESSED") + ## dataset_md.save() + ## dataset_md.reload() + ## del new_md, new_md_xml + ## + ## dataset_md.saveAsXML(dataset_xml.replace(".xml", " new data.xml")) + ## pretty_format_xml_file(dataset_xml.replace(".xml", " new data.xml")) + ## + ## del dataset_md + ## del dataset, dataset_xml + ## del md + + ## # Path to new metadata XML file + ## new_dataset_path = r'{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\new_dataset.xml' + ## poc_template_path = r'{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\poc_template.xml' + ## + ## # Create a new Metadata object, add some content to it, and then save + ## new_md = md.Metadata() + ## new_md.title = 'My Title' + ## new_md.tags = 'Tag1, Tag2' + ## new_md.summary = 'My Summary' + ## new_md.description = 'My Description' + ## new_md.credits = 'My Credits' + ## new_md.accessConstraints = 'My Access Constraints' + ## #new_md.saveAsXML(new_dataset_path, "TEMPLATE") + ## #dataset_md.saveAsXML(new_dataset_path) + ## #del dataset_md + ## + ## # Create the dataset metadata object + ## dataset_md = md.Metadata(dataset) + ## dataset_md.synchronize("ALWAYS") + ## dataset_md.save() + ## dataset_md.reload() + ## dataset_md.saveAsXML(dataset_xml) + ## if not dataset_md.isReadOnly: + ## dataset_md.copy(new_md) + ## dataset_md.synchronize("NOT_CREATED") + ## dataset_md.save() + ## dataset_md.reload() + ## dataset_md.synchronize("NOT_CREATED") + ## dataset_md.copy(new_md) + ## dataset_md.save() + ## dataset_md.reload() + ## # Create the POC metadata object + ## #poc_template_md = md.Metadata(poc_template_path) + ## + ## #Copy the POC metadata to the dataset metadata object + ## # Copy Start + ## #dataset_md.synchronize("ACCESSED", 0) # With copy and ACCESSED the POC overwites all metadata content + ## #dataset_md.synchronize("ALWAYS") # With copy and ALWAYS the POC overwites all metadata content + ## #dataset_md.synchronize("CREATED") # With copy and CREATED the POC overwites all metadata content + ## #dataset_md.synchronize("NOT_CREATED") # With copy and NOT_CREATED the POC overwites all metadata content + ## #dataset_md.synchronize("OVERWRITE") # With copy and OVERWRITE the POC overwites all metadata content + ## #dataset_md.synchronize("SELECTIVE") # With copy and SELECTIVE the POC overwites all metadata content + ## # Copy End + ## # Import Start + ## #dataset_md.synchronize("ACCESSED", 0) # With import and ACCESSED the POC is mergeed, but with only the XML flag + ## #dataset_md.synchronize("ALWAYS") # With import and ALWAYS the POC is mergeed, but with only the XML flag + ## #dataset_md.synchronize("CREATED") # With import and CREATED the POC is mergeed, but with only the XML flag + ## #dataset_md.synchronize("NOT_CREATED") # With import and NOT_CREATED POC is mergeed, but with only the XML flag + ## #dataset_md.synchronize("OVERWRITE") # With import and OVERWRITE the POC is mergeed, but with only the XML flag + ## #dataset_md.synchronize("SELECTIVE") # With import and SELECTIVE the POC is mergeed, but with only the XML flag + ## # Import End + ## #if not dataset_md.isReadOnly: + ## # dataset_md.copy(poc_template_md) + ## #dataset_md.importMetadata(poc_template_md) + ## # Copy Start + ## #dataset_md.synchronize("ACCESSED", 0) # With copy and ACCESSED the POC overwites all metadata content + ## #dataset_md.synchronize("ALWAYS") # With copy and ALWAYS the POC overwites all metadata content + ## #dataset_md.synchronize("CREATED") # With copy and CREATED the POC overwites all metadata content + ## #dataset_md.synchronize("NOT_CREATED") # With copy and NOT_CREATED the POC overwites all metadata content + ## #dataset_md.synchronize("OVERWRITE") # With copy and OVERWRITE the POC overwites all metadata content + ## #dataset_md.synchronize("SELECTIVE") # With copy and SELECTIVE the POC overwites all metadata content + ## # Copy End + ## # Import Start + ## #dataset_md.synchronize("ACCESSED", 0) # With import and ACCESSED the POC is mergeed, but with only the XML flag + ## #dataset_md.synchronize("ALWAYS") # With import and ALWAYS the POC is mergeed, but with only the XML flag + ## #dataset_md.synchronize("CREATED") # With import and CREATED the POC is mergeed, but with only the XML flag + ## #dataset_md.synchronize("NOT_CREATED") # With import and NOT_CREATED POC is mergeed, but with only the XML flag + ## #dataset_md.synchronize("OVERWRITE") # With import and OVERWRITE the POC is mergeed, but with only the XML flag + ## #dataset_md.synchronize("SELECTIVE") # With import and SELECTIVE the POC is mergeed, but with only the XML flag + ## # Import End + ## #dataset_md.save() + ## #dataset_md.reload() + ## #out_xml = new_dataset_path.replace(".xml", " copy do nothing .xml") + ## dataset_md.saveAsXML(new_dataset_path) + ## #dataset_md.saveAsXML(new_dataset_path.replace(".xml", " import SELECTIVE after.xml")) + ## del dataset_md, poc_template_path + ## #del poc_template_md + ## + ## pretty_format_xml_file(new_dataset_path) + ## pretty_format_xml_file(dataset_xml) + ## #del out_xml + ## + ## del new_dataset_path, dataset_xml + ## del md + ## del dataset, new_md + ## + ## # ###--->>> + + ## # ###--->>> COMPARE TWO XML DOCUMENTS + ## # This requires use of the clone ArcGIS Pro arcpy.env. + ## # https://buildmedia.readthedocs.org/media/pdf/xmldiff/latest/xmldiff.pdf + ## table = "DisMAP_Regions" + ## project_folder = os.path.dirname(project_gdb) + ## export_metadata_folder = rf"{project_folder}\ArcGIS Metadata" + ## + ## in_xml = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\DisMAP_Regions.xml" + ## out_xml = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\DisMAP Regions Current.xml" + ## + ## diff = compare_metadata_xml(in_xml, out_xml) + ## if diff: + ## diff_metadata = rf"{export_metadata_folder}\{table} EXACT_COPY DIFF of Import.xml" + ## with open(diff_metadata, "w") as f: + ## f.write(diff) + ## del f + ## del diff_metadata + ## else: + ## pass + ## + ## del diff + ## + ## del in_xml, out_xml + ## del table, project_folder, export_metadata_folder + ## # ###--->>> COMPARE TWO XML DOCUMENTS + + # pretty_format_xml_file(r"{os.environ['USERPROFILE']}\AppData\Local\ESRI\ArcGISPro\Staging\SharingProcesses\SharingMainLog - Copy.xml") + # pretty_format_xml_file(r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\July 1 2024\Export Metadata\EBS_IDW.crf.xml") + + ## Doesn't really work + ## # ###--->>> + ## def xml_json_test(project_gdb, metadata_xml): + ## + ## from xml.dom import minidom + ## import json + ## + ## project_folder = os.path.dirname(project_gdb) + ## metadata_folder = rf"{project_folder}\ArcGIS Metadata" + ## export_metadata_folder = rf"{project_folder}\Export Metadata" + ## metadata_xml_path = rf"{metadata_folder}\{metadata_xml}" + ## + ## def parse_element(element): + ## dict_data = dict() + ## if element.nodeType == element.TEXT_NODE: + ## dict_data['data'] = element.data + ## if element.nodeType not in [element.TEXT_NODE, element.DOCUMENT_NODE, + ## element.DOCUMENT_TYPE_NODE]: + ## for item in element.attributes.items(): + ## dict_data[item[0]] = item[1] + ## if element.nodeType not in [element.TEXT_NODE, element.DOCUMENT_TYPE_NODE]: + ## for child in element.childNodes: + ## child_name, child_dict = parse_element(child) + ## if child_name in dict_data: + ## try: + ## dict_data[child_name].append(child_dict) + ## except AttributeError: + ## dict_data[child_name] = [dict_data[child_name], child_dict] + ## else: + ## dict_data[child_name] = child_dict + ## return element.nodeName, dict_data + ## + ## #dom = minidom.parse('data.xml') + ## #f = open('data.json', 'w') + ## dom = minidom.parse(metadata_xml_path) + ## f = open(rf"{export_metadata_folder}\{metadata_xml.replace('.xml', '.json')}", "w") + ## f.write(json.dumps(parse_element(dom), sort_keys=True, indent=4)) + ## f.close() + ## + ## del minidom, json + ## + ## metadata_xml = "AI_Sample_Locations_20230401.xml" + ## + ## xml_json_test(project_gdb, metadata_xml) + ## + ## del metadata_xml, xml_json_test + ## + ## # ###--->>> + + ## # ###--->>> + ## from arcpy import metadata as md + ## + ## arcpy.env.overwriteOutput = True + ## arcpy.env.workspace = rf"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\DisMAP.gdb" + ## + ## arcpy.management.CreateFeatureclass(arcpy.env.workspace, "temp_fc", "POLYGON") + ## dataset = rf"{arcpy.env.workspace}\temp_fc" + ## dataset_xml = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\Export Metadata\temp_fc.xml" + ## new_md_xml = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\Export Metadata\new_md.xml" + ## + ## poc_template = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\poc_template.xml" + ## + ## # dataset_md = md.Metadata(dataset) + ## # dataset_md.saveAsXML(dataset_xml.replace(".xml", " no sync.xml")) + ## # pretty_format_xml_file(dataset_xml.replace(".xml", " no sync.xml")) + ## # dataset_md.synchronize("ALWAYS") + ## # dataset_md.save() + ## # dataset_md.reload() + ## # dataset_md.title = 'My Title' + ## # dataset_md.tags = 'Tag1, Tag2' + ## # dataset_md.summary = 'My Summary' + ## # dataset_md.description = 'My Description' + ## # dataset_md.credits = 'My Credits' + ## # dataset_md.accessConstraints = 'My Access Constraints' + ## # dataset_md.save() + ## # dataset_md.reload() + ## # dataset_md.saveAsXML(dataset_xml.replace(".xml", " ALWAYS sync.xml")) + ## # pretty_format_xml_file(dataset_xml.replace(".xml", " ALWAYS sync.xml")) + ## + ## #del dataset_md + ## #dataset_md = md.Metadata(dataset) + ## + ## # Create a new Metadata object, add some content to it, and then save + ## new_md = md.Metadata() + ## # new_md.title = 'My Title' + ## # new_md.tags = 'Tag1, Tag2' + ## # new_md.summary = 'My Summary' + ## # new_md.description = 'My Description' + ## # new_md.credits = 'My Credits' + ## # new_md.accessConstraints = 'My Access Constraints' + ## new_md.importMetadata(new_md_xml) + ## new_md.importMetadata(poc_template) + ## #new_md.save() + ## #new_md.reload() + ## new_md.saveAsXML(new_md_xml) + ## pretty_format_xml_file(new_md_xml) + ## + ## del new_md + ## + ## # dataset_md.synchronize("ACCESSED") + ## # dataset_md.importMetadata(new_md_xml) + ## # dataset_md.synchronize("CREATED") + ## # dataset_md.save() + ## # dataset_md.reload() + ## # + ## # del dataset_md + ## # dataset_md = md.Metadata(dataset) + ## # + ## # dataset_md.importMetadata(poc_template) + ## # #dataset_md.save() + ## # #dataset_md.reload() + ## # #dataset_md.synchronize("ALWAYS") + ## # #dataset_md.synchronize("SELECTIVE") + ## # dataset_md.save() + ## # dataset_md.reload() + ## + ## + ## del new_md_xml + ## del poc_template + ## # + ## # #dataset_md.saveAsXML(dataset_xml.replace(".xml", " new data.xml")) + ## # dataset_md.saveAsXML(dataset_xml.replace(".xml", " new data.xml"), "REMOVE_MACHINE_NAMES") + ## # pretty_format_xml_file(dataset_xml.replace(".xml", " new data.xml")) + ## # + ## # del dataset_md + ## + ## del dataset, dataset_xml + ## del md + ## # ###--->>> + + ## # ###--->>> + ## from arcpy import metadata as md + ## + ## metadata_folder = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\Export Metadata" + ## new_md_xml = rf"{metadata_folder}\new_md.xml" + ## dataset_md_xml = rf"{metadata_folder}\dataset_md.xml" + ## + ## # Create a new Metadata object, add some content to it, and then save + ## new_md = md.Metadata() + ## new_md.title = 'My Title' + ## new_md.tags = 'Tag1, Tag2' + ## # new_md.summary = 'My Summary' + ## # new_md.description = 'My Description' + ## # new_md.credits = 'My Credits' + ## # new_md.accessConstraints = 'My Access Constraints' + ## new_md.saveAsXML(new_md_xml) + ## pretty_format_xml_file(new_md_xml) + ## new_md.saveAsXML(dataset_md_xml) + ## pretty_format_xml_file(dataset_md_xml) + ## del new_md + ## + ## dataset_md = md.Metadata(dataset_md_xml) + ## dataset_md.importMetadata("""20240701000000001.0FALSE""") + ## dataset_md.synchronize("NOT_CREATED") + ## dataset_md.save() + ## dataset_md.reload() + ## dataset_md.saveAsXML(dataset_md_xml) + ## pretty_format_xml_file(dataset_md_xml) + ## del dataset_md + ## + ## # Declared Variables + ## del dataset_md_xml + ## del new_md_xml + ## del metadata_folder + ## + ## # Imports + ## del md + ## + ## # ###--->>> + + ## # ###--->>> + ## import datetime + ## import pytz + ## + ## #unaware = datetime.datetime(2011, 8, 15, 8, 15, 12, 0) + ## #aware = datetime.datetime(2011, 8, 15, 8, 15, 12, 0, pytz.UTC) + ## + ## unaware = datetime.datetime(2011, 1, 1, 0, 0, 0, 0) + ## aware = datetime.datetime(2011, 1, 1, 0, 0, 0, 0, pytz.UTC) + ## + ## + ## now_aware = pytz.utc.localize(unaware) + ## assert aware == now_aware + ## + ## arcpy.AddMessage(now_aware) + ## + ## from datetime import datetime, timezone + ## + ## dt = datetime(2011, 1, 1, 0, 0, 0, 0) + ## dt = dt.replace(tzinfo=timezone.utc) + ## arcpy.AddMessage(dt.isoformat()) + ## + ## del datetime, timezone, dt + ## + ## + ## import pandas as pd + ## df = pd.DataFrame({"Year": [2014, 2015, 2016],}) + ## #df.insert(df.columns.get_loc("Year")+1, "StdTime", pd.to_datetime(df["Year"], format="%Y").dt.tz_localize('Etc/GMT')) + ## df.insert(df.columns.get_loc("Year")+1, "StdTime", pd.to_datetime(df["Year"], format="%Y", utc=True)) + ## #df.insert(df.columns.get_loc("Year")+1, "StdTime", pd.to_datetime(df["Year"], format="%Y")) + ## + ## arcpy.AddMessage(df) + ## + ## del pd, df + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + else: + arcpy.AddMessage("\nScript finished successfully.") + return True + finally: arcpy.AddMessage(f"\n{'--End' * 10}--") + + +def test_bed_2(project=""): + try: + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + base_project_folder = os.path.dirname(os.path.dirname(__file__)) + + # Test if passed workspace exists, if not raise SystemExit + if not arcpy.Exists(project_gdb): + raise SystemExit(f"{os.path.basename(project_gdb)} is missing!!") + else: + pass + + ## # ###--->>> + ## from arcpy import metadata as md + ## + ## project_folder = os.path.dirname(project_gdb) + ## + ## metadata_folder = rf"{project_folder}\Export Metadata" + ## new_md_xml = rf"{metadata_folder}\new_md.xml" + ## dataset_md_xml = rf"{metadata_folder}\dataset_md.xml" + ## + ## # Create a new Metadata object, add some content to it, and then save + ## new_md = md.Metadata() + ## #new_md.title = 'My Title' + ## new_md.tags = 'Tag1, Tag2' + ## new_md.summary = 'My Summary' + ## new_md.description = 'My Description' + ## new_md.credits = 'My Credits' + ## new_md.accessConstraints = 'My Access Constraints' + ## # Save the original + ## new_md.saveAsXML(new_md_xml) + ## + ## # Pretty Format + ## pretty_format_xml_file(new_md_xml) + ## + ## # Save a copy to modify + ## new_md.saveAsXML(dataset_md_xml) + ## + ## # Pretty Format + ## pretty_format_xml_file(dataset_md_xml) + ## del new_md + ## + ## dataset_md = md.Metadata(dataset_md_xml) + ## #dataset_md.synchronize("ALWAYS") + ## #dataset_md.importMetadata("""20240701000000001.0FALSE""") + ## #dataset_md.importMetadata(md.Metadata("""My Title""")) + ## + ## #dataset_md.synchronize("SELECTIVE") + ## #dataset_md.importMetadata(rf"{metadata_folder}\AI_IDW_Sample_Locations.xml") + ## #dataset_md.synchronize("CREATED") + ## + ## #dataset_md.synchronize("CREATED") + ## #dataset_md.save() + ## #dataset_md.reload() + ## dataset_md.importMetadata(rf"{metadata_folder}\poc_template.xml") + ## dataset_md.save() + ## dataset_md.synchronize("SELECTIVE") + ## #arcpy.AddMessage(dataset_md.xml) + ## #dataset_md.save() + ## #dataset_md.reload() + ## # Save the modified file + ## #dataset_md.saveAsXML(dataset_md_xml) + ## + ## # Pretty Format + ## pretty_format_xml_file(dataset_md_xml) + ## + ## del dataset_md + ## + ## # Declared Variables + ## del dataset_md_xml + ## del new_md_xml + ## del metadata_folder, project_folder + ## + ## # Imports + ## del md + ## + ## # ###--->>> + + ## # ###--->>> + ## + ## project_folder = os.path.dirname(project_gdb) + ## metadata_folder = rf"{project_folder}\Export Metadata" + ## xml_file_1 = rf"{metadata_folder}\AI_IDW_Sample_Locations.xml" + ## xml_file_2 = rf"{metadata_folder}\poc_template.xml" + ## + ## xml_combiner(project_gdb=project_gdb, xml_file_1=xml_file_1, xml_file_2=xml_file_2) + ## + ## del project_folder, metadata_folder + ## del xml_file_1, xml_file_2 + ## + ## # ###--->>> + + ## # ###--->>> + ## + ## from arcpy import metadata as md + ## + ## project_folder = os.path.dirname(project_gdb) + ## metadata_folder = rf"{project_folder}\Export Metadata" + ## + ## # ArcPy Environments + ## arcpy.env.overwriteOutput = True + ## arcpy.env.parallelProcessingFactor = "100%" + ## arcpy.env.workspace = project_gdb + ## arcpy.env.scratchWorkspace = rf"Scratch\\scratch.gdb" + ## arcpy.SetLogMetadata(True) + ## + ## metadata_dictionary = dataset_title_dict(project_gdb) + ## + ## dataset = os.path.join(project_gdb, "DisMAP_Regions") + ## table = os.path.basename(dataset) + ## + ## # #arcpy.conversion.FeaturesToJSON( + ## # # in_features = dataset, + ## # # out_json_file = rf"{metadata_folder}\{table}.json", + ## # # format_json = "FORMATTED", + ## # # include_z_values = "NO_Z_VALUES", + ## # # include_m_values = "NO_M_VALUES", + ## # # geoJSON = "NO_GEOJSON", + ## # # outputToWGS84 = "KEEP_INPUT_SR", + ## # # use_field_alias = "USE_FIELD_NAME" + ## # # ) + + ## arcpy.AddMessage(f"JSON To Features") + ## + ## arcpy.conversion.JSONToFeatures( + ## in_json_file = rf"{metadata_folder}\{table}.json", + ## out_features = dataset, + ## geometry_type = "POLYLINE" + ## ) + + ## arcpy.AddMessage(f"Dataset: {table}") + ## + ## dataset_md = md.Metadata(dataset) + ## #dataset_md.xml = '20240701000000001.0FALSE' + ## dataset_md.synchronize("ALWAYS") + ## out_xml = rf"{metadata_folder}\{table}_Step_1.xml" + ## dataset_md.saveAsXML(out_xml) + ## + ## pretty_format_xml_file(out_xml) + ## del out_xml + ## + ## dataset_md.importMetadata(rf"{metadata_folder}\poc_john.xml") + ## dataset_md.synchronize("SELECTIVE") + ## dataset_md.save() + ## dataset_md.reload() + ## out_xml = rf"{metadata_folder}\{table}_Step_2.xml" + ## dataset_md.saveAsXML(out_xml) + ## + ## pretty_format_xml_file(out_xml) + ## del out_xml + ## + ## dataset_md.title = metadata_dictionary[table]["Dataset Service Title"] + ## dataset_md.tags = metadata_dictionary[table]["Tags"] + ## dataset_md.summary = metadata_dictionary[table]["Summary"] + ## dataset_md.description = metadata_dictionary[table]["Description"] + ## dataset_md.credits = metadata_dictionary[table]["Credits"] + ## dataset_md.accessConstraints = metadata_dictionary[table]["Access Constraints"] + ## dataset_md.save() + ## dataset_md.reload() + ## out_xml = rf"{metadata_folder}\{table}_Step_3.xml" + ## dataset_md.saveAsXML(out_xml) + ## + ## pretty_format_xml_file(out_xml) + ## del out_xml + ## + ## del dataset_md + + ## # arcpy.AddMessage(f"\tDataset Service: {datasets_dict[dataset]['Dataset Service']}") + ## # arcpy.AddMessage(f"\tDataset Service Title: {datasets_dict[dataset]['Dataset Service Title']}") + ## + ## # # https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm + ## # dataset_md = md.Metadata(dataset) + ## # dataset_md.xml = '' + ## # dataset_md.save() + ## # #dataset_md.synchronize("ALWAYS") + ## # dataset_md.save() + ## # del dataset_md + ## # + ## # dataset_md = md.Metadata(dataset) + ## # dataset_md.importMetadata(rf"{metadata_folder}\poc_template.xml") + ## # dataset_md.save() + ## # del dataset_md + ## # + ## # dataset_md = md.Metadata(dataset) + ## # dataset_md.synchronize("ALWAYS") + ## # dataset_md.importMetadata(rf"{metadata_folder}\dismap_regions_entity.xml") + ## # dataset_md.save() + ## # del dataset_md + ## + ## dataset_md = md.Metadata(dataset) + ## dataset_md.synchronize("ALWAYS") + ## dataset_md.save() + ## dataset_md.reload() + ## #dataset_md.synchronize("SELECTIVE") + ## dataset_md.title = metadata_dictionary[table]["Dataset Service Title"] + ## dataset_md.tags = metadata_dictionary[table]["Tags"] + ## dataset_md.summary = metadata_dictionary[table]["Summary"] + ## dataset_md.description = metadata_dictionary[table]["Description"] + ## dataset_md.credits = metadata_dictionary[table]["Credits"] + ## dataset_md.accessConstraints = metadata_dictionary[table]["Access Constraints"] + ## dataset_md.save() + ## del dataset_md + ## + ## dataset_md = md.Metadata(dataset) + ## + ## #out_xml = rf"{metadata_folder}\{dataset_md.title}.xml" + ## out_xml = rf"{metadata_folder}\{table}.xml" + ## dataset_md.saveAsXML(out_xml, "REMOVE_ALL_SENSITIVE_INFO") + ## #dataset_md.saveAsXML(out_xml, "REMOVE_MACHINE_NAMES") + ## #dataset_md.saveAsXML(out_xml) + ## + ## pretty_format_xml_file(out_xml) + ## del out_xml + ## + ## del dataset_md + ## + ## # arcpy.AddMessage(f"Dataset: {table}") + ## # dataset_md_path = rf"{metadata_folder}\{table}.xml" + ## # if arcpy.Exists(dataset_md_path): + ## # arcpy.AddMessage(f"\tMetadata File: {os.path.basename(dataset_md_path)}") + ## # from arcpy import metadata as md + ## # try: + ## # dataset_md = md.Metadata(dataset) + ## # # Import the standard-format metadata content to the target item + ## # if not dataset_md.isReadOnly: + ## # dataset_md.importMetadata(dataset_md_path, "ARCGIS_METADATA") + ## # dataset_md.save() + ## # dataset_md.reload() + ## # dataset_md.title = title + ## # dataset_md.save() + ## # dataset_md.reload() + ## # + ## # arcpy.AddMessage(f"\tExporting metadata file from {table}") + ## # + ## # out_xml = rf"{project_folder}\Export Metadata\{title} EXACT_COPY.xml" + ## # dataset_md.saveAsXML(out_xml, "EXACT_COPY") + ## # + ## # pretty_format_xml_file(out_xml) + ## # del out_xml + ## # + ## # del dataset_md, md + ## # + ## # except: # noqa: E722 + ## # arcpy.AddError(f"\tDataset metadata import error!! {arcpy.GetMessages()}") + ## # else: + ## # arcpy.AddWarning(f"\tDataset missing metadata file!!") + + ## del md + ## del project_folder, metadata_folder, metadata_dictionary + ## del dataset, table + ## + ## # ###--->>> + + ## # ###--->>> + ## from arcpy import metadata as md + ## + ## base_project_folder = os.path.dirname(os.path.dirname(__file__)) + ## project_gdb = rf"{base_project_folder}\{project}\{project}.gdb" + ## workspace = rf"{base_project_folder}\DisMAP.gdb" + ## + ## arcpy.env.overwriteOutput = True + ## arcpy.env.workspace = workspace + ## + ## arcpy.management.CreateFeatureclass(arcpy.env.workspace, "temp_fc", "POLYGON") + ## + ## dataset = rf"{workspace}\temp_fc" + ## dataset_xml = rf"{base_project_folder}\{project}\Export Metadata\temp_fc.xml" + ## + ## dataset_md = md.Metadata(dataset) + ## dataset_md.saveAsXML(dataset_xml.replace(".xml", " no sync.xml"), "REMOVE_ALL_SENSITIVE_INFO") + ## pretty_format_xml_file(dataset_xml.replace(".xml", " no sync.xml")) + ## + ## dataset_md.synchronize("ALWAYS") + ## dataset_md.save() + ## + ## dataset_md.saveAsXML(dataset_xml.replace(".xml", " ALWAYS.xml"), "REMOVE_ALL_SENSITIVE_INFO") + ## pretty_format_xml_file(dataset_xml.replace(".xml", " ALWAYS.xml")) + ## + ## dataset_md.title = 'My Title' + ## dataset_md.tags = 'Tag1, Tag2' + ## dataset_md.summary = 'My Summary' + ## dataset_md.description = 'My Description' + ## dataset_md.credits = 'My Credits' + ## dataset_md.accessConstraints = 'My Access Constraints' + ## dataset_md.save() + ## dataset_md.saveAsXML(dataset_xml.replace(".xml", " Title added.xml"), "REMOVE_ALL_SENSITIVE_INFO") + ## pretty_format_xml_file(dataset_xml.replace(".xml", " Title added.xml")) + ## + ## del dataset, dataset_xml + ## del dataset_md + ## del md + ## del base_project_folder, workspace + ## # ###--->>> + + # Function parameters + del project_gdb + del project + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + else: + arcpy.AddMessage("\nScript finished successfully.") + return True + finally: arcpy.AddMessage(f"\n{'--End' * 10}--") + + +def script_tool(project_gdb=""): + try: + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage(f"{'-' * 80}\n") + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + # Test if passed workspace exists, if not raise SystemExit + if not arcpy.Exists(project_gdb): + arcpy.AddMessage(f"{os.path.basename(project_gdb)} is missing!!") + else: + pass + + # ###--->>> dataset_title_dict Test #1 + DatasetTitleDict = False + if DatasetTitleDict: + md_dict = dataset_title_dict(project_gdb) + for key in sorted(md_dict): + arcpy.AddMessage(key) + arcpy.AddMessage(f"\tDataset Service Title: {md_dict[key]['Dataset Service Title']}" + ) + arcpy.AddMessage( + f"\tDataset Service: {md_dict[key]['Dataset Service']}" + ) + arcpy.AddMessage(f"\tTags: {md_dict[key]['Tags']}") + del key + del md_dict + else: + pass + del DatasetTitleDict + # ###--->>> + + # ###--->>> Test table_definitions + TestTableDefinitions = False + if TestTableDefinitions: + arcpy.AddMessage(os.path.basename(project_gdb)) + from create_table_definitions_json import \ + get_list_of_table_fields + + project_folder = os.path.dirname(project_gdb) + get_list_of_table_fields(project_gdb) + del get_list_of_table_fields + csv_data_folder = os.path.join(project_folder, "CSV_Data") + # First Test + _table_definitions = table_definitions(csv_data_folder, "HI_IDW") + arcpy.AddMessage(_table_definitions) + # Second Test + _table_definitions = table_definitions(csv_data_folder, "") + # arcpy.AddMessage(_table_definitions) + for table in _table_definitions: + arcpy.AddMessage(f"Table: {table}") + ## #arcpy.AddMessage(f"\t{_table_definitions[table]}"); + ## for field in _table_definitions[table]: + ## arcpy.AddMessage(f"\tfield: {field}") + ## _field_definitions = field_definitions(csv_data_folder, field) + ## #arcpy.AddMessage(_field_definitions) + ## for field in field_definitions: + ## arcpy.AddMessage(field) + ## #arcpy.AddMessage(f"\t{field_definitions[field]}") + ## del field + ## else: + ## arcpy.AddMessage(f"Field: {field} is not in field_definitions") + ## del _field_definitions, field + del table + del _table_definitions + + # ###--->>> + + TestImportMetadata = True + print(project_gdb) + if TestImportMetadata: + project_folder = os.path.dirname(project_gdb) + csv_data_folder = os.path.join(project_folder, "CSV_Data") + table_name = "Datasets.csv" + # table_name = "Species_Filter" + # table_name = "DisMAP_Survey_Info" + # table_name = "HI_IDW_Mosaic" + # table_name = "HI_IDW_Fishnet_Bathymetry" + # table_name = "Indicators" + + try: + #project_name = "August-1-2025" + #import_metadata(csv_data_folder, dataset=rf"{project_gdb}\{table_name}") + import_metadata(csv_data_folder, dataset=os.path.join(csv_data_folder, table_name)) + # import_metadata(csv_data_folder, dataset=rf"{project_folder}\Scratch\HI_IDW.gdb\{table_name}") + + except: # noqa: E722 + pass + + del table_name, csv_data_folder + else: + pass + del TestImportMetadata + + # Declared variables + # Function parameters + del project_gdb + + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage( + f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}" + ) + arcpy.AddMessage( + "Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) + ) + arcpy.AddMessage(f"{'-' * 80}") + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + else: + arcpy.AddMessage("\nScript finished successfully.") + return True + finally: + arcpy.AddMessage(f"\n{'--End' * 10}--") + + +if __name__ == "__main__": + try: + + home_folder = arcpy.GetParameterAsText(0) + project_name = arcpy.GetParameterAsText(1) + + if not home_folder: + home_folder = os.path.join(os.path.expanduser("~"), "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python") + else: + pass + + if not project_name: + project_name = "August-1-2025" + else: # This else block is empty, can be removed. + pass + + script_tool(home_folder, project_name) + + arcpy.SetParameterAsText(2, "Result") + + del home_folder, project_name + + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + except Exception as e: + arcpy.AddError(e) + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_version_project_setup.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_version_project_setup.py new file mode 100644 index 0000000..275e2c1 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/dismap_version_project_setup.py @@ -0,0 +1,235 @@ +""" +Script documentation +- Tool parameters are accessed using arcpy.GetParameter() or + arcpy.GetParameterAsText() +- Update derived parameter values using arcpy.SetParameter() or + arcpy.SetParameterAsText() +""" + +import os +import traceback + +import arcpy + + +def trace(): + import sys # noqa: E401 + import traceback + + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + filename = sys.path[0] + os.sep + "test.py" + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror + + +def _create_project_structure(home_folder, new_project_folder, project_folders): + """ + Helper function to create the project's folder and geodatabase structure. + """ + try: + # Create main project folder + project_path = rf"{home_folder}\{new_project_folder}" + if not arcpy.Exists(project_path): + arcpy.AddMessage(f"Creating Project Folder: '{new_project_folder}'") + arcpy.management.CreateFolder(home_folder, new_project_folder) + arcpy.AddMessage(arcpy.GetMessages()) + else: + arcpy.AddMessage(f"Project Folder: '{new_project_folder}' Exists") + + # Create project geodatabase + project_gdb_path = rf"{project_path}\{new_project_folder}.gdb" + if not arcpy.Exists(project_gdb_path): + arcpy.AddMessage(f"Creating Project GDB: '{new_project_folder}.gdb'") + arcpy.management.CreateFileGDB(project_path, new_project_folder) + arcpy.AddMessage(arcpy.GetMessages()) + else: + arcpy.AddMessage(f"Project GDB: {new_project_folder}.gdb exists") + + # Create Scratch folder + scratch_folder_path = rf"{project_path}\Scratch" + if not arcpy.Exists(scratch_folder_path): + arcpy.AddMessage("Creating the Scratch Folder") + arcpy.management.CreateFolder(project_path, "Scratch") + arcpy.AddMessage(arcpy.GetMessages()) + else: + arcpy.AddMessage(f"Scratch Folder: {new_project_folder}/Scratch exists") + + # Create Scratch geodatabase + scratch_gdb_path = rf"{scratch_folder_path}\scratch.gdb" + if not arcpy.Exists(scratch_gdb_path): + arcpy.AddMessage("Creating the Scratch GDB") + arcpy.management.CreateFileGDB(scratch_folder_path, "scratch") + arcpy.AddMessage(arcpy.GetMessages()) + else: + arcpy.AddMessage("Scratch GDB Exists") + + # Create additional project folders + for _project_folder in project_folders.split(";"): + folder_path = rf"{project_path}\{_project_folder}" + if not arcpy.Exists(folder_path): + arcpy.AddMessage(f"Creating Folder: {_project_folder}") + arcpy.management.CreateFolder(project_path, _project_folder) + arcpy.AddMessage(arcpy.GetMessages()) + else: + arcpy.AddMessage(f"Folder: '{_project_folder}' Exists") + + return True + except Exception as e: + arcpy.AddError(f"Error creating project structure: {e}") + traceback.print_exc() + return False + + +def script_tool(base_project_folder="", new_project_folder="", project_folders=""): + """Script code goes below""" + try: + arcpy.env.overwriteOutput = True + aprx = None # Initialize aprx to None + try: # Attempt to get the current project + aprx = arcpy.mp.ArcGISProject("CURRENT") + except (RuntimeError, FileNotFoundError) as e: # If no current project, try to open a specific one + arcpy.AddWarning(f"Could not open current ArcGIS Project: {e}. Attempting to open default project.") + aprx = arcpy.mp.ArcGISProject(os.path.join(base_project_folder, "DisMAP.aprx")) + except Exception as e: # Catch any other unexpected errors during aprx loading + arcpy.AddError(f"An unexpected error occurred while loading the ArcGIS Project: {e}") + traceback.print_exc() + return False + + # Check if aprx object is valid before proceeding + if aprx is None: + arcpy.AddError("Failed to load ArcGIS Project. Exiting script_tool.") + return False + + aprx.save() + home_folder = aprx.homeFolder + + if not _create_project_structure(home_folder, new_project_folder, project_folders): + return False # Exit if project structure creation failed + + if not arcpy.Exists( + rf"{home_folder}\{new_project_folder}\{new_project_folder}.aprx" + ): + aprx.saveACopy( + rf"{home_folder}\{new_project_folder}\{new_project_folder}.aprx" + ) + arcpy.AddMessage(arcpy.GetMessages()) + else: + pass + + _aprx = arcpy.mp.ArcGISProject( + rf"{home_folder}\{new_project_folder}\{new_project_folder}.aprx" + ) + # Remove maps + _maps = _aprx.listMaps() + if len(_maps) > 0: + for _map in _maps: + arcpy.AddMessage(_map.name) + aprx.deleteItem(_map) + del _map + del _maps + _aprx.save() + + databases = [] + databases.append( + { + "databasePath": rf"{home_folder}\{new_project_folder}\{new_project_folder}.gdb", + "isDefaultDatabase": True, + } + ) + _aprx.updateDatabases(databases) + arcpy.AddMessage(f"Databases: {databases}") + del databases + _aprx.save() + + toolboxes = [] + toolboxes.append( + {"toolboxPath": rf"{home_folder}\DisMAP.atbx", "isDefaultToolbox": True} + ) + _aprx.updateToolboxes(toolboxes) + arcpy.AddMessage(f"Toolboxes: {toolboxes}") + del toolboxes + _aprx.save() + del _aprx + + # Declared variables + del home_folder, aprx + # Function parameters + del new_project_folder, project_folders + except arcpy.ExecuteWarning: + arcpy.AddWarning(arcpy.GetMessages(1)) + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + # raise SystemExit + except SystemExit: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + # raise SystemExit + except Exception: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + # raise SystemExit + except: # noqa: E722 # noqa: E722 + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + # raise SystemExit + else: + pass + return True + finally: + pass + +if __name__ == "__main__": + try: + + base_project_folder = arcpy.GetParameterAsText(0) + new_project_folder = arcpy.GetParameterAsText(1) + project_folders = arcpy.GetParameterAsText(2) + + if not base_project_folder: + base_project_folder = os.path.join( + os.path.expanduser("~"), + f"Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python", + ) + else: + pass + + if not new_project_folder: + new_project_folder = "August-1-2025" + else: + pass + + if not project_folders: + project_folders = ( + "CRFs;CSV_Data;Dataset_Shapefiles;Images;Layers;Metadata_Export;Gemini_Metadata_Export;Publish" + ) + else: + pass + + # Call script_tool and check its return value + result = script_tool(base_project_folder, new_project_folder, project_folders) + + if result: + arcpy.SetParameterAsText(3, "Success") + else: + arcpy.SetParameterAsText(3, "Failed") + + del base_project_folder, new_project_folder, project_folders + + except SystemExit: + # SystemExit is usually raised for intentional exits, but still log it if it happens here. + arcpy.AddError("Script terminated by SystemExit in main block.") + traceback.print_exc() + arcpy.SetParameterAsText(3, "Failed") + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + arcpy.SetParameterAsText(3, "Failed") + except Exception: + traceback.print_exc() + arcpy.AddError("An unexpected error occurred in main block.") + arcpy.SetParameterAsText(3, "Failed") + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/gemini-code-1779566840617.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/gemini-code-1779566840617.py new file mode 100644 index 0000000..f178bd9 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/gemini-code-1779566840617.py @@ -0,0 +1,31 @@ +import os +import requests +import arcpy +from arcpy import metadata as md + +def force_inport_sync_37(table_path): + url = "https://www.fisheries.noaa.gov/inportserve/waf/noaa/nmfs/ost/iso19115/xml/79319.xml" + temp_iso_xml = os.path.join(arcpy.env.scratchFolder, "temp_79319.xml") + + # 1. Pull the raw bytes + response = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'}) + with open(temp_iso_xml, "wb") as f: + f.write(response.content) + + try: + # 2. Initialize the target metadata layout + target_metadata = md.Metadata(table_path) + + # 3. Use the fallback conversion constant that intercepts GMI namespace wrappers + target_metadata.importMetadata(temp_iso_xml, "FROM_ISO19139") + target_metadata.save() + print("🚀 Metadata successfully converted and populated in ArcGIS Pro 3.x!") + + except Exception as e: + print(f"Import failed: {e}") + finally: + if os.path.exists(temp_iso_xml): + os.remove(temp_iso_xml) +if __name__ == "__main__": + TARGET_TABLE = r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\February-1-2026\February-1-2026.gdb\DisMAP_Survey_Info" + force_inport_sync_37(TARGET_TABLE) \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/gemini-code-79319.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/gemini-code-79319.py new file mode 100644 index 0000000..abce9bb --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/gemini-code-79319.py @@ -0,0 +1,92 @@ +import requests +from lxml import etree + +ISO_NS = { + 'gmd': 'http://www.isotc211.org/2005/gmd', + 'gco': 'http://www.isotc211.org/2005/gco', + 'gmi': 'http://www.isotc211.org/2005/gmi', + 'gml': 'http://www.opengis.net/gml/3.2', + 'srv': 'http://www.isotc211.org/2005/srv' +} + +def get_text(element, xpath_query): + """Helper to cleanly extract text or return a default string if empty.""" + result = element.xpath(xpath_query, namespaces=ISO_NS) + if result: + return result[0].strip() + return "Not Provided" + +def get_list(element, xpath_query): + """Helper to extract arrays of items like keywords or constraints.""" + return [str(item).strip() for item in element.xpath(xpath_query, namespaces=ISO_NS) if item] + +def parse_to_arcgis_classic(): + url = "https://www.fisheries.noaa.gov/inportserve/waf/noaa/nmfs/ost/iso19115/xml/79319.xml" + headers = {'User-Agent': 'Mozilla/5.0'} + response = requests.get(url, headers=headers) + + if response.status_code != 200: + print("Failed to fetch XML.") + return + + root = etree.fromstring(response.content) + + print("\n" + "="*80) + print(" 🛠️ ARCGIS PRO METADATA EDITOR (CLASSIC VIEW) - RECORD 79319") + print("="*80) + + # --- SECTION 1: ITEM DESCRIPTION --- + print("\n[🔹 ITEM DESCRIPTION ]") + print(f" Title: {get_text(root, '//gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString/text()')}") + print(f" Alternate Title: {get_text(root, '//gmd:citation/gmd:CI_Citation/gmd:alternateTitle/gco:CharacterString/text()')}") + print(f" Publication Date: {get_text(root, '//gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode[@codeListValue=\"publication\"]]/gmd:date/gco:Date/text()')}") + print(f" File Identifier: {get_text(root, '//gmd:fileIdentifier/gco:CharacterString/text()')}") + print(f" Language: {get_text(root, '//gmd:language/gco:CharacterString/text()')}") + + abstract = get_text(root, '//gmd:abstract/gco:CharacterString/text()') + print(f" Abstract: \n {abstract[:400]}...") # Chunked for readable console print + + purpose = get_text(root, '//gmd:purpose/gco:CharacterString/text()') + print(f" Purpose: \n {purpose[:400]}...") + + # --- SECTION 2: TOPICS & KEYWORDS --- + print("\n[🔹 TOPICS & KEYWORDS ]") + topic_category = get_text(root, '//gmd:topicCategory/gmd:MD_TopicCategoryCode/text()') + print(f" ISO Topic Category: {topic_category}") + + keywords = get_list(root, '//gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:keyword/gco:CharacterString/text()') + print(" Theme Keywords: ") + for i, kw in enumerate(keywords[:8], 1): # Display first 8 + print(f" {i}. {kw}") + if len(keywords) > 8: + print(f" ... and {len(keywords)-8} more items.") + + # --- SECTION 3: SPATIAL EXTENT --- + print("\n[🔹 SPATIAL EXTENT ]") + print(f" West Bounding Long: {get_text(root, '//gmd:westBoundLongitude/gco:Decimal/text()')}") + print(f" East Bounding Long: {get_text(root, '//gmd:eastBoundLongitude/gco:Decimal/text()')}") + print(f" North Bounding Lat: {get_text(root, '//gmd:northBoundLatitude/gco:Decimal/text()')}") + print(f" South Bounding Lat: {get_text(root, '//gmd:southBoundLatitude/gco:Decimal/text()')}") + + # --- SECTION 4: CONTACTS (POINTS OF CONTACT) --- + print("\n[🔹 RESOURCE CONTACTS ]") + print(f" Organization Name: {get_text(root, '//gmd:contact/gmd:CI_ResponsibleParty/gmd:organisationName/gco:CharacterString/text()')}") + print(f" Role Code: {get_text(root, '//gmd:contact/gmd:CI_ResponsibleParty/gmd:role/gmd:CI_RoleCode/@codeListValue')}") + print(f" Contact Email: {get_text(root, '//gmd:contact/gmd:CI_ResponsibleParty//gmd:electronicMailAddress/gco:CharacterString/text()')}") + + # --- SECTION 5: RESOURCE CONSTRAINTS --- + print("\n[🔹 RESOURCE CONSTRAINTS ]") + use_lims = get_list(root, '//gmd:resourceConstraints/gmd:MD_Constraints/gmd:useLimitation/gco:CharacterString/text()') + print(" Use Limitations: ") + for lim in use_lims: + print(f" ⚠️ {lim}") + + # --- SECTION 6: LINEAGE / QUALITY --- + print("\n[🔹 RESOURCE LINEAGE ]") + statement = get_text(root, '//gmd:lineage/gmd:LI_Lineage/gmd:statement/gco:CharacterString/text()') + print(f" Statement: \n {statement[:300]}...") + + print("="*80 + "\n") + +if __name__ == "__main__": + parse_to_arcgis_classic() \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/import_datasets_species_filter_csv_data.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/import_datasets_species_filter_csv_data.py new file mode 100644 index 0000000..14036be --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/import_datasets_species_filter_csv_data.py @@ -0,0 +1,822 @@ +""" +Script documentation +- Tool parameters are accessed using arcpy.GetParameter() or + arcpy.GetParameterAsText() +- Update derived parameter values using arcpy.SetParameter() or + arcpy.SetParameterAsText() +""" +import os +# type: ignore # Temporarily ignore Pylance messages for development mode +import sys +import traceback +import inspect +import arcpy + +def get_encoding_index_col(csv_file): + try: + # Imports + import chardet + import pandas as pd + # Open the file in binary mode + with open(csv_file, 'rb') as f: + # Read the file's content + data = f.read() + # Detect the encoding using chardet.detect() + encoding_result = chardet.detect(data) + # Retrieve the encoding information + __encoding = encoding_result['encoding'] + del f, data, encoding_result + # arcpy.AddMessage the detected encoding + #print("Detected Encoding:", __encoding) + dtypes = {} + # Read the CSV file into a DataFrame + df = pd.read_csv(csv_file, encoding = __encoding, delimiter = ",",) + # Analyze the data types and lengths + for column in df.columns: + dtypes[column] = df[column].dtype + del column + first_column = list(dtypes.keys())[0] + __index_column = 0 if first_column == "Unnamed: 0" else None + # Declared Variables + del df, dtypes, first_column + # Import + del chardet, pd + # Function Parameter + del csv_file + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + return __encoding, __index_column + +def worker(project_gdb="", csv_file=""): + try: + # Imports + import pandas as pd + import numpy as np + import warnings + #import shutil + #from reportlab.lib.pagesizes import letter # noqa: F401 + #from reportlab.platypus import SimpleDocTemplate, Paragraph # noqa: F401 + #from reportlab.lib.styles import getSampleStyleSheet # noqa: F401 + #import webbrowser + + from lxml import etree + from io import StringIO + import json + + from arcpy import metadata as md + import dismap_tools + + # Set History and Metadata logs, set serverity and message level + arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel(2) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # Set basic workkpace variables + table_name = os.path.basename(csv_file).replace(".csv", "") + csv_data_folder = os.path.dirname(csv_file) + project_folder = os.path.dirname(csv_data_folder) + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + project_name = rf"{os.path.basename(project_folder)}" + home_folder = rf"{os.path.dirname(project_folder)}" + + arcgis_metadata = rf"{project_folder}\Metadata_ArcGIS" + # inport_metadata = rf"{project_folder}\Metadata_InPort" + + # Set basic workkpace variables + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = r"Scratch\\scratch.gdb" + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + # print(table_name) + # print(csv_data_folder) + + field_csv_dtypes = dismap_tools.dTypesCSV(csv_data_folder, table_name) + field_gdb_dtypes = dismap_tools.dTypesGDB(csv_data_folder, table_name) + + #print(field_csv_dtypes) + # print(field_gdb_dtypes) + + print(f"\tCreating Table: {table_name}") + arcpy.management.CreateTable(project_gdb, f"{table_name}", "", "", table_name.replace("_", " ")) + print("\t{0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) + + print(f"> Importing {table_name} CSV Table") + #csv_table = f"{table_name}.csv" + # https://pandas.pydata.org/pandas-docs/stable/getting_started/intro_tutorials/09_timeseries.html?highlight=datetime + # https://www.tutorialsandyou.com/python/numpy-data-types-66.html + #df = pd.read_csv('my_file.tsv', sep='\t', header=0) ## not setting the index_col + #df.set_index(['0'], inplace=True) + # C:\. . .\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\numpy\lib\arraysetops.py:583: + # FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison + # mask |= (ar1 == a) + # A fix: https://www.youtube.com/watch?v=TTeElATMpoI + # TLDR: pandas are Jedi; numpy are the hutts; and python is the galatic empire + #encoding, index_column = dismap_tools.get_encoding_index_col(csv_file) + encoding, index_column = get_encoding_index_col(csv_file) # pyright: ignore[reportGeneralTypeIssues] + with warnings.catch_warnings(): + warnings.simplefilter(action='ignore', category=FutureWarning) + # DataFrame + df = pd.read_csv( + csv_file, + index_col = index_column, + encoding = encoding, + delimiter = ",", + dtype = field_csv_dtypes, + ) + del encoding, index_column + #print(field_csv_dtypes) + #print(field_gdb_dtypes) + del field_csv_dtypes + #print(df) + # Replace NaN with an empty string. When pandas reads a cell + # with missing data, it asigns that cell with a Null or nan + # value. So, we are changing that value to an empty string of ''. + # https://community.esri.com/t5/python-blog/those-pesky-null-things/ba-p/902664 + # https://community.esri.com/t5/python-blog/numpy-snippets-6-much-ado-about-nothing-nan-stuff/ba-p/893702 + df.fillna('', inplace=True) + #df.fillna(np.nan) + #df = df.replace({np.nan: None}) + # Alternatively, apply to all columns at once + df = df.apply(lambda x: x.str.strip() if x.dtype == "object" else x) + print(f">-> Creating the {table_name} Geodatabase Table") + try: + array = np.array(np.rec.fromrecords(df.values), dtype = field_gdb_dtypes) + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + raise SystemExit + del df + del field_gdb_dtypes + # Temporary table + tmp_table = rf"memory\{table_name.lower()}_tmp" + try: + arcpy.da.NumPyArrayToTable(array, tmp_table) + del array + # Captures ArcPy type of error + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + raise SystemExit + + print(f">-> Copying the {table_name} Table from memory to the GDB") + fields = [f.name for f in arcpy.ListFields(tmp_table) if f.type == "String"] + for field in fields: + arcpy.management.CalculateField(tmp_table, field=field, expression=f"'' if !{field}! is None else !{field}!") + print("Calculate Field:\t{0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) + del field + del fields + + dataset_path = rf"{project_gdb}\{table_name}" + arcpy.management.CopyRows(tmp_table, dataset_path, "") + print("Copy Rows:\t{0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) + + # Remove the temporary table + arcpy.management.Delete(tmp_table) + del tmp_table + + # Alter Fields + dismap_tools.alter_fields(csv_data_folder, dataset_path) + + version_code = dismap_tools.date_code(project_name) + + contacts = rf"{home_folder}\Initial-Data\DisMAP_Contacts_{version_code}.xml" + + # print(contacts) + etree.parse(contacts, parser=etree.XMLParser(encoding='UTF-8', remove_blank_text=True)).write(contacts, pretty_print=True, xml_declaration=True, encoding="UTF-8") # pyright: ignore[reportAttributeAccessIssue] + + # Copy a file to a new file or into a directory + #dismap_logo = os.path.join(home_folder, "NOAA DisMAP 2026 Final [Logo].png") + #table_thumbnail = os.path.join(home_folder, "table_thumbnail.png") + #shutil.copy(dismap_logo, table_thumbnail) + + xml_file = os.path.join(arcgis_metadata, f"{os.path.basename(dataset_path)}.xml") + + # Load Metadata + #contacts_md = md.Metadata(contacts) + dataset_md = md.Metadata(dataset_path) + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + if not arcpy.Exists(xml_file): + dataset_md.importMetadata(contacts, "ARCGIS_METADATA") + else: + dataset_md.importMetadata(xml_file, "ARCGIS_METADATA") + #dataset_md.copy(contacts_md) + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + #dataset_md.thumbnailUri = table_thumbnail + #dataset_md.save() + #print(dataset_md.thumbnailUri) + #del contacts_md + del dataset_md + del xml_file + + # Import Metadata + dismap_tools.import_metadata(csv_data_folder=csv_data_folder, dataset=dataset_path) + +## #dataset_md.importMetadata(rf"{os.path.join(csv_data_folder, table_name)}.xml", "ARCGIS_METADATA") +## #dataset_md.save() +## dataset_md.synchronize("ALWAYS") +## dataset_md.save() + + dataset_md = md.Metadata(dataset_path) + + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) # pyright: ignore[reportAttributeAccessIssue] + tree = etree.parse(StringIO(dataset_md.xml), parser=parser) # pyright: ignore[reportAttributeAccessIssue] + root = tree.getroot() + + old_linkage = root.find("./distInfo/distTranOps/onLineSrc/linkage").text + new_item_name = root.find("Esri/DataProperties/itemProps/itemName").text + "_" + version_code + old_item_name = old_linkage[old_linkage.find("/services/")+len("/services/"):old_linkage.find("/FeatureServer")] + new_linkage = old_linkage.replace(old_item_name, new_item_name) + root.find("./distInfo/distTranOps/onLineSrc/linkage").text = new_linkage + + res_title = root.find("./dataIdInfo/idCitation/resTitle").text + + root.find(".//enttypl").text = res_title if " Table " in res_title else res_title[:-9] + " Table " + version_code + root.find(".//enttypl").attrib["Sync"] = "FALSE" + + print("*" * 75 + "\n") + + #print(res_title[-8:] if " Table " in res_title else res_title[:-9] + " Table " + version_code) + + print(root.find("./dataIdInfo/idCitation/resTitle").text) + print(root.find(".//enttypl").text) + print("\n" + "*" * 75) + + del res_title + + etree.indent(root, space="\t") # pyright: ignore[reportAttributeAccessIssue] + dataset_md.xml = etree.tostring( # pyright: ignore[reportAttributeAccessIssue] + tree, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + dataset_md.save() + + del new_linkage, old_linkage + del old_item_name, new_item_name + del version_code + del root, tree, parser + + json_path = os.path.join(csv_data_folder, "root_dict.json") + + with open(json_path, "r", encoding='utf-8') as json_file: + root_dict = json.load(json_file) + del json_file + del json_path + ## root_dict = {"Esri" : 0, "dataIdInfo" : 1, "mdChar" : 2, + ## "mdContact" : 3, "mdDateSt" : 4, "mdFileID" : 5, + ## "mdLang" : 6, "mdMaint" : 7, "mdHrLv" : 8, + ## "mdHrLvName" : 9, "refSysInfo" : 10, "spatRepInfo" : 11, + ## "spdoinfo" : 12, "dqInfo" : 13, "distInfo" : 14, + ## "eainfo" : 15, "contInfo" : 16, "spref" : 17, + ## "spatRepInfo" : 18, "dataSetFn" : 19, "Binary" : 100,} + + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) # pyright: ignore[reportAttributeAccessIssue] + + tree = etree.parse(StringIO(dataset_md.xml), parser=parser) # pyright: ignore[reportAttributeAccessIssue] # To parse from a string, use the fromstring() function instead. + + del parser + + root = tree.getroot() + for child in root.xpath("."): + child[:] = sorted(child, key=lambda x: root_dict[x.tag]) + del child + + etree.indent(root, space="\t") # pyright: ignore[reportAttributeAccessIssue] + dataset_md.xml = etree.tostring( # pyright: ignore[reportAttributeAccessIssue] + tree, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + + del root + + dataset_md.save() + + # Save as ArcGIS Metadata XML + #xml_file = os.path.join(arcgis_metadata, f"{os.path.basename(dataset_path)}.xml") + #dataset_md.saveAsXML(xml_file, "REMOVE_ALL_SENSITIVE_INFO") + #etree.parse(xml_file, parser=etree.XMLParser(encoding='UTF-8', remove_blank_text=True)).write(xml_file, pretty_print=True, xml_declaration=True, encoding="UTF-8") # pyright: ignore[reportAttributeAccessIssue] + #webbrowser.open(xml_file) + #del xml_file + + # Save as ArcGIS Metadata HTML + # html_file = os.path.join(arcgis_metadata, f"{os.path.basename(dataset_path)}.html") + # xslt_file = os.path.join(os.path.expanduser('~'), "AppData\\Local\\Programs\\ArcGIS\\Pro\\Resources\\Metadata\\Stylesheets\\ArcGIS_Imports\\htmlHeaderPro.xslt") + # dataset_md.saveAsUsingCustomXSLT(outputPath = html_file, customStylesheetPath = xslt_file) + # del xslt_file, html_file + + # Save as InPort Metadata XML + #xml_file = os.path.join(inport_metadata, f"{os.path.basename(dataset_path)}.xml") + #xsl_file = rf"{os.path.dirname(project_folder)}\Initial-Data\ArcGIS2InPort.xsl" + #dataset_md.saveAsUsingCustomXSLT(outputPath = xml_file, customStylesheetPath = xsl_file) + #etree.parse(xml_file, parser=etree.XMLParser(encoding='UTF-8', remove_blank_text=True)).write(xml_file, pretty_print=True, xml_declaration=True, encoding="UTF-8") # pyright: ignore[reportAttributeAccessIssue] + #del xml_file + + del dataset_md + + # Basic variables + del dataset_path + del table_name, csv_data_folder, project_folder, scratch_workspace + + # Function parameters + del project_gdb, csv_file + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + return True + + +def update_datecode(csv_file="", project_name=""): + try: + #sys.path.append(os.path.abspath('../dev')) + # Imports + import dismap_tools + import pandas as pd + import warnings + # Set History and Metadata logs, set serverity and message level + arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel(2) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + table_name = os.path.basename(csv_file).replace(".csv", "") + csv_data_folder = os.path.dirname(csv_file) + + # Set basic arcpy.env variables + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + field_csv_dtypes = dismap_tools.dTypesCSV(csv_data_folder, table_name) + print(f"\tUpdating CSV file: {os.path.basename(csv_file)}") + + #print(f"\t\t{csv_file}") + # C:\. . .\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\numpy\lib\arraysetops.py:583: + # FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison + # mask |= (ar1 == a) + # A fix: https://www.youtube.com/watch?v=TTeElATMpoI + # TLDR: pandas are Jedi; numpy are the hutts; and python is the galatic empire + with warnings.catch_warnings(): + warnings.simplefilter(action='ignore', category=FutureWarning) + # DataFrame + df = pd.read_csv(csv_file, + index_col = 0, + encoding = "utf-8", + delimiter = ',', + dtype = field_csv_dtypes, + ) + + old_date_code = str(df.DateCode.unique()[0]) + + #new_date_code = dismap_tools.date_code(project_name) + + #print(f"\tOld Date Code: {old_date_code}") + #print(f"\tNew Date Code: {new_date_code}") + # print(old_date_code) + # print(type(old_date_code)) + # print(new_date_code) + # print(type(new_date_code)) + # raise SystemExit + + df = df.replace(regex = old_date_code, value = dismap_tools.date_code(project_name)) + + df.to_csv(path_or_buf = f"{csv_file}", sep = ',') + + del df, pd, warnings + del old_date_code + + print(f"\tCompleted updating CSV file: {os.path.basename(csv_file)}") + + # Declared Variables + del field_csv_dtypes, table_name, csv_data_folder + # Imports + del dismap_tools + # Function parameters + del csv_file, project_name + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + # print("\nScript finished successfully.") + return True + +def metadata_arcgis_worker(project_gdb="", csv_file=""): + try: + # Imports + #import shutil + + from lxml import etree + from io import StringIO + import json + + from arcpy import metadata as md + import dismap_tools + + # Set basic workkpace variables + table_name = os.path.basename(csv_file).replace(".csv", "") + dataset_path = os.path.join(project_gdb, table_name) + csv_data_folder = os.path.dirname(csv_file) + project_folder = os.path.dirname(project_gdb) + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + project_name = rf"{os.path.basename(project_folder)}" + #home_folder = rf"{os.path.dirname(project_folder)}" + + arcgis_metadata = rf"{project_folder}\Metadata_ArcGIS" + inport_metadata = rf"{project_folder}\Metadata_InPort" + + # Set basic workkpace variables + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = r"Scratch\\scratch.gdb" + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + # print(table_name) + # print(csv_data_folder) + + + # Load Metadata + dataset_md = md.Metadata(dataset_path) + + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) # pyright: ignore[reportAttributeAccessIssue] + tree = etree.parse(StringIO(dataset_md.xml), parser=parser) # pyright: ignore[reportAttributeAccessIssue] + root = tree.getroot() + + print("*" * 75 + "\n") + + create_date = root.xpath("/metadata/Esri/CreaDate") + + if len(create_date) > 1: + for i in range(1, len(create_date)): + create_date[i].getparent().remove(create_date[i]) + + if len(create_date) == 1: + print(f"Create Date exists: {create_date[0].text}") + create_date[0].text = dismap_tools.date_code(project_name) + + elif len(create_date) == 0: + print("Create Date does not exists") + esri = root.xpath("/metadata/Esri")[0] + _create_date = etree.SubElement(esri, "CreaDate") + _create_date.text = dismap_tools.date_code(project_name) + del esri, _create_date + else: + pass + del create_date + + create_time = root.xpath("/metadata/Esri/CreaTime") + + if len(create_time) > 1: + for i in range(1, len(create_time)): + create_time[i].getparent().remove(create_time[i]) + + if len(create_time) == 1: + print(f"Create Time exists: {create_time[0].text}") + create_time[0].text = "00000000" + + elif len(create_time) == 0: + print("Create Time does not exists") + esri = root.xpath("/metadata/Esri")[0] + _create_time = etree.SubElement(esri, "CreaTime") + _create_time.text = "00000000" + del esri, _create_time + else: + pass + del create_time + + print("\n" + "*" * 75) + + etree.indent(root, space="\t") # pyright: ignore[reportAttributeAccessIssue] + dataset_md.xml = etree.tostring( # pyright: ignore[reportAttributeAccessIssue] + tree, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + + del tree, root + + dataset_md.save() + + json_path = os.path.join(csv_data_folder, "root_dict.json") + + with open(json_path, "r", encoding='utf-8') as json_file: + root_dict = json.load(json_file) + + del json_file, json_path + + # root_dict = {"Esri" : 0, "dataIdInfo" : 1, "mdChar" : 2, + # "mdContact" : 3, "mdDateSt" : 4, "mdFileID" : 5, + # "mdLang" : 6, "mdMaint" : 7, "mdHrLv" : 8, + # "mdHrLvName" : 9, "refSysInfo" : 10, "spatRepInfo" : 11, + # "spdoinfo" : 12, "dqInfo" : 13, "distInfo" : 14, + # "eainfo" : 15, "contInfo" : 16, "spref" : 17, + # "spatRepInfo" : 18, "dataSetFn" : 19, "Binary" : 100,} + + parser = etree.XMLParser(encoding="UTF-8", remove_blank_text=True) # pyright: ignore[reportAttributeAccessIssue] + + tree = etree.parse(StringIO(dataset_md.xml), parser=parser) # pyright: ignore[reportAttributeAccessIssue] # To parse from a string, use the fromstring() function instead. + + del parser + + root = tree.getroot() + for child in root.xpath("."): + child[:] = sorted(child, key=lambda x: root_dict[x.tag]) + del child + + etree.indent(root, space="\t") # pyright: ignore[reportAttributeAccessIssue] + dataset_md.xml = etree.tostring( # pyright: ignore[reportAttributeAccessIssue] + tree, + encoding="UTF-8", + method="xml", + xml_declaration=True, + pretty_print=True, + ) + + del root + + dataset_md.save() + + # Save as ArcGIS Metadata XML + xml_file = os.path.join(arcgis_metadata, f"{os.path.basename(dataset_path)}.xml") + #dataset_md.saveAsXML(xml_file, "REMOVE_ALL_SENSITIVE_INFO") + dataset_md.saveAsXML(xml_file) + etree.parse(xml_file, parser=etree.XMLParser(encoding='UTF-8', remove_blank_text=True)).write(xml_file, pretty_print=True, xml_declaration=True, encoding="UTF-8") # pyright: ignore[reportAttributeAccessIssue] + #webbrowser.open(xml_file) + del xml_file + + # Save as ArcGIS Metadata HTML + # html_file = os.path.join(arcgis_metadata, f"{os.path.basename(dataset_path)}_2.xml") + # xslt_file = os.path.join(os.path.expanduser('~'), "AppData\\Local\\Programs\\ArcGIS\\Pro\\Resources\\Metadata\\Stylesheets\\ArcGIS_Imports\\htmlHeaderPro.xslt") + # dataset_md.saveAsUsingCustomXSLT(outputPath = html_file, customStylesheetPath = xslt_file) + # del xslt_file, html_file + + # Save as InPort Metadata XML + xml_file = os.path.join(inport_metadata, f"{os.path.basename(dataset_path)}.xml") + xsl_file = rf"{os.path.dirname(project_folder)}\Initial-Data\ArcGIS2InPort.xsl" + dataset_md.saveAsUsingCustomXSLT(outputPath = xml_file, customStylesheetPath = xsl_file) + etree.parse(xml_file, parser=etree.XMLParser(encoding='UTF-8', remove_blank_text=True)).write(xml_file, pretty_print=True, xml_declaration=True, encoding="UTF-8") # pyright: ignore[reportAttributeAccessIssue] + del xml_file + + del dataset_md + + # Basic variables + del dataset_path + del table_name, project_folder, scratch_workspace, csv_data_folder + + # Function parameters + del project_gdb, csv_file + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError(f"Traceback:\n{traceback.print_exc()}") + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + else: + return True + + +def script_tool(project_folder=""): + """Script code goes below""" + try: + from lxml import etree + from io import StringIO + #import requests + + from arcpy import metadata as md + + import dismap_tools + + #xml_file = r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\Initial-Data\DisMAP_Contacts_20260601.xml" + #dismap_tools.print_xml_file(xml_file) + + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage(f"{'-' * 80}\n") + # Imports + #from dev_import_datasets_species_filter_csv_data import worker + # Set basic arcpy.env variables + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + project_name = rf"{os.path.basename(project_folder)}" + project_gdb = rf"{project_folder}\{project_name}.gdb" + home_folder = rf"{os.path.dirname(project_folder)}" + csv_data_folder = rf"{project_folder}\CSV_Data" + datasets_csv = rf"{csv_data_folder}\Datasets.csv" + species_filter_csv = rf"{csv_data_folder}\Species_Filter.csv" + survey_metadata_csv = rf"{csv_data_folder}\DisMAP_Survey_Info.csv" + + SpeciesPersistenceIndicatorTrend = rf"{csv_data_folder}\SpeciesPersistenceIndicatorTrend.csv" + SpeciesPersistenceIndicatorPercentileBin = rf"{csv_data_folder}\SpeciesPersistenceIndicatorPercentileBin.csv" + SpatialGroup_SpeciesPersistenceIndicator = rf"{csv_data_folder}\SpatialGroup_SpeciesPersistenceIndicator.csv" + + arcpy.management.Copy(rf"{home_folder}\Initial-Data\Datasets_{dismap_tools.date_code(project_name)}.csv", datasets_csv) + arcpy.management.Copy(rf"{home_folder}\Initial-Data\Species_Filter_{dismap_tools.date_code(project_name)}.csv", species_filter_csv) + arcpy.management.Copy(rf"{home_folder}\Initial-Data\DisMAP_Survey_Info_{dismap_tools.date_code(project_name)}.csv", survey_metadata_csv) + arcpy.management.Copy(rf"{home_folder}\Initial-Data\SpeciesPersistenceIndicatorTrend_{dismap_tools.date_code(project_name)}.csv", SpeciesPersistenceIndicatorTrend) + arcpy.management.Copy(rf"{home_folder}\Initial-Data\SpeciesPersistenceIndicatorPercentileBin_{dismap_tools.date_code(project_name)}.csv", SpeciesPersistenceIndicatorPercentileBin) + arcpy.management.Copy(rf"{home_folder}\Initial-Data\SpatialGroup_SpeciesPersistenceIndicator_{dismap_tools.date_code(project_name)}.csv", SpatialGroup_SpeciesPersistenceIndicator) + + del csv_data_folder + # + UpdateDatecode = False + if UpdateDatecode: + # Update DateCode + #arcpy.AddMessage(datasets_csv) + arcpy.AddMessage(project_name) + update_datecode(csv_file=datasets_csv, project_name=project_name) + del UpdateDatecode + # + DatasetsCSVFile = True + if DatasetsCSVFile: + # Worker: creates table, loads data, imports metadata, and then saves an XML + worker(project_gdb=project_gdb, csv_file=datasets_csv) + del DatasetsCSVFile + # + SpeciesFilterCSVFile = True + if SpeciesFilterCSVFile: + worker(project_gdb=project_gdb, csv_file=species_filter_csv) + del SpeciesFilterCSVFile + # + DisMAPSurveyInfoFile = True + if DisMAPSurveyInfoFile: + # Worker: creates table, loads data, imports metadata, and then saves an XML + worker(project_gdb=project_gdb, csv_file=survey_metadata_csv) + del DisMAPSurveyInfoFile + # + SpeciesPersistenceIndicatorPercentileBinFile = False + if SpeciesPersistenceIndicatorPercentileBinFile: + # Worker: creates table, loads data, imports metadata, and then saves an XML + worker(project_gdb=project_gdb, csv_file=SpeciesPersistenceIndicatorPercentileBin) + del SpeciesPersistenceIndicatorPercentileBinFile + # + SpeciesPersistenceIndicatorTrendFile = False + if SpeciesPersistenceIndicatorTrendFile: + # Worker: creates table, loads data, imports metadata, and then saves an XML + worker(project_gdb=project_gdb, csv_file=SpeciesPersistenceIndicatorTrend) + del SpeciesPersistenceIndicatorTrendFile + # + SpatialGroup_SpeciesPersistenceIndicatorFile = False + if SpatialGroup_SpeciesPersistenceIndicatorFile: + # Worker: creates table, loads data, imports metadata, and then saves an XML + worker(project_gdb=project_gdb, csv_file=SpatialGroup_SpeciesPersistenceIndicator) + del SpatialGroup_SpeciesPersistenceIndicatorFile + + # Export Meatadata + metadata_arcgis_worker(project_gdb = project_gdb, csv_file = species_filter_csv) + metadata_arcgis_worker(project_gdb = project_gdb, csv_file = survey_metadata_csv) + metadata_arcgis_worker(project_gdb = project_gdb, csv_file = SpeciesPersistenceIndicatorPercentileBin) + metadata_arcgis_worker(project_gdb = project_gdb, csv_file = SpeciesPersistenceIndicatorTrend) + metadata_arcgis_worker(project_gdb = project_gdb, csv_file = SpatialGroup_SpeciesPersistenceIndicator) + + #print(f"Compacting the {os.path.basename(project_gdb)} GDB") + arcpy.management.Compact(project_gdb) + #print("\t"+arcpy.GetMessages().replace("\n", "\n\t")) + + # # # # # # + # Declared Varaiables + del SpeciesPersistenceIndicatorPercentileBin, SpeciesPersistenceIndicatorTrend + del datasets_csv, species_filter_csv, survey_metadata_csv, home_folder, project_name + + # Imports + del etree, md, StringIO, dismap_tools + # Function Parameters + del project_folder + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:") + traceback.print_exc() + else: + arcpy.AddMessage("\nScript finished successfully.\n") + finally: + arcpy.AddMessage(f"\n{'--End' * 10}--") + + +if __name__ == '__main__': + try: + + project_folder = arcpy.GetParameterAsText(0) + if not project_folder: + # project_name = "February-1-2026" + # project_name = "August-1-2025" + project_name = "June-1-2026" + project_folder = os.path.join(os.path.expanduser('~'), f"Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\{project_name}") + else: + pass + + script_tool(project_folder) + + arcpy.SetParameterAsText(1, "Result") + + del project_folder + + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + except Exception: + traceback.print_exc() + + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/import_datasets_species_filter_csv_data.~py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/import_datasets_species_filter_csv_data.~py new file mode 100644 index 0000000..b08263b --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/import_datasets_species_filter_csv_data.~py @@ -0,0 +1,771 @@ +""" +Script documentation +- Tool parameters are accessed using arcpy.GetParameter() or + arcpy.GetParameterAsText() +- Update derived parameter values using arcpy.SetParameter() or + arcpy.SetParameterAsText() +""" +import inspect +import os +import sys +import traceback + +import arcpy + +def trace(): + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + # filename = sys.path[0] + os.sep + f"{os.path.basename(__file__)}" + filename = os.path.basename(__file__) + synerror = traceback.format_exc().splitlines()[-1] + return line, filename, synerror + +def get_encoding_index_col(csv_file): + try: + import datetime + # Imports + import chardet + import pandas as pd + + # Open the file in binary mode + with open(csv_file, "rb") as f: + # Read the file's content + data = f.read() + # Detect the encoding using chardet.detect() + encoding_result = chardet.detect(data) + # Retrieve the encoding information + __encoding = encoding_result["encoding"] + del f, data, encoding_result + # arcpy.AddMessage the detected encoding + # arcpy.AddMessage("Detected Encoding:", __encoding) + dtypes = {} + # Read the CSV file into a DataFrame + df = pd.read_csv( + csv_file, + encoding=__encoding, + delimiter=",", + ) + # Analyze the data types and lengths + for column in df.columns: + dtypes[column] = df[column].dtype + del column + first_column = list(dtypes.keys())[0] + __index_column = 0 if first_column == "Unnamed: 0" else None + # Declared Variables + del df, dtypes, first_column + # Import + del chardet, pd + # Function Parameter + del csv_file + + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError(f"Traceback:\n{traceback.format_exc()}") + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError(f"Traceback:\n{traceback.format_exc()}") + else: + arcpy.AddMessage("\nScript finished successfully.") + return __encoding, __index_column + finally: + pass + # arcpy.AddMessage(f"\n{'--End' * 10}--") + + +# Helper function to find an element by XPath and set its text +def find_and_set(root_element, path, text): + element = root_element.find(path) + if element is not None: + element.text = text + +# Helper function to create a contact element block +def create_contact_element(contact_info, role_code, parent_tag): + contact_element = etree.Element(parent_tag) + etree.SubElement(contact_element, "rpIndName").text = contact_info.get( + "rpIndName" + ) + etree.SubElement(contact_element, "rpOrgName").text = contact_info.get( + "rpOrgName" + ) + etree.SubElement(contact_element, "rpPosName").text = contact_info.get( + "rpPosName" + ) + + rpCntInfo = etree.SubElement(contact_element, "rpCntInfo") + cnt_info_data = contact_info.get("cntInfo", {}) # Safely get cntInfo, default to an empty dict if not present + cntAddress = etree.SubElement(rpCntInfo, "cntAddress") + etree.SubElement(cntAddress, "delPoint").text = cnt_info_data.get( + "delPoint", "" + ) + etree.SubElement(cntAddress, "city").text = cnt_info_data.get("city", "") + etree.SubElement(cntAddress, "adminArea").text = cnt_info_data.get( + "adminArea", "" + ) + etree.SubElement(cntAddress, "postCode").text = cnt_info_data.get( + "postCode", "" + ) + etree.SubElement(cntAddress, "country").text = cnt_info_data.get( + "country", "" + ) + etree.SubElement(cntAddress, "eMailAdd").text = cnt_info_data.get( + "eMailAdd", "" + ) + + cntPhone = etree.SubElement(rpCntInfo, "cntPhone") + etree.SubElement(cntPhone, "voiceNum").text = cnt_info_data.get("voiceNum", "") + + cntOnlineRes = etree.SubElement(rpCntInfo, "cntOnlineRes") + etree.SubElement(cntOnlineRes, "linkage").text = cnt_info_data.get("linkage", "") + + role_element = etree.SubElement(contact_element, "role") + etree.SubElement(role_element, "RoleCd").set("value", role_code) + + return contact_element + + +def worker(project_gdb="", csv_file=""): + try: + import datetime + # Test if passed workspace exists, if not raise SystemExit + if not arcpy.Exists(project_gdb) or not arcpy.Exists(csv_file): + raise SystemExit( + f"{os.path.basename(project_gdb)} OR {os.path.basename(csv_file)} is missing!!" + ) + # Imports + import dismap_tools + from arcpy import metadata as md + + # Set History and Metadata logs, set serverity and message level + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 2 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + # Set basic workkpace variables + table_name = os.path.basename(csv_file).replace(".csv", "") + csv_data_folder = os.path.dirname(csv_file) + project_folder = os.path.dirname(csv_data_folder) + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + # Set basic workkpace variables + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = r"Scratch\\scratch.gdb" + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + # arcpy.AddMessage(table_name) + # arcpy.AddMessage(csv_data_folder) + field_csv_dtypes = dismap_tools.dTypesCSV(csv_data_folder, table_name) + field_gdb_dtypes = dismap_tools.dTypesGDB(csv_data_folder, table_name) + # arcpy.AddMessage(field_csv_dtypes) + # arcpy.AddMessage(field_gdb_dtypes) + arcpy.AddMessage(f"\tCreating Table: {table_name}") + arcpy.management.CreateTable( + project_gdb, f"{table_name}", "", "", table_name.replace("_", " ") + ) + arcpy.AddMessage("\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) + import warnings + +## import numpy as np +## import pandas as pd +## +## arcpy.AddMessage(f"> Importing {table_name} CSV Table") +## # csv_table = f"{table_name}.csv" +## # https://pandas.pydata.org/pandas-docs/stable/getting_started/intro_tutorials/09_timeseries.html?highlight=datetime +## # https://www.tutorialsandyou.com/python/numpy-data-types-66.html +## # df = pd.read_csv('my_file.tsv', sep='\t', header=0) ## not setting the index_col +## # df.set_index(['0'], inplace=True) +## # C:\. . .\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\numpy\lib\arraysetops.py:583: +## # FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison +## # mask |= (ar1 == a) +## # A fix: https://www.youtube.com/watch?v=TTeElATMpoI +## # TLDR: pandas are Jedi; numpy are the hutts; and python is the galatic empire +## # encoding, index_column = dismap_tools.get_encoding_index_col(csv_file) +## encoding, index_column = get_encoding_index_col(csv_file) +## with warnings.catch_warnings(): +## warnings.simplefilter(action="ignore", category=FutureWarning) +## # DataFrame +## df = pd.read_csv( +## csv_file, +## index_col=index_column, +## encoding=encoding, +## delimiter=",", +## dtype=field_csv_dtypes, +## ) +## del encoding, index_column +## # arcpy.AddMessage(field_csv_dtypes) +## # arcpy.AddMessage(field_gdb_dtypes) +## del field_csv_dtypes +## # arcpy.AddMessage(df) +## # Replace NaN with an empty string. When pandas reads a cell +## # with missing data, it asigns that cell with a Null or nan +## # value. So, we are changing that value to an empty string of ''. +## # https://community.esri.com/t5/python-blog/those-pesky-null-things/ba-p/902664 +## # https://community.esri.com/t5/python-blog/numpy-snippets-6-much-ado-about-nothing-nan-stuff/ba-p/893702 +## df.fillna("", inplace=True) +## # df.fillna(np.nan) +## # df = df.replace({np.nan: None}) +## # Alternatively, apply to all columns at once +## df = df.apply(lambda x: x.str.strip() if x.dtype == "object" else x) +## arcpy.AddMessage(f">-> Creating the {table_name} Geodatabase Table") +## try: +## array = np.array(np.rec.fromrecords(df.values), dtype=field_gdb_dtypes) +## except: # noqa: E722 +## traceback.print_exc() +## raise SystemExit +## del df +## del field_gdb_dtypes +## # Temporary table +## tmp_table = rf"memory\{table_name.lower()}_tmp" +## try: +## arcpy.da.NumPyArrayToTable(array, tmp_table) +## del array +## # Captures ArcPy type of error +## except: # noqa: E722 +## traceback.print_exc() +## raise SystemExit +## arcpy.AddMessage(f">-> Copying the {table_name} Table from memory to the GDB") +## fields = [f.name for f in arcpy.ListFields(tmp_table) if f.type == "String"] +## for field in fields: +## arcpy.management.CalculateField( +## tmp_table, +## field=field, +## expression=f"'' if !{field}! is None else !{field}!", +## ) +## arcpy.AddMessage( +## "Calculate Field:\t{0}\n".format( +## arcpy.GetMessages().replace("\n", "\n\t") +## ) +## ) +## del field +## del fields +## dataset_path = rf"{project_gdb}\{table_name}" +## arcpy.management.CopyRows(tmp_table, dataset_path, "") +## arcpy.AddMessage( +## "Copy Rows:\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t")) +## ) +## # Remove the temporary table +## arcpy.management.Delete(tmp_table) +## +## # Alter Fields +## dismap_tools.alter_fields(csv_data_folder, dataset_path) +## +## # --- Data-Driven Metadata Creation (Refactored) --- +## from arcpy import metadata as md +## from lxml import etree +## import json # Moved here to avoid conflict with global datetime import +## +## arcpy.AddMessage(">-> Applying data-driven metadata") +## metadata_applied_successfully = False +## try: +## # Load contact dictionary +## contact_dict_path = os.path.join( +## project_folder, "CSV_Data", "contact_dict.json" +## ) +## with open(contact_dict_path, 'r') as f: +## contact_data = json.load(f) +## +## except FileNotFoundError: +## arcpy.AddWarning(f"Metadata generation skipped: 'contact_dict.json' not found at '{contact_dict_path}'.") +## return # Skip metadata generation if essential file is missing +## except json.JSONDecodeError: +## arcpy.AddWarning(f"Metadata generation skipped: 'contact_dict.json' at '{contact_dict_path}' contains invalid JSON.") +## return # Skip metadata generation if essential file is malformed +## finally: del contact_dict_path +## +## # Load the XML template +## template_xml_path = os.path.join( +## project_folder, "Layers", "metadata_templates", "csv_metadata_template.xml" +## ) +## if not os.path.exists(template_xml_path): +## _create_csv_metadata_template(template_xml_path) +## try: +## parser = etree.XMLParser(encoding='UTF-8', remove_blank_text=True) +## target_tree = etree.parse(template_xml_path, parser) +## target_root = target_tree.getroot() +## except FileNotFoundError: +## arcpy.AddWarning(f"Metadata generation skipped: 'csv_metadata_template.xml' not found at '{template_xml_path}'.") +## return # Skip metadata generation if essential file is missing +## except etree.XMLSyntaxError: +## arcpy.AddWarning(f"Metadata generation skipped: 'csv_metadata_template.xml' at '{template_xml_path}' contains invalid XML.") +## return # Skip metadata generation if essential file is malformed +## del template_xml_path, parser +## +## # Map JSON keys to their parent XML XPaths in the template +## contact_map = { +## "citRespParty": "./dataIdInfo/idCitation", +## "idPoC": "./dataIdInfo", +## "distorCont": "./distInfo/distributor", +## "mdContact": ".", +## "stepProc": ".//prcStep", +## } +## +## # Populate contacts by injecting them into the XML tree +## for key, xpath in contact_map.items(): +## if key in contact_data: +## try: +## parent_element = target_root.find(xpath) +## if parent_element is not None: +## # Remove any existing contacts of the same type before adding new ones +## for old_contact in parent_element.findall(key): +## parent_element.remove(old_contact) +## for contact_info in contact_data[key]: +## contact_xml_block = create_contact_element( +## contact_info, contact_info["role"], key +## ) +## parent_element.append(contact_xml_block) +## except KeyError as ke: +## arcpy.AddWarning(f"Skipping contact '{key}' due to missing key in contact_data: {ke}.") +## +## # Populate other dynamic fields using lxml, not string replacement +## arcpy.AddMessage(">-> Populating dynamic metadata fields using lxml") +## current_time = datetime.datetime.now() +## +## # Core Identification & other fields +## find_and_set(target_root, "./dataIdInfo/idCitation/resTitle", table_name.replace("_", " ")) +## find_and_set(target_root, "./dataIdInfo/idAbs", f"This table, '{table_name.replace('_', ' ')}', contains ancillary data for the DisMAP project, imported from a source CSV file. It serves as a foundational dataset for geospatial analysis and data visualization within the portal.") +## find_and_set(target_root, "./dataIdInfo/idPurp", "This table is used as a lookup table for various attributes within the DisMAP project, supporting fisheries science and management.") +## find_and_set(target_root, "./dataIdInfo/idCredit", "These data were produced by the NMFS Office of Science and Technology as part of the Distribution Mapping and Analysis Portal (DisMAP) initiative.") +## find_and_set(target_root, "./dataIdInfo/resConst/Consts/useLimit", "***No Warranty*** The user assumes the entire risk related to its use of these data. NMFS is providing these data \"as is\" and NMFS disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose. No warranty expressed or implied is made regarding the accuracy or utility of the data on any other system or for general or scientific purposes, nor shall the act of distribution constitute any such warranty. It is strongly recommended that careful attention be paid to the contents of the metadata file associated with these data to evaluate dataset limitations, restrictions or intended use. In no event will NMFS be liable to you or to any third party for any direct, indirect, incidental, consequential, special or exemplary damages or lost profit resulting from any use or misuse of these data.") +## # Dates +## find_and_set(target_root, "./Esri/CreaDate", current_time.strftime("%Y%m%d")) +## find_and_set(target_root, "./Esri/CreaTime", current_time.strftime("%H%M%S") + "00") +## find_and_set(target_root, "./mdDateSt", current_time.strftime("%Y%m%d")) +## find_and_set(target_root, "./dataIdInfo/idCitation/date/pubDate", "2025-08-01") # This seems like a fixed date, keep as is. +## find_and_set(target_root, ".//prcStep/stepDateTm", current_time.isoformat()) +## +## # Apply the new metadata to the geodatabase table +## dataset_md = md.Metadata(dataset_path) +## dataset_md.xml = etree.tostring( +## target_root, encoding="UTF-8", xml_declaration=True, pretty_print=True +## ) +## dataset_md.save() +## metadata_applied_successfully = True +## +## # --- End of Metadata Logic --- +## +## # Load Metadata +## # dataset_md = md.Metadata(dataset_path) +## # dataset_md.synchronize("ALWAYS") +## # dataset_md.save() +## # del dataset_md +## arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") +## arcpy.management.Compact(project_gdb) +## arcpy.AddMessage("\t" + arcpy.GetMessages().replace("\n", "\n\t")) +## # Basic variables +## del tmp_table, dataset_path +## del table_name, csv_data_folder, project_folder, scratch_workspace +## # Imports +## del dismap_tools, pd, np, warnings +## # Function parameters +## del project_gdb, csv_file + + except arcpy.ExecuteError as e: + arcpy.AddWarning(f"ArcPy metadata error for {table_name}: {e}.") + traceback.print_exc() + except KeyError as e: + arcpy.AddWarning(f"Metadata generation for {table_name} failed due to missing key: {e}. Check the metadata template or contact_dict.json.") + traceback.print_exc() + except Exception as e: + arcpy.AddWarning(f"An unexpected error occurred during metadata generation for {table_name}: {e}.") + traceback.print_exc() + + +def update_datecode(csv_file="", project_name=""): + try: + # sys.path.append(os.path.abspath('../dev')) + # Imports + import warnings + + import dismap_tools + import pandas as pd + + # Set History and Metadata logs, set serverity and message level + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 2 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + table_name = os.path.basename(csv_file).replace(".csv", "") + csv_data_folder = os.path.dirname(csv_file) + # Set basic arcpy.env variables + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + field_csv_dtypes = dismap_tools.dTypesCSV(csv_data_folder, table_name) + arcpy.AddMessage(f"\tUpdating CSV file: {os.path.basename(csv_file)}") + # arcpy.AddMessage(f"\t\t{csv_file}") + # C:\. . .\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\numpy\lib\arraysetops.py:583: + # FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison + # mask |= (ar1 == a) + # A fix: https://www.youtube.com/watch?v=TTeElATMpoI + # TLDR: pandas are Jedi; numpy are the hutts; and python is the galatic empire + with warnings.catch_warnings(): + warnings.simplefilter(action="ignore", category=FutureWarning) + # DataFrame + df = pd.read_csv( + csv_file, + index_col=0, + encoding="utf-8", + delimiter=",", + dtype=field_csv_dtypes, + ) + old_date_code = df.DateCode.unique()[0] + arcpy.AddMessage(f"\tOld Date Code: {old_date_code}") + arcpy.AddMessage(f"\tNew Date Code: {dismap_tools.date_code(project_name)}") + df = df.replace(regex=old_date_code, value=dismap_tools.date_code(project_name)) + df.to_csv(path_or_buf=f"{csv_file}", sep=",") + del df, pd, warnings + del old_date_code + arcpy.AddMessage(f"\tCompleted updating CSV file: {os.path.basename(csv_file)}") + # Declared Variables + del field_csv_dtypes, table_name, csv_data_folder + # Imports + del dismap_tools + # Function parameters + del csv_file, project_name + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError(f"Traceback:\n{traceback.format_exc()}") + except SystemExit: + # This is not an error, so we allow the script to exit. + raise + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError(f"Traceback:\n{traceback.format_exc()}") + else: + arcpy.AddMessage("\nScript finished successfully.") + return True + finally: + pass + #arcpy.AddMessage(f"\n{'--End' * 10}--") + + +def _create_csv_metadata_template(template_path): + """ + Creates a basic XML metadata template file for CSV data. + """ + try: + if not os.path.exists(os.path.dirname(template_path)): + os.makedirs(os.path.dirname(template_path)) + os.makedirs(os.path.dirname(template_path), exist_ok=True) + + current_datetime = datetime.datetime.now() # Use datetime.datetime + crea_date = current_datetime.strftime("%Y%m%d") + crea_time = current_datetime.strftime("%H%M%S") + "00" + + template_content = f""" + + + {crea_date} + {crea_time} + 1.0 + TRUE + + + + CSV Data Table + + This is a generic metadata template for CSV data tables used in the DisMAP project. + This template provides a basic structure for metadata associated with CSV files, ensuring consistency and discoverability within the DisMAP project. + NMFS Office of Science and Technology + + + ***No Warranty*** The user assumes the entire risk related to its use of these data. NMFS is providing these data "as is" and NMFS disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose. No warranty expressed or implied is made regarding the accuracy or utility of the data on any other system or for a particular purpose. No warranty expressed or implied is made regarding the accuracy or utility of the data on any other system or for general or scientific purposes, nor shall the act of distribution constitute any such warranty. It is strongly recommended that careful attention be paid to the contents of the metadata file associated with these data to evaluate dataset limitations, restrictions or intended use. In no event will NMFS be liable to you or to any third party for any direct, indirect, incidental, consequential, special or exemplary damages or lost profit resulting from any use or misuse of these data. + + + +""" + + with open(template_path, "w", encoding="utf-8") as f: + f.write(template_content) + arcpy.AddMessage(f"Created missing CSV metadata template: {os.path.basename(template_path)}") + except Exception as e: + arcpy.AddError(f"Error creating CSV metadata template: {e}") + traceback.print_exc() # Added traceback for debugging + raise + + + +def script_tool(project_gdb=""): + """Script code goes below""" + try: + from io import StringIO + from time import gmtime, localtime, strftime, time + + import dismap_tools + from arcpy import metadata as md + from lxml import etree + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage(f"{'-' * 80}\n") + # Imports + # from dev_import_datasets_species_filter_csv_data import worker + # Set basic arcpy.env variables + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + project_folder = rf"{os.path.dirname(project_gdb)}" + project_name = rf"{os.path.basename(project_folder)}" + + #print(project_name) + + #print(dismap_tools.date_code(project_name)) + #project_gdb = rf"{project_folder}\{project_name}.gdb" + home_folder = rf"{os.path.dirname(project_folder)}" + metadata_template_folder = rf"{project_folder}\Layers\metadata_templates" + csv_data_folder = rf"{project_folder}\CSV_Data" + datasets_csv = rf"{csv_data_folder}\Datasets.csv" + species_filter_csv = rf"{csv_data_folder}\Species_Filter.csv" + survey_metadata_csv = rf"{csv_data_folder}\DisMAP_Survey_Info.csv" + SpeciesPersistenceIndicatorTrend = ( + rf"{csv_data_folder}\SpeciesPersistenceIndicatorTrend.csv" + ) + SpeciesPersistenceIndicatorPercentileBin = ( + rf"{csv_data_folder}\SpeciesPersistenceIndicatorPercentileBin.csv" + ) + arcpy.management.Copy( + rf"{home_folder}\Initial-Data\Datasets_{dismap_tools.date_code(project_name)}.csv", + datasets_csv, + ) + arcpy.management.Copy( + rf"{home_folder}\Initial-Data\Species_Filter_{dismap_tools.date_code(project_name)}.csv", + species_filter_csv, + ) + arcpy.management.Copy( + rf"{home_folder}\Initial-Data\DisMAP_Survey_Info_{dismap_tools.date_code(project_name)}.csv", + survey_metadata_csv, + ) + arcpy.management.Copy( + rf"{home_folder}\Initial-Data\SpeciesPersistenceIndicatorTrend_{dismap_tools.date_code(project_name)}.csv", + SpeciesPersistenceIndicatorTrend, + ) + arcpy.management.Copy( + rf"{home_folder}\Initial-Data\SpeciesPersistenceIndicatorPercentileBin_{dismap_tools.date_code(project_name)}.csv", + SpeciesPersistenceIndicatorPercentileBin, + ) + import json + + if not os.path.exists(metadata_template_folder): + os.makedirs(metadata_template_folder) + + template_xml_path = os.path.join( + metadata_template_folder, "csv_metadata_template.xml" + ) + + if not os.path.exists(template_xml_path): + _create_csv_metadata_template(template_xml_path) + + json_path = rf"{csv_data_folder}\root_dict.json" + with open(json_path, "r", encoding='utf-8') as json_file: + root_dict = json.load(json_file) + del json_file + del json_path + del json + + datasets = [ + datasets_csv, + species_filter_csv, + survey_metadata_csv, + SpeciesPersistenceIndicatorTrend, + SpeciesPersistenceIndicatorPercentileBin, + ] + for dataset in datasets: + arcpy.AddMessage(rf"Metadata for: {os.path.basename(dataset)}") + dataset_md = md.Metadata(dataset) + dataset_md.synchronize("ALWAYS") + # Start with a clean slate and import the full template + dataset_md.copy(md.Metadata()) + dataset_md.save() + dataset_md.importMetadata(template_xml_path, "ARCGIS_METADATA") + dataset_md.save() # Save after import + dataset_md.synchronize("ALWAYS") + dataset_md.save() + target_tree = etree.parse( + StringIO(dataset_md.xml), + parser=etree.XMLParser(encoding="UTF-8", remove_blank_text=True), + ) + target_root = target_tree.getroot() + target_root[:] = sorted( + target_root, key=lambda x: root_dict.get(x.tag, 99) + ) # Sort elements based on root_dict + + # Customize Title + title = os.path.basename(dataset).replace(".csv", "").replace("_", " ") + resTitle = target_root.find("./dataIdInfo/idCitation/resTitle") + if resTitle is not None: + resTitle.text = title + + etree.indent(target_root, space=" ") + dataset_md.xml = etree.tostring( + target_tree, + encoding="UTF-8", + method="xml", # Specify method for consistency + xml_declaration=True, + pretty_print=True, + ) + dataset_md.save() + dataset_md.synchronize("ALWAYS") + dataset_md.save() + # arcpy.AddMessage(dataset_md.xml) + del dataset_md, title, resTitle + del dataset, target_tree, target_root + del datasets + del csv_data_folder, metadata_template_folder + # + UpdateDatecode = True + if UpdateDatecode: + # Update DateCode + # arcpy.AddMessage(datasets_csv) + arcpy.AddMessage(project_name) + update_datecode(csv_file=datasets_csv, project_name=project_name) + del UpdateDatecode + # + DatasetsCSVFile = True + if DatasetsCSVFile: + worker(project_gdb=project_gdb, csv_file=datasets_csv) + del DatasetsCSVFile + # + SpeciesFilterCSVFile = True + if SpeciesFilterCSVFile: + worker(project_gdb=project_gdb, csv_file=species_filter_csv) + del SpeciesFilterCSVFile + # + DisMAPSurveyInfoFile = True + if DisMAPSurveyInfoFile: + worker(project_gdb=project_gdb, csv_file=survey_metadata_csv) + del DisMAPSurveyInfoFile + # + SpeciesPersistenceIndicatorPercentileBinFile = True + if SpeciesPersistenceIndicatorPercentileBinFile: + worker( + project_gdb=project_gdb, + csv_file=SpeciesPersistenceIndicatorPercentileBin, + ) + del SpeciesPersistenceIndicatorPercentileBinFile + # + SpeciesPersistenceIndicatorTrendFile = False + if SpeciesPersistenceIndicatorTrendFile: + worker(project_gdb=project_gdb, csv_file=SpeciesPersistenceIndicatorTrend) + del SpeciesPersistenceIndicatorTrendFile + # # # # # # + # Declared Varaiables + del SpeciesPersistenceIndicatorPercentileBin, SpeciesPersistenceIndicatorTrend + del ( + datasets_csv, + species_filter_csv, + survey_metadata_csv, + home_folder, + project_name, + ) + # Declared Variables + #del contacts, target_tree, target_root, new_item_name, root_dict + # Imports + del etree, md, StringIO, dismap_tools + # Function Parameters + del project_folder + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + arcpy.AddMessage(f"\n{'-' * 80}") + arcpy.AddMessage( + f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}" + ) + arcpy.AddMessage( + "Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) + ) + arcpy.AddMessage(f"{'-' * 80}") + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + # Compact GDB + # arcpy.AddMessage(f"\nCompacting: {os.path.basename(project_gdb)}" ) + arcpy.management.Compact(project_gdb) + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError(f"Traceback:\n{traceback.format_exc()}") + except SystemExit: + # This is not an error, so we allow the script to exit. + raise + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError(f"Traceback:\n{traceback.format_exc()}") + else: + arcpy.AddMessage("\nScript finished successfully.") + return True + finally: + arcpy.AddMessage(f"\n{'--End' * 10}--") + + +if __name__ == "__main__": + try: + + project_gdb = arcpy.GetParameterAsText(0) + if not project_gdb: + project_name = "August-1-2025" + project_gdb = os.path.join( + os.path.expanduser("~"), + f"Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\{project_name}\\{project_name}.gdb", + ) + del project_name + else: + pass + + script_tool(project_gdb) + arcpy.SetParameterAsText(1, "Result") + + except SystemExit: + pass + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + except Exception: + traceback.print_exc() + + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/inport_to_arcgis_lxml.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/inport_to_arcgis_lxml.py new file mode 100644 index 0000000..f77c230 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/inport_to_arcgis_lxml.py @@ -0,0 +1,139 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +================================================================================ +NOAA Fisheries - Office of Science and Technology (OST) +Project: Distribution Mapping and Analysis Portal (DisMAP) +Script: inport_to_arcgis_lxml.py +Purpose: Translates standalone InPort XML catalog items back into + ISO 19139-compliant ArcGIS Metadata records using lxml (No ArcPy). + +Compliance Notice: +This script has been generated and/or updated with the assistance of automated +tools in accordance with NOAA Administrative Order (NAO) 216-128. In line with +NOAA Scientific Integrity policies (NAO 202-735D.3), all logical pathways, +lxml tree manipulations, and documentation descriptions have been manually +reviewed, validated, and verified by a human analyst to ensure absolute code +transparency and algorithmic reliability. +================================================================================ +""" + +import os +import sys + +# Core open-source library fallback for handling XML parsing and transformations +try: + from lxml import etree +except ImportError: + print("[CRITICAL ERROR] The 'lxml' library is required to run this script.") + print("Please install it using: pip install lxml") + sys.exit(1) + + +def transform_xml_pure_python(inport_xml_path, xsl_stylesheet_path, output_xml_path): + """ + Executes an XSLT transformation on an InPort XML document to generate an + ArcGIS-compatible metadata record without using any Esri ArcPy modules. + + Parameters: + ----------- + inport_xml_path : str + System path to the source InPort XML export. + xsl_stylesheet_path : str + System path to the InPort2ArcGIS.xsl mapping file. + output_xml_path : str + System path where the converted output XML will be saved. + + Returns: + -------- + bool + Returns True if the transformation executes and saves successfully. + """ + print("=====================================================================") + print(" NOAA DisMAP: Open-Source Schema Transformation Pipeline (lxml)") + print("=====================================================================") + + # ------------------------------------------------------------------------- + # 1. Verification of Files + # ------------------------------------------------------------------------- + if not os.path.exists(inport_xml_path): + print(f"[ERROR] Source file missing: {inport_xml_path}") + return False + if not os.path.exists(xsl_stylesheet_path): + print(f"[ERROR] Stylesheet file missing: {xsl_stylesheet_path}") + return False + + try: + # ------------------------------------------------------------------------- + # 2. Parse Source XML and XSL Stylesheet + # ------------------------------------------------------------------------- + print(f"[STATUS] Parsing source InPort document node structures...") + inport_dom = etree.parse(inport_xml_path) + + print(f"[STATUS] Compiling XSLT translation logic sheets...") + xslt_root = etree.parse(xsl_stylesheet_path) + transform_engine = etree.XSLT(xslt_root) + + # ------------------------------------------------------------------------- + # 3. Execute Transformation Tree Build + # ------------------------------------------------------------------------- + print(f"[STATUS] Running schema transformation tree conversions...") + transformed_dom = transform_engine(inport_dom) + + # ------------------------------------------------------------------------- + # 4. Serialize and Output Resulting Node Document + # ------------------------------------------------------------------------- + print(f"[STATUS] Serializing transformed tree to file architecture...") + with open(output_xml_path, 'wb') as output_file: + # Writing out with pretty_print and XML declaration preservation + output_file.write( + etree.tostring( + transformed_dom, + pretty_print=True, + xml_declaration=True, + encoding="UTF-8" + ) + ) + + if os.path.exists(output_xml_path): + print(f"[SUCCESS] Target ArcGIS-compatible file has been compiled.") + print(f"--> File Path: {output_xml_path}") + print("=====================================================================\n") + return True + else: + print("[ERROR] Processing completed, but file write task failed.") + return False + + except etree.XMLSyntaxError as xml_err: + print(f"[XML SYNTAX ERROR] Failed to parse documents: {str(xml_err)}") + return False + except etree.XSLTApplyError as xslt_err: + print(f"[XSLT COMPILATION ERROR] Application failed: {str(xslt_err)}") + return False + except Exception as general_err: + print(f"[PIPELINE BLOCK ERROR] Critical system failure: {str(general_err)}") + return False + + +if __name__ == "__main__": + # ------------------------------------------------------------------------- + # Environmental Working Context Parameters + # ------------------------------------------------------------------------- + # Define primary regional directory configurations + WORKING_DIRECTORY = r"C:\DataSci\DisMAP_Project" + + # Establish document pathways + # INPORT_SOURCE_FILE = os.path.join(WORKING_DIRECTORY, "_inport_79319.xml") + # REVERSE_XSLT_SHEET = os.path.join(WORKING_DIRECTORY, "InPort2ArcGIS.xsl") + # ARCGIS_OUTPUT_FILE = os.path.join(WORKING_DIRECTORY, "DisMAP_ArcGIS_ImportReady.xml") + + INPORT_SOURCE_FILE = r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\February-1-2026\Metadata_Export\_inport_79319.xml" + REVERSE_XSLT_SHEET = r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\Initial-Data\InPort2ArcGIS.xsl" + ARCGIS_OUTPUT_FILE = r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\February-1-2026\Metadata_Export\_inport_79319_ImportReady.xml" + + # Run the open-source pipeline engine + transform_xml_pure_python( + inport_xml_path=INPORT_SOURCE_FILE, + xsl_stylesheet_path=REVERSE_XSLT_SHEET, + output_xml_path=ARCGIS_OUTPUT_FILE + ) \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/iso_tc211.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/iso_tc211.py new file mode 100644 index 0000000..9152c39 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/iso_tc211.py @@ -0,0 +1,77 @@ +"""NOAA ISO 19115-2 to ISO 19115-3 Pipeline. + +Downloads legacy ISO 19139/19115-2 XML streams and utilizes official +ISO/TC 211 XSLT matrices via lxml to upgrade the namespaces and structure. +""" + +import os +import sys +import requests +from lxml import etree + + +def convert_to_iso_19115_3( + iso_url: str, tc211_xslt_path: str, output_xml_path: str +) -> None: + """Extracts 19115-2 stream and transforms it to 19115-3 via local TC211 XSLT.""" + + # Ensure target output directory exists before serialization + output_dir = os.path.dirname(output_xml_path) + if not os.path.exists(output_dir): + os.makedirs(output_dir) + + print("📡 Extracting ISO 19115-2 (19139) stream from NOAA WAF...") + try: + response = requests.get( + iso_url, headers={"User-Agent": "Mozilla/5.0"}, timeout=30 + ) + response.raise_for_status() + raw_xml_content = response.content + except requests.RequestException as req_err: + print(f"❌ Network transfer failed: {req_err}") + sys.exit(1) + + print("⚙️ Executing official ISO/TC 211 upgrade matrix...") + try: + # Load the raw 19115-2 bytes directly into memory + source_tree = etree.fromstring(raw_xml_content) + + # Parse the local TC211 stylesheet (this handles all local xsl:includes natively) + xslt_tree = etree.parse(tc211_xslt_path) + transform_engine = etree.XSLT(xslt_tree) + + # Execute transformation to 19115-3 + output_tree = transform_engine(source_tree) + + # Write output to disk + with open(output_xml_path, "wb") as out_f: + out_f.write( + etree.tostring( + output_tree, pretty_print=True, encoding="UTF-8", xml_declaration=True + ) + ) + + print(f"🏆 ISO 19115-3 Conversion Complete: {output_xml_path}") + + except etree.LxmlError as xml_err: + print(f"❌ XML Parsing or XSLT Compilation engine failure: {xml_err}") + except Exception as runtime_err: + print(f"❌ Transformation execution rejected: {runtime_err}") + + +if __name__ == "__main__": + # The NOAA WAF endpoint containing the actual ISO 19115-2 schema + NOAA_ISO_19115_2_URL = "https://www.fisheries.noaa.gov/inportserve/waf/noaa/nmfs/ost/iso19115/xml/79319.xml" + + # Path to your locally cloned ISO-TC211 repository crosswalk + # Update this path to match the exact filename in your cloned /XML/ repo + TC211_XSLT_MATRIX = r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\Scripts\dismap_tools\XML\19115\-3\mmi\1.0\19115-2_to_19115-3.xsl" + + # Final AI-Ready Export Path + FINAL_19115_3_EXPORT = r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\February-1-2026\Metadata_Export\DisMAP_79319_ISO19115-3.xml" + + if not os.path.exists(TC211_XSLT_MATRIX): + print(f"❌ Error: ISO TC211 XSLT not found at: {TC211_XSLT_MATRIX}") + print("Please ensure you have cloned the ISO-TC211 XML GitHub repository.") + else: + convert_to_iso_19115_3(NOAA_ISO_19115_2_URL, TC211_XSLT_MATRIX, FINAL_19115_3_EXPORT) \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/publish_to_portal_director.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/publish_to_portal_director.py new file mode 100644 index 0000000..7c86aa8 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/publish_to_portal_director.py @@ -0,0 +1,1375 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: module1 +# Purpose: +# +# Author: john.f.kennedy +# +# Created: 03/03/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import os +import sys +import traceback +import inspect +import arcpy + + +def feature_sharing_draft_report(sd_draft=""): + try: + import xml.dom.minidom as DOM + + docs = DOM.parse(sd_draft) + key_list = docs.getElementsByTagName("Key") + value_list = docs.getElementsByTagName("Value") + + for i in range(key_list.length): + value = ( + f"Value: {value_list[i].firstChild.nodeValue}" + if value_list[i].firstChild + else "Value is missing" + ) + + arcpy.AddMessage(f"\t\tKey: {key_list[i].firstChild.nodeValue:<45} {value}") + # arcpy.AddMessage(f"\t\tKey: {key_list[i].firstChild.nodeValue:<45} {value[:50]}") + del i, value + + del DOM, key_list, value_list, docs + del sd_draft + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:") + traceback.print_exc() + + +def create_feature_class_layers(project_folder=""): + try: + # Import + from arcpy import metadata as md + from dismap_tools import dataset_title_dict + + # Set varaibales + project_gdb = os.path.join(project_folder, os.path.basename(project_folder) + ".gdb") + project_name = os.path.basename(project_folder) + csv_data_folder = os.path.join(project_folder, "CSV_Data") + scratch_folder = os.path.join(project_folder, "Scratch") + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + + # Set basic workkpace variables + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + aprx = arcpy.mp.ArcGISProject(rf"{project_folder}\{project_name}.aprx") + + del scratch_folder, scratch_workspace + + arcpy.AddMessage("Loading the Dataset Title Dictionary. Please wait") + + datasets_dict = dataset_title_dict(project_gdb) + + datasets = [] + + # datasets.extend(arcpy.ListFeatureClasses("AI_IDW_Sample_Locations")) +## datasets.extend(arcpy.ListFeatureClasses("*Sample_Locations")) +## datasets.extend(arcpy.ListFeatureClasses("DisMAP_Regions")) +## datasets.extend(arcpy.ListTables("Indicators")) + datasets.extend(arcpy.ListTables("Species_Filter")) +## datasets.extend(arcpy.ListTables("DisMAP_Survey_Info")) +## datasets.extend(arcpy.ListTables("SpeciesPersistenceIndicatorPercentileBin")) +## datasets.extend(arcpy.ListTables("SpeciesPersistenceIndicatorTrend")) +## datasets.extend(arcpy.ListTables("SpatialGroup_SpeciesPersistenceIndicator")) + + for dataset in sorted(datasets): + + feature_service_title = datasets_dict[dataset]["Dataset Service Title"] + + arcpy.AddMessage(f"Dataset: {dataset}") + arcpy.AddMessage(f"\tTitle: {feature_service_title}") + + desc = arcpy.da.Describe(dataset) + + feature_class_path = rf"{project_gdb}\{dataset}" + + if desc["dataType"] == "FeatureClass": + + arcpy.AddMessage("\tMake Feature Layer") + feature_class_layer = arcpy.management.MakeFeatureLayer(feature_class_path, feature_service_title) + + feature_class_layer_file = (rf"{project_folder}\Layers\{feature_class_layer}.lyrx") + + arcpy.AddMessage("\tSave Layer File") + _result = arcpy.management.SaveToLayerFile(in_layer = feature_class_layer, out_layer = feature_class_layer_file, is_relative_path = "RELATIVE", version="CURRENT",) + del _result + + arcpy.management.Delete(feature_class_layer) + del feature_class_layer + + elif desc["dataType"] == "Table": + + arcpy.AddMessage("\tMake Table View") + table_view_layer = arcpy.management.MakeTableView(in_table=feature_class_path, out_view=feature_service_title,) + table_view_layer_file = rf"{project_folder}\Layers\{table_view_layer}.lyrx" + + arcpy.AddMessage("\tSave Layer File") + arcpy.management.SaveToLayerFile(in_layer = table_view_layer, out_layer = table_view_layer_file, is_relative_path = "RELATIVE", version = "CURRENT",) + + arcpy.management.Delete(table_view_layer) + del table_view_layer + + layer_file = arcpy.mp.LayerFile(table_view_layer_file) + + table_md = md.Metadata(layer_file.listTables(feature_service_title)[0].dataSource) + + print("*" * 80) + + #print(layer_file.listLayers()) + #print(layer_file.listTables()) + + layer_file.metadata.copy(table_md) + layer_file.metadata.save() + + print(layer_file.metadata.title) + #print(layer_file.metadata.thumbnailUri) + + + print("*" * 80) + + del table_md + + + elif desc["dataType"] == "RasterDataset": + arcpy.AddMessage("\tRaster Dataset") + + + elif desc["dataType"] == "MosaicDataset": + arcpy.AddMessage("\tMosaic Dataset") + + else: + pass + + # Test if time field exists + if [f.name for f in arcpy.ListFields(feature_class_path) if f.name == "StdTime"]: + arcpy.AddMessage("\tSet Time Enabled if time field is in dataset") + # Get time information from a layer in a layer file + layer_file = arcpy.mp.LayerFile(feature_class_layer_file) + layer = layer_file.listLayers()[0] + layer.enableTime("StdTime", "StdTime", True) + layer.time.timeZone = arcpy.mp.ListTimeZones("(UTC) Coordinated Universal Time")[0] + layer_file.save() + del layer + + for layer in layer_file.listLayers(): + if layer.supports("TIME"): + if layer.isTimeEnabled: + lyrTime = layer.time + startTime = lyrTime.startTime + endTime = lyrTime.endTime + timeDelta = endTime - startTime + startTimeField = lyrTime.startTimeField + endTimeField = lyrTime.endTimeField + arcpy.AddMessage(f"\tLayer: {layer.name}") + arcpy.AddMessage(f"\t\tStart Time Field: {startTimeField}") + arcpy.AddMessage(f"\t\tEnd Time Field: {endTimeField}") + arcpy.AddMessage( + f"\t\tStart Time: {str(startTime.strftime('%m-%d-%Y'))}" + ) + arcpy.AddMessage( + f"\t\tEnd Time: {str(endTime.strftime('%m-%d-%Y'))}" + ) + arcpy.AddMessage( + f"\t\tTime Extent: {str(timeDelta.days)} days" + ) + arcpy.AddMessage( + f"\t\tTime Zone: {str(layer.time.timeZone)}" + ) + del lyrTime, startTime, endTime, timeDelta + del startTimeField, endTimeField + else: + arcpy.AddMessage( + "No time properties have been set on the layer" + ) + else: + arcpy.AddMessage("Time is not supported on this layer") + del layer + del layer_file + else: + arcpy.AddMessage("\tDataset does not have a time field") + + +## # aprx.listBasemaps() to get a list of available basemaps +## # +## # ['Charted Territory Map', +## # 'Colored Pencil Map', +## # 'Community Map', +## # 'Dark Gray Canvas', +## # 'Firefly Imagery Hybrid', +## # 'GEBCO Basemap (NOAA NCEI Visualization)', +## # 'GEBCO Basemap/Contours (NOAA NCEI Visualization)', +## # 'GEBCO Gray Basemap (NOAA NCEI Visualization)', +## # 'GEBCO Gray Basemap/Contours (NOAA NCEI Visualization)', +## # 'Human Geography Dark Map', +## # 'Human Geography Map', +## # 'Imagery', +## # 'Imagery Hybrid', +## # 'Light Gray Canvas', +## # 'Mid-Century Map', +## # 'Modern Antique Map', +## # 'National Geographic Style Map', +## # 'Navigation', +## # 'Navigation (Dark)', +## # 'Newspaper Map', +## # 'NOAA Charts', +## # 'NOAA ENC® Charts', +## # 'Nova Map', +## # 'Oceans', +## # 'OpenStreetMap', +## # 'Streets', +## # 'Streets (Night)', +## # 'Terrain with Labels', +## # 'Topographic'] +## +## if aprx.listMaps(feature_service_title): +## aprx.deleteItem(aprx.listMaps(feature_service_title)[0]) +## aprx.save() +## else: +## pass +## +## arcpy.AddMessage(f"\tCreating Map: {feature_service_title}") +## aprx.createMap(f"{feature_service_title}", "Map") +## aprx.save() +## +## current_map = aprx.listMaps(feature_service_title)[0] +## +## basemap = "Terrain with Labels" +## current_map.addLayer(layer_file) +## current_map.addBasemap(basemap) +## aprx.save() +## del basemap +## +## arcpy.AddMessage("\t\tCreate map thumbnail and update metadata") +## current_map_view = current_map.defaultView +## current_map_view.exportToPNG( +## rf"{project_folder}\Layers\{feature_service_title}.png", +## width=288, +## height=192, +## resolution=96, +## color_mode="24-BIT_TRUE_COLOR", +## embed_color_profile=True, +## ) +## del current_map_view +## +## fc_md = md.Metadata(feature_class_path) +## #fc_md.title = feature_service_title +## print("*" * 50) +## print(fc_md.title) +## print("*" * 50) +## if not fc_md.thumbnailUri: +## fc_md.thumbnailUri = rf"{project_folder}\Layers\{feature_service_title}.png" +## else: +## pass +## fc_md.save() +## fc_md.reload() +## fc_md.saveAsXML( +## rf"{project_folder}\Metadata_Export\{feature_service_title}.xml" +## ) +## del fc_md +## +## # parse_xml_file_format_and_save( +## # csv_data_folder=csv_data_folder, +## # xml_file=rf"{project_folder}\Metadata_Export\{feature_service_title}.xml", +## # sort=True, +## # ) +## # parse_xml_file_format_and_save(csv_data_folder=csv_data_folder, xml_file="", sort=True) +## +## in_md = md.Metadata(feature_class_path) +## layer_file.metadata.copy(in_md) +## layer_file.metadata.save() +## layer_file.save() +## current_map.metadata.copy(in_md) +## current_map.metadata.save() +## aprx.save() +## del in_md +## +## arcpy.AddMessage(f"\t\tLayer File Path: {layer_file.filePath}") +## arcpy.AddMessage(f"\t\tLayer File Version: {layer_file.version}") +## arcpy.AddMessage("\t\tLayer File Metadata:") +## arcpy.AddMessage( +## f"\t\t\tLayer File Title: {layer_file.metadata.title}" +## ) +## # arcpy.AddMessage(f"\t\t\tLayer File Tags: {layer_file.metadata.tags}") +## # arcpy.AddMessage(f"\t\t\tLayer File Summary: {layer_file.metadata.summary}") +## # arcpy.AddMessage(f"\t\t\tLayer File Description: {layer_file.metadata.description}") +## # arcpy.AddMessage(f"\t\t\tLayer File Credits: {layer_file.metadata.credits}") +## # arcpy.AddMessage(f"\t\t\tLayer File Access Constraints: {layer_file.metadata.accessConstraints}") +## +## arcpy.AddMessage("\t\tList of layers or tables in Layer File:") +## if current_map.listLayers(feature_service_title): +## layer = current_map.listLayers(feature_service_title)[0] +## elif current_map.listTables(feature_service_title): +## layer = current_map.listTables(feature_service_title)[0] +## else: +## arcpy.AddWarning("Something wrong") +## +## in_md = md.Metadata(feature_class_path) +## layer.metadata.copy(in_md) +## layer.metadata.save() +## layer_file.save() +## aprx.save() +## del in_md +## +## arcpy.AddMessage(f"\t\t\tLayer Name: {layer.name}") +## arcpy.AddMessage("\t\t\tLayer Metadata:") +## arcpy.AddMessage( +## f"\t\t\t\tLayer Title: {layer.metadata.title}" +## ) +## # arcpy.AddMessage(f"\t\t\t\tLayer Tags: {layer.metadata.tags}") +## # arcpy.AddMessage(f"\t\t\t\tLayer Summary: {layer.metadata.summary}") +## # arcpy.AddMessage(f"\t\t\t\tLayer Description: {layer.metadata.description}") +## # arcpy.AddMessage(f"\t\t\t\tLayer Credits: {layer.metadata.credits}") +## # arcpy.AddMessage(f"\t\t\t\tLayer Access Constraints: {layer.metadata.accessConstraints}") +## del layer +## del layer_file +## del feature_class_layer_file +## del feature_class_path +## +## aprx.deleteItem(current_map) +## del current_map +## aprx.save() +## +## # del dataset_code, point_feature_type, feature_class_name, region, season +## # del date_code, distribution_project_code +## # del feature_class_path +## +## del desc +## del feature_service_title +## del dataset + + del datasets_dict + del datasets + + # Declared Variables set in function + del aprx + del csv_data_folder, project_folder, project_name + + # Imports + del dataset_title_dict, md + + # Function Parameters + del project_gdb + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:") + traceback.print_exc() + + +def create_feature_class_services(project_folder=""): + try: + # Import + from lxml import etree + from arcpy import metadata as md + from dismap_tools import dataset_title_dict + + # Set basic workkpace variables + project_name = os.path.basename(project_folder) + project_gdb = os.path.join(project_folder, f"{project_name}.gdb") + csv_data_folder = os.path.join(project_folder, "CSV_Data") + scratch_folder = os.path.join(project_folder, "Scratch") + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + + # Set basic workkpace variables + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + aprx = arcpy.mp.ArcGISProject(rf"{project_folder}\{project_name}.aprx") + + del scratch_folder, scratch_workspace + + arcpy.AddMessage("Loading the Dataset Title Dictionary. Please wait") + datasets_dict = dataset_title_dict(project_gdb) + + datasets = [] + +## # datasets.extend(arcpy.ListFeatureClasses("AI_IDW_Sample_Locations")) +## datasets.extend(arcpy.ListFeatureClasses("*Sample_Locations")) +## datasets.extend(arcpy.ListFeatureClasses("DisMAP_Regions")) +## datasets.extend(arcpy.ListTables("Indicators")) + datasets.extend(arcpy.ListTables("Species_Filter")) +## datasets.extend(arcpy.ListTables("DisMAP_Survey_Info")) +## datasets.extend(arcpy.ListTables("SpeciesPersistenceIndicatorPercentileBin")) +## datasets.extend(arcpy.ListTables("SpeciesPersistenceIndicatorTrend")) +## datasets.extend(arcpy.ListTables("SpatialGroup_SpeciesPersistenceIndicator")) + + for dataset in sorted(datasets): + + feature_service = datasets_dict[dataset]["Dataset Service"] + feature_service_title = datasets_dict[dataset]["Dataset Service Title"] + + arcpy.AddMessage(f"Dataset: {dataset}") + arcpy.AddMessage(f"\tFS: {feature_service}") + arcpy.AddMessage(f"\tFST: {feature_service_title}") + + feature_class_layer_file = os.path.join(project_folder, f"Layers\\{feature_service_title}.lyrx") + + layer_file = arcpy.mp.LayerFile(feature_class_layer_file) + + # Loop through layers inside the layer file (usually contains one main layer) + for lyr in layer_file.listLayers(): + if lyr.isFeatureLayer or lyr.isRasterLayer: + # Access the CIM definition (Use 'V3' for ArcGIS Pro 3.x) + lyr_cim = lyr.getDefinition('V3') + + # Explicitly assign the static unique ID + new_id = 0 + #lyr_cim.serviceLayerID = new_id + lyr_cim.serviceLayerID = new_id + + # Push the modified CIM back to the layer + lyr.setDefinition(lyr_cim) + + print(f"Assigned ID {new_id} to layer: {lyr.name}") + + # Save the modifications back to the file + layer_file.save() + + del feature_class_layer_file + + # aprx.listBasemaps() to get a list of available basemaps + # + # ['Charted Territory Map', + # 'Colored Pencil Map', + # 'Community Map', + # 'Dark Gray Canvas', + # 'Firefly Imagery Hybrid', + # 'GEBCO Basemap (NOAA NCEI Visualization)', + # 'GEBCO Basemap/Contours (NOAA NCEI Visualization)', + # 'GEBCO Gray Basemap (NOAA NCEI Visualization)', + # 'GEBCO Gray Basemap/Contours (NOAA NCEI Visualization)', + # 'Human Geography Dark Map', + # 'Human Geography Map', + # 'Imagery', + # 'Imagery Hybrid', + # 'Light Gray Canvas', + # 'Mid-Century Map', + # 'Modern Antique Map', + # 'National Geographic Style Map', + # 'Navigation', + # 'Navigation (Dark)', + # 'Newspaper Map', + # 'NOAA Charts', + # 'NOAA ENC® Charts', + # 'Nova Map', + # 'Oceans', + # 'OpenStreetMap', + # 'Streets', + # 'Streets (Night)', + # 'Terrain with Labels', + # 'Topographic'] + + if aprx.listMaps(feature_service_title): + aprx.deleteItem(aprx.listMaps(feature_service_title)[0]) + aprx.save() + else: + pass + + arcpy.AddMessage(f"\tCreating Map: {feature_service_title}") + aprx.createMap(feature_service_title, "Map") + aprx.save() + + current_map = aprx.listMaps(feature_service_title)[0] + + map_cim = current_map.getDefinition('V3') + map_cim.useServiceLayerIDs = True + current_map.setDefinition(map_cim) + + current_map.addLayer(layer_file) + + aprx.save() + + del layer_file + + arcpy.AddMessage("\t\tList of layers or tables in Layer File:") + if current_map.listLayers(feature_service_title): + lyr = current_map.listLayers(feature_service_title)[0] + + elif current_map.listTables(feature_service_title): + lyr = current_map.listTables(feature_service_title)[0] + + else: + arcpy.AddWarning("Something wrong") + + lyr_md = md.Metadata(lyr) + print(lyr.dataSource) + print(lyr_md.title) + #lyr.metadata.copy(in_md) + #lyr.metadata.save() + #aprx.save() + current_map_md = md.Metadata(current_map) + current_map_md.copy(lyr_md) + current_map_md.save() + aprx.save() + + del current_map_md + del lyr_md + + arcpy.AddMessage("\tGet Web Layer Sharing Draft") + # Get Web Layer Sharing Draft + server_type = "HOSTING_SERVER" # FEDERATED_SERVER + # m.getWebLayerSharingDraft (server_type, service_type, service_name, {layers_and_tables}) + # sddraft = m.getWebLayerSharingDraft(server_type, "FEATURE", service_name, [selected_layer, selected_table]) + # https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/featuresharingdraft-class.htm#GUID-8E27A3ED-A705-4ACF-8C7D-AA861327AD26 + sddraft = current_map.getWebLayerSharingDraft( + server_type=server_type, + service_type="FEATURE", + service_name=feature_service, + layers_and_tables=lyr, + ) + del server_type + + sddraft.allowExporting = True + sddraft.allowUpdateWithoutMValues = True # Default + sddraft.approvePublicDataCollection = False + sddraft.checkUniqueIDAssignment = True + # sddraft.credits = lyr.metadata.credits + # sddraft.description = lyr.metadata.description + sddraft.featureCapabilities = "Query,Extract" + sddraft.maxRecordCount = 10000 + sddraft.offline = False + sddraft.offlineTarget = None + sddraft.overwriteExistingService = True + sddraft.portalFolder = f"DisMAP {project_name}" + sddraft.preserveEditUsersAndTimestamps = False # Default + # sddraft.serverType + # sddraft.serviceName + # sddraft.sharing.groups + # sddraft.sharing.sharingLevel + # sddraft.summary = lyr.metadata.summary + # sddraft.tags = lyr.metadata.tags + sddraft.timezone.ID = "UTC" + sddraft.timezone.DaylightSavingTime = True + # sddraft.timezone.preferredTimezoneID + # sddraft.timezone.preferredTimezoneIDDaylightSavingTime + # sddraft.useCIMSymbols + # sddraft.useLimitations = lyr.metadata.accessConstraints + # sddraft.zDefault.enable + # sddraft.zDefault.value + + del lyr + + arcpy.AddMessage(f"\t\tAllow Exporting: {sddraft.allowExporting}") + arcpy.AddMessage(f"\t\tAllow allow Update Without M Values: {sddraft.allowUpdateWithoutMValues}") + arcpy.AddMessage(f"\t\tApprove Public Data Collection: {sddraft.approvePublicDataCollection}") + arcpy.AddMessage(f"\t\tCheck Unique ID Assignment: {sddraft.checkUniqueIDAssignment}") + arcpy.AddMessage(f"\t\tCredits: {sddraft.credits}") + arcpy.AddMessage(f"\t\tDescription: {sddraft.description}") + arcpy.AddMessage(f"\t\tFeature Capabilities: {sddraft.featureCapabilities}") + arcpy.AddMessage(f"\t\tMaxRecordCount: {sddraft.maxRecordCount}") + arcpy.AddMessage(f"\t\tOffline: {sddraft.offline}") + arcpy.AddMessage(f"\t\tOffline Target: {sddraft.offlineTarget}") + arcpy.AddMessage(f"\t\tOverwrite Existing Service: {sddraft.overwriteExistingService}") + arcpy.AddMessage(f"\t\tPortal Folder: {sddraft.portalFolder}") + arcpy.AddMessage(f"\t\tPreserveEditUsersAndTimestamps: {sddraft.preserveEditUsersAndTimestamps}") + arcpy.AddMessage(f"\t\tServer Type: {sddraft.serverType}") + arcpy.AddMessage(f"\t\tService Name: {sddraft.serviceName}") + arcpy.AddMessage(f"\t\tSharing Groups: {sddraft.sharing.groups}") + arcpy.AddMessage(f"\t\tSharing Levek: {sddraft.sharing.sharingLevel}") + arcpy.AddMessage(f"\t\tSummary: {sddraft.summary}") + arcpy.AddMessage(f"\t\tTags: {sddraft.tags}") + arcpy.AddMessage(f"\t\tTimezone ID: {sddraft.timezone.ID}") + arcpy.AddMessage(f"\t\tTimezone Daylight Saving Time: {sddraft.timezone.DaylightSavingTime}") + #arcpy.AddMessage(f"\t\tPreferred Timezone ID: {sddraft.timezone.preferredTimezoneID}") + #arcpy.AddMessage(f"\t\tPreferred Timezone Daylight Saving Time: {sddraft.timezone.preferredTimezoneID}") + arcpy.AddMessage(f"\t\tUse CIM Symbols: {sddraft.useCIMSymbols}") + arcpy.AddMessage(f"\t\tUse Limitations: {sddraft.useLimitations}") + arcpy.AddMessage(f"\t\tZ Default Enable: {sddraft.zDefault.enable}") + arcpy.AddMessage(f"\t\tZ Default Value: {sddraft.zDefault.value}") + + arcpy.AddMessage("\tExport to SD Draft") + # Create Service Definition Draft file + sd_draft = os.path.join(project_folder, f"Publish\\{feature_service}.sddraft") + + sddraft.exportToSDDraft(sd_draft) + + + #tree = etree.parse(r"C:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\June-1-2026\Publish\Species_Filter_20260601.sddraft", parser=parser) + + etree.parse(sd_draft, parser=etree.XMLParser(encoding='UTF-8', remove_blank_text=True)).write(sd_draft, pretty_print=True, xml_declaration=True, encoding="UTF-8") + + del sddraft + +## arcpy.AddMessage("\tModify SD Draft") +## # https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/featuresharingdraft-class.htm +## # https://www.esri.com/arcgis-blog/products/arcgis-pro/mapping/streamline-your-code-with-new-properties-in-arcpy-sharing +## import xml.dom.minidom as DOM +## +## docs = DOM.parse(sd_draft) +## key_list = docs.getElementsByTagName("Key") +## value_list = docs.getElementsByTagName("Value") +## +## for i in range(key_list.length): +## if key_list[i].firstChild.nodeValue == "maxRecordCount": +## arcpy.AddMessage("\t\tUpdating maxRecordCount from 2000 to 10000") +## value_list[i].firstChild.nodeValue = 2000 +## if key_list[i].firstChild.nodeValue == "ServiceTitle": +## arcpy.AddMessage( +## f"\t\tUpdating ServiceTitle from {value_list[i].firstChild.nodeValue} to {feature_service_title}" +## ) +## value_list[i].firstChild.nodeValue = feature_service_title +## # Doesn't work +## # if key_list[i].firstChild.nodeValue == "GeodataServiceName": +## # arcpy.AddMessage(f"\t\tUpdating GeodataServiceName from {value_list[i].firstChild.nodeValue} to {feature_service}") +## # value_list[i].firstChild.nodeValue = feature_service +## del i +## +## # Write to the .sddraft file +## f = open(sd_draft, "w") +## docs.writexml(f) +## f.close() +## del f +## +## del DOM, docs, key_list, value_list + + FeatureSharingDraftReport = False + if FeatureSharingDraftReport: + arcpy.AddMessage(f"\tReport for {os.path.basename(sd_draft)} SD File") + feature_sharing_draft_report(sd_draft) + del FeatureSharingDraftReport + + StageService = False + if StageService: + arcpy.AddMessage(f"\tCreate/Stage {os.path.basename(sd_draft)} SD File") + arcpy.server.StageService( + in_service_definition_draft=sd_draft, + out_service_definition=sd_draft.replace("sddraft", "sd"), + staging_version=5, + ) + del StageService + + UploadServiceDefinition = False + if UploadServiceDefinition: + arcpy.AddMessage( + f"\tUpload {os.path.basename(sd_draft).replace('sddraft', 'sd')} Service Definition" + ) + arcpy.server.UploadServiceDefinition( + in_sd_file=sd_draft.replace("sddraft", "sd"), + in_server = "HOSTING_SERVER", # in_service_name = "", #in_cluster = "", + in_folder_type = "FROM_SERVICE_DEFINITION", # EXISTING #in_folder = "", + in_startupType = "STARTED", + in_override = "OVERRIDE_DEFINITION", + in_my_contents = "NO_SHARE_ONLINE", + in_public = "PRIVATE", + in_organization = "NO_SHARE_ORGANIZATION", # in_groups = "" + ) + + del UploadServiceDefinition + + del sd_draft + + # aprx.deleteItem(current_map) + del current_map + aprx.save() + + del feature_service, feature_service_title + del dataset + del datasets + del datasets_dict + + # TODO: Possibly create a dictionary that can be saved to JSON + + aprx.save() + + current_maps = aprx.listMaps() + + if current_maps: + arcpy.AddMessage("\nCurrent Maps\n") + for current_map in current_maps: + arcpy.AddMessage(f"\tProject Map: {current_map.name}") + del current_map + else: + arcpy.AddWarning("No maps in Project") + + del current_maps + + # Declared Variables set in function for aprx + + # Save aprx one more time and then delete + aprx.save() + del aprx + + # Declared Variables set in function + del project_folder, project_name, csv_data_folder + + # Imports + del dataset_title_dict, md + + # Function Parameters + del project_gdb + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:") + traceback.print_exc() + +##def update_metadata_from_published_md(project_gdb=""): +## try: +## # Import +## import dismap_tools +## +## arcpy.env.overwriteOutput = True +## arcpy.env.parallelProcessingFactor = "100%" +## arcpy.SetLogMetadata(True) +## arcpy.SetSeverityLevel(2) +## arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION +## +## LogInAGOL = False +## if LogInAGOL: +## try: +## portal = "https://noaa.maps.arcgis.com/" +## user = "John.F.Kennedy_noaa" +## +## # Sign in to portal +## #arcpy.SignInToPortal("https://www.arcgis.com", "MyUserName", "MyPassword") +## # For example: 'http://www.arcgis.com/' +## arcpy.SignInToPortal(portal) +## +## arcpy.AddMessage(f"###---> Signed into Portal: {arcpy.GetActivePortalURL()} <---###") +## del portal, user +## except: +## arcpy.AddError(f"###---> Signed into Portal faild <---###") +## del LogInAGOL +## +## aprx = arcpy.mp.ArcGISProject(base_project_file) +## home_folder = aprx.homeFolder +## del aprx +## +## project_gdb = rf"{project_folder}\{project}.gdb" +## +## +## +## # DatasetCode, CSVFile, TransformUnit, TableName, GeographicArea, CellSize, +## # PointFeatureType, FeatureClassName, Region, Season, DateCode, Status, +## # DistributionProjectCode, DistributionProjectName, SummaryProduct, +## # FilterRegion, FilterSubRegion, FeatureServiceName, FeatureServiceTitle, +## # MosaicName, MosaicTitle, ImageServiceName, ImageServiceTitle +## +## # Get values for table_name from Datasets table +## #fields = ["FeatureClassName", "FeatureServiceName", "FeatureServiceTitle"] +## fields = ["DatasetCode", "PointFeatureType", "FeatureClassName", "Region", "Season", "DateCode", "DistributionProjectCode"] +## datasets = [row for row in arcpy.da.SearchCursor(os.path.join(project_gdb, "Datasets"), fields, where_clause = f"FeatureClassName IS NOT NULL AND DistributionProjectCode NOT IN ('GLMME', 'GFDL')")] +## #datasets = [row for row in arcpy.da.SearchCursor(os.path.join(project_gdb, "Datasets"), fields, where_clause = f"FeatureClassName IN ('AI_IDW_Sample_Locations', 'DisMAP_Regions')")] +## del fields +## +## for dataset in datasets: +## dataset_code, point_feature_type, feature_class_name, region_latitude, season, date_code, distribution_project_code = dataset +## +## feature_service_name = f"{dataset_code}_{point_feature_type}_{date_code}".replace("None", "").replace(" ", "_").replace("__", "_") +## +## if distribution_project_code == "IDW": +## feature_service_title = f"{region_latitude} {season} {point_feature_type} {date_code}".replace("None", "").replace(" ", " ") +## #elif distribution_project_code in ["GLMME", "GFDL"]: +## # feature_service_title = f"{region_latitude} {distribution_project_code} {point_feature_type} {date_code}".replace("None", "").replace(" ", " ") +## else: +## feature_service_title = f"{feature_service_name}".replace("_", " ") +## +## map_title = feature_service_title.replace("GRID Points", "").replace("Sample Locations", "").replace(" ", " ") +## +## feature_class_path = f"{project_gdb}\{feature_class_name}" +## +## arcpy.AddMessage(f"Dataset Code: {dataset_code}") +## arcpy.AddMessage(f"\tFeature Service Name: {feature_service_name}") +## arcpy.AddMessage(f"\tFeature Service Title: {feature_service_title}") +## arcpy.AddMessage(f"\tMap Title: {map_title}") +## arcpy.AddMessage(f"\tLayer Title: {feature_service_title}") +## arcpy.AddMessage(f"\tFeature Class Name: {feature_class_name}") +## arcpy.AddMessage(f"\tFeature Class Path: {feature_class_path}") +## +## if arcpy.Exists(rf"{project_folder}\Publish\{feature_service_name}.xml"): +## arcpy.AddMessage(f"\t###--->>> {feature_service_name}.xml Exists <<<---###") +## +## from arcpy import metadata as md +## in_md = md.Metadata(rf"{project_folder}\Publish\{feature_service_name}.xml") +## fc_md = md.Metadata(feature_class_path) +## fc_md.copy(in_md) +## fc_md.save() +## del in_md, fc_md +## del md +## +## else: +## arcpy.AddWarning(f"\t###--->>> {feature_service_name}.xml Does Not Exist <<<---###") +## +## del dataset_code, point_feature_type, feature_class_name, region_latitude, season +## del date_code, distribution_project_code +## +## del feature_service_name, feature_service_title +## del map_title, feature_class_path +## del dataset +## del datasets +## +## arcpy.AddMessage(f"\n{'-' * 90}\n") +## +## # Declared Variables set in function +## del project_gdb +## del home_folder +## +## # Imports +## del dismap +## +## # Function Parameters +## del base_project_file, project +## +## except arcpy.ExecuteWarning: +## arcpy.AddWarning( +## f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" +## ) +## except arcpy.ExecuteError: +## arcpy.AddError( +## f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" +## ) +## arcpy.AddError("Traceback:\n") +## traceback.print_exc() +## except SystemExit: +## # This is not an error, so we allow the script to exit. +## pass +## except Exception as e: +## arcpy.AddError( +## f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" +## ) +## arcpy.AddError("Traceback:") +## traceback.print_exc() + + +def create_image_services(project_gdb=""): + try: + # Import + + # Set History and Metadata logs, set serverity and message level + arcpy.SetLogHistory( + True + ) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History + arcpy.SetLogMetadata(True) + arcpy.SetSeverityLevel( + 1 + ) # 0—A tool will not throw an exception, even if the tool produces an error or warning. + # 1—If a tool produces a warning or an error, it will throw an exception. + # 2—If a tool produces an error, it will throw an exception. This is the default. + arcpy.SetMessageLevels( + ["NORMAL"] + ) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION + + # aprx = arcpy.mp.ArcGISProject(base_project_file) # noqa: F821 + # home_folder = aprx.homeFolder + # project_gdb = rf"{project_folder}\{project}.gdb" # noqa: F821 + + # Set basic workkpace variables + project_folder = os.path.dirname(project_gdb) + crfs_folder = os.path.join(project_folder, "CRFs") + scratch_folder = os.path.join(project_folder, "Scratch") + scratch_workspace = os.path.join(project_folder, "Scratch\\scratch.gdb") + + # Create Scratch Workspace for Project + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + if not arcpy.Exists(scratch_folder): + os.makedirs(scratch_folder) + if not arcpy.Exists(os.path.join(scratch_folder, "scratch.gdb")): + arcpy.management.CreateFileGDB(rf"{scratch_folder}", "scratch") + + # Set basic workkpace variables + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = scratch_workspace + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + del scratch_folder, scratch_workspace + + arcpy.env.workspace = crfs_folder + + for crf in arcpy.ListRasters("*"): + arcpy.AddMessage(crf) + + arcpy.env.workspace = project_gdb + + ## LogIntoPortal = False + ## if LogIntoPortal: + ## try: + ## portal = "https://noaa.maps.arcgis.com/" + ## user = "John.F.Kennedy_noaa" + ## + ## #portal = "https://maps.fisheries.noaa.gov/portal/home" + ## #portal = "https://maps.fisheries.noaa.gov" + ## #user = "John.F.Kennedy_noaa" + ## + ## # Sign in to portal + ## # arcpy.SignInToPortal("https://www.arcgis.com", "MyUserName", "MyPassword") + ## # For example: 'http://www.arcgis.com/' + ## arcpy.SignInToPortal(portal) + ## + ## arcpy.AddMessage(f"###---> Signed into Portal: {arcpy.GetActivePortalURL()} <---###") + ## del portal, user + ## except: # noqa: E722 + ## arcpy.AddError("###---> Signed into Portal faild <---###") + ## sys.exit() + ## del LogIntoPortal + + # Publishes an image service to a machine "myserver" from a folder of ortho images + # this code first author a mosaic dataset from the images, then publish it as an image service. + # A connection to ArcGIS Server must be established in the Catalog window of ArcMap + # before running this script + + # import time + # import arceditor # this is required to create a mosaic dataset from images + + # + # Define local variables: + # ImageSource=r"\\myserver\data\SourceData\Portland" # the folder of input images + # MyWorkspace=r"\\myserver\Data\DemoData\ArcPyPublishing" # the folder for mosaic dataset and the service defintion draft file + # GdbName="fgdb1.gdb" + # GDBpath = os.path.join(MyWorkspace,GdbName) #File geodatabase used to store a mosaic dataset + # Name = "OrthoImages" + # Md = os.path.join(GDBpath, Name) + # Sddraft = os.path.join(MyWorkspace,Name+".sddraft") + # Sd = os.path.join(MyWorkspace,Name+".sd") + # con = os.path.join(MyWorkspace, "arcgis on myserver_6080 (admin).ags") + + con = os.path.join( + os.path.expanduser("~"), + "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis\\image on maps.fisheries.noaa.gov.ags", + ) + + mosiac_name = "SEUS_FAL_Mosaic" + mosiac_path = rf"{project_gdb}\{mosiac_name}" + mosiac_sddraft = rf"{project_folder}\Publish\{mosiac_name}.sddraft" + + # Create service definition draft + + arcpy.AddMessage("Creating SD draft") + # arcpy.CreateImageSDDraft(Md, Sddraft, Name, 'ARCGIS_SERVER', con, False, None, "Ortho Images","ortho images,image service") + arcpy.CreateImageSDDraft( + mosiac_path, + mosiac_sddraft, + mosiac_name, + "ARCGIS_SERVER", + con, + False, + None, + "Biomass Rasters", + "biomass rasters,image service", + ) + + ## # Analyze the service definition draft + ## analysis = arcpy.mapping.AnalyzeForSD(Sddraft) + ## arcpy.AddMessage("The following information was returned during analysis of the image service:") + ## for key in ('messages', 'warnings', 'errors'): + ## arcpy.AddMessage('----' + key.upper() + '---') + ## vars = analysis[key] + ## for ((message, code), layerlist) in vars.iteritems(): + ## arcpy.AddMessage(' ', message, ' (CODE %i)' % code) + ## arcpy.AddMessage(' applies to:'), + ## for layer in layerlist: + ## arcpy.AddMessage(layer.name), + ## arcpy.AddMessage() + ## + ## # Stage and upload the service if the sddraft analysis did not contain errors + ## if analysis['errors'] == {}: + ## try: + ## arcpy.AddMessage("Adding data path to data store to avoid data copy") + ## arcpy.AddDataStoreItem(con, "FOLDER","Images", MyWorkspace, MyWorkspace) + ## + ## arcpy.AddMessage("Staging service to create service definition") + ## arcpy.StageService_server(Sddraft, Sd) + ## + ## arcpy.AddMessage("Uploading the service definition and publishing image service") + ## arcpy.UploadServiceDefinition_server(Sd, con) + ## + ## arcpy.AddMessage("Service successfully published") + ## except: + ## arcpy.AddError(arcpy.GetMessages()+ "\n\n") + ## sys.exit("Failed to stage and upload service") + ## else: + ## arcpy.AddError("Service could not be published because errors were found during analysis.") + ## arcpy.AddError(arcpy.GetMessages(2)) + + # del project_gdb + + # Declared Variables set in function for aprx + # del home_folder + # Save aprx one more time and then delete + # aprx.save() + # del aprx + + # Declared Variables set in function + + # Imports + + # Function Parameters + del project_gdb + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:") + traceback.print_exc() + + +def create_thumbnails(project_folder=""): + try: + # Import + from arcpy import metadata as md + from dismap_tools import dataset_title_dict + + arcpy.env.overwriteOutput = True + arcpy.env.parallelProcessingFactor = "100%" + + home_folder = os.path.dirname(project_folder) + home_folder_file = os.path.join(home_folder, "DisMAP.aprx") + project_name = os.path.basename(project_folder) + project_gdb = os.path.join(project_folder, f"{project_name}.gdb") + metadata_folder = os.path.join(project_folder, "Metadata_Export") + scratch_folder = os.path.join(project_folder, "Scratch") + + arcpy.env.workspace = project_gdb + arcpy.env.scratchWorkspace = os.path.join(scratch_folder, "scratch.gdb") + + aprx = arcpy.mp.ArcGISProject(home_folder_file) + + # arcpy.AddMessage(f"\n{'-' * 90}\n") + + metadata_dictionary = dataset_title_dict(project_gdb) + + datasets = list() + + walk = arcpy.da.Walk(project_gdb) + + for dirpath, dirnames, filenames in walk: + for filename in filenames: + datasets.append(os.path.join(dirpath, filename)) + del filename + del dirpath, dirnames, filenames + del walk + + for dataset_path in sorted(datasets): + arcpy.AddMessage(dataset_path) + dataset_name = os.path.basename(dataset_path) + data_type = arcpy.Describe(dataset_path).dataType + arcpy.AddMessage(f"Dataset Name: {dataset_name}") + arcpy.AddMessage(f"\tData Type: {data_type}") + + if data_type == "Table": + + + if "IDW" in dataset_name: + arcpy.AddMessage(f"Dataset Name: {dataset_name}") + if "Indicators" in dataset_name: + arcpy.AddMessage("\tRegion Indicators") + + elif "LayerSpeciesYearImageName" in dataset_name: + arcpy.AddMessage("\tRegion Layer Species Year Image Name") + + else: + arcpy.AddMessage("\tRegion Table") + + else: + arcpy.AddMessage(f"Dataset Name: {dataset_name}") + if "Indicators" in dataset_name: + arcpy.AddMessage("\tMain Indicators Table") + + elif "LayerSpeciesYearImageName" in dataset_name: + arcpy.AddMessage("\tLayer Species Year Image Name") + + elif "Datasets" in dataset_name: + arcpy.AddMessage("\tDataset Table") + + elif "Species_Filter" in dataset_name: + arcpy.AddMessage("\tSpecies Filter Table") + + else: + arcpy.AddMessage(f"\tDataset Name: {dataset_name}") + + elif data_type == "FeatureClass": + # arcpy.AddMessage(f"\tData Type: {data_type}") + + if "IDW" in dataset_name: + arcpy.AddMessage(f"Dataset Name: {dataset_name}") + if dataset_name.endswith("Boundary"): + arcpy.AddMessage("\tBoundary") + + elif dataset_name.endswith("Extent_Points"): + arcpy.AddMessage("\tExtent_Points") + + elif dataset_name.endswith("Fishnet"): + arcpy.AddMessage("\tFishnet") + + elif dataset_name.endswith("Lat_Long"): + arcpy.AddMessage("\tLat_Long") + + elif dataset_name.endswith("Region"): + arcpy.AddMessage("\tRegion") + + elif dataset_name.endswith("Sample_Locations"): + arcpy.AddMessage("\tSample_Locations") + + else: + pass + + elif "DisMAP_Regions" == dataset_name: + arcpy.AddMessage(f"Dataset Name: {dataset_name}") + if dataset_name.endswith("Regions"): + arcpy.AddMessage("\tDisMAP Regions") + + else: + arcpy.AddMessage(f"Else Dataset Name: {dataset_name}") + + elif data_type == "RasterDataset": + + if "IDW" in dataset_name: + arcpy.AddMessage(f"Dataset Name: {dataset_name}") + if dataset_name.endswith("Bathymetry"): + arcpy.AddMessage("\tBathymetry") + + elif dataset_name.endswith("Latitude"): + arcpy.AddMessage("\tLatitude") + + elif dataset_name.endswith("Longitude"): + arcpy.AddMessage("\tLongitude") + + elif dataset_name.endswith("Raster_Mask"): + arcpy.AddMessage("\tRaster_Mask") + else: + pass + + elif data_type == "MosaicDataset": + + if "IDW" in dataset_name: + arcpy.AddMessage(f"Dataset Name: {dataset_name}") + if dataset_name.endswith("Mosaic"): + arcpy.AddMessage("\tMosaic") + else: + pass + + elif "CRF" in dataset_name: + arcpy.AddMessage(f"Dataset Name: {dataset_name}") + if dataset_name.endswith("CRF"): + arcpy.AddMessage("\tCRF") + + else: + pass + else: + pass + + del data_type + + del dataset_name, dataset_path + del datasets + + # Declared Variables set in function for aprx + del home_folder + # Save aprx one more time and then delete + aprx.save() + del aprx + + # Declared Variables set in function + del metadata_folder + del project_folder, scratch_folder + del metadata_dictionary + + # Imports + del dataset_title_dict, md + + # Function Parameters + del project_gdb + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:") + traceback.print_exc() + + +def script_tool(project_folder=""): + try: + # Imports + from time import localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + arcpy.AddMessage(f"{'-' * 80}") + arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") + arcpy.AddMessage(f"Location: .. {'/'.join(__file__.split(os.sep)[-4:])}") + arcpy.AddMessage(f"Python Version: {sys.version}") + arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") + arcpy.AddMessage( + f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}" + ) + arcpy.AddMessage(f"{'-' * 80}\n") + + CreateFeatureClassLayers = False + if CreateFeatureClassLayers: + create_feature_class_layers(project_folder) + del CreateFeatureClassLayers + + CreateFeaturClasseServices = True + if CreateFeaturClasseServices: + create_feature_class_services(project_folder) + del CreateFeaturClasseServices + + CreateImagesServices = False + if CreateImagesServices: + create_image_services(project_folder) + del CreateImagesServices + + # UpdateMetadataFromPublishedMd = False + # if UpdateMetadataFromPublishedMd: + # update_metadata_from_published_md(project_folder) + # del UpdateMetadataFromPublishedMd + +## CreateThumbnails = False +## if CreateThumbnails: +## create_thumbnails(project_folder) +## del CreateThumbnails + + ## CreateBasicTemplateXMLFiles = False + ## if CreateBasicTemplateXMLFiles: + ## create_basic_template_xml_files(project_folder) + ## del CreateBasicTemplateXMLFiles + ## + ## ImportBasicTemplateXmlFiles = False + ## if ImportBasicTemplateXmlFiles: + ## import_basic_template_xml_files(project_folder) + ## del ImportBasicTemplateXmlFiles + + # Variable created in function + + # Function Parameters + del project_folder + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:") + traceback.print_exc() + else: + arcpy.AddMessage("\nScript finished successfully.\n") + finally: + arcpy.AddMessage(f"\n{'--End' * 10}--") + + +if __name__ == "__main__": + try: + + project_folder = arcpy.GetParameterAsText(0) + if not project_folder: + # project_name = "February-1-2026" + # project_name = "August-1-2025" + project_name = "June-1-2026" + project_folder = os.path.join(os.path.expanduser('~'), f"Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\{project_name}") + else: + pass + + script_tool(project_folder) + + arcpy.SetParameterAsText(1, "Result") + + del project_folder + + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + except Exception: + traceback.print_exc() + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/saxon.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/saxon.py new file mode 100644 index 0000000..95933d2 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/saxon.py @@ -0,0 +1,64 @@ +import os +import requests +import arcpy +from arcpy import metadata as md +from saxonche import PySaxonProcessor + +def execute_lossless_research_pipeline(target_gdb_table, xsl_path, final_xml_out): + """ + Executes an enterprise-grade metadata extraction and conversion pipeline. + Bypasses Esri standard import limits via explicit XSLT 3.0 translation mapping. + """ + url = "https://www.fisheries.noaa.gov/inportserve/waf/noaa/nmfs/ost/inport-xml/xml/79319.xml" + + # Secure scratch workspace vectors + temp_raw = os.path.join(arcpy.env.scratchFolder, "inport_raw_79319.xml") + temp_transformed = os.path.join(arcpy.env.scratchFolder, "native_transformed_79319.xml") + + print("📡 Extracting full structural XML stream from NOAA InPort server...") + response = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'}, timeout=30) + response.raise_for_status() + with open(temp_raw, "wb") as f: + f.write(response.content) + + try: + # Run XSLT 3.0 Engine via Saxon Core + print("⚙️ Compiling XSLT schema rules via Saxon-HE engine...") + with PySaxonProcessor(license=False) as proc: + xslt_compiler = proc.new_xslt30_processor() + executable = xslt_compiler.compile_stylesheet(stylesheet_file=xsl_path) + + print("🔄 Executing full namespace-flattening transformation...") + executable.transform_to_file(source_file=temp_raw, output_file=temp_transformed) + + # Ingest directly into Geodatabase Architecture + print(f"📂 Injecting native-formatted XML schema to: {target_gdb_table}") + arcpy_metadata = md.Metadata(target_gdb_table) + + # 'FROM_ARCGIS' instructs the database that the file matches native storage arrays + arcpy_metadata.importMetadata(temp_transformed, "FROM_ARCGIS") + arcpy_metadata.save() + + # Serialize finalized database asset onto your local disk for code review + arcpy_metadata.saveAsXML(final_xml_out) + print(f"🏆 Verification File Generated Successfully: {final_xml_out}") + + except Exception as pipeline_error: + print(f"❌ Critical Pipeline Failure: {pipeline_error}") + + finally: + # Erase cache footprints from storage hardware + for temp_file in [temp_raw, temp_transformed]: + if os.path.exists(temp_file): + os.remove(temp_file) + +if __name__ == "__main__": + # Target Parameters + GEODATABASE_TABLE = r"C:\GIS_Projects\Scientific_Data.gdb\InPort_79319_Table" + XSL_STYLESHEET = "inport_to_arcgis_pro_native.xsl" + FINAL_REVIEW_FILE = r"C:\GIS_Projects\ArcGIS_Native_79319.xml" + + if arcpy.Exists(GEODATABASE_TABLE): + execute_lossless_research_pipeline(GEODATABASE_TABLE, XSL_STYLESHEET, FINAL_REVIEW_FILE) + else: + print(f"❌ Geodatabase target layer path invalid: {GEODATABASE_TABLE}") \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/zip_and_unzip_csv_data.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/zip_and_unzip_csv_data.py similarity index 73% rename from ArcGIS-Analysis-Python/src/dismap_tools/zip_and_unzip_csv_data.py rename to ArcGIS-Analysis-Python/Scripts/dismap_tools/zip_and_unzip_csv_data.py index f33ca37..9e84a83 100644 --- a/ArcGIS-Analysis-Python/src/dismap_tools/zip_and_unzip_csv_data.py +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/zip_and_unzip_csv_data.py @@ -5,25 +5,39 @@ - Update derived parameter values using arcpy.SetParameter() or arcpy.SetParameterAsText() """ +import os +import sys + import arcpy -import traceback, os, sys -def script_tool(home_folder, source_zip_file): + + +def trace(): + import sys # noqa: E401 + import traceback + tb = sys.exc_info()[2] + tbinfo = traceback.format_tb(tb)[0] + line = tbinfo.split(", ")[1] + filename = sys.path[0] + os.sep + "test.py" + synerror = traceback.print_exc().splitlines()[-1] + return line, filename, synerror + +def script_tool(project_folder, source_zip_file): """Script code goes below""" try: - import copy + from io import StringIO from zipfile import ZipFile + from arcpy import metadata as md from lxml import etree - from io import StringIO, BytesIO aprx = arcpy.mp.ArcGISProject("CURRENT") #aprx.save() - home_folder = aprx.homeFolder - arcpy.AddMessage(home_folder) - out_data_path = rf"{home_folder}\CSV_Data" + project_folder = aprx.homeFolder + arcpy.AddMessage(project_folder) + out_data_path = rf"{project_folder}\CSV_Data" import json json_path = rf"{out_data_path}\root_dict.json" - with open(json_path, "r") as json_file: + with open(json_path, "r", encoding='utf-8') as json_file: root_dict = json.load(json_file) del json_file del json_path @@ -56,7 +70,7 @@ def script_tool(home_folder, source_zip_file): arcpy.AddMessage(f"Adding metadata to CSV file") tmp_workspace = arcpy.env.workspace arcpy.env.workspace = out_data_path - contacts = rf"{os.path.dirname(home_folder)}\Datasets\DisMAP Contacts 2025 08 01.xml" + contacts = rf"{os.path.dirname(project_folder)}\Datasets\DisMAP Contacts 2025 08 01.xml" csv_files = arcpy.ListFiles("*_IDW.csv") for csv_file in csv_files: arcpy.AddMessage(f"\t{csv_file}") @@ -102,10 +116,11 @@ def script_tool(home_folder, source_zip_file): del csv_files arcpy.env.workspace = tmp_workspace del tmp_workspace - del home_folder + del project_folder del source_zip_file del md return out_data_path + except arcpy.ExecuteError: arcpy.AddError(arcpy.GetMessages(2)) traceback.print_exc() @@ -119,24 +134,32 @@ def script_tool(home_folder, source_zip_file): del out_data_path if __name__ == "__main__": try: - home_folder = arcpy.GetParameterAsText(0) - if not home_folder: - home_folder = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025" + project_folder = arcpy.GetParameterAsText(0) + if not project_folder: + project_folder = os.path.join(os.path.expanduser('~'), "Documents\\ArcGIS\Projects\\DisMAP\\ArcGIS-Analysis-Python\\February 1 2026" else: pass - - source_zip_file = arcpy.GetParameterAsText(1) + + source_zip_file = arcpy.GetParameterAsText(1) if not source_zip_file: - source_zip_file = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\Datasets\CSV Data 2025 08 01.zip" + source_zip_file = os.path.join(os.path.expanduser('~'), "Documents\\ArcGIS\Projects\\DisMAP\\ArcGIS-Analysis-Python\\Initial Data\\CSV Data 20260201.zip" else: pass - - script_tool(home_folder, source_zip_file) - arcpy.SetParameterAsText(2, "Result") + + script_tool(project_folder, source_zip_file) + arcpy.SetParameterAsText(2, True) + except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except: - import traceback - traceback.print_exc() - arcpy.AddError(arcpy.GetMessages(2)) + #Return Geoprocessing tool specific errors + line, filename, err = trace() + arcpy.AddError("Geoprocessing error on " + line + " of " + filename + " :") + for msg in range(0, arcpy.GetMessageCount()): + if arcpy.GetSeverity(msg) == 2: + arcpy.AddReturnMessage(msg) + except: # noqa: E722 + #Gets non-tool errors + line, filename, err = trace() + arcpy.AddError("Python error on " + line + " of " + filename) + arcpy.AddError(err) + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools/zip_and_unzip_shapefile_data.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools/zip_and_unzip_shapefile_data.py new file mode 100644 index 0000000..1113493 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools/zip_and_unzip_shapefile_data.py @@ -0,0 +1,104 @@ +""" +Script documentation +- Tool parameters are accessed using arcpy.GetParameter() or + arcpy.GetParameterAsText() +- Update derived parameter values using arcpy.SetParameter() or + arcpy.SetParameterAsText() +""" +import os +from zipfile import ZipFile +import traceback +import inspect + +import arcpy + + +def script_tool(project_folder="", source_zip_file=""): + """Script code goes below""" + try: + + # aprx = arcpy.mp.ArcGISProject("CURRENT") + # aprx.save() + # home_folder = aprx.homeFolder + + arcpy.AddMessage(project_folder) + out_data_path = rf"{project_folder}\Dataset_Shapefiles" + arcpy.AddMessage(out_data_path) + + # Change Directory + os.chdir(out_data_path) + + arcpy.AddMessage(f"Un-Zipping files from {os.path.basename(source_zip_file)}") + with ZipFile(source_zip_file, mode="r") as archive: + for file in archive.namelist(): + archive.extract(file, ".") + del file + del archive + + arcpy.AddMessage( + f"Done Un-Zipping files from {os.path.basename(source_zip_file)}" + ) + del project_folder, source_zip_file + + except arcpy.ExecuteWarning: + arcpy.AddWarning( + f"ArcPy Execute Warning in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(1)}" + ) + except arcpy.ExecuteError: + arcpy.AddError( + f"ArcPy Execute Error in '{inspect.stack()[0][3]}':\n{arcpy.GetMessages(2)}" + ) + arcpy.AddError("Traceback:\n") + traceback.print_exc() + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except Exception as e: + arcpy.AddError( + f"An unexpected error occurred in '{inspect.stack()[0][3]}': {e}" + ) + arcpy.AddError("Traceback:") + traceback.print_exc() + else: + arcpy.AddMessage("\nScript finished successfully.\n") + finally: + arcpy.AddMessage(f"\n{'--End' * 10}--") + +if __name__ == "__main__": + try: + + project_folder = arcpy.GetParameterAsText(0) + if not project_folder: + # project_name = "February-1-2026" + # project_name = "August-1-2025" + project_name = "June-1-2026" + project_folder = os.path.join(os.path.expanduser('~'), f"Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\{project_name}") + else: + pass + + source_zip_file = arcpy.GetParameterAsText(1) + if not source_zip_file: + source_zip_file = os.path.join(os.path.expanduser('~'), "Documents\\ArcGIS\\Projects\\DisMAP\\ArcGIS-Analysis-Python\\Initial-Data\\Dataset-Shapefiles-20260601.zip") + else: + pass + + # print(project_folder) + # print(source_zip_file) + + script_tool(project_folder, source_zip_file) + + arcpy.SetParameterAsText(1, "Result") + + del project_folder, source_zip_file + + except SystemExit: + # This is not an error, so we allow the script to exit. + pass + except arcpy.ExecuteError: + arcpy.AddError(arcpy.GetMessages(2)) + traceback.print_exc() + except Exception: + traceback.print_exc() + + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/__pycache__/dismap_metadata_processing.cpython-313.pyc b/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/__pycache__/dismap_metadata_processing.cpython-313.pyc new file mode 100644 index 0000000..33e5d01 Binary files /dev/null and b/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/__pycache__/dismap_metadata_processing.cpython-313.pyc differ diff --git a/ArcGIS-Analysis-Python/src/dismap_tools_dev/arcpy da Editor.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/arcpy da Editor.py similarity index 72% rename from ArcGIS-Analysis-Python/src/dismap_tools_dev/arcpy da Editor.py rename to ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/arcpy da Editor.py index 18f366b..ae06b0b 100644 --- a/ArcGIS-Analysis-Python/src/dismap_tools_dev/arcpy da Editor.py +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/arcpy da Editor.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------- # Name: module1 # Purpose: # @@ -7,9 +7,10 @@ # Created: 06/12/2024 # Copyright: (c) john.f.kennedy 2024 # Licence: -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------- import arcpy + def main(): try: workspace = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\National Mapper\National Mapper.gdb" @@ -20,7 +21,7 @@ def main(): edit.startOperation() arcpy.AddMessage("operation started") # Perform edits - #with arcpy.da.InsertCursor(fc, fields) as fc_icursor: + # with arcpy.da.InsertCursor(fc, fields) as fc_icursor: # fc_icursor.insertRow(someNewRow) edit.stopOperation() arcpy.AddMessage("operation stopped") @@ -28,18 +29,24 @@ def main(): arcpy.AddMessage("edit stopped") except Exception as err: arcpy.AddMessage(err) - if 'edit' in locals(): + if "edit" in locals(): if edit.isEditing: edit.stopOperation() arcpy.AddMessage("operation stopped in except") - edit.stopEditing(False) ## Stop the edit session with False to abandon the changes + edit.stopEditing( + False + ) ## Stop the edit session with False to abandon the changes arcpy.AddMessage("edit stopped in except") except: import traceback + traceback.print_exc() finally: # Cleanup arcpy.management.ClearWorkspaceCache() -if __name__ == '__main__': + +if __name__ == "__main__": main() + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dev_dismap_director.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dev_dismap_director.py new file mode 100644 index 0000000..e3bf7fd --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dev_dismap_director.py @@ -0,0 +1,831 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------- +# Name: dismap.py +# Purpose: Common DisMAP functions +# +# Author: john.f.kennedy +# +# Created: 12/01/2024 +# Copyright: (c) john.f.kennedy 2024 +# Licence: +# ------------------------------------------------------------------------------- +import importlib +import inspect +import os # built-ins first +import sys +import traceback + +import arcpy # third-parties second + + +def main(project_gdb=""): + try: + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + print(f"{'-' * 80}") + print(f"Python Script: {os.path.basename(__file__)}") + print( + f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}" + ) + print(f"Python Version: {sys.version}") + print(f"Environment: {os.path.basename(sys.exec_prefix)}") + print(f"{'-' * 80}\n") + + # Set varaibales + project_folder = os.path.dirname(project_gdb) + project_name = os.path.basename(project_folder) + base_project_folder = os.path.dirname(project_folder) + + # + # Step 0 - create an ArcGIS Project + # + + # ########################################################################## + # Step 1 - update ArcGIS Project with the databases and folders for a given + # ########################################################################## + # project version + DisMapProjectSetup = False + if DisMapProjectSetup: + import dev_dismap_project_setup + + base_project_file = rf"{base_project_folder}\DisMAP.aprx" + dev_dismap_project_setup.project_folders(base_project_file, project_name) + # Declared variables + del base_project_file + # Imports + del dev_dismap_project_setup + else: + pass + del DisMapProjectSetup + # ########################################################################## + # Step 2 - zip and unzip the region shapefiles and the CSV data for a given + # ########################################################################## + # project version + ZipAndUnzipCsvData = False + if ZipAndUnzipCsvData: + # Imports + import dev_zip_and_unzip_csv_data + + # If "project" is the same, then an archieve file is created. + # If different, then the archieve is created and upzipped in the new + # location + # In Data Path + in_data_path = rf"{project_folder}\CSV Data" + out_data_path = rf"{project_folder}\CSV Data" + selected_files = [ + "AI_IDW.csv", + "Datasets.csv", + "EBS_IDW.csv", + "ENBS_IDW.csv", + "GMEX_IDW.csv", + "GOA_IDW.csv", + "HI_IDW.csv", + "NBS_IDW.csv", + "NEUS_FAL_IDW.csv", + "NEUS_SPR_IDW.csv", + "SEUS_FAL_IDW.csv", + "SEUS_SPR_IDW.csv", + "SEUS_SUM_IDW.csv", + "Species_Filter.csv", + "WC_ANN_IDW.csv", + "WC_GLMME.csv", + "WC_TRI_IDW.csv", + "field_definitions.json", + "metadata_dictionary.json", + "table_definitions.json", + ] + selected_files = ";".join(selected_files) + dev_zip_and_unzip_csv_data.main(in_data_path, out_data_path, selected_files) + # Declared variables + del in_data_path, out_data_path, selected_files + # Imports + del dev_zip_and_unzip_csv_data + else: + pass + del ZipAndUnzipCsvData + + ZipAndUnzipShapefileData = False + if ZipAndUnzipShapefileData: + # Imports + import dev_zip_and_unzip_shapefile_data + + # If "project_name" is the same, then an archieve file is created. + # If different, then the archieve is created and upzipped in the new + # location + in_data_path = rf"{project_folder}\Dataset_Shapefiles" + out_data_path = rf"{project_folder}\Dataset_Shapefiles" + selected_files = [ + "AI_IDW_Region.shp", + "EBS_IDW_Region.shp", + "ENBS_IDW_Region.shp", + "GMEX_IDW_Region.shp", + "GOA_IDW_Region.shp", + "HI_IDW_Region.shp", + "NBS_IDW_Region.shp", + "NEUS_FAL_IDW_Region.shp", + "NEUS_SPR_IDW_Region.shp", + "SEUS_FAL_IDW_Region.shp", + "SEUS_SPR_IDW_Region.shp", + "SEUS_SUM_IDW_Region.shp", + "WC_ANN_IDW_Region.shp", + "WC_GFDL_Region.shp", + "WC_GLMME_Region.shp", + "WC_TRI_IDW_Region.shp", + ] + selected_files = ";".join(selected_files) + dev_zip_and_unzip_shapefile_data.main( + in_data_path, out_data_path, selected_files + ) + # Declared variables + del in_data_path, out_data_path, selected_files + # Imports + del dev_zip_and_unzip_shapefile_data + del ZipAndUnzipShapefileData + + # ###--->>> + # Write script that checks CSV file headers and updates as necessary + # ###--->>> + # ########################################################################## + # Step 3 - Create base bathymetry datasets in project folder + # ########################################################################## + # ToDo1 CreateBaseBathymetry = False + CreateBaseBathymetry = False + if CreateBaseBathymetry: + # Imports + from dev_create_base_bathymetry import (create_alasaka_bathymetry, + create_hawaii_bathymetry, + gebco_bathymetry) + + # Process base Alasak bathymetry + create_alasaka_bathymetry(project_gdb) + # Process base Hawaii bathymetry + create_hawaii_bathymetry(project_gdb) + # Process base GEBCO bathymetry + gebco_bathymetry(project_gdb) + # Declared variables + # Imports + del create_alasaka_bathymetry, create_hawaii_bathymetry, gebco_bathymetry + else: + pass + del CreateBaseBathymetry + # ########################################################################## + # Step 4 - import the "Datasets" and the "Species_Filter" table into the + # ########################################################################## + # project GDB + ImportDatasetsSpeciesFilterCsvData = False + if ImportDatasetsSpeciesFilterCsvData: + # Imports + from dev_create_table_and_field_definitions_json import \ + generate_data_dictionary + from dev_import_datasets_species_filter_csv_data import ( + update_datecode, worker) + + datasets_csv = rf"{project_folder}\CSV_Data\Datasets.csv" + species_filter_csv = rf"{project_folder}\CSV_Data\Species_Filter.csv" + survey_metadata_csv = rf"{project_folder}\CSV_Data\DisMAP_Survey_Info.csv" + # Update DateCode + update_datecode(csv_file=datasets_csv, project_name=project_name) + # Datasets CSV File + worker(project_gdb=project_gdb, csv_file=datasets_csv) + # Species Filter CSV File + worker(project_gdb=project_gdb, csv_file=species_filter_csv) + # DisMAP Survey Info CSV File + worker(project_gdb=project_gdb, csv_file=survey_metadata_csv) + # Generate Table and Field Definitions JSON + generate_data_dictionary(project_gdb) + # Declared variables + del datasets_csv, species_filter_csv, survey_metadata_csv + # Imports + del update_datecode, worker, generate_data_dictionary + else: + pass + del ImportDatasetsSpeciesFilterCsvData + # ########################################################################## + # Step 5 - Create regions from shapefiles + # ########################################################################## + CreateRegionsFromShapefiles = False + if CreateRegionsFromShapefiles: + # Imports + from dev_create_regions_from_shapefiles_director import director + + Test = False + if Test: + director( + project_gdb=project_gdb, + Sequential=True, + table_names=["WC_TRI_IDW", "AI_IDW"], + ) + elif not Test: + director(project_gdb=project_gdb, Sequential=False, table_names=[]) + else: + pass + del Test + # Declared variables + # Imports + del director + else: + pass + del CreateRegionsFromShapefiles + # ########################################################################## + # Step 6 - Create region fishnets + # ########################################################################## + CreateRegionFishnets = False + if CreateRegionFishnets: + from dev_create_region_fishnets_director import director + + Test = False + if Test: + director( + project_gdb=project_gdb, + Sequential=True, + table_names=["WC_TRI_IDW", "AI_IDW"], + ) + elif not Test: + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NBS_IDW", + "ENBS_IDW", + "HI_IDW", + "SEUS_FAL_IDW", + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "WC_TRI_IDW", + "GMEX_IDW", + "AI_IDW", + "GOA_IDW", + "WC_ANN_IDW", + "NEUS_FAL_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=["NEUS_SPR_IDW", "EBS_IDW"], + ) + # director(project_gdb=project_gdb, Sequential=False, table_names=[]) + else: + pass + del Test + # Declared variables + # Imports + del director + else: + pass + del CreateRegionFishnets + # ########################################################################## + # Step 7 - Create Region Bathymetry + # ########################################################################## + CreateRegionBathymetry = False + if CreateRegionBathymetry: + # Imports + from dev_create_region_bathymetry_director import director + + Test = False + if Test: + director( + project_gdb=project_gdb, + Sequential=True, + table_names=["WC_TRI_IDW", "AI_IDW"], + ) + elif not Test: + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NBS_IDW", + "ENBS_IDW", + "HI_IDW", + "SEUS_FAL_IDW", + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "WC_TRI_IDW", + "GMEX_IDW", + "AI_IDW", + "GOA_IDW", + "WC_ANN_IDW", + "NEUS_FAL_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=["NEUS_SPR_IDW", "EBS_IDW"], + ) + else: + pass + del Test + # Declared variables + # Imports + del director + else: + pass + del CreateRegionBathymetry + # ########################################################################## + # Step 8 - create_region_sample_locations_director + # ########################################################################## + CreateRegionSampleLocations = True + if CreateRegionSampleLocations: + # Imports + from dev_create_region_sample_locations_director import director + + Test = False + if Test: + director( + project_gdb=project_gdb, + Sequential=True, + table_names=["WC_TRI_IDW", "AI_IDW"], + ) + elif not Test: + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NBS_IDW", + "ENBS_IDW", + "HI_IDW", + "SEUS_FAL_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + "WC_TRI_IDW", + "GMEX_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "AI_IDW", + "GOA_IDW", + "WC_ANN_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=["NEUS_FAL_IDW", "NEUS_SPR_IDW", "EBS_IDW"], + ) + else: + pass + del Test + # Declared variables + # Imports + del director + else: + pass + del CreateRegionSampleLocations + + # ########################################################################## + # Step 9 - Create species year image name table + # ########################################################################## + CreateSpeciesYearImageNameTable = False + if CreateSpeciesYearImageNameTable: + # Imports + from dev_create_species_year_image_name_table_director import ( + director, process_image_name_tables) + + Test = False + if Test: + # Debug + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "GMEX_IDW", + ], + ) + # Debug + elif not Test: + director(project_gdb=project_gdb, Sequential=False, table_names=[]) + else: + pass + del Test + # Combine Image Name Tables + # process_image_name_tables(project_gdb=project_gdb, project=project_name) + + # Declared variables + # Imports + del director, process_image_name_tables + else: + pass + del CreateSpeciesYearImageNameTable + + # ########################################################################## + # Step 10 - Create Rasters + # ########################################################################## + CreateRasters = False + if CreateRasters: + # Imports + from dev_create_rasters_director import director + + Test = False + if Test: + # Debug + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "GMEX_IDW", + ], + ) + # Debug + elif not Test: + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NBS_IDW", + "ENBS_IDW", + "HI_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "SEUS_FAL_IDW", + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "WC_TRI_IDW", + "AI_IDW", + "GMEX_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "GOA_IDW", + "WC_ANN_IDW", + "NEUS_FAL_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NEUS_SPR_IDW", + "EBS_IDW", + ], + ) + else: + pass + del Test + # Declared variables + # Imports + del director + else: + pass + del CreateRasters + + # ########################################################################## + # Step 11 - Create Indicators Table + # ########################################################################## + CreateIndicatorsTable = False + if CreateIndicatorsTable: + # Imports + from dev_create_indicators_table_director import ( + director, process_indicator_tables) + + Test = False + if Test: + # Debug + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "GMEX_IDW", + ], + ) + # Debug + elif not Test: + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NBS_IDW", + "ENBS_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "HI_IDW", + "SEUS_FAL_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "WC_TRI_IDW", + "GMEX_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "AI_IDW", + "GOA_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "WC_ANN_IDW", + "NEUS_FAL_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NEUS_SPR_IDW", + "EBS_IDW", + ], + ) + + # Combine Indicator Tables + else: + pass + del Test + # process_indicator_tables(project_gdb=project_gdb, project=project) + # Declared variables + # Imports + del director, process_indicator_tables + else: + pass + del CreateIndicatorsTable + + # dataset_comparison - rasters + # dataset_comparison - feature classes + # dataset_comparison - tables + + # Step 12 - Create Species Richness Rasters + CreateSpeciesRichnessRasters = False + if CreateSpeciesRichnessRasters: + # Imports + from dev_create_species_richness_rasters_director import director + + Test = False + if Test: + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "GMEX_IDW", + ], + ) + elif not Test: + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NBS_IDW", + "ENBS_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "HI_IDW", + "SEUS_FAL_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "WC_TRI_IDW", + "GMEX_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "AI_IDW", + "GOA_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "WC_ANN_IDW", + "NEUS_FAL_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NEUS_SPR_IDW", + "EBS_IDW", + ], + ) + else: + pass + del Test + # Declared variables + # Imports + del director + else: + pass + del CreateSpeciesRichnessRasters + + # create_mosaics_director + # Step 12 - Create Mosaics + CreateMosaics = False + if CreateMosaics: + # Imports + from dev_create_mosaics_director import director + + Test = False + if Test: + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "GMEX_IDW", + ], + ) + elif not Test: + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NBS_IDW", + "ENBS_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "HI_IDW", + "SEUS_FAL_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "SEUS_SPR_IDW", + "SEUS_SUM_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "WC_TRI_IDW", + "GMEX_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "AI_IDW", + "GOA_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "WC_ANN_IDW", + "NEUS_FAL_IDW", + ], + ) + director( + project_gdb=project_gdb, + Sequential=False, + table_names=[ + "NEUS_SPR_IDW", + "EBS_IDW", + ], + ) + else: + pass + del Test + # Declared variables + # Imports + del director + else: + pass + del CreateMosaics + + # publish_to_portal_director + + # Declared Varaiables + del project_name, project_folder + # Imports + # Function Parameters + del project_gdb + + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + print(f"\n{'-' * 80}") + print( + f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}" + ) + print( + "Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) + ) + print(f"{'-' * 80}") + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + except: + traceback.print_exc() + raise SystemExit + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +if __name__ == "__main__": + try: + # Append the location of this scrip to the System Path + sys.path.append(os.path.dirname(os.path.dirname(__file__))) + # Imports + base_project_folder = rf"{os.path.dirname(os.path.dirname(__file__))}" + # project = "May 1 2024" + # project_name = "July 1 2024" + # project_name = "December 1 2024" + # project_name = "June 1 2025" + # for project_name in ["June 1 2025"]: + for project_name in ["December 1 2024", "June 1 2025"]: + project_folder = rf"{base_project_folder}" + project_gdb = rf"{project_folder}\{project_name}\{project_name}.gdb" + main(project_gdb=project_gdb) + del project_gdb, project_folder, project_name + # Decated Variables + del base_project_folder + # Imports + except SystemExit: + pass + except: + traceback.print_exc() + else: + pass + finally: + pass +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/src/dismap_tools_dev/dev_dismap_metadata_processing.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dev_dismap_metadata_processing.~py similarity index 100% rename from ArcGIS-Analysis-Python/src/dismap_tools_dev/dev_dismap_metadata_processing.py rename to ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dev_dismap_metadata_processing.~py diff --git a/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dev_export_arcgis_metadata.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dev_export_arcgis_metadata.py new file mode 100644 index 0000000..0b67e60 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dev_export_arcgis_metadata.py @@ -0,0 +1,203 @@ +""" +This module contains . . . + +Requires : Python 3.11 + ArcGIS Pro 3.x + +Copyright 2025 NMFS +Licensed under the Apache License, Version 2.0 (the 'License'); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an 'AS IS' BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +import inspect +# Python Built-in's modules are loaded first +import os +import sys +import traceback + + +def export_metadata(project_gdb="", metadata_workspace=""): + try: + # Imports + # Third-party modules are loaded second + import arcpy + import dev_create_folders + from arcpy import metadata as md + # Project modules + from Scripts.project_tools import pretty_format_xml_file + + # Use all of the cores on the machine + arcpy.env.parallelProcessingFactor = "100%" + arcpy.env.overwriteOutput = True + + # Define variables + project_folder = os.path.dirname(project_gdb) + scratch_folder = rf"{project_folder}\Scratch" + scratch_gdb = rf"{scratch_folder}\scratch.gdb" + + # Set the workspace environment to local file geodatabase + arcpy.env.workspace = project_gdb + # Set the scratchWorkspace environment to local file geodatabase + arcpy.env.scratchWorkspace = scratch_gdb + + # Clean-up variables + del scratch_folder, scratch_gdb + + print(f"\n{'--Start' * 10}--\n") + + if not os.path.isdir(rf"{project_folder}\{metadata_workspace}"): + dev_create_folders.create_folders(project_folder, [metadata_workspace]) + + fcs = arcpy.ListFeatureClasses() + + print(f"Synchronize and export feature classes metadata from Project GDB\n") + for fc in sorted(fcs): + print(f"Exporting the metadata record for: '{fc}'") + + fc_path = rf"{project_gdb}\{fc}" + + export_xml_metadata_path = ( + rf"{project_folder}\{metadata_workspace}\{fc}.xml" + ) + + dataset_md = md.Metadata(fc_path) + dataset_md.synchronize("ALWAYS") + dataset_md.title = fc + dataset_md.save() + dataset_md.reload() + dataset_md.saveAsXML(export_xml_metadata_path, "REMOVE_ALL_SENSITIVE_INFO") + # if dataset_md.thumbnailUri: + # arcpy.management.Copy(dataset_md.thumbnailUri, rf"{metadata_workspace}\{fc} Thumbnail.jpg") + # arcpy.management.Copy(dataset_md.thumbnailUri, rf"{metadata_workspace}\{fc} Browse Graphic.jpg") + + del dataset_md + + if os.path.isfile(export_xml_metadata_path): + pretty_format_xml_file(export_xml_metadata_path) + else: + print(f"Problem with '{os.path.basename(export_xml_metadata_path)}'") + + del export_xml_metadata_path + del fc, fc_path + + del fcs + del project_folder + + print(f"\n{'--End' * 10}--") + + # Imports + del md, pretty_format_xml_file, dev_create_folders + # Function parameters + del project_gdb, metadata_workspace + + except: + traceback.print_exc() + else: + # Cleanup + arcpy.management.ClearWorkspaceCache() + # Imports + del arcpy + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +def main(project_gdb="", metadata_workspace=""): + try: + from time import gmtime, localtime, strftime, time + + # Set a start time so that we can see how log things take + start_time = time() + print(f"{'-' * 80}") + print(f"Python Script: {os.path.basename(__file__)}") + print(f"Location: {os.path.dirname(__file__)}") + print( + f"Python Version: {sys.version} Environment: {os.path.basename(sys.exec_prefix)}" + ) + print(f"{'-' * 80}\n") + + export_metadata(project_gdb=project_gdb, metadata_workspace=metadata_workspace) + + # Declared Variables + + # Function parameters + del project_gdb, metadata_workspace + + # Elapsed time + end_time = time() + elapse_time = end_time - start_time + print(f"\n{'-' * 80}") + print( + f"Python script: {os.path.basename(__file__)} successfully completed {strftime('%a %b %d %I:%M %p', localtime())}" + ) + print( + "Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) + ) + print(f"{'-' * 80}") + del elapse_time, end_time, start_time + del gmtime, localtime, strftime, time + + except: + traceback.print_exc() + else: + # While in development, leave here. For test, move to finally + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk + return True + finally: + pass + + +if __name__ == "__main__": + try: + # Imports + from datetime import date + + # Append the location of this scrip to the System Path + # sys.path.append(os.path.dirname(__file__)) + sys.path.append(os.path.dirname(os.path.dirname(__file__))) + + today = date.today() + date_string = today.strftime("%Y-%m-%d") + + project_folder = rf"{os.path.dirname(os.path.dirname(__file__))}" + project_name = "National Mapper" + # project_name = "NMFS_ESA_Range" + project_gdb = rf"{project_folder}\{project_name}.gdb" + metadata_workspace = f"Export" + # metadata_workspace = f"Export {date_string}" + # metadata_workspace = f"Export 2025-01-27" + + main(project_gdb=project_gdb, metadata_workspace=metadata_workspace) + + # Declared Variables + del project_folder, project_name, project_gdb, metadata_workspace + del today, date_string + # Imports + del date + + except: + traceback.print_exc() + else: + pass + finally: + pass +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/src/dismap_tools_dev/dev_zip_and_unzip_csv_data.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dev_zip_and_unzip_csv_data.py similarity index 67% rename from ArcGIS-Analysis-Python/src/dismap_tools_dev/dev_zip_and_unzip_csv_data.py rename to ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dev_zip_and_unzip_csv_data.py index b94c62b..18f948a 100644 --- a/ArcGIS-Analysis-Python/src/dismap_tools_dev/dev_zip_and_unzip_csv_data.py +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dev_zip_and_unzip_csv_data.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------- # Name: zip_and_unzip_csv_data # Purpose: # @@ -8,13 +8,15 @@ # Created: 09/03/2024 # Copyright: (c) john.f.kennedy 2024 # Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback +# ------------------------------------------------------------------------------- import importlib import inspect +import os # built-ins first +import sys +import traceback + +import arcpy # third-parties second -import arcpy # third-parties second def zip_data(source_folder, selected_files, out_zip_file): try: @@ -50,11 +52,17 @@ def zip_data(source_folder, selected_files, out_zip_file): traceback.print_exc() else: # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: print(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk return __results finally: - if "__results" in locals().keys(): del __results + if "__results" in locals().keys(): + del __results + def un_zip_data(source_zip_file, out_data_path): try: @@ -69,7 +77,7 @@ def un_zip_data(source_zip_file, out_data_path): with ZipFile(source_zip_file, mode="r") as archive: for file in archive.namelist(): - #if file.endswith(".csv"): + # if file.endswith(".csv"): # archive.extract(file, ".") archive.extract(file, ".") del file @@ -90,20 +98,29 @@ def un_zip_data(source_zip_file, out_data_path): traceback.print_exc() else: # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: print(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk return __results finally: - if "__results" in locals().keys(): del __results + if "__results" in locals().keys(): + del __results + def main(in_data_path, out_data_path, selected_files): try: from time import gmtime, localtime, strftime, time + # Set a start time so that we can see how log things take start_time = time() print(f"{'-' * 80}") print(f"Python Script: {os.path.basename(__file__)}") - print(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") + print( + f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}" + ) print(f"Python Version: {sys.version}") print(f"Environment: {os.path.basename(sys.exec_prefix)}") print(f"{'-' * 80}\n") @@ -135,11 +152,15 @@ def main(in_data_path, out_data_path, selected_files): # Elapsed time end_time = time() - elapse_time = end_time - start_time + elapse_time = end_time - start_time print(f"\n{'-' * 80}") - print(f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}") - print(u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time)))) + print( + f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}" + ) + print( + "Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) + ) print(f"{'-' * 80}") del elapse_time, end_time, start_time del gmtime, localtime, strftime, time @@ -150,44 +171,64 @@ def main(in_data_path, out_data_path, selected_files): traceback.print_exc() else: # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: print(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk + rk = [key for key in locals().keys() if not key.startswith("__")] + if rk: + print( + f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##" + ) + del rk return True finally: pass + if __name__ == "__main__": try: # Append the location of this scrip to the System Path - #sys.path.append(os.path.dirname(__file__)) + # sys.path.append(os.path.dirname(__file__)) sys.path.append(os.path.dirname(os.path.dirname(__file__))) # Imports import dev_zip_and_unzip_csv_data + importlib.reload(dev_zip_and_unzip_csv_data) base_project_folder = rf"{os.path.dirname(os.path.dirname(__file__))}" - #in_project = "July 1 2024" + # in_project = "July 1 2024" in_project = "December 1 2024" in_data_path = rf"{base_project_folder}\{in_project}\CSV Data" del in_project - #out_project = "December 1 2024" + # out_project = "December 1 2024" out_project = "June 1 2025" out_data_path = rf"{base_project_folder}\{out_project}\CSV Data" del out_project - selected_files = ["AI_IDW.csv", "Datasets.csv", "DisMAP_Survey_Info.csv", - "EBS_IDW.csv", "ENBS_IDW.csv", "field_definitions.json", - "GMEX_IDW.csv", "GOA_IDW.csv", "HI_IDW.csv", - "metadata_dictionary.json", "NBS_IDW.csv", - "NEUS_FAL_IDW.csv", "NEUS_SPR_IDW.csv", - "SEUS_FAL_IDW.csv", "SEUS_SPR_IDW.csv", - "SEUS_SUM_IDW.csv", "Species_Filter.csv", - "table_definitions.json", "WC_ANN_IDW.csv", - "WC_GFDL.csv", "WC_GLMME.csv", "WC_TRI_IDW.csv", - ] + selected_files = [ + "AI_IDW.csv", + "Datasets.csv", + "DisMAP_Survey_Info.csv", + "EBS_IDW.csv", + "ENBS_IDW.csv", + "field_definitions.json", + "GMEX_IDW.csv", + "GOA_IDW.csv", + "HI_IDW.csv", + "metadata_dictionary.json", + "NBS_IDW.csv", + "NEUS_FAL_IDW.csv", + "NEUS_SPR_IDW.csv", + "SEUS_FAL_IDW.csv", + "SEUS_SPR_IDW.csv", + "SEUS_SUM_IDW.csv", + "Species_Filter.csv", + "table_definitions.json", + "WC_ANN_IDW.csv", + "WC_GFDL.csv", + "WC_GLMME.csv", + "WC_TRI_IDW.csv", + ] selected_files = ";".join(selected_files) @@ -205,3 +246,5 @@ def main(in_data_path, out_data_path, selected_files): pass finally: pass + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/src/dismap_tools_dev/dismap_metadata_processing.py b/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dismap_metadata_processing.~py similarity index 99% rename from ArcGIS-Analysis-Python/src/dismap_tools_dev/dismap_metadata_processing.py rename to ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dismap_metadata_processing.~py index cb3cc2a..7ef469c 100644 --- a/ArcGIS-Analysis-Python/src/dismap_tools_dev/dismap_metadata_processing.py +++ b/ArcGIS-Analysis-Python/Scripts/dismap_tools_dev/dismap_metadata_processing.~py @@ -2457,13 +2457,13 @@ def main(project=""): try: - CreateBasicTemplateXMLFiles = False + CreateBasicTemplateXMLFiles = True if CreateBasicTemplateXMLFiles: result = create_basic_template_xml_files(base_project_file, project) results.extend(result); del result del CreateBasicTemplateXMLFiles - ImportBasicTemplateXmlFiles = False + ImportBasicTemplateXmlFiles = True if ImportBasicTemplateXmlFiles: result = import_basic_template_xml_files(base_project_file, project) results.extend(result); del result @@ -2533,7 +2533,8 @@ def main(project=""): #project = "May 1 2024" #project = "July 1 2024" - project = "December 1 2024" + #project = "December 1 2024" + project = "April 1 2023" # Tested on 8/1/2024 -- PASSED main(project=project) diff --git a/ArcGIS-Analysis-Python/Scripts/metadata_validation_report.csv b/ArcGIS-Analysis-Python/Scripts/metadata_validation_report.csv new file mode 100644 index 0000000..9fcb6a9 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/metadata_validation_report.csv @@ -0,0 +1,162 @@ +filename,Title_present,Title_source,Abstract_present,Abstract_source,MD File ID_present,MD File ID_source,Contact_present,Contact_source,Keywords_present,Keywords_source,Publication Date_present,Publication Date_source,Maintenance Frequency_present,Maintenance Frequency_source,Presentation Form_present,Presentation Form_source,EsriCreationDate_present,EsriCreationDate_source,BoundingBox_present,BoundingBox_source,title,mdFileID,pubdate,missing_user_action,missing_arcgis_auto,error +Aleutian Islands Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Aleutian Islands Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Aleutian Islands Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Aleutian Islands Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Aleutian Islands Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Aleutian Islands Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Aleutian Islands Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Aleutian Islands Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Aleutian Islands IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Aleutian Islands IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Aleutian Islands IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Aleutian Islands IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Aleutian Islands Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Aleutian Islands Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Aleutian Islands Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Aleutian Islands Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Aleutian Islands Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Aleutian Islands Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Aleutian Islands Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Aleutian Islands Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Aleutian Islands Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Aleutian Islands Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, +Datasets 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Datasets 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +DisMAP Regions 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,DisMAP Regions 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +DisMAP Survey Info Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,DisMAP Survey Info Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern Bering Sea Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern Bering Sea Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern Bering Sea Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern Bering Sea Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern Bering Sea Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern Bering Sea Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern Bering Sea Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern Bering Sea Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern Bering Sea IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern Bering Sea IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern Bering Sea IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern Bering Sea IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern Bering Sea Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern Bering Sea Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern Bering Sea Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern Bering Sea Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern Bering Sea Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern Bering Sea Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern Bering Sea Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern Bering Sea Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern Bering Sea Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern Bering Sea Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern and Northern Bering Sea Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern and Northern Bering Sea Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern and Northern Bering Sea Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern and Northern Bering Sea Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern and Northern Bering Sea Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern and Northern Bering Sea Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern and Northern Bering Sea Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern and Northern Bering Sea Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern and Northern Bering Sea IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern and Northern Bering Sea IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern and Northern Bering Sea IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern and Northern Bering Sea IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern and Northern Bering Sea Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern and Northern Bering Sea Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern and Northern Bering Sea Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern and Northern Bering Sea Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern and Northern Bering Sea Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern and Northern Bering Sea Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern and Northern Bering Sea Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern and Northern Bering Sea Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Eastern and Northern Bering Sea Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Eastern and Northern Bering Sea Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Alaska Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Alaska Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Alaska Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Alaska Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Alaska Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Alaska Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Alaska Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Alaska Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Alaska IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Alaska IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Alaska IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Alaska IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Alaska Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Alaska Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Alaska Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Alaska Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Alaska Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Alaska Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Alaska Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Alaska Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Alaska Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Alaska Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Mexico Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Mexico Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Mexico Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Mexico Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Mexico Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Mexico Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Mexico Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Mexico Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Mexico IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Mexico IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Mexico IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Mexico IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Mexico Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Mexico Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Mexico Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Mexico Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Mexico Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Mexico Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Mexico Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Mexico Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Gulf of Mexico Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Gulf of Mexico Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, +Hawai'i Islands Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Hawai'i Islands Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Hawai'i Islands Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Hawai'i Islands Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Hawai'i Islands Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Hawai'i Islands Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Hawai'i Islands Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Hawai'i Islands Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Hawai'i Islands IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Hawai'i Islands IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Hawai'i Islands IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Hawai'i Islands IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Hawai'i Islands Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Hawai'i Islands Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Hawai'i Islands Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Hawai'i Islands Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Hawai'i Islands Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Hawai'i Islands Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Hawai'i Islands Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Hawai'i Islands Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Hawai'i Islands Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Hawai'i Islands Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, +Indicators 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Indicators 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Fall Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Fall Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Fall Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Fall Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Fall Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Fall Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Fall IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Fall IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Fall IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Fall IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Fall Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Fall Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Fall Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Fall Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Fall Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Fall Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Fall Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Fall Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Fall Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Fall Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Fall Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Fall Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Spring Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Spring Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Spring Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Spring Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Spring Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Spring Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Spring IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Spring IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Spring IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Spring IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Spring Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Spring Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Spring Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Spring Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Spring Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Spring Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Spring Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Spring Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Spring Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Spring Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northeast US Spring Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northeast US Spring Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, +Northern Bering Sea Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northern Bering Sea Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northern Bering Sea Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northern Bering Sea Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northern Bering Sea Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northern Bering Sea Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northern Bering Sea Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northern Bering Sea Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northern Bering Sea IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northern Bering Sea IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northern Bering Sea IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northern Bering Sea IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northern Bering Sea Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northern Bering Sea Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northern Bering Sea Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northern Bering Sea Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northern Bering Sea Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northern Bering Sea Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northern Bering Sea Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northern Bering Sea Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Northern Bering Sea Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Northern Bering Sea Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Fall Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Fall Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Fall Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Fall Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Fall Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Fall Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Fall IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Fall IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Fall IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Fall IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Fall Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Fall Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Fall Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Fall Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Fall Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Fall Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Fall Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Fall Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Fall Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Fall Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Fall Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Fall Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Spring Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Spring Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Spring Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Spring Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Spring Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Spring Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Spring IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Spring IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Spring IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Spring IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Spring Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Spring Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Spring Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Spring Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Spring Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Spring Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Spring Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Spring Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Spring Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Spring Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Spring Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Spring Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Summer Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Summer Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Summer Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Summer Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Summer Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Summer Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Summer IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Summer IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Summer IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Summer IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Summer Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Summer Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Summer Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Summer Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Summer Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Summer Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Summer Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Summer Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Summer Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Summer Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Southeast US Summer Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Southeast US Summer Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, +Species Filter Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Species Filter Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Species Persistence Indicator Percentile Bin Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Species Persistence Indicator Percentile Bin Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +Species Persistence Indicator Trend Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,Species Persistence Indicator Trend Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Annual Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Annual Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Annual Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Annual Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Annual Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Annual Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Annual IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Annual IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Annual IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Annual IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Annual Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Annual Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Annual Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Annual Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Annual Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Annual Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Annual Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Annual Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Annual Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Annual Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Annual Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Annual Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Triennial Bathymetry 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Triennial Bathymetry 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Triennial Extent Points 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Triennial Extent Points 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Triennial Fishnet 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Triennial Fishnet 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Triennial IDW 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Triennial IDW 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Triennial IDW Mosaic 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Triennial IDW Mosaic 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Triennial Lat Long 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Triennial Lat Long 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Triennial Latitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Triennial Latitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Triennial Layer Species Year Image Name Table 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Triennial Layer Species Year Image Name Table 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Triennial Longitude 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Triennial Longitude 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Triennial Raster Mask 20260201.xml,True,user,True,user,False,user,False,user,True,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Triennial Raster Mask 20260201,,,mdFileID;contact;publication_date;maintenance_frequency;presentation_form,bbox, +West Coast Triennial Sample Locations 20260201.xml,True,user,False,user,False,user,False,user,False,user,False,user,False,user,False,user,True,arcgis,False,arcgis,West Coast Triennial Sample Locations 20260201,,,abstract;mdFileID;contact;keywords;publication_date;maintenance_frequency;presentation_form,bbox, diff --git a/ArcGIS-Analysis-Python/Scripts/summarize_missing_user_fields.py b/ArcGIS-Analysis-Python/Scripts/summarize_missing_user_fields.py new file mode 100644 index 0000000..13f1870 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/summarize_missing_user_fields.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +import collections +import csv +import os + +csv_path = os.path.join(os.path.dirname(__file__), "metadata_validation_report.csv") +if not os.path.exists(csv_path): + print("Report not found:", csv_path) + raise SystemExit(2) + +counter = collections.Counter() +rows = 0 +with open(csv_path, encoding="utf-8") as f: + reader = csv.DictReader(f) + for row in reader: + rows += 1 + miss = row.get("missing_user_action", "") or "" + for k in miss.split(";"): + k = k.strip() + if k: + counter[k] += 1 + +print("Total metadata files:", rows) +print("\nTop missing user-maintained fields:") +for key, cnt in counter.most_common(): + print(f"{key}: {cnt}") + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/Scripts/validate_metadata_exports.py b/ArcGIS-Analysis-Python/Scripts/validate_metadata_exports.py new file mode 100644 index 0000000..cc7aca5 --- /dev/null +++ b/ArcGIS-Analysis-Python/Scripts/validate_metadata_exports.py @@ -0,0 +1,264 @@ +#!/usr/bin/env python3 +"""Simple validator for Metadata_Export XML files. + +Checks multiple metadata elements for presence and reports which are +likely user-maintained vs automatically managed by ArcGIS Pro. + +Fields checked and assumed source: + - title (`resTitle`): user + - abstract (`idAbs`): user + - mdFileID (`mdFileID`): user + - contact (email/org/person): user + - keywords (`themeKeys`/`placeKeys`): user + - publication date (`idCitation/date/pubDate`): user + - maintenance frequency (`resMaint/maintFreq`): user + - data presentation form (`presForm`): user + - bounding box (west/east/north/south): arcgis + - Esri creation date (`Esri/CreaDate`): arcgis + +The script writes a CSV with boolean flags for each field plus a +`missing_user_action` column listing missing fields that need user input. +""" +import csv +import os +import sys +import xml.etree.ElementTree as ET + + +def find_text_by_localname(root, localname): + for elem in root.iter(): + if isinstance(elem.tag, str) and elem.tag.endswith("}" + localname): + return (elem.text or "").strip() + if isinstance(elem.tag, str) and elem.tag == localname: + return (elem.text or "").strip() + return "" + + +def find_all_localnames(root, localname): + vals = [] + for elem in root.iter(): + if not isinstance(elem.tag, str): + continue + if elem.tag.endswith("}" + localname) or elem.tag == localname: + if (elem.text or "").strip(): + vals.append((elem.text or "").strip()) + return vals + + +def has_contact(root): + # look for email or organization name in common contact elements + for elem in root.iter(): + tag = elem.tag + if not isinstance(tag, str): + continue + lname = tag.split("}")[-1] + if lname in ("eMailAdd", "rpOrgName", "rpIndName"): + if (elem.text or "").strip(): + return True + return False + + +def has_bbox(root): + # common ISO element names for bounding box + required = ( + "westBoundLongitude", + "eastBoundLongitude", + "northBoundLatitude", + "southBoundLatitude", + ) + found = set() + for elem in root.iter(): + if not isinstance(elem.tag, str): + continue + lname = elem.tag.split("}")[-1] + if lname in required and (elem.text or "").strip(): + found.add(lname) + return len(found) == 4 + + +def has_keywords(root): + # look for any elements under themeKeys or placeKeys or elsewhere + kws = find_all_localnames(root, "keyword") + return len(kws) > 0 + + +def validate_file(path): + try: + tree = ET.parse(path) + root = tree.getroot() + except Exception as e: + return {"error": str(e)} + + # basic checks + title = find_text_by_localname(root, "resTitle") + abstract = find_text_by_localname(root, "idAbs") + mdFileID = find_text_by_localname(root, "mdFileID") + contact = has_contact(root) + + # additional checks + keywords = has_keywords(root) + pubdate = find_text_by_localname(root, "pubDate") + maintfreq = find_text_by_localname(root, "MaintFreqCd") or find_text_by_localname( + root, "maintFreq" + ) + presform = find_text_by_localname(root, "PresFormCd") or find_text_by_localname( + root, "presForm" + ) + esri_crea = find_text_by_localname(root, "CreaDate") or find_text_by_localname( + root, "Esri/CreaDate" + ) + bbox = has_bbox(root) + # extended checks + # extent CRS - ArcGIS usually populates spatial reference info + extent_crs = bool( + find_text_by_localname(root, "referenceSystemIdentifier") + or find_text_by_localname(root, "srsName") + or find_text_by_localname(root, "referenceSystem") + or find_text_by_localname(root, "gmd:referenceSystemInfo") + ) + + # contact roles (e.g., originator, point of contact, metadata contact) + contact_roles = False + for elem in root.iter(): + if not isinstance(elem.tag, str): + continue + lname = elem.tag.split("}")[-1] + if ( + lname in ("RoleCd", "role") + and (elem.text or elem.get("value") or "").strip() + ): + contact_roles = True + break + + # data sources and process steps + data_sources = bool( + find_all_localnames(root, "srcInfo") + or find_all_localnames(root, "source") + or find_all_localnames(root, "sourceDesc") + ) + process_steps = bool(find_all_localnames(root, "processStep")) + + # distribution info + distribution = bool( + find_all_localnames(root, "distInfo") + or find_all_localnames(root, "distributor") + or find_all_localnames(root, "distorCont") + ) + + # license / use constraints + license_info = bool( + find_all_localnames(root, "useLimitation") + or find_all_localnames(root, "accessConstraints") + or find_all_localnames(root, "useConstraints") + ) + + # mapping of field -> (present_bool, source) + checks = { + "title": (bool(title), "user"), + "abstract": (bool(abstract), "user"), + "mdFileID": (bool(mdFileID), "user"), + "contact": (contact, "user"), + "keywords": (keywords, "user"), + "publication_date": (bool(pubdate), "user"), + "maintenance_frequency": (bool(maintfreq), "user"), + "presentation_form": (bool(presform), "user"), + "esri_creation_date": (bool(esri_crea), "arcgis"), + "bbox": (bbox, "arcgis"), + "extent_crs": (extent_crs, "arcgis"), + "contact_roles": (contact_roles, "user"), + "data_sources": (data_sources, "user"), + "process_steps": (process_steps, "user"), + "distribution": (distribution, "user"), + "license": (license_info, "user"), + } + + return { + "checks": checks, + "title": title, + "mdFileID": mdFileID, + "pubdate": pubdate, + "error": None, + } + + +def main(): + base = os.path.join( + os.path.dirname(__file__), "..", "February 1 2026", "Metadata_Export" + ) + base = os.path.normpath(base) + if not os.path.isdir(base): + print("Metadata_Export folder not found at", base) + sys.exit(2) + + out_path = os.path.join(os.path.dirname(__file__), "metadata_validation_report.csv") + files = [f for f in os.listdir(base) if f.lower().endswith(".xml")] + files.sort() + + # define fields and output header + fields = [ + ("title", "Title"), + ("abstract", "Abstract"), + ("mdFileID", "MD File ID"), + ("contact", "Contact"), + ("keywords", "Keywords"), + ("publication_date", "Publication Date"), + ("maintenance_frequency", "Maintenance Frequency"), + ("presentation_form", "Presentation Form"), + ("esri_creation_date", "EsriCreationDate"), + ("bbox", "BoundingBox"), + ] + + header = ["filename"] + for key, label in fields: + header.append(f"{label}_present") + header.append(f"{label}_source") + header += [ + "title", + "mdFileID", + "pubdate", + "missing_user_action", + "missing_arcgis_auto", + "error", + ] + + with open(out_path, "w", newline="", encoding="utf-8") as csvfile: + writer = csv.writer(csvfile) + writer.writerow(header) + for fn in files: + path = os.path.join(base, fn) + res = validate_file(path) + if "error" in res and res["error"]: + # write row with error + row = [fn] + [""] * (len(header) - 2) + [res["error"]] + writer.writerow(row) + continue + + checks = res.get("checks", {}) + row = [fn] + missing_user = [] + missing_arcgis = [] + for key, _ in fields: + present, source = checks.get(key, (False, "unknown")) + row.append(str(bool(present))) + row.append(source) + if not present: + if source == "user": + missing_user.append(key) + elif source == "arcgis": + missing_arcgis.append(key) + + row.append(res.get("title", "")) + row.append(res.get("mdFileID", "")) + row.append(res.get("pubdate", "")) + row.append(";".join(missing_user)) + row.append(";".join(missing_arcgis)) + row.append("") + writer.writerow(row) + + print("Validation complete. Report at:", out_path) + + +if __name__ == "__main__": + main() + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/__init__.py b/ArcGIS-Analysis-Python/__init__.py new file mode 100644 index 0000000..d44460e --- /dev/null +++ b/ArcGIS-Analysis-Python/__init__.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 +# For relative imports to work in Python 3.13 + + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/inport_to_arcgis_metadata_converter.py b/ArcGIS-Analysis-Python/inport_to_arcgis_metadata_converter.py new file mode 100644 index 0000000..cc9f4a9 --- /dev/null +++ b/ArcGIS-Analysis-Python/inport_to_arcgis_metadata_converter.py @@ -0,0 +1,296 @@ +import os # For path manipulation +import xml.etree.ElementTree as ET +from xml.dom import minidom # For pretty printing XML + + +def parse_inport_xml(inport_xml_path): + """ + Parses an InPort XML file and extracts relevant metadata into a dictionary. + + Args: + inport_xml_path (str): Absolute path to the InPort XML file. + + Returns: + dict: A dictionary containing extracted metadata. + """ + try: + tree = ET.parse(inport_xml_path) + root = tree.getroot() + except ET.ParseError as e: + print(f"Error parsing InPort XML file {inport_xml_path}: {e}") + return {} + except FileNotFoundError: + print(f"InPort XML file not found at {inport_xml_path}") + return {} + + metadata = {} + + # --- Item Identification --- + item_id = root.find("item-identification") + if item_id is not None: + metadata["title"] = item_id.findtext("title") + metadata["abstract"] = item_id.findtext("abstract") + metadata["purpose"] = item_id.findtext("purpose") + + # --- Keywords --- + metadata["keywords"] = [] + for keyword_elem in root.findall("keywords/keyword"): + keyword_text = keyword_elem.findtext("keyword") + if keyword_text: + metadata["keywords"].append(keyword_text) + + # --- Support Roles (Contacts) --- + metadata["point_of_contact"] = {} + metadata["metadata_contact"] = {} + for role_elem in root.findall("support-roles/support-role"): + role_type = role_elem.findtext("support-role-type") + contact_info = {} + contact_info["name"] = role_elem.findtext("contact-name") + contact_info["email"] = role_elem.findtext("contact-email") + contact_info["phone"] = role_elem.findtext("contact-phone-number") + + # Extract address details + contact_info["address"] = role_elem.findtext("contact-address") + contact_info["city"] = role_elem.findtext("contact-address-city") + contact_info["state"] = role_elem.findtext("contact-address-state") + contact_info["zip"] = role_elem.findtext("contact-address-zip") + contact_info["country"] = role_elem.findtext("contact-address-country") + + if role_type == "Point of Contact": + metadata["point_of_contact"] = contact_info + elif role_type == "Metadata Contact": + metadata["metadata_contact"] = contact_info + + # --- Extents (Geographic and Temporal) --- + extents_elem = root.find("extents/extent") + if extents_elem is not None: + geo_area = extents_elem.find("geographic-areas/geographic-area") + if geo_area is not None: + metadata["west_bound"] = geo_area.findtext("west-bound") + metadata["east_bound"] = geo_area.findtext("east-bound") + metadata["north_bound"] = geo_area.findtext("north-bound") + metadata["south_bound"] = geo_area.findtext("south-bound") + + time_frame = extents_elem.find("time-frames/time-frame") + if time_frame is not None: + metadata["start_date"] = time_frame.findtext("start-date-time") + metadata["end_date"] = time_frame.findtext("end-date-time") + + # --- Access Information (Use Constraints) --- + access_info = root.find("access-information") + if access_info is not None: + metadata["use_constraints"] = access_info.findtext("data-use-constraints") + + return metadata + + +def create_arcgis_metadata_xml(metadata, output_xml_path): + """ + Creates an ArcGIS metadata XML file from extracted metadata. + This function constructs a simplified ArcGIS metadata structure, + focusing on key elements mapped from InPort. + + Args: + metadata (dict): Dictionary containing metadata extracted from InPort. + output_xml_path (str): Absolute path to save the generated ArcGIS XML file. + """ + # Root element for ArcGIS metadata + root = ET.Element("metadata", attrib={"xml:lang": "en"}) + + # Esri block - many values are typically hardcoded or derived from the ArcGIS environment + esri_elem = ET.SubElement(root, "Esri") + esri_elem.append( + ET.Comment("These Esri-specific tags are placeholders and may need adjustment.") + ) + ET.SubElement(esri_elem, "CreaDate").text = "20230407" # Example creation date + ET.SubElement(esri_elem, "CreaTime").text = "16462600" # Example creation time + ET.SubElement(esri_elem, "ArcGISFormat").text = "1.0" + ET.SubElement(esri_elem, "SyncOnce").text = "FALSE" + # Add other Esri elements as needed based on your ArcGIS metadata standard + + # Data Identification Information + data_id_info = ET.SubElement(root, "dataIdInfo") + + # Citation + id_citation = ET.SubElement(data_id_info, "idCitation") + res_title = ET.SubElement(id_citation, "resTitle", attrib={"Sync": "TRUE"}) + res_title.text = metadata.get("title", "Untitled Resource from InPort") + + date_elem = ET.SubElement(id_citation, "date") + pub_date = ET.SubElement(date_elem, "pubDate") + # ArcGIS often expects YYYY-MM-DDTHH:MM:SS format for pubDate + # We take the date part from InPort's start_date and append a default time + pub_date.text = ( + metadata.get("start_date", "1900-01-01T00:00:00").split("T")[0] + "T00:00:00" + ) + + # Abstract and Purpose + id_abs = ET.SubElement(data_id_info, "idAbs") + id_abs.text = metadata.get("abstract", "No abstract provided in InPort XML.") + + id_purp = ET.SubElement(data_id_info, "idPurp") + id_purp.text = metadata.get("purpose", "No purpose provided in InPort XML.") + + # Keywords + search_keys = ET.SubElement(data_id_info, "searchKeys") + for keyword in metadata.get("keywords", []): + ET.SubElement(search_keys, "keyword").text = keyword + + # Theme Keys (often duplicates search keys in ArcGIS metadata, or uses a controlled vocabulary) + theme_keys = ET.SubElement(data_id_info, "themeKeys") + ET.SubElement( + ET.SubElement(theme_keys, "thesaLang"), "languageCode", attrib={"value": "eng"} + ) + for keyword in metadata.get("keywords", []): + ET.SubElement(theme_keys, "keyword").text = keyword + + # Use Constraints + res_const = ET.SubElement(data_id_info, "resConst") + consts = ET.SubElement(res_const, "Consts") + use_limit = ET.SubElement(consts, "useLimit") + use_limit.text = metadata.get( + "use_constraints", "No warranty expressed or implied. User assumes entire risk." + ) + + # Geographic Extent + data_ext = ET.SubElement(data_id_info, "dataExt") + geo_ele = ET.SubElement(data_ext, "geoEle") + geo_bnd_box = ET.SubElement( + geo_ele, "GeoBndBox", attrib={"esriExtentType": "search"} + ) + ET.SubElement(geo_bnd_box, "westBL", attrib={"Sync": "TRUE"}).text = metadata.get( + "west_bound", "-180" + ) + ET.SubElement(geo_bnd_box, "eastBL", attrib={"Sync": "TRUE"}).text = metadata.get( + "east_bound", "180" + ) + ET.SubElement(geo_bnd_box, "northBL", attrib={"Sync": "TRUE"}).text = metadata.get( + "north_bound", "90" + ) + ET.SubElement(geo_bnd_box, "southBL", attrib={"Sync": "TRUE"}).text = metadata.get( + "south_bound", "-90" + ) + ET.SubElement(geo_bnd_box, "exTypeCode").text = "1" + + # Temporal Extent + temp_ele = ET.SubElement(data_ext, "tempEle") + temp_extent = ET.SubElement(temp_ele, "TempExtent") + ex_temp = ET.SubElement(temp_extent, "exTemp") + tm_period = ET.SubElement(ex_temp, "TM_Period") + ET.SubElement(tm_period, "tmBegin").text = metadata.get("start_date", "UNKNOWN") + ET.SubElement(tm_period, "tmEnd").text = metadata.get("end_date", "UNKNOWN") + + # Point of Contact (idPoC) + poc_data = metadata.get("point_of_contact", {}) + if poc_data: + id_poc = ET.SubElement(data_id_info, "idPoC") + ET.SubElement(id_poc, "rpIndName").text = poc_data.get("name", "Unknown") + ET.SubElement(id_poc, "rpOrgName").text = "NMFS/OST/AMD" # Placeholder + ET.SubElement(id_poc, "rpPosName").text = ( + "Fisheries Science Coordinator" # Placeholder + ) + cnt_info = ET.SubElement(id_poc, "rpCntInfo") + cnt_address = ET.SubElement( + cnt_info, "cntAddress", attrib={"addressType": "both"} + ) + ET.SubElement(cnt_address, "delPoint").text = poc_data.get("address", "N/A") + ET.SubElement(cnt_address, "city").text = poc_data.get("city", "N/A") + ET.SubElement(cnt_address, "adminArea").text = poc_data.get("state", "N/A") + ET.SubElement(cnt_address, "postCode").text = poc_data.get("zip", "N/A") + ET.SubElement(cnt_address, "country").text = poc_data.get("country", "US") + ET.SubElement(cnt_address, "eMailAdd").text = poc_data.get( + "email", "unknown@noaa.gov" + ) + cnt_phone = ET.SubElement(cnt_info, "cntPhone") + ET.SubElement(cnt_phone, "voiceNum").text = poc_data.get("phone", "N/A") + ET.SubElement( + ET.SubElement(id_poc, "role"), "RoleCd", attrib={"value": "007"} + ) # Hardcoded role + + # Metadata Contact (mdContact) + md_contact_data = metadata.get("metadata_contact", {}) + if md_contact_data: + md_contact = ET.SubElement(root, "mdContact") + ET.SubElement(md_contact, "rpIndName").text = md_contact_data.get( + "name", "Unknown" + ) + ET.SubElement(md_contact, "rpOrgName").text = ( + "NMFS Office of Science and Technology" # Placeholder + ) + ET.SubElement(md_contact, "rpPosName").text = "GIS Specialist" # Placeholder + cnt_info = ET.SubElement(md_contact, "rpCntInfo") + cnt_address = ET.SubElement( + cnt_info, "cntAddress", attrib={"addressType": "both"} + ) + ET.SubElement(cnt_address, "delPoint").text = md_contact_data.get( + "address", "N/A" + ) + ET.SubElement(cnt_address, "city").text = md_contact_data.get("city", "N/A") + ET.SubElement(cnt_address, "adminArea").text = md_contact_data.get( + "state", "N/A" + ) + ET.SubElement(cnt_address, "postCode").text = md_contact_data.get("zip", "N/A") + ET.SubElement(cnt_address, "eMailAdd").text = md_contact_data.get( + "email", "unknown@noaa.gov" + ) + cnt_phone = ET.SubElement(cnt_info, "cntPhone") + ET.SubElement(cnt_phone, "voiceNum").text = md_contact_data.get("phone", "N/A") + ET.SubElement( + ET.SubElement(md_contact, "role"), "RoleCd", attrib={"value": "011"} + ) # Hardcoded role + + # Add other mandatory ArcGIS metadata elements with default/placeholder values + # These are often static or derived from the ArcGIS environment/template + ET.SubElement(ET.SubElement(root, "mdChar"), "CharSetCd", attrib={"value": "004"}) + ET.SubElement(root, "mdDateSt", attrib={"Sync": "TRUE"}).text = ( + "20230401" # Example date + ) + ET.SubElement(root, "mdFileID").text = "gov.noaa.nmfs.inport:" # Placeholder + md_lang = ET.SubElement(root, "mdLang") + ET.SubElement(md_lang, "languageCode", attrib={"value": "eng"}) + ET.SubElement(md_lang, "countryCode", attrib={"value": "US"}) + md_maint = ET.SubElement(root, "mdMaint") + ET.SubElement( + ET.SubElement(ET.SubElement(md_maint, "maintFreq"), "MaintFreqCd"), "value" + ).text = "009" + md_hrlv = ET.SubElement(root, "mdHrLv") + ET.SubElement(ET.SubElement(md_hrlv, "ScopeCd"), "value").text = "005" + ET.SubElement(root, "mdHrLvName", attrib={"Sync": "TRUE"}).text = "dataset" + + # Pretty print and save the XML + rough_string = ET.tostring(root, "utf-8") + reparsed = minidom.parseString(rough_string) + pretty_xml_as_string = reparsed.toprettyxml(indent=" ") + + try: + with open(output_xml_path, "w", encoding="utf-8") as f: + f.write(pretty_xml_as_string) + print(f"Generated ArcGIS metadata saved to: {output_xml_path}") + except IOError as e: + print(f"Error writing ArcGIS XML file {output_xml_path}: {e}") + + +# --- Example Usage --- +if __name__ == "__main__": + inport_file_path = r"c:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\April 1 2023\scratch\InPort_66799.xml" + output_arcgis_file_path = r"c:\Users\john.f.kennedy\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\April 1 2023\scratch\Generated_ArcGIS_Metadata.xml" + + # Ensure the output directory exists + output_dir = os.path.dirname(output_arcgis_file_path) + if not os.path.exists(output_dir): + os.makedirs(output_dir) + + # 1. Extract metadata from the InPort XML + print(f"Parsing InPort XML from: {inport_file_path}") + extracted_metadata = parse_inport_xml(inport_file_path) + + if extracted_metadata: + # 2. Create the ArcGIS metadata XML + print(f"Creating ArcGIS metadata XML to: {output_arcgis_file_path}") + create_arcgis_metadata_xml(extracted_metadata, output_arcgis_file_path) + else: + print( + "Failed to extract metadata from InPort XML. No ArcGIS metadata generated." + ) + +# This is an autogenerated comment. diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_base_bathymetry.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_base_bathymetry.py deleted file mode 100644 index 5d6982f..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_base_bathymetry.py +++ /dev/null @@ -1,773 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: create_base_bathymetry -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 05/03/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback -import importlib -import inspect - -import arcpy # third-parties second - -def raster_properties_report(dataset=""): - try: - if not dataset: - arcpy.AddWarning(f"{dataset} is missing") - else: - pixel_types = {"U1" : "1 bit", "U2" : "2 bits", "U4" : "4 bits", - "U8" : "Unsigned 8-bit integers", "S8" : "8-bit integers", - "U16" : "Unsigned 16-bit integers", "S16" : "16-bit integers", - "U32" : "Unsigned 32-bit integers", "S32" : "32-bit integers", - "F32" : "Single-precision floating point", - "F64" : "Double-precision floating point",} - - raster = arcpy.Raster(dataset) - - arcpy.AddMessage(f"\t\t {raster.name}") - arcpy.AddMessage(f"\t\t\t Spatial Reference: {raster.spatialReference.name}") - arcpy.AddMessage(f"\t\t\t XYResolution: {raster.spatialReference.XYResolution} {raster.spatialReference.linearUnitName}s") - arcpy.AddMessage(f"\t\t\t XYTolerance: {raster.spatialReference.XYTolerance} {raster.spatialReference.linearUnitName}s") - arcpy.AddMessage(f"\t\t\t Extent: {raster.extent.XMin} {raster.extent.YMin} {raster.extent.XMax} {raster.extent.YMax} (XMin, YMin, XMax, YMax)") - arcpy.AddMessage(f"\t\t\t Cell Size: {raster.meanCellHeight}, {raster.meanCellWidth} (H, W)") - arcpy.AddMessage(f"\t\t\t Rows, Columns: {raster.height} {raster.width} (H, W)") - arcpy.AddMessage(f"\t\t\t Statistics: {raster.minimum} {raster.maximum} {raster.mean} {raster.standardDeviation} (Min, Max, Mean, STD)") - arcpy.AddMessage(f"\t\t\t Pixel Type: {pixel_types[raster.pixelType]}") - - del raster - del pixel_types - del dataset - - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: - arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##") - else: - pass - del rk - return True - finally: - pass - -def create_alasaka_bathymetry(project_folder=""): - try: - # Imports - from dismap_tools import check_transformation - - # Set History and Metadata logs, set serverity and message level - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic workkpace variables - arcpy.env.workspace = rf"{project_folder}\Bathymetry\Bathymetry.gdb" - arcpy.env.scratchWorkspace = rf"{project_folder}\Scratch\scratch.gdb" - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - arcpy.env.cellSize = 1000 - - arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR DEFAULT 75 NO_SKIP" - arcpy.env.rasterStatistics = "STATISTICS 1 1" - arcpy.env.resamplingMethod = "BILINEAR" - - arcpy.env.outputCoordinateSystem = None - - arcpy.AddMessage(f"Processing Alaska Bathymetry") - -# ###--->>> Setting up the base folder bathymetry for all projects - # Set Alaska Bathymetry - - ai_bathy = rf"{project_folder}\Bathymetry\Alaska Bathymetry\AI_IDW_Bathy.grd" # ASCII GRIDs - ebs_bathy = rf"{project_folder}\Bathymetry\Alaska Bathymetry\EBS_IDW_Bathy.grd" # ASCII GRIDs - goa_bathy = rf"{project_folder}\Bathymetry\Alaska Bathymetry\GOA_IDW_Bathy.grd" # ASCII GRIDs - - ai_bathy_grid = rf"{project_folder}\Bathymetry\Bathymetry.gdb\AI_IDW_Bathy_Grid" # ASCII GRIDs imported to the FGDB - ebs_bathy_grid = rf"{project_folder}\Bathymetry\Bathymetry.gdb\EBS_IDW_Bathy_Grid" # ASCII GRIDs imported to the FGDB - goa_bathy_grid = rf"{project_folder}\Bathymetry\Bathymetry.gdb\GOA_IDW_Bathy_Grid" # ASCII GRIDs imported to the FGDB - - ai_bathy_raster = rf"{project_folder}\Bathymetry\Bathymetry.gdb\AI_IDW_Bathy_Raster" - ebs_bathy_raster = rf"{project_folder}\Bathymetry\Bathymetry.gdb\EBS_IDW_Bathy_Raster" - goa_bathy_raster = rf"{project_folder}\Bathymetry\Bathymetry.gdb\GOA_IDW_Bathy_Raster" - - ai_bathymetry = rf"{project_folder}\Bathymetry\Bathymetry.gdb\AI_IDW_Bathymetry" - ebs_bathymetry = rf"{project_folder}\Bathymetry\Bathymetry.gdb\EBS_IDW_Bathymetry" - goa_bathymetry = rf"{project_folder}\Bathymetry\Bathymetry.gdb\GOA_IDW_Bathymetry" - enbs_bathymetry = rf"{project_folder}\Bathymetry\Bathymetry.gdb\ENBS_IDW_Bathymetry" - nbs_bathymetry = rf"{project_folder}\Bathymetry\Bathymetry.gdb\NBS_IDW_Bathymetry" - - arcpy.AddMessage(f"Processing Esri Raster Grids") - - spatial_ref = arcpy.Describe(ai_bathy).spatialReference.name - arcpy.AddMessage(f"Spatial Reference for {os.path.basename(ai_bathy)}: {spatial_ref}") - - spatial_ref = arcpy.Describe(ai_bathy).spatialReference - # Set Output Coordinate System - arcpy.env.outputCoordinateSystem = spatial_ref - - if spatial_ref.linearUnitName == "Kilometer": - arcpy.env.cellSize = 1 - arcpy.env.XYResolution = 0.1 - arcpy.env.XYResolution = 1.0 - elif spatial_ref.linearUnitName == "Meter": - arcpy.env.cellSize = 1000 - arcpy.env.XYResolution = 0.0001 - arcpy.env.XYResolution = 0.001 - - del spatial_ref - - arcpy.AddMessage(f"Copy AI_IDW_Bathy.grd to AI_IDW_Bathy_Grid") - - arcpy.management.CopyRaster(ai_bathy, ai_bathy_grid) - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - del ai_bathy - - arcpy.AddMessage(f"Copy EBS_IDW_Bathy.grd to EBS_IDW_Bathy_Grid") - - arcpy.management.CopyRaster(ebs_bathy, ebs_bathy_grid) - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - del ebs_bathy - - arcpy.AddMessage(f"Copy GOA_IDW_Bathy.grd to GOA_IDW_Bathy_Grid") - - arcpy.management.CopyRaster(goa_bathy, goa_bathy_grid) - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - del goa_bathy - - arcpy.AddMessage(f"Converting AI_IDW_Bathy_Grid from positive values to negative") - - tmp_grid = arcpy.sa.Times(ai_bathy_grid, -1) - arcpy.AddMessage("\tTimes: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - tmp_grid.save(ai_bathy_raster) - del tmp_grid - - arcpy.AddMessage(f"Converting EBS_IDW_Bathy_Grid from positive values to negative") - - tmp_grid = arcpy.sa.Times(ebs_bathy_grid, -1) - arcpy.AddMessage("\tTimes: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - tmp_grid.save(ebs_bathy_raster) - del tmp_grid - - arcpy.AddMessage(f"Setting values equal to and less than 0 in the GOA_IDW_Bathy_Grid Null values") - - tmp_grid = arcpy.sa.SetNull(goa_bathy_grid, goa_bathy_grid, "Value < -1.0") - arcpy.AddMessage("\tSet Null: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - tmp_grid.save(goa_bathy_raster+'_SetNull') - del tmp_grid - - arcpy.AddMessage(f"Converting the GOA_IDW_Bathy_Grid from positive values to negative") - - tmp_grid = arcpy.sa.Times(goa_bathy_raster+'_SetNull', -1) - arcpy.AddMessage("\tTimes: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - tmp_grid.save(goa_bathy_raster) - del tmp_grid - - arcpy.AddMessage(f"Deleteing the GOA_IDW_Bathy Null grid") - - arcpy.management.Delete(goa_bathy_raster+'_SetNull') - arcpy.AddMessage("\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.AddMessage(f"Appending the AI raster to the GOA grid to ensure complete coverage") - - extent = arcpy.Describe(goa_bathy_raster).extent - X_Min, Y_Min, X_Max, Y_Max = extent.XMin-(1000 * 366), extent.YMin-(1000 * 80), extent.XMax, extent.YMax - extent = f"{X_Min} {Y_Min} {X_Max} {Y_Max}" - arcpy.env.extent = extent - - arcpy.management.Append(inputs = ai_bathy_raster, target = goa_bathy_raster, schema_type="TEST", field_mapping="", subtype="") - arcpy.AddMessage("\tAppend: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.AddMessage(f"Cliping GOA Raster") - - arcpy.management.Clip(goa_bathy_raster, extent, goa_bathy_raster+"_Clip") - arcpy.AddMessage("\tClip: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del extent - - arcpy.AddMessage(f"Copying GOA Raster") - - arcpy.management.CopyRaster(goa_bathy_raster+"_Clip", goa_bathy_raster) - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.management.Delete(goa_bathy_raster+"_Clip") - arcpy.AddMessage("\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.AddMessage(f"Appending the EBS raster to the AI grid to ensure complete coverage") - - extent = arcpy.Describe(ai_bathy_raster).extent - X_Min, Y_Min, X_Max, Y_Max = extent.XMin, extent.YMin, extent.XMax, extent.YMax - extent = f"{X_Min} {Y_Min} {X_Max} {Y_Max}" - arcpy.env.extent = extent - del X_Min, Y_Min, X_Max, Y_Max - - arcpy.management.Append(inputs = ebs_bathy_raster, target = ai_bathy_raster, schema_type="TEST", field_mapping="", subtype="") - arcpy.AddMessage("\tAppend: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.AddMessage(f"Cliping AI Raster") - - arcpy.management.Clip(ai_bathy_raster, extent, ai_bathy_raster+"_Clip") - arcpy.AddMessage("\tClip: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del extent - - arcpy.AddMessage(f"Copying AI Raster") - - arcpy.management.CopyRaster(ai_bathy_raster+"_Clip", ai_bathy_raster) - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.management.Delete(ai_bathy_raster+"_Clip") - arcpy.AddMessage("\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.ClearEnvironment("extent") - - # ###--->>> Final copy of rasters in Base Folder Start - - # Get the reference system defined for the region in datasets - # Set the output coordinate system to what is needed for the - # DisMAP project - region = "AI_IDW" - arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(rf"{project_folder}\Dataset Shapefiles\{region}\{region}_Region.prj") - #arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" - #arcpy.env.geographicTransformations = check_transformation(goa_bathy_raster, region_sr) - #del region_sr - del region - - arcpy.AddMessage(f"Copy AI_IDW_Bathymetry_Raster to AI_IDW_Bathymetry") - - arcpy.management.CopyRaster(ai_bathy_raster, ai_bathymetry) - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - # Get the reference system defined for the region in datasets - # Set the output coordinate system to what is needed for the - # DisMAP project - region = "EBS_IDW" - arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(rf"{project_folder}\Dataset Shapefiles\{region}\{region}_Region.prj") - #arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" - #arcpy.env.geographicTransformations = check_transformation(goa_bathy_raster, region_sr) - #del region_sr - del region - - arcpy.AddMessage(f"Copy EBS_IDW_Bathymetry_Raster to EBS_IDW_Bathymetry") - - arcpy.management.CopyRaster(ebs_bathy_raster, ebs_bathymetry) - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - # Get the reference system defined for the region in datasets - # Set the output coordinate system to what is needed for the - # DisMAP project - region = "ENBS_IDW" - arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(rf"{project_folder}\Dataset Shapefiles\{region}\{region}_Region.prj") - #arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" - #arcpy.env.geographicTransformations = check_transformation(goa_bathy_raster, region_sr) - #del region_sr - del region - - arcpy.AddMessage(f"Copy EBS_IDW_Bathymetry_Raster to ENBS_Bathymetry") - - arcpy.management.CopyRaster(ebs_bathy_raster, enbs_bathymetry) - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - # Get the reference system defined for the region in datasets - # Set the output coordinate system to what is needed for the - # DisMAP project - region = "NBS_IDW" - arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(rf"{project_folder}\Dataset Shapefiles\{region}\{region}_Region.prj") - #arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" - #arcpy.env.geographicTransformations = check_transformation(goa_bathy_raster, region_sr) - #del region_sr - del region - - arcpy.AddMessage(f"Copy EBS_IDW_Bathymetry_Raster to NBS_Bathymetry") - - arcpy.management.CopyRaster(ebs_bathy_raster, nbs_bathymetry) - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - # Get the reference system defined for the region in datasets - # Set the output coordinate system to what is needed for the - # DisMAP project - region = "GOA_IDW" - arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(rf"{project_folder}\Dataset Shapefiles\{region}\{region}_Region.prj") - #arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" - #arcpy.env.geographicTransformations = check_transformation(goa_bathy_raster, region_sr) - #del region_sr - del region - - arcpy.AddMessage(f"Copy GOA_IDW_Bathymetry_Raster to GOA_IDW_Bathymetry") - - arcpy.management.CopyRaster(goa_bathy_raster, goa_bathymetry) - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - del ai_bathy_grid, ebs_bathy_grid, goa_bathy_grid - del ai_bathy_raster, ebs_bathy_raster, goa_bathy_raster - - # ###--->>> Final copy of rasters in Base Folder End - - # ###--->>> Copy rasters for Base Folder to Project Folder Start - - # Set Output Coordinate System - arcpy.env.outputCoordinateSystem = arcpy.Describe(ai_bathymetry).spatialReference - - arcpy.AddMessage(f"Copy AI_IDW_Bathymetry to the Project Bathymetry GDB") - arcpy.management.CopyRaster(ai_bathymetry, rf"{project_folder}\Bathymetry\Bathymetry.gdb\{os.path.basename(ai_bathymetry)}") - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - # Set Output Coordinate System - arcpy.env.outputCoordinateSystem = arcpy.Describe(ebs_bathymetry).spatialReference - - arcpy.AddMessage(f"Copy EBS_IDW_Bathymetry to the Project Bathymetry GDB") - arcpy.management.CopyRaster(ebs_bathymetry, rf"{project_folder}\Bathymetry\Bathymetry.gdb\{os.path.basename(ebs_bathymetry)}") - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - # Set Output Coordinate System - arcpy.env.outputCoordinateSystem = arcpy.Describe(enbs_bathymetry).spatialReference - - arcpy.AddMessage(f"Copy ENBS_IDW_Bathymetry to the Project Bathymetry GDB") - arcpy.management.CopyRaster(enbs_bathymetry, rf"{project_folder}\Bathymetry\Bathymetry.gdb\{os.path.basename(enbs_bathymetry)}") - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - # Set Output Coordinate System - arcpy.env.outputCoordinateSystem = arcpy.Describe(nbs_bathymetry).spatialReference - - arcpy.AddMessage(f"Copy nbs_bathymetry to the Project Bathymetry GDB") - arcpy.management.CopyRaster(nbs_bathymetry, rf"{project_folder}\Bathymetry\Bathymetry.gdb\{os.path.basename(nbs_bathymetry)}") - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - # Set Output Coordinate System - arcpy.env.outputCoordinateSystem = arcpy.Describe(goa_bathymetry).spatialReference - - arcpy.AddMessage(f"Copy GOA_IDW_Bathymetry to the Project Bathymetry GDB") - arcpy.management.CopyRaster(goa_bathymetry, rf"{project_folder}\Bathymetry\Bathymetry.gdb\{os.path.basename(goa_bathymetry)}") - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - gdb = rf"{project_folder}\Bathymetry\Bathymetry.gdb" - arcpy.AddMessage(f"Compacting the {os.path.basename(gdb)} GDB") - arcpy.management.Compact(gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - del gdb - - gdb = rf"{project_folder}\Bathymetry\Bathymetry.gdb" - arcpy.AddMessage(f"Compacting the {os.path.basename(gdb)} GDB") - arcpy.management.Compact(gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - del gdb - - # Imports - del check_transformation - # Declared Variables for this function only - del ai_bathymetry, ebs_bathymetry, goa_bathymetry, enbs_bathymetry, nbs_bathymetry - # Function parameter - del project_folder - - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: - arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##") - else: - pass - del rk - return True - finally: - pass - -def create_hawaii_bathymetry(project_folder=""): - try: - # Set History and Metadata logs, set serverity and message level - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic workkpace variables - arcpy.env.workspace = rf"{project_folder}\Bathymetry\Bathymetry.gdb" - arcpy.env.scratchWorkspace = rf"{project_folder}\Scratch\scratch.gdb" - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - arcpy.env.cellSize = 500 - - arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR DEFAULT 75 NO_SKIP" - arcpy.env.rasterStatistics = "STATISTICS 1 1" - arcpy.env.resamplingMethod = "BILINEAR" - - arcpy.env.outputCoordinateSystem = None - - hi_bathy_grid = rf"{project_folder}\Bathymetry\Hawaii Bathymetry\BFISH_PSU.shp" - hi_bathy_raster = rf"{project_folder}\Bathymetry\Bathymetry.gdb\HI_IDW_Bathy_Raster" - hi_bathymetry = rf"{project_folder}\Bathymetry\Bathymetry.gdb\HI_IDW_Bathymetry" - - arcpy.AddMessage(f"Converting Hawaii Polygon Grid to a Raster") - - arcpy.conversion.PolygonToRaster(in_features = hi_bathy_grid, value_field = "Depth_MEDI", out_rasterdataset = hi_bathy_raster, cell_assignment="CELL_CENTER", priority_field="NONE", cellsize="500") - arcpy.AddMessage("\tPolygon To Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - tmp_grid = arcpy.sa.Times(hi_bathy_raster, -1.0) - arcpy.AddMessage("\tTimes: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - tmp_grid.save(hi_bathymetry) - del tmp_grid - - arcpy.AddMessage(f"Copy Hawaii Raster to the Bathymetry GDB") - - arcpy.management.CopyRaster(hi_bathymetry, rf"{project_folder}\Bathymetry\Bathymetry.gdb\HI_IDW_Bathymetry") - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - gdb = rf"{project_folder}\Bathymetry\Bathymetry.gdb" - arcpy.AddMessage(f"Compacting the {os.path.basename(gdb)} GDB") - arcpy.management.Compact(gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - del gdb - - gdb = rf"{project_folder}\Bathymetry\Bathymetry.gdb" - arcpy.AddMessage(f"Compacting the {os.path.basename(gdb)} GDB") - arcpy.management.Compact(gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - del gdb - - # Declared Variables for this function only - del hi_bathy_grid, hi_bathy_raster, hi_bathymetry - # Function parameter - del project_folder - - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: - arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##") - else: - pass - del rk - return True - finally: - pass - -def gebco_bathymetry(project_folder=""): - try: - - # Imports - from dismap_tools import check_transformation - - # Set History and Metadata logs, set serverity and message level - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic workkpace variables - arcpy.env.workspace = rf"{project_folder}\Bathymetry\Bathymetry.gdb" - arcpy.env.scratchWorkspace = rf"{project_folder}\Scratch\scratch.gdb" - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - arcpy.env.cellSize = 1000 - - arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR DEFAULT 75 NO_SKIP" - arcpy.env.rasterStatistics = "STATISTICS 1 1" - arcpy.env.resamplingMethod = "BILINEAR" - - arcpy.env.outputCoordinateSystem = None - - arcpy.AddMessage(f"Processing GEBCO Raster Grids") - - #gebco_dict = get_dms_points_for_gebco(project_gdb) - gebco_dict = { - 'GMEX_IDW' : 'gebco_2022_n30.6_s25.8_w-97.4_e-81.6.asc', - 'NEUS_FAL_IDW' : 'gebco_2022_n44.8_s35.0_w-75.8_e-65.4.asc', - 'NEUS_SPR_IDW' : 'gebco_2022_n44.8_s35.0_w-75.8_e-65.4.asc', - 'SEUS_FAL_IDW' : 'gebco_2022_n35.4_s28.6_w-81.4_e-75.6.asc', - 'SEUS_SPR_IDW' : 'gebco_2022_n35.4_s28.6_w-81.4_e-75.6.asc', - 'SEUS_SUM_IDW' : 'gebco_2022_n35.4_s28.6_w-81.4_e-75.6.asc', - 'WC_ANN_IDW' : 'gebco_2022_n48.6_s32.0_w-126.0_e-115.8.asc', - 'WC_TRI_IDW' : 'gebco_2022_n49.2_s36.0_w-126.6_e-121.6.asc', - } - - arcpy.AddMessage(f"Processing Regions") - # Start looping over the datasets array as we go region by region. - for table_name in gebco_dict: - gebco_file_name = gebco_dict[table_name] - - gebco_grid = rf"{project_folder}\Bathymetry\GEBCO Bathymetry\{gebco_file_name}" - bathy_grid = rf"{project_folder}\Bathymetry\Bathymetry.gdb\{table_name}_Bathy_Grid" - bathy_raster = rf"{project_folder}\Bathymetry\Bathymetry.gdb\{table_name}_Bathy_Raster" - bathymetry = rf"{project_folder}\Bathymetry\Bathymetry.gdb\{table_name}_Bathymetry" - - arcpy.AddMessage(f"Copy GEBCO File: {os.path.basename(gebco_grid)} to {os.path.basename(bathy_grid)}") - - # Execute ASCIIToRaster - arcpy.conversion.ASCIIToRaster(gebco_grid, bathy_grid, "FLOAT") - arcpy.AddMessage("\tASCII To Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.AddMessage(f"Define projection for {os.path.basename(bathy_grid)}") - - arcpy.management.DefineProjection(bathy_grid, gebco_grid.replace('.asc', '.prj')) - arcpy.AddMessage("\tDefine Projection: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.AddMessage(f"Project Raster to create: {os.path.basename(bathy_raster)}") - - # Get the reference system defined for the region in datasets - # Set the output coordinate system to what is needed for the - # DisMAP project - region_sr = arcpy.SpatialReference(rf"{project_folder}\Dataset Shapefiles\{table_name}\{table_name}_Region.prj") - - if region_sr.linearUnitName == "Kilometer": - arcpy.env.cellSize = 0.1 - arcpy.env.XYResolution = 0.0001 - arcpy.env.XYResolution = 0.001 - elif region_sr.linearUnitName == "Meter": - arcpy.env.cellSize = 1000 - arcpy.env.XYResolution = 0.0001 - arcpy.env.XYResolution = 0.001 - - arcpy.env.outputCoordinateSystem = region_sr - #arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" - transform = check_transformation(bathy_grid, region_sr) - arcpy.env.geographicTransformations = transform - - arcpy.AddMessage(f"\tOut Spatial Reference: {region_sr.name}") - arcpy.AddMessage(f"\tGeographic Transformations: {transform}") - - # Project Raster management - arcpy.management.ProjectRaster(in_raster = bathy_grid, out_raster = bathy_raster, out_coor_system = region_sr) - arcpy.AddMessage("\tProject Raster: {0}".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - # Cleanup after last use - del region_sr, transform - - arcpy.AddMessage(f"Set Null for positive elevation values to create: {os.path.basename(bathymetry)}") - with arcpy.EnvManager(scratchWorkspace=arcpy.env.scratchGDB, workspace=arcpy.env.workspace): - out_raster = arcpy.sa.SetNull( - in_conditional_raster = bathy_raster, - in_false_raster_or_constant = bathy_raster, - where_clause="Value > 1.0" - ) - arcpy.AddMessage("\tSet Null: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - out_raster.save(bathymetry) - del out_raster - - del gebco_grid, bathy_grid, bathy_raster, bathymetry - del gebco_file_name, table_name - - del gebco_dict - - gdb = rf"{project_folder}\Bathymetry\Bathymetry.gdb" - arcpy.AddMessage(f"Compacting the {os.path.basename(gdb)} GDB") - arcpy.management.Compact(gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - del gdb - - # Declared Variables for this function only - - # Imports - del check_transformation - # Function parameter - del project_folder - - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: - arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##") - else: - pass - del rk - return True - finally: - pass - -def main(project_folder=""): - try: - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - # Create Scratch Workspace for Project - if not arcpy.Exists(rf"{project_folder}\Scratch\scratch.gdb"): - if not arcpy.Exists(rf"{project_folder}\Scratch"): - os.makedirs(rf"{project_folder}\Scratch") - if not arcpy.Exists(rf"{project_folder}\Scratch\scratch.gdb"): - arcpy.management.CreateFileGDB(rf"{project_folder}\Scratch", f"scratch") - - # Base Bathymetry Folder - if not os.path.isdir(rf"{project_folder}\Bathymetry"): - arcpy.AddMessage("Create Folder: 'Bathymetry'") - arcpy.management.CreateFolder(rf"{project_folder}\Bathymetry") - get_messages = "\t" + arcpy.GetMessages().replace('\n', '\n\t') + "\n" - arcpy.AddMessage(f"{get_messages}") - del get_messages - else: - pass - # Base Bathymetry GDB - if not arcpy.Exists(rf"{project_folder}\Bathymetry\Bathymetry.gdb"): - arcpy.AddMessage("Create File GDB: 'Bathymetry.gdb'") - arcpy.management.CreateFileGDB(rf"{project_folder}\Bathymetry", "Bathymetry") - get_messages = "\t" + arcpy.GetMessages().replace('\n', '\n\t') + "\n" - arcpy.AddMessage(f"{get_messages}") - del get_messages - else: - pass - - test = True - # Process base Alaska bathymetry - if test: - result = create_alasaka_bathymetry(project_folder) - #arcpy.AddMessage(result) - del result - else: - pass - - #test = True - # Process base Hawaii bathymetry - if test: - result = create_hawaii_bathymetry(project_folder) - #arcpy.AddMessage(result) - del result - else: - pass - - #test = False - # Process base GEBCO bathymetry - if test: - result = gebco_bathymetry(project_folder) - #arcpy.AddMessage(result) - del result - else: - pass - - del test - - # Declared Varaiables - - # Imports - - # Function Parameters - del project_folder - - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}") - arcpy.AddMessage(u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time)))) - arcpy.AddMessage(f"{'-' * 80}") - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - else: - return True - finally: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: - arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##") - else: - pass - del rk - -if __name__ == '__main__': - try: - arcgis_folder = rf"{os.path.expanduser('~')}\Documents\ArcGIS" - sys.path.append(arcgis_folder) - - project_folder = arcpy.GetParameterAsText(0) - - if not project_folder: - project_folder = rf"{arcgis_folder}\Projects\DisMAP\ArcGIS-Analysis-Python" - else: - pass - - result = main(project_folder) - arcpy.SetParameterAsText(1, result) - del result - - # Declared Variables - del project_folder, arcgis_folder - - except: - arcpy.AddMessage(arcpy.GetMessages(0)) - traceback.print_exc() - else: - pass - #print(f"Remaining Keys: ##--> '{', '.join([key for key in locals().keys() if not key.startswith('__')])}' <--##") - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_data_dictionary_json_files.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_data_dictionary_json_files.py deleted file mode 100644 index c7c4b21..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_data_dictionary_json_files.py +++ /dev/null @@ -1,2231 +0,0 @@ -""" -Script documentation - -- Tool parameters are accessed using arcpy.GetParameter() or - arcpy.GetParameterAsText() -- Update derived parameter values using arcpy.SetParameter() or - arcpy.SetParameterAsText() -""" -import arcpy, os -import traceback - -def script_tool(project_gdb=""): - """Script code goes below""" - try: - # Imports - # Use all of the cores on the machine - arcpy.env.parallelProcessingFactor = "100%" - arcpy.env.overwriteOutput = True - - # Define variables - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - scratch_gdb = rf"{scratch_folder}\scratch.gdb" - - # Set the workspace environment to local file geodatabase - arcpy.env.workspace = project_gdb - # Set the scratchWorkspace environment to local file geodatabase - arcpy.env.scratchWorkspace = scratch_gdb - # Clean-up variables - del scratch_folder, scratch_gdb - - arcpy.AddMessage(f"\n{'--Start' * 10}--\n") - arcpy.AddMessage(f"Creating Table and Field definitions for: {os.path.basename(project_gdb)}") - - field_definitions = { - "CSVFile": { - "field_aliasName": "CSV File", - "field_baseName": "CSVFile", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 20, - "field_name": "CSVFile", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "CSV File", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "CSV File" - } - }, - "Category": { - "field_aliasName": "Category", - "field_baseName": "Category", - "field_defaultValue": "null", - "field_domain": "MosaicCatalogItemCategoryDomain", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 4, - "field_name": "Category", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Integer", - "field_attrdef": "Category", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Category" - } - }, - "CellSize": { - "field_aliasName": "Cell Size", - "field_baseName": "CellSize", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 4, - "field_name": "CellSize", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Cell Size", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Cell Size" - } - }, - "CenterOfGravityDepth": { - "field_aliasName": "Center of Gravity Depth", - "field_baseName": "CenterOfGravityDepth", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "CenterOfGravityDepth", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Center of Gravity Depth", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Center of Gravity Depth" - } - }, - "CenterOfGravityDepthSE": { - "field_aliasName": "Center of Gravity Depth Standard Error", - "field_baseName": "CenterOfGravityDepthSE", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "CenterOfGravityDepthSE", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Center of Gravity Depth Standard Error", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Center of Gravity Depth Standard Error" - } - }, - "CenterOfGravityLatitude": { - "field_aliasName": "Center of Gravity Latitude", - "field_baseName": "CenterOfGravityLatitude", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "CenterOfGravityLatitude", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Center of Gravity Latitude", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Center of Gravity Latitude" - } - }, - "CenterOfGravityLatitudeSE": { - "field_aliasName": "Center of Gravity Latitude Standard Error", - "field_baseName": "CenterOfGravityLatitudeSE", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "CenterOfGravityLatitudeSE", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Center of Gravity Latitude Standard Error", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Center of Gravity Latitude Standard Error" - } - }, - "CenterOfGravityLongitude": { - "field_aliasName": "Center of Gravity Longitude", - "field_baseName": "CenterOfGravityLongitude", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "CenterOfGravityLongitude", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Center of Gravity Longitude", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Center of Gravity Longitude" - } - }, - "CenterOfGravityLongitudeSE": { - "field_aliasName": "Center of Gravity Longitude Standard Error", - "field_baseName": "CenterOfGravityLongitudeSE", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "CenterOfGravityLongitudeSE", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Center of Gravity Longitude Standard Error", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Center of Gravity Longitude Standard Error" - } - }, - "CenterX": { - "field_aliasName": "CenterX", - "field_baseName": "CenterX", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "CenterX", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "CenterX", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "CenterX" - } - }, - "CenterY": { - "field_aliasName": "CenterY", - "field_baseName": "CenterY", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "CenterY", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "CenterY", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "CenterY" - } - }, - "CommonName": { - "field_aliasName": "Common Name", - "field_baseName": "CommonName", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 40, - "field_name": "CommonName", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Common Name", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Common Name" - } - }, - "CommonNameSpecies": { - "field_aliasName": "Common Name (Species)", - "field_baseName": "CommonNameSpecies", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 90, - "field_name": "CommonNameSpecies", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Common Name (Species)", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Common Name (Species)" - } - }, - "CoreSpecies": { - "field_aliasName": "Core Species", - "field_baseName": "CoreSpecies", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 5, - "field_name": "CoreSpecies", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Core Species", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Core Species" - } - }, - "Count": { - "field_aliasName": "Count", - "field_baseName": "Count", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "false", - "field_isNullable": "true", - "field_length": 8, - "field_name": "Count", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Count", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Count" - } - }, - "DataCitation": { - "field_aliasName": "Data Citation", - "field_baseName": "DataCitation", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 255, - "field_name": "DataCitation", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Data Citation", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Data Citation" - } - }, - "DataFilteringNotes": { - "field_aliasName": "Data Filtering Notes", - "field_baseName": "DataFilteringNotes", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 150, - "field_name": "DataFilteringNotes", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Data Filtering Notes", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Data Filtering Notes" - } - }, - "DataSource": { - "field_aliasName": "Data Source", - "field_baseName": "DataSource", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 100, - "field_name": "DataSource", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Data Source", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Data Source" - } - }, - "DatasetCode": { - "field_aliasName": "Dataset Code", - "field_baseName": "DatasetCode", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 50, - "field_name": "DatasetCode", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Dataset Code", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Dataset Code" - } - }, - "DateCode": { - "field_aliasName": "Date Code", - "field_baseName": "DateCode", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 20, - "field_name": "DateCode", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Date Code", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Date Code" - } - }, - "Depth": { - "field_aliasName": "Depth", - "field_baseName": "Depth", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "Depth", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Depth", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Depth" - } - }, - "Dimensions": { - "field_aliasName": "Dimensions", - "field_baseName": "Dimensions", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 10, - "field_name": "Dimensions", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Dimensions", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Dimensions" - } - }, - "DistributionProjectCode": { - "field_aliasName": "Distribution Project Code", - "field_baseName": "DistributionProjectCode", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 10, - "field_name": "DistributionProjectCode", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Distribution Project Code", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Distribution Project Code" - } - }, - "DistributionProjectName": { - "field_aliasName": "Distribution Project Name", - "field_baseName": "DistributionProjectName", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 60, - "field_name": "DistributionProjectName", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Distribution Project Name", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Distribution Project Name" - } - }, - "Easting": { - "field_aliasName": "Easting", - "field_baseName": "Easting", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "Easting", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Easting", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Easting" - } - }, - "FeatureClassName": { - "field_aliasName": "Feature Class Name", - "field_baseName": "FeatureClassName", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 60, - "field_name": "FeatureClassName", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Feature Class Name", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Feature Class Name" - } - }, - "FeatureServiceName": { - "field_aliasName": "Feature Service Name", - "field_baseName": "FeatureServiceName", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 60, - "field_name": "FeatureServiceName", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Feature Service Name", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Feature Service Name" - } - }, - "FeatureServiceTitle": { - "field_aliasName": "Feature Service Title", - "field_baseName": "FeatureServiceTitle", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 80, - "field_name": "FeatureServiceTitle", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Feature Service Title", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Feature Service Title" - } - }, - "FilterRegion": { - "field_aliasName": "Filter Region", - "field_baseName": "FilterRegion", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 25, - "field_name": "FilterRegion", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Filter Region", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Filter Region" - } - }, - "FilterSubRegion": { - "field_aliasName": "Filter Sub-Region", - "field_baseName": "FilterSubRegion", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 40, - "field_name": "FilterSubRegion", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Filter Sub-Region", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Filter Sub-Region" - } - }, - "Frequency": { - "field_aliasName": "Frequency", - "field_baseName": "Frequency", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 25, - "field_name": "Frequency", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Frequency", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Frequency" - } - }, - "GearType": { - "field_aliasName": "Gear Type", - "field_baseName": "GearType", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 150, - "field_name": "GearType", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Gear Type", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Gear Type" - } - }, - "GeographicArea": { - "field_aliasName": "Geographic Area", - "field_baseName": "GeographicArea", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 20, - "field_name": "GeographicArea", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Geographic Area", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Geographic Area" - } - }, - "GroupName": { - "field_aliasName": "Group Name", - "field_baseName": "GroupName", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 100, - "field_name": "GroupName", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Group Name", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Group Name" - } - }, - "HaulBin": { - "field_aliasName": "Haul Bin", - "field_baseName": "HaulBin", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 20, - "field_name": "HaulBin", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Haul Bin", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Haul Bin" - } - }, - "HaulProportion": { - "field_aliasName": "Haul Proportion", - "field_baseName": "HaulProportion", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "HaulProportion", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Haul Proportion", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Haul Proportion" - } - }, - "HighPS": { - "field_aliasName": "HighPS", - "field_baseName": "HighPS", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "HighPS", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "HighPS", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "HighPS" - } - }, - "ID": { - "field_aliasName": "ID", - "field_baseName": "ID", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 2, - "field_name": "ID", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "ID", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "ID" - } - }, - "ImageName": { - "field_aliasName": "Image Name", - "field_baseName": "ImageName", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 100, - "field_name": "ImageName", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Image Name", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Image Name" - } - }, - "ImageServiceName": { - "field_aliasName": "Image Service Name", - "field_baseName": "ImageServiceName", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 40, - "field_name": "ImageServiceName", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Image Service Name", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Image Service Name" - } - }, - "ImageServiceTitle": { - "field_aliasName": "Image Service Title", - "field_baseName": "ImageServiceTitle", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 60, - "field_name": "ImageServiceTitle", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Image Service Title", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Image Service Title" - } - }, - "ItemTS": { - "field_aliasName": "ItemTS", - "field_baseName": "ItemTS", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "ItemTS", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "ItemTS", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "ItemTS" - } - }, - "Latitude": { - "field_aliasName": "Latitude", - "field_baseName": "Latitude", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "Latitude", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Latitude", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Latitude" - } - }, - "Longitude": { - "field_aliasName": "Longitude", - "field_baseName": "Longitude", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "Longitude", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Longitude", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Longitude" - } - }, - "LowPS": { - "field_aliasName": "LowPS", - "field_baseName": "LowPS", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "LowPS", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "LowPS", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "LowPS" - } - }, - "ManagementBody": { - "field_aliasName": "Management Body", - "field_baseName": "ManagementBody", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 20, - "field_name": "ManagementBody", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Management Body", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Management Body" - } - }, - "ManagementPlan": { - "field_aliasName": "Management Plan", - "field_baseName": "ManagementPlan", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 90, - "field_name": "ManagementPlan", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Management Plan", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Management Plan" - } - }, - "MapValue": { - "field_aliasName": "Map Value", - "field_baseName": "MapValue", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "MapValue", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Map Value", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Map Value" - } - }, - "MaxPS": { - "field_aliasName": "MaxPS", - "field_baseName": "MaxPS", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "MaxPS", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "MaxPS", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "MaxPS" - } - }, - "MaximumDepth": { - "field_aliasName": "Maximum Depth", - "field_baseName": "MaximumDepth", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "MaximumDepth", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Maximum Depth", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Maximum Depth" - } - }, - "MaximumLatitude": { - "field_aliasName": "Maximum Latitude", - "field_baseName": "MaximumLatitude", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "MaximumLatitude", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Maximum Latitude", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Maximum Latitude" - } - }, - "MaximumLongitude": { - "field_aliasName": "Maximum Longitude", - "field_baseName": "MaximumLongitude", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "MaximumLongitude", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Maximum Longitude", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Maximum Longitude" - } - }, - "MedianEstimate": { - "field_aliasName": "Median Estimate", - "field_baseName": "MedianEstimate", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "MedianEstimate", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Median Estimate", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Median Estimate" - } - }, - "MinPS": { - "field_aliasName": "MinPS", - "field_baseName": "MinPS", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "MinPS", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "MinPS", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "MinPS" - } - }, - "MinimumDepth": { - "field_aliasName": "Minimum Depth", - "field_baseName": "MinimumDepth", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "MinimumDepth", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Minimum Depth", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Minimum Depth" - } - }, - "MinimumLatitude": { - "field_aliasName": "Minimum Latitude", - "field_baseName": "MinimumLatitude", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "MinimumLatitude", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Minimum Latitude", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Minimum Latitude" - } - }, - "MinimumLongitude": { - "field_aliasName": "Minimum Longitude", - "field_baseName": "MinimumLongitude", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "MinimumLongitude", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Minimum Longitude", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Minimum Longitude" - } - }, - "MosaicName": { - "field_aliasName": "Mosaic Name", - "field_baseName": "MosaicName", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 20, - "field_name": "MosaicName", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Mosaic Name", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Mosaic Name" - } - }, - "MosaicTitle": { - "field_aliasName": "Mosaic Title", - "field_baseName": "MosaicTitle", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 60, - "field_name": "MosaicTitle", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Mosaic Title", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Mosaic Title" - } - }, - "Name": { - "field_aliasName": "Name", - "field_baseName": "Name", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 200, - "field_name": "Name", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Name", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Name" - } - }, - "NetWTCPUE": { - "field_aliasName": "Net WTCPUE", - "field_baseName": "NetWTCPUE", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "NetWTCPUE", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Net WTCPUE", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Net WTCPUE" - } - }, - "Northing": { - "field_aliasName": "Northing", - "field_baseName": "Northing", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "Northing", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Northing", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Northing" - } - }, - "Notes": { - "field_aliasName": "Notes", - "field_baseName": "Notes", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 40, - "field_name": "Notes", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Notes", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Notes" - } - }, - "OffsetDepth": { - "field_aliasName": "Offset Depth", - "field_baseName": "OffsetDepth", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "OffsetDepth", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Offset Depth", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Offset Depth" - } - }, - "OffsetLatitude": { - "field_aliasName": "Offset Latitude", - "field_baseName": "OffsetLatitude", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "OffsetLatitude", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Offset Latitude", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Offset Latitude" - } - }, - "OffsetLongitude": { - "field_aliasName": "Offset Longitude", - "field_baseName": "OffsetLongitude", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "OffsetLongitude", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Offset Longitude", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Offset Longitude" - } - }, - "Percentile": { - "field_aliasName": "Percentile", - "field_baseName": "Percentile", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "Percentile", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Percentile", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Percentile" - } - }, - "PercentileBin": { - "field_aliasName": "Percentile Bin", - "field_baseName": "PercentileBin", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 20, - "field_name": "PercentileBin", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Percentile Bin", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Percentile Bin" - } - }, - "PointFeatureType": { - "field_aliasName": "Point Feature Type", - "field_baseName": "PointFeatureType", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 20, - "field_name": "PointFeatureType", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Point Feature Type", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Point Feature Type" - } - }, - "ProductName": { - "field_aliasName": "Product Name", - "field_baseName": "ProductName", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 100, - "field_name": "ProductName", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Product Name", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Product Name" - } - }, - "Raster": { - "field_aliasName": "Raster", - "field_baseName": "Raster", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 0, - "field_name": "Raster", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Raster", - "field_attrdef": "Raster", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Raster" - } - }, - "Region": { - "field_aliasName": "Region", - "field_baseName": "Region", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 40, - "field_name": "Region", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Region", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Region" - } - }, - "SampleID": { - "field_aliasName": "Sample ID", - "field_baseName": "SampleID", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 20, - "field_name": "SampleID", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Sample ID", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Sample ID" - } - }, - "Season": { - "field_aliasName": "Season", - "field_baseName": "Season", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 15, - "field_name": "Season", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Season", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Season" - } - }, - "Species": { - "field_aliasName": "Species", - "field_baseName": "Species", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 50, - "field_name": "Species", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Species", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Species" - } - }, - "SpeciesCommonName": { - "field_aliasName": "Species (Common Name)", - "field_baseName": "SpeciesCommonName", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 90, - "field_name": "SpeciesCommonName", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Species (Common Name)", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Species (Common Name)" - } - }, - "StandardError": { - "field_aliasName": "Standard Error", - "field_baseName": "StandardError", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "StandardError", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Standard Error", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Standard Error" - } - }, - "Status": { - "field_aliasName": "Status", - "field_baseName": "Status", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 10, - "field_name": "Status", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Status", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Status" - } - }, - "StdTime": { - "field_aliasName": "StdTime", - "field_baseName": "StdTime", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "StdTime", - "field_precision": 1, - "field_required": "true", - "field_scale": 0, - "field_type": "Date", - "field_attrdef": "StdTime", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "StdTime" - } - }, - "Stratum": { - "field_aliasName": "Stratum", - "field_baseName": "Stratum", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 20, - "field_name": "Stratum", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Stratum", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Stratum" - } - }, - "StratumArea": { - "field_aliasName": "Stratum Area", - "field_baseName": "StratumArea", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "StratumArea", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "Stratum Area", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Stratum Area" - } - }, - "SummaryProduct": { - "field_aliasName": "Summary Product", - "field_baseName": "SummaryProduct", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 5, - "field_name": "SummaryProduct", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Summary Product", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Summary Product" - } - }, - "SurveyName": { - "field_aliasName": "Survey Name", - "field_baseName": "SurveyName", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 100, - "field_name": "SurveyName", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Survey Name", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Survey Name" - } - }, - "TableName": { - "field_aliasName": "Table Name", - "field_baseName": "TableName", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 50, - "field_name": "TableName", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Table Name", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Table Name" - } - }, - "Tag": { - "field_aliasName": "Tag", - "field_baseName": "Tag", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 100, - "field_name": "Tag", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Tag", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Tag" - } - }, - "TaxonomicGroup": { - "field_aliasName": "Taxonomic Group", - "field_baseName": "TaxonomicGroup", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 80, - "field_name": "TaxonomicGroup", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Taxonomic Group", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Taxonomic Group" - } - }, - "TotalSpeciesCount": { - "field_aliasName": "Total Species Count", - "field_baseName": "TotalSpeciesCount", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 4, - "field_name": "TotalSpeciesCount", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Total Species Count", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Total Species Count" - } - }, - "TransformUnit": { - "field_aliasName": "Transform Unit", - "field_baseName": "TransformUnit", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 20, - "field_name": "TransformUnit", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Transform Unit", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Transform Unit" - } - }, - "TrendCategory": { - "field_aliasName": "Trend Category", - "field_baseName": "TrendCategory", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 40, - "field_name": "TrendCategory", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Trend Category", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Trend Category" - } - }, - "TypeID": { - "field_aliasName": "Raster Type ID", - "field_baseName": "TypeID", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 4, - "field_name": "TypeID", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Integer", - "field_attrdef": "Raster Type ID", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Raster Type ID" - } - }, - "Uri": { - "field_aliasName": "Uri", - "field_baseName": "Uri", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 0, - "field_name": "Uri", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Blob", - "field_attrdef": "Uri", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Uri" - } - }, - "UriHash": { - "field_aliasName": "UriHash", - "field_baseName": "UriHash", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 50, - "field_name": "UriHash", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "UriHash", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "UriHash" - } - }, - "Value": { - "field_aliasName": "Value", - "field_baseName": "Value", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 50, - "field_name": "Value", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Value", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Value" - } - }, - "Variable": { - "field_aliasName": "Variable", - "field_baseName": "Variable", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 50, - "field_name": "Variable", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Variable", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Variable" - } - }, - "WTCPUE": { - "field_aliasName": "WTCPUE", - "field_baseName": "WTCPUE", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 8, - "field_name": "WTCPUE", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Double", - "field_attrdef": "WTCPUE", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "WTCPUE" - } - }, - "Year": { - "field_aliasName": "Year", - "field_baseName": "Year", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 4, - "field_name": "Year", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Year", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Year" - } - }, - "Years": { - "field_aliasName": "Years", - "field_baseName": "Years", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 25, - "field_name": "Years", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "String", - "field_attrdef": "Years", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "Years" - } - }, - "ZOrder": { - "field_aliasName": "ZOrder", - "field_baseName": "ZOrder", - "field_defaultValue": "null", - "field_domain": "", - "field_editable": "true", - "field_isNullable": "true", - "field_length": 4, - "field_name": "ZOrder", - "field_precision": 0, - "field_required": "true", - "field_scale": 0, - "field_type": "Integer", - "field_attrdef": "ZOrder", - "field_attrdefs": "DisMAP Project GDB Data Dictionary", - "field_attrdomv": { - "udom": "ZOrder" - } - } - } - - _Bathymetry = [] - _Boundary = ["DatasetCode", "Region", "Season", "DistributionProjectCode"] - _Datasets = ["DatasetCode", "CSVFile", "TransformUnit", "TableName", - "GeographicArea", "CellSize", "PointFeatureType", "FeatureClassName", - "Region", "Season", "DateCode", "Status", "DistributionProjectCode", - "DistributionProjectName", "SummaryProduct", "FilterRegion", - "FilterSubRegion", "FeatureServiceName", "FeatureServiceTitle", - "MosaicName", "MosaicTitle", "ImageServiceName", - "ImageServiceTitle"] - _DisMAP_Survey_Info = ["SurveyName", "Region", "Season", "GearType", - "Years", "Frequency", "DataFilteringNotes", - "TotalSpeciesCount", "DataSource", "DataCitation"] - _Extent_Points = ["Easting", "Northing", "Longitude", "Latitude"] - _Fishnet = [] - #_GLMME = ["DatasetCode", "Region", "SummaryProduct", "Year", "StdTime", - # "Species", "WTCPUE", "MapValue", "StandardError", "TransformUnit", - # "CommonName", "SpeciesCommonName", "CommonNameSpecies", "Easting", - # "Northing", "Latitude", "Longitude", "MedianEstimate", "Depth"] - #_GRID_Points = ["DatasetCode", "Region", "SummaryProduct", "Year", - # "StdTime", "Species", "WTCPUE", "MapValue", "StandardError", - # "TransformUnit", "CommonName", "SpeciesCommonName", - # "CommonNameSpecies", "Easting", "Northing", "Latitude", - # "Longitude", "MedianEstimate", "Depth"] - _IDW = ["DatasetCode", "Region", "Season", "DistributionProjectName", - "SummaryProduct", "SampleID", "Year", "StdTime", "Species", - "WTCPUE", "MapValue", "TransformUnit", "CommonName", - "SpeciesCommonName", "CommonNameSpecies", "CoreSpecies", - "Stratum", "StratumArea", "Latitude", "Longitude", "Depth"] - _Indicators = ["DatasetCode", "Region", "Season", "DateCode", "Species", - "CommonName", "CoreSpecies", "Year", "DistributionProjectName", - "DistributionProjectCode", "SummaryProduct", - "CenterOfGravityLatitude", "MinimumLatitude", - "MaximumLatitude", "OffsetLatitude", "CenterOfGravityLatitudeSE", - "CenterOfGravityLongitude", "MinimumLongitude", - "MaximumLongitude", "OffsetLongitude", "CenterOfGravityLongitudeSE", - "CenterOfGravityDepth", "MinimumDepth", "MaximumDepth", - "OffsetDepth", "CenterOfGravityDepthSE"] - _LayerSpeciesYearImageName = ["DatasetCode", "Region", "Season", "SummaryProduct", - "FilterRegion", "FilterSubRegion", "Species", - "CommonName", "SpeciesCommonName", - "CommonNameSpecies", "TaxonomicGroup", - "ManagementBody", "ManagementPlan", - "DistributionProjectName", "CoreSpecies", - "Year", "StdTime", "Variable", - "Value", "Dimensions", "ImageName"] - _Lat_Long = ["Easting", "Northing", "Longitude", "Latitude"] - _Latitude = [] - _Longitude = [] - _Mosaic = ["Raster", "Name", "MinPS", "MaxPS", "LowPS", "HighPS", - "Category", "Tag", "GroupName", "ProductName", "CenterX", - "CenterY", "ZOrder", "TypeID", "ItemTS", "UriHash", "Uri", - "DatasetCode", "Region", "Season", "Species", "CommonName", - "SpeciesCommonName", "CoreSpecies", "Year", "StdTime", - "Variable", "Value", "Dimensions"] - _Raster_Mask = ["Value", "Count", "ID"] - _Region = ["DatasetCode", "Region", "Season", "DistributionProjectCode"] - _Sample_Locations = ["DatasetCode", "Region", "Season", "SummaryProduct", - "SampleID", "Year", "StdTime", "Species", "WTCPUE", - "MapValue", "TransformUnit", "CommonName", - "SpeciesCommonName", "CommonNameSpecies", "CoreSpecies", - "Stratum", "StratumArea", "Latitude", "Longitude", - "Depth"] - _Species_Filter = ["Species", "CommonName", "TaxonomicGroup", "FilterRegion", - "FilterSubRegion", "ManagementBody", "ManagementPlan", "DistributionProjectName"] - _SpeciesPersistenceIndicatorTrend = ["Region", "SurveyName", "Species", "CommonName", "TrendCategory", "Notes"] - _SpeciesPersistenceIndicatorPercentileBin = ["Region", "SurveyName", "Year", "Species", "CommonName", "PercentileBin", "WTCPUE", "HaulProportion", "HaulBin"] - - #datasets_table = arcpy.ListTables("Datasets")[0] - #datasets_table_fields = [f.name for f in arcpy.ListFields(datasets_table) if f.type not in ["Geometry", "OID"] and f.name not in ["Shape_Area", "Shape_Length"]] - - data_dictionary = dict() - #arcpy.AddMessage(datasets_table_fields) - #['DatasetCode', 'CSVFile', 'TransformUnit', 'TableName', - # 'GeographicArea', 'CellSize', 'PointFeatureType', 'FeatureClassName', - # 'Region', 'Season', 'DateCode', 'Status', 'DistributionProjectCode', - # 'DistributionProjectName', 'SummaryProduct', 'FilterRegion', - # 'FilterSubRegion', 'FeatureServiceName', 'FeatureServiceTitle', - # 'MosaicName', 'MosaicTitle', 'ImageServiceName', 'ImageServiceTitle'] - - table_names = ["AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", - "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", - "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", - "WC_ANN_IDW", "WC_TRI_IDW", "DisMAP_Regions", "Datasets", - "LayerSpeciesYearImageName", "Indicators", "Species_Filter", - "DisMAP_Survey_Info", "SpeciesPersistenceIndicatorTrend", - "SpeciesPersistenceIndicatorPercentileBin",] - - for table_name in table_names: - arcpy.AddMessage(table_name) - if table_name == "DisMAP_Regions": - data_dictionary[table_name] = _Region - elif table_name == "Datasets": - data_dictionary[table_name] = _Datasets - elif table_name == "LayerSpeciesYearImageName": - data_dictionary[table_name] = _LayerSpeciesYearImageName - elif table_name == "Indicators": - data_dictionary[table_name] = _Indicators - elif table_name == "Species_Filter": - data_dictionary[table_name] = _Species_Filter - elif table_name == "DisMAP_Survey_Info": - data_dictionary[table_name] = _DisMAP_Survey_Info - elif table_name == "SpeciesPersistenceIndicatorPercentileBin": - data_dictionary[table_name] = _SpeciesPersistenceIndicatorPercentileBin - elif table_name == "SpeciesPersistenceIndicatorTrend": - data_dictionary[table_name] = _SpeciesPersistenceIndicatorTrend - elif table_name.endswith("_IDW"): # or table_name.endswith("_GLMME"): - if table_name.endswith("_IDW"): - data_dictionary[table_name] = _IDW - data_dictionary[f"{table_name}_Sample_Locations"] = _Sample_Locations - data_dictionary[f"{table_name}_Indicators"] = _Indicators - #elif table_name.endswith("_GLMME"): - # data_dictionary[table_name] = _GLMME - # data_dictionary[f"{table_name}_GRID_Points"] = _GRID_Points - else: - pass - data_dictionary[f"{table_name}_Bathymetry"] = _Bathymetry - data_dictionary[f"{table_name}_Boundary"] = _Boundary - data_dictionary[f"{table_name}_Extent_Points"] = _Extent_Points - data_dictionary[f"{table_name}_Fishnet"] = _Fishnet - data_dictionary[f"{table_name}_LayerSpeciesYearImageName"] = _LayerSpeciesYearImageName - data_dictionary[f"{table_name}_Lat_Long"] = _Lat_Long - data_dictionary[f"{table_name}_Latitude"] = _Latitude - data_dictionary[f"{table_name}_Longitude"] = _Longitude - data_dictionary[f"{table_name}_Mosaic"] = _Mosaic - data_dictionary[f"{table_name}_Raster_Mask"] = _Raster_Mask - data_dictionary[f"{table_name}_Region"] = _Region - else: - pass - del table_name - -## fields = ['DatasetCode', 'DistributionProjectCode'] - -## with arcpy.da.SearchCursor(datasets_table, fields) as cursor: -## for row in cursor: -## DatasetCode = f'{row[0]}' -## DistributionProjectCode = f'{"_"+row[1] if row[1] is not None and row[1] not in row[0] else ""}' -## table_name = f'{DatasetCode}{DistributionProjectCode}' -## arcpy.AddMessage(table_name) -## if table_name == "DisMAP_Regions": -## data_dictionary[table_name] = _Region -## elif table_name == "Datasets": -## data_dictionary[table_name] = _Datasets -## elif table_name == "LayerSpeciesYearImageName": -## data_dictionary[table_name] = _LayerSpeciesYearImageName -## elif table_name == "Indicators": -## data_dictionary[table_name] = _Indicators -## elif table_name == "Species_Filter": -## data_dictionary[table_name] = _Species_Filter -## elif table_name == "DisMAP_Survey_Info": -## data_dictionary[table_name] = _DisMAP_Survey_Info -## elif table_name == "SpeciesPersistenceIndicatorPercentileBin": -## data_dictionary[table_name] = _SpeciesPersistenceIndicatorPercentileBin -## elif table_name == "SpeciesPersistenceIndicatorTrend": -## data_dictionary[table_name] = _SpeciesPersistenceIndicatorTrend -## elif table_name.endswith("_IDW") or table_name.endswith("_GLMME"): -## if table_name.endswith("_IDW"): -## data_dictionary[table_name] = _IDW -## data_dictionary[f"{table_name}_Sample_Locations"] = _Sample_Locations -## data_dictionary[f"{table_name}_Indicators"] = _Indicators -## elif table_name.endswith("_GLMME"): -## data_dictionary[table_name] = _GLMME -## data_dictionary[f"{table_name}_GRID_Points"] = _GRID_Points -## else: -## pass -## data_dictionary[f"{table_name}_Bathymetry"] = _Bathymetry -## data_dictionary[f"{table_name}_Boundary"] = _Boundary -## data_dictionary[f"{table_name}_Extent_Points"] = _Extent_Points -## data_dictionary[f"{table_name}_Fishnet"] = _Fishnet -## data_dictionary[f"{table_name}_LayerSpeciesYearImageName"] = _LayerSpeciesYearImageName -## data_dictionary[f"{table_name}_Lat_Long"] = _Lat_Long -## data_dictionary[f"{table_name}_Latitude"] = _Latitude -## data_dictionary[f"{table_name}_Longitude"] = _Longitude -## data_dictionary[f"{table_name}_Mosaic"] = _Mosaic -## data_dictionary[f"{table_name}_Raster_Mask"] = _Raster_Mask -## data_dictionary[f"{table_name}_Region"] = _Region -## else: -## pass -## del DistributionProjectCode -## del DatasetCode -## del table_name -## del row -## del cursor - - for key in sorted(data_dictionary): - arcpy.AddMessage(f"Table: {key}") - _fields = data_dictionary[key] - for _field in _fields: - arcpy.AddMessage(f"\t{_field}") - del _field - del _fields - del key - - table_definitions = {k:v for k,v in sorted(data_dictionary.items())} - import json - # Write to File - json_path = rf"{project_folder}\CSV_Data\table_definitions.json" - #print(f"project folder: {project_folder}") - with open(json_path, 'w') as json_file: - json.dump(table_definitions, json_file, indent=4) - del json_file - del json_path - del json - - for table in table_definitions: - #arcpy.AddMessage(f"{table}") - fields = table_definitions[table] - #arcpy.AddMessage(f"\t{type(fields)}") - del table - for field in fields: - #arcpy.AddMessage(f"\t{field}") - if field in field_definitions.keys(): - pass - #arcpy.AddMessage(f"\t{field_definitions[field]}") - else: - pass - #arcpy.AddMessage(f"\t\t###--->>> {field} not in _field_definitions") - del field - del fields - del table_definitions - - #for key in sorted(field_definitions): - # #arcpy.AddMessage(f"Table: {key}") - # _fields = field_definitions[key] - # if "attrdef" not in _fields: - # field_definitions[key]["field_attrdef"] = field_definitions[key]["field_aliasName"] - # if "attrdefs" not in _fields: - # field_definitions[key]["field_attrdefs"] = "DisMAP Project GDB Data Dictionary" - # if "attrdomv" not in _fields: - # field_definitions[key]["field_attrdomv"] = {"udom": f"{field_definitions[key]['field_aliasName']}"} - # else: - # pass - # del _fields - # del key - - #for key in sorted(field_definitions): - # #arcpy.AddMessage(f"Table: {key}") - # _fields = field_definitions[key] - # for _field in _fields: - # #arcpy.AddMessage(f"\t{_field}") - # del _field - # del _fields - # del key - - import json - # Write to File - json_path = rf"{project_folder}\CSV_Data\field_definitions.json" - with open(json_path, 'w') as json_file: - json.dump(field_definitions, json_file, indent=4) - del json_file - del json_path - del json - - del field_definitions - del data_dictionary, table_names - del _Bathymetry, _Boundary, _Datasets, _DisMAP_Survey_Info, - del _Extent_Points, _Fishnet, _IDW, _Indicators, - #del _GLMME, _GRID_Points, - del _LayerSpeciesYearImageName, _Lat_Long, _Latitude, _Longitude, - del _Mosaic, _Raster_Mask, _Region, _Sample_Locations, _Species_Filter - del _SpeciesPersistenceIndicatorPercentileBin - del _SpeciesPersistenceIndicatorTrend - - # Compact GDB - #arcpy.AddMessage(f"\nCompacting: {os.path.basename(project_gdb)}" ) - arcpy.management.Compact(project_gdb) - - arcpy.AddMessage(f"\n{'--End' * 10}--") - - # Declared Variables - del project_folder - # Imports - # Function parameters - del project_gdb - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == "__main__": - try: - - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - - del project_gdb - - except SystemExit: - pass - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - else: - pass - finally: - pass - - - - - - diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_indicators_table_director.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_indicators_table_director.py deleted file mode 100644 index 4ad468e..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_indicators_table_director.py +++ /dev/null @@ -1,472 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: create_indicators_table_director -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 09/03/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback -import inspect - -import arcpy # third-parties second - -def director(project_gdb="", Sequential=True, table_names=[]): - try: - # Imports - import dismap_tools - from create_indicators_table_worker import preprocessing, worker - - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(rf"{project_gdb}"): - arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") - arcpy.AddError(arcpy.GetMessages(2)) - sys.exit() - else: - pass - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - #project_folder = os.path.dirname(project_gdb) - scratch_workspace = rf"{os.path.dirname(project_gdb)}\Scratch\scratch.gdb" - scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" - csv_data_folder = rf"{os.path.dirname(project_gdb)}\CSV_Data" - - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - - preprocessing(project_gdb=project_gdb, table_names=table_names, clear_folder=True) - - # Sequential Processing - if Sequential: - arcpy.AddMessage(f"Sequential Processing") - for i in range(0, len(table_names)): - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - try: - worker(region_gdb=region_gdb) - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del region_gdb, table_name - del i - else: - pass - - # Non-Sequential Processing - if not Sequential: - arcpy.AddMessage(f"Non-Sequential Processing") - # Imports - import multiprocessing - from time import time, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"Start multiprocessing using the ArcGIS Pro pythonw.exe.") - #Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS - #get_install_path() uses a registry query to figure out 64bit python exe if available - multiprocessing.set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe')) - # Get CPU count and then take 2 away for other process - _processes = multiprocessing.cpu_count() - 2 - _processes = _processes if len(table_names) >= _processes else len(table_names) - arcpy.AddMessage(f"Creating the multiprocessing Pool with {_processes} processes") - #Create a pool of workers, keep one cpu free for surfing the net. - #Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) - with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: - arcpy.AddMessage(f"\tPrepare arguments for processing") - # Use apply_async so we can handle exceptions gracefully - jobs={} - for i in range(0, len(table_names)): - try: - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - jobs[table_name] = pool.apply_async(worker, [region_gdb]) - del table_name, region_gdb - except: - pool.terminate() - traceback.print_exc() - sys.exit() - del i - all_finished = False - # Set a start time so that we can see how log things take - start_time = time() - result_completed = {} - while True: - all_finished = True - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - arcpy.AddMessage(f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"Have the workers finished?") - finish_time = strftime('%a %b %d %I:%M %p', localtime()) - time_elapsed = u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) - arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") - finish_time = f"{finish_time}.\n\t{time_elapsed}" - del time_elapsed - for table_name, result in jobs.items(): - if result.ready(): - if table_name not in result_completed: - result_completed[table_name] = finish_time - try: - # wait for and get the result from the task - result.get() - except: - pool.terminate() - traceback.print_exc() - sys.exit() - else: - pass - arcpy.AddMessage(f"Process {table_name}\n\tFinished on {result_completed[table_name]}") - else: - all_finished = False - arcpy.AddMessage(f"Process {table_name} is running. . .") - del table_name, result - del elapse_time, end_time, finish_time - if all_finished: - break - sleep(_processes * 7.5) - del result_completed - del start_time - del all_finished - arcpy.AddMessage(f"\tClose the process pool") - # close the process pool - pool.close() - # wait for all tasks to complete and processes to close - arcpy.AddMessage(f"\tWait for all tasks to complete and processes to close") - pool.join() - # Just in case - pool.terminate() - del pool - del jobs - del _processes - del time, multiprocessing, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"\tDone with multiprocessing Pool") - - # Post-Processing - arcpy.AddMessage("Post-Processing Begins") - - datasets = list() - walk = arcpy.da.Walk(scratch_folder, datatype=["Table", "FeatureClass"]) - for dirpath, dirnames, filenames in walk: - for filename in filenames: - datasets.append(os.path.join(dirpath, filename)) - del filename - del dirpath, dirnames, filenames - del walk - for dataset in datasets: - datasets_short_path = f"{os.path.basename(os.path.dirname(os.path.dirname(dataset)))}\{os.path.basename(os.path.dirname(dataset))}\{os.path.basename(dataset)}" - dataset_name = os.path.basename(dataset) - region_gdb = os.path.dirname(dataset) - arcpy.AddMessage(f"\tDataset: '{dataset_name}'") - arcpy.AddMessage(f"\t\tPath: '{datasets_short_path}'") - arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") - arcpy.management.Copy(dataset, rf"{project_gdb}\{dataset_name}") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - #arcpy.management.Delete(dataset) - #arcpy.AddMessage(f"\t\tAlter Fields for: '{dataset}'") - #dismap_tools.alter_fields(csv_data_folder, rf"{project_gdb}\{dataset}") - del region_gdb, dataset_name, datasets_short_path - del dataset - del datasets - - arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") - arcpy.management.Compact(project_gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - # Declared Variables - del scratch_folder, csv_data_folder, scratch_workspace - # Imports - del preprocessing, worker, dismap_tools - # Function Parameters - del project_gdb, Sequential, table_names - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def process_indicator_tables(project_gdb=""): - try: - # Import - from arcpy import metadata as md - import dismap_tools - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - csv_data_folder = rf"{project_folder}\CSV_Data" - - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - arcpy.management.CreateTable(project_gdb, "Indicators", "", "", "") - arcpy.AddMessage("\tCreate Table: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - indicators = rf"{project_gdb}\Indicators" - - dismap_tools.add_fields(csv_data_folder, indicators) - #dismap_tools.alter_fields(csv_data_folder, indicators) - dismap_tools.import_metadata(csv_data_folder, indicators) - - #in_tables = [it for it in arcpy.ListTables("*_Indicators") if it == "AI_IDW_Indicators"] - #in_tables = [it for it in arcpy.ListTables("*_Indicators") if not any(lo in it for lo in ["GFDL", "GLMME"])] - in_tables = [it for it in arcpy.ListTables("*_Indicators")] - - if not in_tables: - arcpy.AddWarning(f"Indicator Tables are not present in the {os.path.basename(project_gdb)} GDB") - else: - for in_table in sorted(in_tables): - arcpy.AddMessage(f"Table: {in_table}") - in_table_path = rf"{project_gdb}\{in_table}" - del in_table - - arcpy.AddMessage(f"\tUpdating field values to replace None with empty string") - - fields = [f.name for f in arcpy.ListFields(in_table_path) if f.type == "String"] - #for field in fields: - # arcpy.AddMessage(f"\t{field.name}\t{field.type}") - # del field - # Create update cursor for feature class - with arcpy.da.UpdateCursor(in_table_path, fields) as cursor: - for row in cursor: - #arcpy.AddMessage(row) - for field_value in row: - #arcpy.AddMessage(field_value) - if field_value is None: - row[row.index(field_value)] = "" - cursor.updateRow(row) - del field_value - del row - del cursor - del fields - - fields = [f.name for f in arcpy.ListFields(in_table_path) if f.name == "DateCode"] - #for field in fields: - # arcpy.AddMessage(f"\t{field.name}\t{field.type}") - # del field - # Create update cursor for feature class - with arcpy.da.UpdateCursor(in_table_path, fields) as cursor: - for row in cursor: - #arcpy.AddMessage(row) - #arcpy.AddMessage(dismap_tools.date_code(row[0])) - datecode = dismap_tools.date_code(row[0]) - #arcpy.AddMessage(datecode) - row[0] = datecode - cursor.updateRow(row) - del datecode - del row - del cursor - del fields - - arcpy.management.Append(inputs=in_table_path, target=indicators, schema_type="TEST", field_mapping="", subtype="") - arcpy.AddMessage("\tAppend: {0} {1}\n".format(f"{os.path.basename(in_table_path)}", arcpy.GetMessages(0).replace("\n", '\n\t'))) - - del in_table_path - # end for loop - - dataset_md = md.Metadata(indicators) - dataset_md.synchronize("ALWAYS") - dataset_md.save() - del dataset_md - - arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") - arcpy.management.Compact(project_gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - # Declared Variables assigned in function - del in_tables, indicators - del scratch_folder, scratch_workspace, csv_data_folder, project_folder - # Imports - del dismap_tools, md - # Function Parameters - del project_gdb - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - # Imports - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(project_gdb): - sys.exit()(f"{os.path.basename(project_gdb)} is missing!!") - else: - pass - - try: - pass - # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", - # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", - - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["AI_IDW", "HI_IDW",]) - elif not Test: - pass - #director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "EBS_IDW", "ENBS_IDW", "GOA_IDW", "NBS_IDW",]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW", "WC_ANN_IDW", "WC_TRI_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW",]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["HI_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW",]) - else: - pass - del Test - - # Combine Indicator Tables - CombineIndicatorTables = True - if CombineIndicatorTables: - process_indicator_tables(project_gdb=project_gdb) - else: - pass - del CombineIndicatorTables - - except: - traceback.print_exc() - sys.exit() - - # Declared Variables - # Imports - # Function Parameters - del project_gdb - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - if "Test" in locals().keys(): del Test - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_indicators_table_worker.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_indicators_table_worker.py deleted file mode 100644 index 35a90a1..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_indicators_table_worker.py +++ /dev/null @@ -1,1058 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: dev_create_indicators_table_worker -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 09/03/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback -import inspect - -import arcpy # third-parties second - -def printRowContent(region_indicators): - try: - arcpy.AddMessage("Print records in the Region Indicators table") - - fields = [f.name for f in arcpy.ListFields(region_indicators) if f.type not in ['Geometry', 'OID']] - with arcpy.da.SearchCursor(region_indicators, fields) as cursor: - #with arcpy.da.SearchCursor(region_indicators, fields, "CoreSpecies = 'No'") as cursor: - for row in cursor: - #arcpy.AddMessage(', '.join((row))) - - DatasetCode = row[0] - Region = row[1] - Season = row[2] - DateCode = row[3] - Species = row[4] - CommonName = row[5] - CoreSpecies = row[6] - Year = row[7] - #DistributionProjectName = row[8] - DistributionProjectCode = row[9] - SummaryProduct = row[10] - CenterOfGravityLatitude = '' if row[11] is None else f'{row[11]:.1f}' - MinimumLatitude = '' if row[12] is None else f'{row[12]:.1f}' - MaximumLatitude = '' if row[13] is None else f'{row[13]:.1f}' - OffsetLatitude = '' if row[14] is None else f'{row[14]:.1f}' - CenterOfGravityLatitudeSE = '' if row[15] is None else f'{row[15]:.1f}' - CenterOfGravityLongitude = '' if row[16] is None else f'{row[16]:.1f}' - MinimumLongitude = '' if row[17] is None else f'{row[17]:.1f}' - MaximumLongitude = '' if row[18] is None else f'{row[18]:.1f}' - OffsetLongitude = '' if row[19] is None else f'{row[19]:.1f}' - CenterOfGravityLongitudeSE = '' if row[20] is None else f'{row[20]:.1f}' - CenterOfGravityDepth = '' if row[21] is None else f'{row[21]:.1f}' - MinimumDepth = '' if row[22] is None else f'{row[22]:.1f}' - MaximumDepth = '' if row[23] is None else f'{row[23]:.1f}' - OffsetDepth = '' if row[24] is None else f'{row[24]:.1f}' - CenterOfGravityDepthSE = '' if row[25] is None else f'{row[25]:.1f}' - - #arcpy.AddMessage(DatasetCode, Region, Season, DateCode, Species, CommonName, CoreSpecies, Year, DistributionProjectName, DistributionProjectCode, SummaryProduct, CenterOfGravityLatitude, MinimumLatitude, MaximumLatitude, OffsetLatitude, CenterOfGravityLatitudeSE, CenterOfGravityLongitude, MinimumLongitude, MaximumLongitude, OffsetLongitude, CenterOfGravityLongitudeSE, CenterOfGravityDepth, MinimumDepth, MaximumDepth, OffsetDepth, CenterOfGravityDepthSE) - arcpy.AddMessage(f"{DatasetCode}, {Region}, {Season}, {DateCode}, {Species}, {CommonName}, {CoreSpecies}, {Year}, {DistributionProjectCode}, {SummaryProduct}, {CenterOfGravityLatitude}, {MinimumLatitude}, {MaximumLatitude}, {OffsetLatitude}, {CenterOfGravityLatitudeSE}, {CenterOfGravityLongitude}, {MinimumLongitude}, {MaximumLongitude}, {OffsetLongitude}, {CenterOfGravityLongitudeSE}, {CenterOfGravityDepth}, {MinimumDepth}, {MaximumDepth}, {OffsetDepth}, {CenterOfGravityDepthSE}") - - del DatasetCode, Region, Season, DateCode, Species, CommonName - #del DistributionProjectName - del CoreSpecies, Year - del DistributionProjectCode, SummaryProduct, CenterOfGravityLatitude - del MinimumLatitude, MaximumLatitude, OffsetLatitude - del CenterOfGravityLatitudeSE, CenterOfGravityLongitude - del MinimumLongitude, MaximumLongitude, OffsetLongitude - del CenterOfGravityLongitudeSE, CenterOfGravityDepth, MinimumDepth - del MaximumDepth, OffsetDepth, CenterOfGravityDepthSE - - del row - del cursor - del fields - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def worker(region_gdb=""): - try: - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(rf"{region_gdb}"): - arcpy.AddError(f"{os.path.basename(region_gdb)} is missing!!") - arcpy.AddError(f"Function: '{inspect.stack()[0][3]}', Line Number: {inspect.stack()[0][2]}") - sys.exit() - else: - pass - - import numpy as np - import math - - import dismap_tools - - np.seterr(divide='ignore', invalid='ignore') - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(2) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - table_name = os.path.basename(region_gdb).replace(".gdb","") - scratch_folder = os.path.dirname(region_gdb) - project_folder = os.path.dirname(scratch_folder) - csv_data_folder = rf"{project_folder}\CSV_Data" - image_folder = rf"{project_folder}\Images" - scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - - arcpy.AddMessage(f"Table Name: {table_name}\nProject Folder: {os.path.basename(project_folder)}\nScratch Folder: {os.path.basename(scratch_folder)}\n") - - arcpy.env.workspace = region_gdb - arcpy.env.scratchWorkspace = scratch_workspace - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - #arcpy.env.compression = "LZ77" - #arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" - #arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR LZ77 NO_SKIP" - arcpy.env.resamplingMethod = "BILINEAR" - arcpy.env.rasterStatistics = "STATISTICS 1 1" - #arcpy.env.buildStatsAndRATForTempRaster = True - - arcpy.management.CreateTable(region_gdb, f"{table_name}_Indicators", "", "", "") - arcpy.AddMessage("\tCreate Table: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - dismap_tools.add_fields(csv_data_folder, os.path.join(region_gdb, f"{table_name}_Indicators")) - #dismap_tools.import_metadata(rf"{region_gdb}\{table_name}_Indicators") - - del csv_data_folder - - arcpy.AddMessage(f"Generating {table_name} Indicators Table") - - # "DatasetCode", "CSVFile", "TransformUnit", "TableName", "GeographicArea", - # "CellSize", "PointFeatureType", "FeatureClassName", "Region", "Season", - # "DateCode", "Status", "DistributionProjectCode", "DistributionProjectName", - # "SummaryProduct", "FilterRegion", "FilterSubRegion", "FeatureServiceName", - # "FeatureServiceTitle", "MosaicName", "MosaicTitle", "ImageServiceName", - # "ImageServiceTitle" - - arcpy.AddMessage(f"\tGet list of vaules for the {table_name} Indicators table from the Datasets table") - - fields = ["DatasetCode", "TableName", "CellSize", "Region", "Season", - "DateCode", "DistributionProjectCode", "DistributionProjectName", - "SummaryProduct",] - region_list = [row for row in arcpy.da.SearchCursor(rf"{region_gdb}\Datasets", fields, where_clause = f"TableName = '{table_name}'")][0] - del fields - - # Assigning variables from items in the chosen table list - # ['AI_IDW', 'AI_IDW_Region', 'AI', 'Aleutian Islands', None, 'IDW'] - datasetcode = region_list[0] - table_name = region_list[1] - cellsize = region_list[2] - region = region_list[3] - season = region_list[4] - datecode = region_list[5] - distributionprojectcode = region_list[6] - distributionprojectname = region_list[7] - summaryproduct = region_list[8] - del region_list - - # Convert the Month Day Year date code to YYYYMMDD - #datecode = dismap.date_code(datecode) - #arcpy.AddMessage(datecode) - #arcpy.AddMessage(dismap.date_code(datecode)) - - arcpy.env.cellSize = cellsize; del cellsize - - # Region Raster Mask - datasetcode_raster_mask = os.path.join(region_gdb, f"{table_name}_Raster_Mask") - - # we need to set the mask and extent of the environment, or the raster and items may not come out correctly. - arcpy.env.extent = arcpy.Describe(datasetcode_raster_mask).extent - arcpy.env.mask = datasetcode_raster_mask - arcpy.env.snapRaster = datasetcode_raster_mask - del datasetcode_raster_mask - - # Region Indicators - region_indicators = rf"{region_gdb}\{table_name}_Indicators" - - # Region Bathymetry - region_bathymetry = rf"{region_gdb}\{table_name}_Bathymetry" - - # Region Latitude - region_latitude = rf"{region_gdb}\{table_name}_Latitude" - - # Region Longitude - region_longitude = rf"{region_gdb}\{table_name}_Longitude" - - layerspeciesyearimagename = rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName" - - input_rasters = {} - - arcpy.AddMessage(f"\tCreate a list of input biomass raster path locations") - - #fields = "DatasetCode;Region;Season;Species;CommonName;SpeciesCommonName;CoreSpecies;Year;StdTime;Variable;Value;Dimensions" - #fields = fields.split(";") - fields = ['ImageName', 'Variable', 'Species', 'CommonName', 'CoreSpecies', 'Year'] - - #arcpy.AddMessage(fields) - #fields = [f.name for f in arcpy.ListFields(datasetcode_tmp) if f.type not in ['Geometry', 'OID']] - with arcpy.da.SearchCursor(layerspeciesyearimagename, fields, where_clause = f"DatasetCode = '{datasetcode}'") as cursor: - for row in cursor: - image_name, variable, species, commonname, corespecies, year = row[0], row[1], row[2], row[3], row[4], row[5] - #if variable not in variables: variables.append(variable) - #arcpy.AddMessage(variable, image_name) - #variable = f"_{variable}" if "Species Richness" in variable else variable - if "Species Richness" not in variable: - #arcpy.AddMessage(variable, year) - input_raster_path = rf"{image_folder}\{table_name}\{variable}\{image_name}.tif" - #arcpy.AddMessage(input_raster_path) - #input_rasters[variable, year] = [image_name, variable, species, commonname, corespecies, year, input_raster_path] - #input_rasters[variable][year] = [image_name, variable, species, commonname, corespecies, year, input_raster_path] - #input_rasters[variable] = {year : image_name} - if variable not in input_rasters: - input_rasters[variable] = {year : [image_name, variable, species, commonname, corespecies, year, input_raster_path]} - else: - value = input_rasters[variable] - if year not in value: - value[year] = [image_name, variable, species, commonname, corespecies, year, input_raster_path] - input_rasters[variable] = value - del value - - del input_raster_path - - del row, image_name, variable, species, commonname, corespecies, year - del cursor - - #arcpy.AddMessage(variables) - del fields - #del variables - del layerspeciesyearimagename - del image_folder - - # Start with empty row_values list of list - row_values = [] - - arcpy.AddMessage(f"Interate over the species names") - - for variable in sorted(input_rasters): - - first_year = 9999 - - raster_years = input_rasters[variable] - - for raster_year in sorted(raster_years): - - image_name, variable, species, commonname, corespecies, year, input_raster_path = raster_years[raster_year] - - PrintRecord = False - if PrintRecord: - arcpy.AddMessage(f"\t> Image Name: {image_name}") - arcpy.AddMessage(f"\t\t> Variable: {variable}") - arcpy.AddMessage(f"\t\t> Species: {species}") - arcpy.AddMessage(f"\t\t> Common Name: {commonname}") - arcpy.AddMessage(f"\t\t> Core Species: {corespecies}") - arcpy.AddMessage(f"\t\t> Year: {year}") - arcpy.AddMessage(f"\t\t> Output Raster: {os.path.basename(input_raster_path)}") - del PrintRecord - - arcpy.AddMessage(f"Processing {image_name} Biomass Raster for year: {raster_year}") - - # Get maximumBiomass value to filter out "zero" rasters - maximumBiomass = float(arcpy.management.GetRasterProperties(input_raster_path, "MAXIMUM").getOutput(0)) - - arcpy.AddMessage(f"\t> Biomass Raster Maximum: {maximumBiomass}") - - # arcpy.AddMessage(variable, corespecies, first_year, year) - - # If maximumBiomass greater than zero, then process raster - if maximumBiomass > 0.0: - # Test is for first year - - first_year = year if year < first_year else first_year - #arcpy.AddMessage(f"\t{first_year}, {year} {first_year == year}") - - arcpy.AddMessage(f"\t> Calculating biomassArray") - - biomassArray = arcpy.RasterToNumPyArray(input_raster_path, nodata_to_value=np.nan) - biomassArray[biomassArray <= 0.0] = np.nan - - #sumWtCpue = sum of all wtcpue values (get this from input_raster_path stats??) - sumBiomassArray = np.nansum(biomassArray) - - arcpy.AddMessage(f"\t> sumBiomassArray: {sumBiomassArray}") - - arcpy.AddMessage(f"\t> biomassArray non-nan count: {np.count_nonzero(~np.isnan(biomassArray))}") - - # ###--->>> Biomass End - - arcpy.AddMessage(f"\t> Calculating latitudeArray") - - # ###--->>> Latitude Start - #CenterOfGravityLatitude = None - #MinimumLatitude = None - #MaximumLatitude = None - #OffsetLatitude = None - #CenterOfGravityLatitudeSE = None - - # Latitude - latitudeArray = arcpy.RasterToNumPyArray(region_latitude, nodata_to_value=np.nan) - #arcpy.AddMessage(latitudeArray.shape) - latitudeArray[np.isnan(biomassArray)] = np.nan - #arcpy.AddMessage(latitudeArray.shape) - - #arcpy.AddMessage(f"\t\t> latitudeArray non-nan count: {np.count_nonzero(~np.isnan(latitudeArray)):,d}") - - #arcpy.AddMessage(f"\t\t> Latitude Min: {np.nanmin(latitudeArray)}") - - #arcpy.AddMessage(f"\t\t> Latitude Max: {np.nanmax(latitudeArray)}") - - # make the biomass and latitude arrays one dimensional - - flatBiomassArray = biomassArray.flatten() - - flatLatitudeArray = latitudeArray.flatten() - - # latsInds is an array of indexes representing the sort - - latsInds = flatLatitudeArray.argsort() - - # sort biomass and latitude arrays by lat sorted index - - sortedBiomassArray = flatBiomassArray[latsInds] - sortedLatitudeArray = flatLatitudeArray[latsInds] - - # calculate the cumulative sum of the sorted biomass values - - sortedBiomassArrayCumSum = np.nancumsum(sortedBiomassArray) - - # quantile is cumulative sum value divided by total biomass - - sortedBiomassArrayQuantile = sortedBiomassArrayCumSum / np.nansum(flatBiomassArray) - - # find the difference between 0.95 and each cumulative sum value ... asbolute value gives the closest distance - - diffArray = np.abs(sortedBiomassArrayQuantile - 0.95) - - # find the index of the smallest difference - - minIndex = diffArray.argmin() - - # get the lat at that index - - #maxLat = sortedLatitudeArray[minIndex] - MaximumLatitude = sortedLatitudeArray[minIndex] - - # do the same for 0.05 - - diffArray = np.abs(sortedBiomassArrayQuantile - 0.05) - - minIndex = diffArray.argmin() - - #minLat = sortedLatitudeArray[minIndex] - MinimumLatitude = sortedLatitudeArray[minIndex] - - del sortedBiomassArrayCumSum, sortedBiomassArrayQuantile - del diffArray, minIndex - del sortedLatitudeArray, sortedBiomassArray, flatBiomassArray - del latsInds, flatLatitudeArray - - weightedLatitudeArray = np.multiply(biomassArray, latitudeArray) - - sumWeightedLatitudeArray = np.nansum(weightedLatitudeArray) - - #arcpy.AddMessage("\t\t> Sum Weighted Latitude: {sumWeightedLatitudeArray}") - - CenterOfGravityLatitude = sumWeightedLatitudeArray / sumBiomassArray - - if year == first_year: - first_year_offset_latitude = CenterOfGravityLatitude - - OffsetLatitude = CenterOfGravityLatitude - first_year_offset_latitude - - weightedLatitudeArrayVariance = np.nanvar(weightedLatitudeArray) - weightedLatitudeArrayCount = np.count_nonzero(~np.isnan(weightedLatitudeArray)) - - CenterOfGravityLatitudeSE = math.sqrt(weightedLatitudeArrayVariance) / math.sqrt(weightedLatitudeArrayCount) - - del weightedLatitudeArrayVariance, weightedLatitudeArrayCount - - #arcpy.AddMessage(f"\t\t> Center of Gravity Latitude: {round(CenterOfGravityLatitude,6)}" - arcpy.AddMessage(f"\t\t> Center of Gravity Latitude: {CenterOfGravityLatitude}") - arcpy.AddMessage(f"\t\t> Minimum Latitude (5th Percentile): {MinimumLatitude}") - arcpy.AddMessage(f"\t\t> Maximum Latitude (95th Percentile): {MaximumLatitude}") - arcpy.AddMessage(f"\t\t> Offset Latitude: {OffsetLatitude}") - arcpy.AddMessage(f"\t\t> Center of Gravity Latitude Standard Error: {CenterOfGravityLatitudeSE}") - - del latitudeArray, weightedLatitudeArray, sumWeightedLatitudeArray - - # ###--->>> Latitude End - - arcpy.AddMessage(f"\t> Calculating longitudeArray") - - # ###--->>> Longitude Start - #CenterOfGravityLongitude = None - #MinimumLongitude = None - #MaximumLongitude = None - #OffsetLongitude = None - #CenterOfGravityLongitudeSE = None - - # For issue of international date line - # Added/Modified by JFK June 15, 2022 - longitudeArray = arcpy.RasterToNumPyArray(region_longitude, nodata_to_value=np.nan) - - longitudeArray = np.mod(longitudeArray, 360.0) - - longitudeArray[np.isnan(biomassArray)] = np.nan - - # make the biomass and latitude arrays one dimensional - - flatBiomassArray = biomassArray.flatten() - - flatLongitudeArray = longitudeArray.flatten() - - # longsInds is an array of indexes representing the sort - - longsInds = flatLongitudeArray.argsort() - - # sort biomass and latitude arrays by long sorted index - - sortedBiomassArray = flatBiomassArray[longsInds] - sortedLongitudeArray = flatLongitudeArray[longsInds] - - # calculate the cumulative sum of the sorted biomass values - - sortedBiomassArrayCumSum = np.nancumsum(sortedBiomassArray) - - # quantile is cumulative sum value divided by total biomass - - sortedBiomassArrayQuantile = sortedBiomassArrayCumSum / np.nansum(flatBiomassArray) - - # find the difference between 0.95 and each cumulative sum value ... asbolute value gives the closest distance - - diffArray = np.abs(sortedBiomassArrayQuantile - 0.95) - - # find the index of the smallest difference - - minIndex = diffArray.argmin() - - # get the lat at that index - - MaximumLongitude = sortedLongitudeArray[minIndex] - - # do the same for 0.05 - - diffArray = np.abs(sortedBiomassArrayQuantile - 0.05) - - minIndex = diffArray.argmin() - - MinimumLongitude = sortedLongitudeArray[minIndex] - - del sortedBiomassArrayCumSum, sortedBiomassArrayQuantile, diffArray, minIndex - del sortedLongitudeArray, sortedBiomassArray, flatBiomassArray - del longsInds, flatLongitudeArray - - weightedLongitudeArray = np.multiply(biomassArray, longitudeArray) - - sumWeightedLongitudeArray = np.nansum(weightedLongitudeArray) - - CenterOfGravityLongitude = sumWeightedLongitudeArray / sumBiomassArray - - if year == first_year: - first_year_offset_longitude = CenterOfGravityLongitude - - OffsetLongitude = CenterOfGravityLongitude - first_year_offset_longitude - - weightedLongitudeArrayVariance = np.nanvar(weightedLongitudeArray) - weightedLongitudeArrayCount = np.count_nonzero(~np.isnan(weightedLongitudeArray)) - - CenterOfGravityLongitudeSE = math.sqrt(weightedLongitudeArrayVariance) / math.sqrt(weightedLongitudeArrayCount) - - del weightedLongitudeArrayVariance, weightedLongitudeArrayCount - - # Convert 360 back to 180 - # Added/Modified by JFK June 15, 2022 - CenterOfGravityLongitude = np.mod(CenterOfGravityLongitude - 180.0, 360.0) - 180.0 - MinimumLongitude = np.mod(MinimumLongitude - 180.0, 360.0) - 180.0 - MaximumLongitude = np.mod(MaximumLongitude - 180.0, 360.0) - 180.0 - - #arcpy.AddMessage(f"\t\t> Sum Weighted Longitude: {0}".format(sumWeightedLongitudeArray)) - - #arcpy.AddMessage(f"\t\t> Center of Gravity Longitude: {round(CenterOfGravityLongitude,6)}" - arcpy.AddMessage(f"\t\t> Center of Gravity Longitude: {CenterOfGravityLongitude}") - - #arcpy.AddMessage(F"\t\t> Center of Gravity Longitude: {np.mod(CenterOfGravityLongitude - 180.0, 360.0) -180.0}") - - arcpy.AddMessage(f"\t\t> Minimum Longitude (5th Percentile): {MinimumLongitude}") - arcpy.AddMessage(f"\t\t> Maximum Longitude (95th Percentile): {MaximumLongitude}") - arcpy.AddMessage(f"\t\t> Offset Longitude: {OffsetLongitude}") - arcpy.AddMessage(f"\t\t> Center of Gravity Longitude Standard Error: {CenterOfGravityLongitudeSE}") - - del longitudeArray, weightedLongitudeArray, sumWeightedLongitudeArray - - # ###--->>> Longitude End - - arcpy.AddMessage(f"\t> Calculating bathymetryArray") - - # ###--->>> Center of Gravity Depth (Bathymetry) Start - - #CenterOfGravityDepth = None - #MinimumDepth = None - #MaximumDepth = None - #OffsetDepth = None - #CenterOfGravityDepthSE = None - - # Bathymetry - bathymetryArray = arcpy.RasterToNumPyArray(region_bathymetry, nodata_to_value=np.nan) - # If biomass cells are Null, make bathymetry cells Null as well - bathymetryArray[np.isnan(biomassArray)] = np.nan - # For bathymetry values zero are larger, make zero - bathymetryArray[bathymetryArray >= 0.0] = 0.0 - - #arcpy.AddMessage("\t\t> bathymetryArray non-nan count: {0}".format(np.count_nonzero(~np.isnan(bathymetryArray))) - #arcpy.AddMessage("\t\t> Bathymetry Min: {0}".format(np.nanmin(bathymetryArray)) - #arcpy.AddMessage("\t\t> Bathymetry Max: {0}".format(np.nanmax(bathymetryArray)) - # make the biomass and latitude arrays one dimensional - - flatBiomassArray = biomassArray.flatten() - - flatBathymetryArray = bathymetryArray.flatten() - - # bathyInds is an array of indexes representing the sort - - bathyInds = flatBathymetryArray.argsort() - - # sort biomass and latitude arrays by lat sorted index - - sortedBiomassArray = flatBiomassArray[bathyInds] - sortedBathymetryArray = flatBathymetryArray[bathyInds] - - # calculate the cumulative sum of the sorted biomass values - - sortedBiomassArrayCumSum = np.nancumsum(sortedBiomassArray) - - # quantile is cumulative sum value divided by total biomass - - sortedBiomassArrayQuantile = sortedBiomassArrayCumSum/np.nansum(flatBiomassArray) - - # find the difference between 0.95 and each cumulative sum - # value ... asbolute value gives the closest distance - - diffArray = np.abs(sortedBiomassArrayQuantile - 0.95) - - # find the index of the smallest difference - - minIndex = diffArray.argmin() - - # get the lat at that index - - #maxLat = sortedBathymetryArray[minIndex] - MaximumDepth = sortedBathymetryArray[minIndex] - - # do the same for 0.05 - - diffArray = np.abs(sortedBiomassArrayQuantile - 0.05) - - minIndex = diffArray.argmin() - - #minLat = sortedBathymetryArray[minIndex] - MinimumDepth = sortedBathymetryArray[minIndex] - - del sortedBiomassArrayCumSum, sortedBiomassArrayQuantile, diffArray, minIndex - del sortedBathymetryArray, sortedBiomassArray, flatBiomassArray - del bathyInds, flatBathymetryArray - - weightedBathymetryArray = np.multiply(biomassArray, bathymetryArray) - - sumWeightedBathymetryArray = np.nansum(weightedBathymetryArray) - - arcpy.AddMessage(f"\t\t> Sum Weighted Bathymetry: {sumWeightedBathymetryArray}") - - CenterOfGravityDepth = sumWeightedBathymetryArray / sumBiomassArray - - if year == first_year: - first_year_offset_depth = CenterOfGravityDepth - - OffsetDepth = CenterOfGravityDepth - first_year_offset_depth - - weightedBathymetryArrayVariance = np.nanvar(weightedBathymetryArray) - weightedBathymetryArrayCount = np.count_nonzero(~np.isnan(weightedBathymetryArray)) - - CenterOfGravityDepthSE = math.sqrt(weightedBathymetryArrayVariance) / math.sqrt(weightedBathymetryArrayCount) - - del weightedBathymetryArrayVariance, weightedBathymetryArrayCount - - arcpy.AddMessage("\t\t> Center of Gravity Depth: {0}".format(CenterOfGravityDepth)) - - arcpy.AddMessage("\t\t> Minimum Depth (5th Percentile): {0}".format(MinimumDepth)) - - arcpy.AddMessage("\t\t> Maximum Depth (95th Percentile): {0}".format(MaximumDepth)) - - arcpy.AddMessage("\t\t> Offset Depth: {0}".format(OffsetDepth)) - - arcpy.AddMessage("\t\t> Center of Gravity Depth Standard Error: {0}".format(CenterOfGravityDepthSE)) - - del bathymetryArray, weightedBathymetryArray - del sumWeightedBathymetryArray - - # ###--->>> Center of Gravity Depth (Bathymetry) End - - # Clean Up - del biomassArray, sumBiomassArray - - elif maximumBiomass == 0.0: - CenterOfGravityLatitude = None - MinimumLatitude = None - MaximumLatitude = None - OffsetLatitude = None - CenterOfGravityLatitudeSE = None - CenterOfGravityLongitude = None - MinimumLongitude = None - MaximumLongitude = None - OffsetLongitude = None - CenterOfGravityLongitudeSE = None - CenterOfGravityDepth = None - MinimumDepth = None - MaximumDepth = None - OffsetDepth = None - CenterOfGravityDepthSE = None - - else: - arcpy.AddMessage('Something wrong with biomass raster') - - - arcpy.AddMessage(f"\t> Assigning variables to row values") - - # Clean-up - del maximumBiomass - - # Standard for all records - DatasetCode = datasetcode - Region = region - Season = season - DateCode = datecode - Species = species - CommonName = commonname - CoreSpecies = corespecies - Year = year - DistributionProjectName = distributionprojectname - DistributionProjectCode = distributionprojectcode - SummaryProduct = summaryproduct - - row = [ - DatasetCode, - Region, - Season, - DateCode, - Species, - CommonName, - CoreSpecies, - Year, - DistributionProjectName, - DistributionProjectCode, - SummaryProduct, - CenterOfGravityLatitude, - MinimumLatitude, - MaximumLatitude, - OffsetLatitude, - CenterOfGravityLatitudeSE, - CenterOfGravityLongitude, - MinimumLongitude, - MaximumLongitude, - OffsetLongitude, - CenterOfGravityLongitudeSE, - CenterOfGravityDepth, - MinimumDepth, - MaximumDepth, - OffsetDepth, - CenterOfGravityDepthSE, - ] - - del DatasetCode, Region, Season, DateCode, Species, CommonName - del CoreSpecies, Year, DistributionProjectName - del DistributionProjectCode, SummaryProduct, CenterOfGravityLatitude - del MinimumLatitude, MaximumLatitude, OffsetLatitude - del CenterOfGravityLatitudeSE, CenterOfGravityLongitude - del MinimumLongitude, MaximumLongitude, OffsetLongitude - del CenterOfGravityLongitudeSE, CenterOfGravityDepth, MinimumDepth - del MaximumDepth, OffsetDepth, CenterOfGravityDepthSE - - # Append to list - row_values.append(row) - del row - - del image_name, variable, species, commonname, corespecies, year, input_raster_path - del raster_year - - del raster_years - del first_year - - if "first_year_offset_latitude" in locals(): del first_year_offset_latitude - if "first_year_offset_longitude" in locals(): del first_year_offset_longitude - if "first_year_offset_depth" in locals(): del first_year_offset_depth - - del region_bathymetry, region_latitude, region_longitude, input_rasters - - arcpy.AddMessage("Inserting records into the table") - - # This gets a list of fields in the table - fields = [f.name for f in arcpy.ListFields(region_indicators) if f.type not in ['Geometry', 'OID']] - - # Open an InsertCursor - cursor = arcpy.da.InsertCursor(region_indicators, fields) - del fields - - # Insert new rows into the table - for row in row_values: - try: - row = [None if x != x else x for x in row] - cursor.insertRow(row) - except: - # Get the traceback object - tb = sys.exc_info()[2] - tbinfo = traceback.format_tb(tb)[0] - # Concatenate information together concerning the error into a message string - pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) - sys.exit()(pymsg) - finally: - del row - - # Delete cursor object - del cursor - - # Delete - del row_values - - getcount = arcpy.management.GetCount(region_indicators)[0] - arcpy.AddMessage(f'\n> "{os.path.basename(region_indicators)}" has {getcount} records\n') - del getcount - - PrintRowContent = False - if PrintRowContent: - printRowContent(region_indicators) - del PrintRowContent - - del region_indicators - - arcpy.management.Delete(rf"{region_gdb}\Datasets") - arcpy.management.Delete(rf"{region_gdb}\{table_name}_Bathymetry") - arcpy.management.Delete(rf"{region_gdb}\{table_name}_Latitude") - arcpy.management.Delete(rf"{region_gdb}\{table_name}_Longitude") - arcpy.management.Delete(rf"{region_gdb}\{table_name}_Raster_Mask") - arcpy.management.Delete(rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName") - - # Values from Datasets table - del datasetcode, region, season, datecode, distributionprojectcode - del distributionprojectname, summaryproduct - # Declared Variables assigned based on the passed paramater - del table_name, scratch_folder, project_folder, scratch_workspace - # Imported modules - del np, math, dismap_tools - # Passed paramater - del region_gdb - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def preprocessing(project_gdb="", table_names="", clear_folder=True): - try: - import dismap_tools - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic arcpy.env variables - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - # Set varaibales - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - - # Clear Scratch Folder - #ClearScratchFolder = True - #if ClearScratchFolder: - if clear_folder: - dismap_tools.clear_folder(folder=rf"{os.path.dirname(project_gdb)}\Scratch") - else: - pass - #del ClearScratchFolder - del clear_folder - - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - del project_folder, scratch_workspace - - if not table_names: - table_names = [row[0] for row in arcpy.da.SearchCursor(f"{project_gdb}\Datasets", - "TableName", - where_clause = "TableName LIKE '%_IDW'")] - else: - pass - - for table_name in table_names: - arcpy.AddMessage(f"Pre-Processing: {table_name}") - - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - - # Create Scratch Workspace for Region - if not arcpy.Exists(region_scratch_workspace): - os.makedirs(rf"{scratch_folder}\{table_name}") - if not arcpy.Exists(region_scratch_workspace): - arcpy.AddMessage(f"Create File GDB: '{table_name}'") - arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del region_scratch_workspace - # # # CreateFileGDB - arcpy.AddMessage(f"Creating File GDB: '{table_name}'") - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # CreateFileGDB - # # # Datasets - # Process: Make Table View (Make Table View) (management) - datasets = rf'{project_gdb}\Datasets' - arcpy.AddMessage(f"'{os.path.basename(datasets)}' has {arcpy.management.GetCount(datasets)[0]} records") - arcpy.management.Copy(datasets, rf"{region_gdb}\Datasets") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # Datasets - - # # # LayerSpeciesYearImageName - LayerSpeciesYearImageName = rf"{project_gdb}\{table_name}_LayerSpeciesYearImageName" - arcpy.AddMessage(f"The table '{table_name}_LayerSpeciesYearImageName' has {arcpy.management.GetCount(LayerSpeciesYearImageName)[0]} records") - arcpy.management.Copy(rf"{project_gdb}\{table_name}_LayerSpeciesYearImageName", rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del LayerSpeciesYearImageName - # # # LayerSpeciesYearImageName - - # # # Raster_Mask - arcpy.AddMessage(f"Copy Raster Mask for '{table_name}'") - arcpy.management.Copy(rf"{project_gdb}\{table_name}_Raster_Mask", rf"{region_gdb}\{table_name}_Raster_Mask") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # Raster_Mask - - # # # Bathymetry - arcpy.AddMessage(f"Copy Bathymetry for '{table_name}'") - arcpy.management.Copy(rf"{project_gdb}\{table_name}_Bathymetry", rf"{region_gdb}\{table_name}_Bathymetry") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # Bathymetry - - # # # Latitude - arcpy.AddMessage(f"Copy Latitude for '{table_name}'") - arcpy.management.Copy(rf"{project_gdb}\{table_name}_Latitude", rf"{region_gdb}\{table_name}_Latitude") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # Latitude - - # # # Longitude - arcpy.AddMessage(f"Copy Longitude for '{table_name}'") - arcpy.management.Copy(rf"{project_gdb}\{table_name}_Longitude", rf"{region_gdb}\{table_name}_Longitude") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # Longitude - - # Declared Variables - del table_name - del datasets - - # Declared Variables - del scratch_folder, region_gdb - # Imports - del dismap_tools - # Function Parameters - del project_gdb, table_names - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - # Imports - import dismap_tools - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - - - ## # Set worker parameters - ## #table_name = "AI_IDW" - ## table_name = "HI_IDW" - ## #table_name = "NBS_IDW" - ## #table_name = "ENBS_IDW" - - table_names = ["HI_IDW",] - - #preprocessing(project_gdb=project_gdb, table_names=table_names, clear_folder=True) - - for table_name in table_names: - region_gdb = rf"{os.path.dirname(project_gdb)}\Scratch\{table_name}.gdb" - try: - pass - worker(region_gdb=region_gdb) - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del table_name, region_gdb - del table_names - - # Declared Varaiables - # Imports - del dismap_tools - # Function Parameters - del project_gdb - - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_metadata_json_files.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_metadata_json_files.py deleted file mode 100644 index f595cb6..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_metadata_json_files.py +++ /dev/null @@ -1,612 +0,0 @@ -""" -Script documentation - -- Tool parameters are accessed using arcpy.GetParameter() or - arcpy.GetParameterAsText() -- Update derived parameter values using arcpy.SetParameter() or - arcpy.SetParameterAsText() -""" -import os, sys, traceback, inspect - -import arcpy - - -def script_tool(project_gdb=""): - """Script code goes below""" - try: - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - project_folder = os.path.dirname(project_gdb) - out_data_path = rf"{project_folder}\CSV_Data" - - root_dict = {"Esri" : 0, - "dataIdInfo" : 1, - "dqInfo" : 2, - "distInfo" : 3, - "mdContact" : 4, - "mdLang" : 5, - "mdChar" : 6, - "mdDateSt" : 7, - "mdHrLv" : 8, - "mdHrLvName" : 9, - "mdFileID" : 10, - "mdParentID" : 11, - "mdMaint" : 12, - "refSysInfo" : 13, - "spatRepInfo" : 14, - "spdoinfo" : 15, - "spref" : 16, - "contInfo" : 17, - "dataSetFn" : 18, - "eainfo" : 19, - "Binary" : 20, - } - - import json - json_path = rf"{out_data_path}\root_dict.json" - # Write to File - with open(json_path, 'w') as json_file: - json.dump(root_dict, json_file, indent=4) - del json_file - del root_dict - with open(json_path, "r") as json_file: - root_dict = json.load(json_file) - del json_file - arcpy.AddMessage(root_dict) - del root_dict - del json_path - del json - - esri_dict ={"CreaDate" : 0, - "CreaTime" : 1, - "ArcGISFormat" : 2, - "ArcGISstyle" : 3, - "ArcGISProfile" : 4, - "SyncOnce" : 5, - "DataProperties" : 6, - "lineage" : 0, - "itemProps" : 1, - "itemName" : 0, - "imsContentType" : 1, - "nativeExtBox" : 2, - "westBL" : 0, - "eastBL" : 1, - "southBL" : 2, - "northBL" : 3, - "exTypeCode" : 4, - "itemLocation" : 3, - "linkage" : 0, - "protocol" : 1, - "coordRef" : 4, - "type" : 0, - "geogcsn" : 1, - "csUnits" : 2, - "projcsn" : 3, - "peXml" : 4, - "SyncDate" : 7, - "SyncTime" : 8, - "ModDate" : 9, - "ModTime" : 10, - "scaleRange" : 11, - "minScale" : 12, - "maxScale" : 13, - "locales" : 14, - } - - import json - json_path = rf"{out_data_path}\esri_dict.json" - # Write to File - with open(json_path, 'w') as json_file: - json.dump(esri_dict, json_file, indent=4) - del json_file - del esri_dict - with open(json_path, "r") as json_file: - esri_dict = json.load(json_file) - del json_file - arcpy.AddMessage(esri_dict) - del esri_dict - del json_path - del json - - dataIdInfo_dict = {"dataIdInfo" : 0, - "envirDesc" : 0, - "dataLang" : 1, - "dataChar" : 2, - "idCitation" : 3, - "resTitle" : 0, - "resAltTitle" : 1, - "collTitle" : 2, - "date" : 3, - "presForm" : 4, - "PresFormCd" : 0, - "fgdcGeoform" : 1, - "citRespParty" : 5, - "spatRpType" : 4, - "dataExt" : 5, - "exDesc" : 0, - "geoEle" : 1, - "GeoBndBox" : 0, - "exTypeCode" : 0, - "westBL" : 1, - "eastBL" : 2, - "northBL" : 3, - "southBL" : 4, - "tempEle" : 2, - "TempExtent" : 0, - "exTemp" : 0, - "TM_Period" : 0, - "tmBegin" : 0, - "tmEnd" : 1, - "TM_Instant" : 1, - "tmPosition" : 0, - "searchKeys" : 1, - "idPurp" : 2, - "idAbs" : 3, - "idCredit" : 4, - "idStatus" : 5, - "resConst" : 6, - "discKeys" : 7, - "keyword" : 0, - "thesaName" : 1, - "resTitle" : 0, - "date" : 1, - "createDate" : 0, - "pubDate" : 1, - "reviseDate" : 2, - "citOnlineRes" : 2, - "linkage" : 0, - "orFunct" : 1, - "OnFunctCd" : 0, - "thesaLang" : 2, - "languageCode" : 0, - "countryCode" : 1, - "themeKeys" : 8, - "keyword" : 0, - "thesaName" : 1, - "resTitle" : 0, - "date" : 1, - "createDate" : 0, - "pubDate" : 1, - "reviseDate" : 2, - "citOnlineRes" : 2, - "linkage" : 0, - "orFunct" : 1, - "OnFunctCd" : 0, - "thesaLang" : 2, - "languageCode" : 0, - "countryCode" : 1, - "placeKeys" : 9, - "keyword" : 0, - "thesaName" : 1, - "resTitle" : 0, - "date" : 1, - "createDate" : 0, - "pubDate" : 1, - "reviseDate" : 2, - "citOnlineRes" : 2, - "linkage" : 0, - "orFunct" : 1, - "OnFunctCd" : 0, - "thesaLang" : 2, - "languageCode" : 0, - "countryCode" : 1, - "tempKeys" : 10, - "keyword" : 0, - "thesaName" : 1, - "resTitle" : 0, - "date" : 1, - "createDate" : 0, - "pubDate" : 1, - "reviseDate" : 2, - "citOnlineRes" : 2, - "linkage" : 0, - "orFunct" : 1, - "OnFunctCd" : 0, - "thesaLang" : 2, - "languageCode" : 0, - "countryCode" : 1, - "otherKeys" : 11, - "keyword" : 0, - "thesaName" : 1, - "resTitle" : 0, - "date" : 1, - "createDate" : 0, - "pubDate" : 1, - "reviseDate" : 2, - "citOnlineRes" : 2, - "linkage" : 0, - "orFunct" : 1, - "OnFunctCd" : 0, - "thesaLang" : 2, - "languageCode" : 0, - "countryCode" : 1, - "idPoC" : 11, - "resMaint" : 12, - - "tpCat" : 18, - } - - import json - json_path = rf"{out_data_path}\dataIdInfo_dict.json" - # Write to File - with open(json_path, 'w') as json_file: - json.dump(dataIdInfo_dict, json_file, indent=4) - del json_file - del dataIdInfo_dict - with open(json_path, "r") as json_file: - dataIdInfo_dict = json.load(json_file) - del json_file - arcpy.AddMessage(dataIdInfo_dict) - del dataIdInfo_dict - del json_path - del json - - idCitation_dict = {"idCitation" : 0, - "resTitle" : 0, - "resAltTitle" : 1, - "collTitle" : 2, - "presForm" : 3, - "PresFormCd" : 0, - "fgdcGeoform" : 1, - "date" : 4, - "createDate" : 0, - "pubDate" : 1, - "reviseDate" : 2, - "citRespParty" : 6, - } - - import json - json_path = rf"{out_data_path}\idCitation_dict.json" - # Write to File - with open(json_path, 'w') as json_file: - json.dump(idCitation_dict, json_file, indent=4) - del json_file - del idCitation_dict - with open(json_path, "r") as json_file: - idCitation_dict = json.load(json_file) - del json_file - arcpy.AddMessage(idCitation_dict) - del idCitation_dict - del json_path - del json - - contact_element_order_dict = {"editorSource" : 0, "editorDigest" : 1,"rpIndName" : 2, - "rpOrgName" : 3, "rpPosName" : 4, "rpCntInfo" : 5, - "cntAddress" : 0, "delPoint" : 0, "city" : 1, - "adminArea" : 2, "postCode" : 3, "eMailAdd" : 4, - "country" : 5, "cntPhone" : 1, "voiceNum" : 0, - "faxNum" : 1, "cntHours" : 2, "cntOnlineRes" : 3, - "linkage" : 0, "protocol" : 1, "orName" : 2, - "orDesc" : 3, "orFunct" : 4, "OnFunctCd" : 0, - "editorSave" : 6, "displayName" : 7, "role" : 8, - "RoleCd" : 0, "srcCitatn" : 1, "resTitle" : 0, - "resAltTitle" : 1, "collTitle" : 2, "date" : 10, - "createDate" : 0, "pubDate" : 1, "reviseDate" : 2, - "presForm" : 3, "PresFormCd" : 0, "fgdcGeoform" : 1, - "citRespParty" : 6, "citOnlineRes" : 2, - } - - import json - json_path = rf"{out_data_path}\contact_element_order_dict.json" - # Write to File - with open(json_path, 'w') as json_file: - json.dump(contact_element_order_dict, json_file, indent=4) - del json_file - del contact_element_order_dict - with open(json_path, "r") as json_file: - contact_element_order_dict = json.load(json_file) - del json_file - arcpy.AddMessage(contact_element_order_dict) - del contact_element_order_dict - del json_path - del json - - dqInfo_dict = { "dqScope" : 0, - "scpLvl" : 0, - "ScopeCd" : 0, - "scpLvlDesc" : 1, - "datasetSet" : 0, - "report" : 1, - "measDesc" : 0, - "measResult" : 1, - "dataLineage" : 3, - "statement" : 0, - "dataSource" : 1, - "srcDesc" : 0, - "srcCitatn" : 1, - "resTitle" : 0, - "resAltTitle" : 1, - "collTitle" : 2, - "citOnlineRes" : 2, - "linkage" : 0, - "protocol" : 1, - "orName" : 2, - "orDesc" : 3, - "orFunct" : 4, - "OnFunctCd" : 0, - "date" : 3, - "createDate" : 0, - "pubDate" : 1, - "reviseDate" : 2, - "otherCitDet" : 4, - "presForm" : 5, - "PresFormCd" : 0, - "fgdcGeoform" : 1, - "citRespParty" : 6, - "editorSource" : 0, "editorDigest" : 1,"rpIndName" : 2, - "rpOrgName" : 3, "rpPosName" : 4, "rpCntInfo" : 5, - "cntAddress" : 0, "delPoint" : 0, "city" : 1, - "adminArea" : 2, "postCode" : 3, "eMailAdd" : 4, - "country" : 5, "cntPhone" : 1, "voiceNum" : 0, - "faxNum" : 1, "cntHours" : 2, "cntOnlineRes" : 3, - "linkage" : 0, "protocol" : 1, "orName" : 2, - "orDesc" : 3, "orFunct" : 4, "OnFunctCd" : 0, - "editorSave" : 6, "displayName" : 7, "role" : 8, - "RoleCd" : 0, - "srcMedName" : 7, - "MedNameCd" : 0, - "prcStep" : 3, - "stepDesc" : 0, - "stepProc" : 1, - "editorSource" : 0, "editorDigest" : 1,"rpIndName" : 2, - "rpOrgName" : 3, "rpPosName" : 4, "rpCntInfo" : 5, - "cntAddress" : 0, "delPoint" : 0, "city" : 1, - "adminArea" : 2, "postCode" : 3, "eMailAdd" : 4, - "country" : 5, "cntPhone" : 1, "voiceNum" : 0, - "faxNum" : 1, "cntHours" : 2, "cntOnlineRes" : 3, - "linkage" : 0, "protocol" : 1, "orName" : 2, - "orDesc" : 3, "orFunct" : 4, "OnFunctCd" : 0, - "editorSave" : 6, "displayName" : 7, "role" : 8, - "RoleCd" : 0, - - "stepDateTm" : 2, - "cntOnlineRes" : 3, "linkage" : 0, - "protocol" : 1, "orName" : 2, "orDesc" : 3, - "orFunct" : 4, "OnFunctCd" : 0, - } - - import json - json_path = rf"{out_data_path}\dqInfo_dict.json" - # Write to File - with open(json_path, 'w') as json_file: - json.dump(dqInfo_dict, json_file, indent=4) - del json_file - del dqInfo_dict - with open(json_path, "r") as json_file: - dqInfo_dict = json.load(json_file) - del json_file - arcpy.AddMessage(dqInfo_dict) - del dqInfo_dict - del json_path - del json - - distInfo_dict = {"distInfo" : 0, - "distFormat" : 0, - "formatName" : 0, - "formatVer" : 1, - "fileDecmTech" : 2, - "formatInfo" : 3, - "distributor" : 1, - "distorCont" : 0, - "editorSource" : 0, - "editorDigest" : 1, - "rpIndName" : 2, - "rpOrgName" : 3, - "rpPosName" : 4, - "rpCntInfo" : 5, - "cntAddress" : 0, - "delPoint" : 0, - "city" : 1, - "adminArea" : 2, - "postCode" : 3, - "eMailAdd" : 4, - "country" : 5, - "cntPhone" : 1, - "voiceNum" : 0, - "faxNum" : 1, - "cntHours" : 2, - "cntOnlineRes" : 3, - "linkage" : 0, - "orName" : 1, - "orDesc" : 2, - "orFunct" : 3, - "OnFunctCd" : 0, - "editorSave" : 6, - "displayName" : 7, - "role" : 8, - "RoleCd" : 0, - "distTranOps" : 2, - "unitsODist" : 0, - "transSize" : 1, - "onLineSrc" : 2, - "linkage" : 0, - "protocol" : 1, - "orName" : 2, - "orDesc" : 3, - "orFunct" : 4, - "OnFunctCd" : 0, - } - - import json - json_path = rf"{out_data_path}\distInfo_dict.json" - # Write to File - with open(json_path, 'w') as json_file: - json.dump(distInfo_dict, json_file, indent=4) - del json_file - del distInfo_dict - with open(json_path, "r") as json_file: - distInfo_dict = json.load(json_file) - del json_file - arcpy.AddMessage(distInfo_dict) - del distInfo_dict - del json_path - del json - - RoleCd_dict = {"001" : "Resource Provider", "002" : "Custodian", - "003" : "Owner", "004" : "User", - "005" : "Distributor", "006" : "Originator", - "007" : "Point of Contact", "008" : "Principal Investigator", - "009" : "Processor", "010" : "Publisher", - "011" : "Author", "012" : "Collaborator", - "013" : "Editor", "014" : "Mediator", - "015" : "Rights Holder",} - - import json - json_path = rf"{out_data_path}\RoleCd_dict.json" - # Write to File - with open(json_path, 'w') as json_file: - json.dump(RoleCd_dict, json_file, indent=4) - del json_file - del RoleCd_dict - with open(json_path, "r") as json_file: - RoleCd_dict = json.load(json_file) - del json_file - arcpy.AddMessage(RoleCd_dict) - del RoleCd_dict - del json_path - del json - - #role_dict = {"citRespParty" : , - # "idPoC" : , - # "distorCont" : , - # "mdContact" : , - # "stepProc" - - - tpCat_dict = {"002": '', - "007": '', - "014": '',} - - import json - json_path = rf"{out_data_path}\tpCat_dict.json" - # Write to File - with open(json_path, 'w') as json_file: - json.dump(tpCat_dict, json_file, indent=4) - del json_file - del tpCat_dict - with open(json_path, "r") as json_file: - tpCat_dict = json.load(json_file) - del json_file - arcpy.AddMessage(tpCat_dict) - del tpCat_dict - del json_path - del json - - # ###################### DisMAP ######################################## - RoleCd_dict = {"001" : "Resource Provider", "002" : "Custodian", - "003" : "Owner", "004" : "User", - "005" : "Distributor", "006" : "Originator", - "007" : "Point of Contact", "008" : "Principal Investigator", - "009" : "Processor", "010" : "Publisher", - "011" : "Author", "012" : "Collaborator", - "013" : "Editor", "014" : "Mediator", - "015" : "Rights Holder",} - contact_dict = {"citRespParty" : [{"role" : "Custodian", "rpIndName" : "Timothy J Haverland", "eMailAdd" : "tim.haverland@noaa.gov"},], - "idPoC" : [{"role" : "Point of Contact", "rpIndName" : "Melissa Ann Karp", "eMailAdd" : "melissa.karp@noaa.gov"},], - "distorCont" : [{"role" : "Distributor", "rpIndName" : "Timothy J Haverland", "eMailAdd" : "tim.haverland@noaa.gov"},], - "mdContact" : [{"role" : "Author", "rpIndName" : "John F Kennedy", "eMailAdd" : "john.f.kennedy@noaa.gov"},], - "srcCitatn" : [{"role" : "Principal Investigator", "rpIndName" : "Melissa Ann Karp", "eMailAdd" : "melissa.karp@noaa.gov"},], - "stepProc" : [{"role" : "Processor", "rpIndName" : "John F Kennedy", "eMailAdd" : "john.f.kennedy@noaa.gov"}, - {"role" : "Processor", "rpIndName" : "Melissa Ann Karp", "eMailAdd" : "melissa.karp@noaa.gov"}, - ],} - del RoleCd_dict - - import json - json_path = rf"{out_data_path}\contact_dict.json" - #arcpy.AddMessage(json_path) - # Write to File - with open(json_path, 'w') as json_file: - json.dump(contact_dict, json_file, indent=4) - del json_file - del contact_dict - with open(json_path, "r") as json_file: - contact_dict = json.load(json_file) - del json_file - arcpy.AddMessage(contact_dict) - del contact_dict - del json_path - del json - - # ###################### DisMAP ######################################## - - # Declared Varaiables - del project_folder, out_data_path - # Imports - # Function Parameters - del project_gdb - - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == "__main__": - try: - - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - - script_tool(project_gdb=project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - - except SystemExit: - pass - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - else: - pass - finally: - sys.exit() \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_mosaics_director.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_mosaics_director.py deleted file mode 100644 index 6dc1cfb..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_mosaics_director.py +++ /dev/null @@ -1,382 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: create_species_year_image_name_table_director -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 09/03/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback -import inspect - -import arcpy # third-parties second - -def director(project_gdb="", Sequential=True, table_names=[]): - try: - # Imports - import dismap_tools - from create_mosaics_worker import preprocessing, worker - - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(rf"{project_gdb}"): - arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") - arcpy.AddError(arcpy.GetMessages(2)) - sys.exit() - else: - pass - - # Set History and Metadata logs, set serverity and message level - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(2) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic arcpy.env values - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = rf"{os.path.dirname(project_gdb)}\Scratch\scratch.gdb" - - preprocessing(project_gdb=project_gdb, table_names=table_names, clear_folder=True) - - # Set basic workkpace variables - scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" - csv_data_folder = rf"{os.path.dirname(project_gdb)}\CSV_Data" - - # Sequential Processing - if Sequential: - arcpy.AddMessage(f"Sequential Processing") - for i in range(0, len(table_names)): - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - try: - worker(region_gdb=region_gdb) - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del region_gdb, table_name - del i - else: - pass - - # Non-Sequential Processing - if not Sequential: - arcpy.AddMessage(f"Non-Sequential Processing") - # Imports - import multiprocessing - from time import time, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"Start multiprocessing using the ArcGIS Pro pythonw.exe.") - #Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS - #get_install_path() uses a registry query to figure out 64bit python exe if available - multiprocessing.set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe')) - # Get CPU count and then take 2 away for other process - _processes = multiprocessing.cpu_count() - 2 - _processes = _processes if len(table_names) >= _processes else len(table_names) - arcpy.AddMessage(f"Creating the multiprocessing Pool with {_processes} processes") - #Create a pool of workers, keep one cpu free for surfing the net. - #Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) - with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: - arcpy.AddMessage(f"\tPrepare arguments for processing") - # Use apply_async so we can handle exceptions gracefully - jobs={} - for i in range(0, len(table_names)): - try: - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - jobs[table_name] = pool.apply_async(worker, [region_gdb]) - del table_name, region_gdb - except: - pool.terminate() - traceback.print_exc() - sys.exit() - del i - all_finished = False - # Set a start time so that we can see how log things take - start_time = time() - result_completed = {} - while True: - all_finished = True - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - arcpy.AddMessage(f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"Have the workers finished?") - finish_time = strftime('%a %b %d %I:%M %p', localtime()) - time_elapsed = u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) - arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") - finish_time = f"{finish_time}.\n\t{time_elapsed}" - del time_elapsed - for table_name, result in jobs.items(): - if result.ready(): - if table_name not in result_completed: - result_completed[table_name] = finish_time - try: - # wait for and get the result from the task - result.get() - except: - pool.terminate() - traceback.print_exc() - sys.exit() - else: - pass - arcpy.AddMessage(f"Process {table_name}\n\tFinished on {result_completed[table_name]}") - else: - all_finished = False - arcpy.AddMessage(f"Process {table_name} is running. . .") - del table_name, result - del elapse_time, end_time, finish_time - if all_finished: - break - sleep(_processes * 7.5) - del result_completed - del start_time - del all_finished - arcpy.AddMessage(f"Close the process pool") - # close the process pool - pool.close() - # wait for all tasks to complete and processes to close - arcpy.AddMessage(f"\tWait for all tasks to complete and processes to close") - pool.join() - # Just in case - pool.terminate() - del pool - del jobs - del _processes - del time, multiprocessing, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"Done with multiprocessing Pool\n") - - # Post-Processing - arcpy.AddMessage("Post-Processing Begins") - - crf_folder = rf"{os.path.dirname(project_gdb)}\CRFs" - - datasets = list() - walk = arcpy.da.Walk(scratch_folder, datatype=["RasterDataset", "MosaicDataset"]) - for dirpath, dirnames, filenames in walk: - for filename in filenames: - datasets.append(os.path.join(dirpath, filename)) - del filename - del dirpath, dirnames, filenames - del walk - for dataset in datasets: - datasets_short_path = f"{os.path.basename(os.path.dirname(os.path.dirname(dataset)))}\{os.path.basename(os.path.dirname(dataset))}\{os.path.basename(dataset)}" - dataset_name = os.path.basename(dataset) - dataset_type = arcpy.Describe(dataset).datatype - region_gdb = os.path.dirname(dataset) - arcpy.AddMessage(f"\tDataset: '{dataset_name}'") - arcpy.AddMessage(f"\t\tType: '{dataset_type}'") - arcpy.AddMessage(f"\t\tPath: '{datasets_short_path}'") - arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") - if dataset.endswith("Mosaic"): - try: - if arcpy.Exists(rf"{project_gdb}\{dataset_name}"): - arcpy.management.Delete(rf"{project_gdb}\{dataset_name}") - else: - pass - arcpy.AddMessage(f"Copy '{dataset_name}'") - arcpy.management.Copy(in_data = dataset, - out_data = rf"{project_gdb}\{dataset_name}", - data_type = "MosaicDataset", - associated_data = "MosaicCatalogItemCategoryDomain 'CV domain' MosaicCatalogItemCategoryDomain DEFAULTS") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - #arcpy.AddMessage(f"\t\tAlter Fields for: '{dataset_name}'") - #dismap_tools.alter_fields(csv_data_folder, rf"{project_gdb}\{dataset_name}") - dismap_tools.import_metadata(csv_data_folder, rf"{project_gdb}\{dataset_name}") - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - - elif dataset.endswith(".crf"): - try: - if arcpy.Exists(rf"{crf_folder}\{dataset_name}"): - arcpy.management.Delete(rf"{crf_folder}\{dataset_name}") - else: - pass - arcpy.AddMessage(f"Copy '{dataset_name}'") - arcpy.management.Copy(in_data = dataset, - out_data = rf"{crf_folder}\{dataset_name}", - data_type = "MosaicDataset", - associated_data = "MosaicCatalogItemCategoryDomain 'CV domain' MosaicCatalogItemCategoryDomain DEFAULTS") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - dismap_tools.import_metadata(csv_data_folder, rf"{project_gdb}\{dataset_name}") - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - else: - pass - arcpy.management.Delete(dataset) - arcpy.AddMessage("\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del region_gdb, dataset_name, datasets_short_path, dataset_type - del dataset - del datasets - - arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") - arcpy.management.Compact(project_gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages().replace("\n", "\n\t")) - # Declared Variables assigned in function - del scratch_folder, csv_data_folder, crf_folder - # Imports - del preprocessing, worker, dismap_tools - # Function Parameters - del project_gdb, Sequential, table_names - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - # Imports - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - # Clear Scratch Folder - ClearScratchFolder = False - if ClearScratchFolder: - import dismap_tools - dismap_tools.clear_folder(folder=scratch_folder) - del dismap_tools - else: - pass - del ClearScratchFolder - - try: - # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", - # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", - Test = True - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["SEUS_FAL_IDW"]) - elif not Test: - #director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW", "HI_IDW"]) - #director(project_gdb=project_gdb, Sequential=True, table_names=["SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "AI_IDW", "GMEX_IDW"]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["GOA_IDW", "WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=True, table_names=["NEUS_FAL_IDW", "NEUS_SPR_IDW"]) - else: - pass - del Test - - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - - # Declared Variables - - # Imports - # Function Parameters - del project_gdb - - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - arcpy.AddError(f"Caught an KeyboardInterrupt in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}.") - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: '{se}' in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: '{e}' in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - if "Test" in locals().keys(): del Test - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_mosaics_worker.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_mosaics_worker.py deleted file mode 100644 index 59da677..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_mosaics_worker.py +++ /dev/null @@ -1,566 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: create_species_year_image_name_table_worker -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 09/03/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback -import inspect - -import arcpy # third-parties second - -def worker(region_gdb=""): - try: - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(rf"{region_gdb}"): - arcpy.AddError(f"{os.path.basename(region_gdb)} is missing!!") - arcpy.AddError(f"Function: '{inspect.stack()[0][3]}', Line Number: {inspect.stack()[0][2]}") - sys.exit() - else: - pass - - # Set History and Metadata logs, set serverity and message level - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(2) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - table_name = os.path.basename(region_gdb).replace(".gdb","") - scratch_folder = os.path.dirname(region_gdb) - project_folder = os.path.dirname(scratch_folder) - scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - region_raster_mask = rf"{region_gdb}\{table_name}_Raster_Mask" - - arcpy.AddMessage(f"Table Name: {table_name}\nProject Folder: {os.path.basename(project_folder)}\nScratch Folder: {os.path.basename(scratch_folder)}\n") - - # Set basic workkpace variables - arcpy.env.workspace = region_gdb - arcpy.env.scratchWorkspace = scratch_workspace - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - #arcpy.env.compression = "LZ77" - #arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" - #arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR LZ77 NO_SKIP" - arcpy.env.resamplingMethod = "BILINEAR" - arcpy.env.rasterStatistics = "STATISTICS 1 1" - #arcpy.env.buildStatsAndRATForTempRaster = True - - # DatasetCode, CSVFile, TransformUnit, TableName, GeographicArea, CellSize, - # PointFeatureType, FeatureClassName, Region, Season, DateCode, Status, - # DistributionProjectCode, DistributionProjectName, SummaryProduct, - # FilterRegion, FilterSubRegion, FeatureServiceName, FeatureServiceTitle, - # MosaicName, MosaicTitle, ImageServiceName, ImageServiceTitle - - # Get values for table_name from Datasets table - fields = ["TableName", "GeographicArea", "DatasetCode", "CellSize", "MosaicName", "MosaicTitle"] - region_list = [row for row in arcpy.da.SearchCursor(rf"{region_gdb}\Datasets", fields, where_clause = f"TableName = '{table_name}'")][0] - del fields - - # Assigning variables from items in the chosen table list - # ['AI_IDW', 'AI_IDW_Region', 'AI', 'Aleutian Islands', None, 'IDW'] - table_name = region_list[0] - #geographic_area = region_list[1] - datasetcode = region_list[2] - cell_size = region_list[3] - mosaic_name = region_list[4] - mosaic_title = region_list[5] - del region_list - - # Start of business logic for the worker function - arcpy.AddMessage(f"Processing: {table_name}") - - #geographic_area_sr = rf"{project_folder}\Dataset_Shapefiles\{table_name}\{geographic_area}.prj" - # Set the output coordinate system to what is needed for the - # DisMAP project - #psr = arcpy.SpatialReference(geographic_area_sr) - #arcpy.env.outputCoordinateSystem = psr - #del geographic_area_sr, geographic_area - - arcpy.AddMessage(f"\tSet the 'outputCoordinateSystem' based on the projection information for the geographic region") - psr = arcpy.Describe(region_raster_mask).spatialReference - arcpy.env.outputCoordinateSystem = psr - del region_raster_mask - - arcpy.AddMessage(f"Building the 'input_raster_paths' list") - - layerspeciesyearimagename = rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName" - - input_raster_paths = [] - - fields = ['Variable', 'ImageName'] - with arcpy.da.SearchCursor(layerspeciesyearimagename, fields, where_clause = f"DatasetCode = '{datasetcode}'") as cursor: - for row in cursor: - variable, image_name = row[0], row[1] - #if variable not in variables: variables.append(variable) - #arcpy.AddMessage(f"{variable}, {image_name}") - variable = f"_{variable}" if "Species Richness" in variable else variable - input_raster_path = rf"{project_folder}\Images\{table_name}\{variable}\{image_name}.tif" - if arcpy.Exists(input_raster_path): - #arcpy.AddMessage(input_raster_path) - input_raster_paths.append(input_raster_path) - else: - arcpy.AddError(f"{os.path.basename(input_raster_path)} is missing!!") - #arcpy.AddMessage(input_raster_path) - del row, variable, image_name, input_raster_path - del cursor - del fields - - mosaic_path = os.path.join(region_gdb, mosaic_name) - - # Loading images into the Mosaic. - arcpy.AddMessage(f"Loading the '{table_name}' Mosaic. This may take a while. . . Please wait. . .") - - with arcpy.EnvManager(scratchWorkspace = scratch_workspace, workspace = region_gdb): - arcpy.management.CreateMosaicDataset(in_workspace = region_gdb, - in_mosaicdataset_name = mosaic_name, - coordinate_system = psr, - num_bands = "1", - pixel_type = "32_BIT_FLOAT", - product_definition = "", - product_band_definitions = "") - - arcpy.AddMessage("\tCreate Mosaic Dataset: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.AddMessage(f"Loading Rasters into the {os.path.basename(mosaic_path)}.") - - arcpy.management.AddRastersToMosaicDataset(in_mosaic_dataset = mosaic_path, - raster_type = "Raster Dataset", - input_path = input_raster_paths, - update_cellsize_ranges = "UPDATE_CELL_SIZES", - #update_cellsize_ranges = "NO_CELL_SIZES", - update_boundary = "UPDATE_BOUNDARY", - #update_boundary = "NO_BOUNDARY", - update_overviews = "NO_OVERVIEWS", - maximum_pyramid_levels = None, - maximum_cell_size = "0", - minimum_dimension = "1500", - spatial_reference = psr, - filter = "", - sub_folder = "NO_SUBFOLDERS", - #duplicate_items_action = "OVERWRITE_DUPLICATES", - duplicate_items_action = "EXCLUDE_DUPLICATES", - build_pyramids = "NO_PYRAMIDS", - #calculate_statistics = "CALCULATE_STATISTICS", - calculate_statistics = "NO_STATISTICS", - #build_thumbnails = "BUILD_THUMBNAILS", - build_thumbnails = "NO_THUMBNAILS", - operation_description = "DisMAP", - #force_spatial_reference= "NO_FORCE_SPATIAL_REFERENCE", - force_spatial_reference = "FORCE_SPATIAL_REFERENCE", - #estimate_statistics = "ESTIMATE_STATISTICS", - estimate_statistics = "NO_STATISTICS", - ) - arcpy.AddMessage("\tAdd Rasters To Mosaic Dataset: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del input_raster_paths - del psr - - arcpy.AddMessage(f"Joining {os.path.basename(mosaic_path)} with {os.path.basename(layerspeciesyearimagename)}") - - arcpy.management.JoinField(in_data = mosaic_path, in_field="Name", join_table = layerspeciesyearimagename, join_field="ImageName", fields="DatasetCode;Region;Season;Species;CommonName;SpeciesCommonName;CoreSpecies;Year;StdTime;Variable;Value;Dimensions") - arcpy.AddMessage("\tJoin Field: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del layerspeciesyearimagename - - arcpy.AddMessage(f'Removing field index from {os.path.basename(mosaic_path)}') - - try: - arcpy.management.RemoveIndex(mosaic_path, [f"{table_name}_MosaicSpeciesIndex",]) - except: - pass - - arcpy.AddMessage(f"Adding field index to {os.path.basename(mosaic_path)}") - - # Add Attribute Index - arcpy.management.AddIndex(mosaic_path, ['Species', 'CommonName', 'SpeciesCommonName', 'Year'], f"{table_name}_MosaicSpeciesIndex", "NON_UNIQUE", "NON_ASCENDING") - arcpy.AddMessage("\tAdd Index: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.management.CalculateStatistics(mosaic_path, 1, 1, [], "OVERWRITE", "") - arcpy.AddMessage("\tCalculate Statistics: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - #--->>> SetMosaicDatasetProperties - arcpy.AddMessage(f"Set Mosaic Dataset Properties for {os.path.basename(mosaic_path)}") - - #fields = [f.name for f in arcpy.ListFields(mosaic_path) if f.type not in ['Geometry', 'OID'] and f.name not in ["Shape", "Raster", "Category", "TypeID", "ItemTS", "UriHash", "Uri",]] - fields = [f.name for f in arcpy.ListFields(mosaic_path)] - - fields = ";".join(fields) - - arcpy.management.SetMosaicDatasetProperties(in_mosaic_dataset = mosaic_path, - rows_maximum_imagesize = 4100, - columns_maximum_imagesize = 15000, - allowed_compressions = "LZ77;None", - default_compression_type = "LZ77", - JPEG_quality = 75, - LERC_Tolerance = 0.01, - resampling_type = "BILINEAR", - clip_to_footprints = "NOT_CLIP", - footprints_may_contain_nodata = "FOOTPRINTS_MAY_CONTAIN_NODATA", - clip_to_boundary = "CLIP", - color_correction = "NOT_APPLY", - allowed_mensuration_capabilities = "Basic", - default_mensuration_capabilities = "Basic", - allowed_mosaic_methods = "None", - default_mosaic_method = "None", - order_field = "StdTime", - order_base = "", - sorting_order = "ASCENDING", - mosaic_operator = "FIRST", - blend_width = 10, - view_point_x = 600, - view_point_y = 300, - max_num_per_mosaic = 50, - cell_size_tolerance = 0.8, - cell_size = f"{cell_size} {cell_size}", - metadata_level = "FULL", - transmission_fields = fields, - use_time = "ENABLED", - start_time_field = "StdTime", - end_time_field = "StdTime", - time_format = "YYYY", #YYYYMMDD - geographic_transform = None, - max_num_of_download_items = 20, - max_num_of_records_returned = 1000, - data_source_type = "GENERIC", - minimum_pixel_contribution = 1, - processing_templates = "None", - default_processing_template = "None", - time_interval = 1, - time_interval_units = "Years", - product_definition = "NONE", - product_band_definitions = None - ) - arcpy.AddMessage("\tSet Mosaic Dataset Properties: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del fields - - arcpy.AddMessage(f"Analyze Mosaic {os.path.basename(mosaic_path)} Dataset") - - arcpy.management.AnalyzeMosaicDataset( - in_mosaic_dataset = mosaic_path, - where_clause = "", - checker_keywords = "FOOTPRINT;FUNCTION;RASTER;PATHS;SOURCE_VALIDITY;STALE;PYRAMIDS;STATISTICS;PERFORMANCE;INFORMATION" - ) - arcpy.AddMessage("\tSet Mosaic Dataset Properties: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.AddMessage(f"Adding Multidimensional Information to {os.path.basename(mosaic_path)} Dataset") - - with arcpy.EnvManager(scratchWorkspace = scratch_workspace, workspace = region_gdb): - arcpy.md.BuildMultidimensionalInfo( - in_mosaic_dataset = mosaic_path, - variable_field = "Variable", - dimension_fields = [["StdTime", "Time Step", "Year"],], - variable_desc_units = None, - delete_multidimensional_info = "NO_DELETE_MULTIDIMENSIONAL_INFO" - ) - arcpy.AddMessage("\tBuild Multidimensional Info: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - #arcpy.management.CalculateStatistics(mosaic_path, 1, 1, [], "OVERWRITE", "") - #arcpy.AddMessage("\tCalculate Statistics: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - # Copy Raster to CRF - crf_path = rf"{scratch_folder}\{table_name}\{mosaic_name.replace('_Mosaic', '')}.crf" - - arcpy.management.CopyRaster( - in_raster = mosaic_path, - out_rasterdataset = crf_path, - config_keyword = "", - background_value = None, - nodata_value = "-3.40282e+38", - onebit_to_eightbit = "NONE", - colormap_to_RGB = "NONE", - pixel_type = "32_BIT_FLOAT", - scale_pixel_value = "NONE", - RGB_to_Colormap = "NONE", - format = "CRF", - transform = None, - process_as_multidimensional = "ALL_SLICES", - build_multidimensional_transpose = "NO_TRANSPOSE" - ) - arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.AddMessage(f"Calculate Statistics for {os.path.basename(crf_path)}") - - arcpy.management.CalculateStatistics(crf_path, 1, 1, [], "OVERWRITE", "") - arcpy.AddMessage("\tCalculate Statistics: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del crf_path - del mosaic_path - - # End of business logic for the worker function - arcpy.AddMessage(f"Processing for: {table_name} complete") - - arcpy.management.Delete(rf"{region_gdb}\Datasets") - arcpy.management.Delete(rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName") - arcpy.management.Delete(rf"{region_gdb}\{table_name}_Raster_Mask") - - # Declared Variables for this function only - del datasetcode, cell_size, mosaic_name, mosaic_title - # Basic variables - del table_name, scratch_folder, project_folder, scratch_workspace - # Imports - # Function parameter - del region_gdb - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def preprocessing(project_gdb="", table_names="", clear_folder=True): - try: - import dismap_tools - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic arcpy.env variables - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - # Set varaibales - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - - # Clear Scratch Folder - #ClearScratchFolder = True - #if ClearScratchFolder: - if clear_folder: - dismap_tools.clear_folder(folder=rf"{os.path.dirname(project_gdb)}\Scratch") - else: - pass - #del ClearScratchFolder - del clear_folder - - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - del project_folder, scratch_workspace - - if not table_names: - table_names = [row[0] for row in arcpy.da.SearchCursor(f"{project_gdb}\Datasets", - "TableName", - where_clause = "TableName LIKE '%_IDW'")] - else: - pass - - for table_name in table_names: - arcpy.AddMessage(f"Pre-Processing: {table_name}") - - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - - # Create Scratch Workspace for Region - if not arcpy.Exists(region_scratch_workspace): - os.makedirs(rf"{scratch_folder}\{table_name}") - if not arcpy.Exists(region_scratch_workspace): - arcpy.AddMessage(f"Create File GDB: '{table_name}'") - arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del region_scratch_workspace - # # # CreateFileGDB - arcpy.AddMessage(f"Creating File GDB: '{table_name}'") - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # CreateFileGDB - # # # Datasets - # Process: Make Table View (Make Table View) (management) - datasets = rf'{project_gdb}\Datasets' - arcpy.AddMessage(f"'{os.path.basename(datasets)}' has {arcpy.management.GetCount(datasets)[0]} records") - arcpy.management.Copy(datasets, rf"{region_gdb}\Datasets") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # Datasets - - # # # LayerSpeciesYearImageName - LayerSpeciesYearImageName = rf"{project_gdb}\{table_name}_LayerSpeciesYearImageName" - arcpy.AddMessage(f"The table '{table_name}_LayerSpeciesYearImageName' has {arcpy.management.GetCount(LayerSpeciesYearImageName)[0]} records") - arcpy.management.Copy(rf"{project_gdb}\{table_name}_LayerSpeciesYearImageName", rf"{region_gdb}\{table_name}_LayerSpeciesYearImageName") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del LayerSpeciesYearImageName - # # # LayerSpeciesYearImageName - - # # # Raster_Mask - arcpy.AddMessage(f"Copy Raster Mask for '{table_name}'") - arcpy.management.Copy(rf"{project_gdb}\{table_name}_Raster_Mask", rf"{region_gdb}\{table_name}_Raster_Mask") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # Raster_Mask - - del datasets - # Declared Variables - del table_name - - # Declared Variables - del scratch_folder, region_gdb - # Imports - del dismap_tools - # Function Parameters - del project_gdb, table_names - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - # Imports - import dismap_tools - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - ## # Set worker parameters - ## #table_name = "AI_IDW" - ## table_name = "HI_IDW" - ## #table_name = "NBS_IDW" - ## #table_name = "ENBS_IDW" - - table_names = ["HI_IDW", "NBS_IDW"] - - preprocessing(project_gdb=project_gdb, table_names=table_names, clear_folder=True) - - for table_name in table_names: - region_gdb = rf"{os.path.dirname(project_gdb)}\Scratch\{table_name}.gdb" - try: - pass - worker(region_gdb=region_gdb) - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del table_name, region_gdb - del table_names - - # Declared Varaiables - # Imports - del dismap_tools - # Function Parameters - del project_gdb - - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_rasters_director.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_rasters_director.py deleted file mode 100644 index c201cd1..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_rasters_director.py +++ /dev/null @@ -1,293 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: create_species_year_image_name_table_director -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 09/03/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback - -import inspect - -import arcpy # third-parties second - -def director(project_gdb="", Sequential=True, table_names=[]): - try: - from create_rasters_worker import preprocessing, worker - - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(rf"{project_gdb}"): - arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") - arcpy.AddError(arcpy.GetMessages(2)) - sys.exit() - #sys.exit() - else: - pass - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - preprocessing(project_gdb=project_gdb, table_names=table_names, clear_folder=True) - - # Sequential Processing - if Sequential: - arcpy.AddMessage(f"Sequential Processing") - for i in range(0, len(table_names)): - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{os.path.dirname(project_gdb)}\Scratch\{table_name}.gdb" - try: - pass - worker(region_gdb=region_gdb) - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del region_gdb, table_name - del i - else: - pass - - # Non-Sequential Processing - if not Sequential: - import multiprocessing - from time import time, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"Start multiprocessing using the ArcGIS Pro pythonw.exe.") - #Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS - #get_install_path() uses a registry query to figure out 64bit python exe if available - multiprocessing.set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe')) - # Get CPU count and then take 2 away for other process - _processes = multiprocessing.cpu_count() - 2 - _processes = _processes if len(table_names) >= _processes else len(table_names) - arcpy.AddMessage(f"Creating the multiprocessing Pool with {_processes} processes") - #Create a pool of workers, keep one cpu free for surfing the net. - #Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) - with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: - arcpy.AddMessage(f"\tPrepare arguments for processing") - # Use apply_async so we can handle exceptions gracefully - jobs={} - for i in range(0, len(table_names)): - try: - arcpy.AddMessage(f"Processing: {tablenames[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - jobs[table_name] = pool.apply_async(worker, [region_gdb]) - del table_name, region_gdb - except: - pool.terminate() - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del i - all_finished = False - # Set a start time so that we can see how log things take - start_time = time() - result_completed = {} - while True: - all_finished = True - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - arcpy.AddMessage(f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"Have the workers finished?") - finish_time = strftime('%a %b %d %I:%M %p', localtime()) - time_elapsed = u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) - arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") - finish_time = f"{finish_time}.\n\t{time_elapsed}" - del time_elapsed - for table_name, result in jobs.items(): - if result.ready(): - if table_name not in result_completed: - result_completed[table_name] = finish_time - try: - # wait for and get the result from the task - result.get() - except: - pool.terminate() - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - pass - arcpy.AddMessage(f"Process {table_name}\n\tFinished on {result_completed[table_name]}") - else: - all_finished = False - arcpy.AddMessage(f"Process {table_name} is running. . .") - del table_name, result - del elapse_time, end_time, finish_time - if all_finished: - break - sleep(_processes * 7.5) - del result_completed - del start_time - del all_finished - arcpy.AddMessage(f"\tClose the process pool") - # close the process pool - pool.close() - # wait for all tasks to complete and processes to close - arcpy.AddMessage(f"\tWait for all tasks to complete and processes to close") - pool.join() - # Just in case - pool.terminate() - del pool - del jobs - del _processes - del time, multiprocessing, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"\tDone with multiprocessing Pool") - - # No Post-Processing - - arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") - arcpy.management.Compact(project_gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - # Declared Variables assigned in function - del scratch_folder - # Imports - del preprocessing, worker - # Function Parameters - del project_gdb, Sequential, table_names - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - # Imports - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - try: - pass - # table_names = ["AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW",] - - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["HI_IDW", "AI_IDW",]) - - elif not Test: - # - #director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", ]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "NBS_IDW", ]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["HI_IDW",]) - #director(project_gdb=project_gdb, Sequential=False, table_names=[ "WC_ANN_IDW", "WC_TRI_IDW",]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_FAL_IDW", "NEUS_SPR_IDW", ]) - #director(project_gdb=project_gdb, Sequential=False, table_names=[]) - else: - pass - del Test - - except: - pass - #arcpy.AddError(arcpy.GetMessages(2)) - #traceback.print_exc() - #sys.exit() - - # Declared Varaiables - # Imports - - # Function Parameters - del project_gdb - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_region_bathymetry_director.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_region_bathymetry_director.py deleted file mode 100644 index 0449423..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_region_bathymetry_director.py +++ /dev/null @@ -1,405 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: module1 -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 05/03/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback -import inspect - -import arcpy # third-parties second - -def director(project_gdb="", Sequential=True, table_names=[]): - try: - # Imports - import dismap_tools - from create_region_bathymetry_worker import preprocessing, worker - - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(rf"{project_gdb}"): - arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") - arcpy.AddError(arcpy.GetMessages(2)) - sys.exit() - else: - pass - - # Set History and Metadata logs, set serverity and message level - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(2) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" - scratch_workspace = rf"{os.path.dirname(project_gdb)}\Scratch\scratch.gdb" - csv_data_folder = rf"{os.path.dirname(project_gdb)}\CSV_Data" - #project_bathymetry_gdb = rf"{os.path.dirname(project_gdb)}\Bathymetry\Bathymetry.gdb" - - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - - preprocessing(project_gdb=project_gdb, table_names=table_names, clear_folder=True) - - del project_folder, scratch_workspace - -## if not table_names: -## table_names = [row[0] for row in arcpy.da.SearchCursor(f"{project_gdb}\Datasets", -## "TableName", -## where_clause = "TableName LIKE '%_IDW'")] -## else: -## pass -## -## # Pre Processing -## for table_name in table_names: -## arcpy.AddMessage(f"Pre-Processing: {table_name}") -## -## region_gdb = rf"{scratch_folder}\{table_name}.gdb" -## region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" -## -## # Create Scratch Workspace for Region -## if not arcpy.Exists(region_scratch_workspace): -## os.makedirs(rf"{scratch_folder}\{table_name}") -## if not arcpy.Exists(region_scratch_workspace): -## arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") -## del region_scratch_workspace -## -## #datasets = [rf"{project_gdb}\{table_name}_Fishnet", ] -## #if not any(arcpy.management.GetCount(d)[0] == 0 for d in datasets): -## -## if not arcpy.Exists(rf"{scratch_folder}\{table_name}.gdb"): -## arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") -## arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) -## else: -## pass -## arcpy.management.Copy(rf"{project_gdb}\{table_name}_Fishnet", rf"{region_gdb}\{table_name}_Fishnet") -## arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) -## -## arcpy.management.CopyRaster(rf"{project_gdb}\{table_name}_Raster_Mask", rf"{region_gdb}\{table_name}_Raster_Mask") -## arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) -## -## arcpy.management.CopyRaster(rf"{project_bathymetry_gdb}\{table_name}_Bathymetry", rf"{region_gdb}\{table_name}_Fishnet_Bathymetry") -## arcpy.AddMessage("\tCopy Raster: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) -## -## #else: -## # arcpy.AddWarning(f"One or more datasets contains zero records!!") -## # for d in datasets: -## # arcpy.AddMessage(f"\t{os.path.basename(d)} has {arcpy.management.GetCount(d)[0]} records") -## # del d -## # se = f"SystemExit at line number: '{traceback.extract_stack()[-1].lineno}'" -## # sys.exit()(se) -## #if "datasets" in locals().keys(): del datasets -## -## del region_gdb, table_name -## -## del project_bathymetry_gdb - - # Sequential Processing - if Sequential: - arcpy.AddMessage(f"Sequential Processing") - for i in range(0, len(table_names)): - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - try: - pass - #worker(region_gdb=region_gdb) - except: - traceback.print_exc() - del region_gdb, table_name - del i - else: - pass - - # Non-Sequential Processing - if not Sequential: - import multiprocessing - from time import time, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"Start multiprocessing using the ArcGIS Pro pythonw.exe.") - #Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS - #get_install_path() uses a registry query to figure out 64bit python exe if available - multiprocessing.set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe')) - # Get CPU count and then take 2 away for other process - _processes = multiprocessing.cpu_count() - 2 - _processes = _processes if len(table_names) >= _processes else len(table_names) - arcpy.AddMessage(f"Creating the multiprocessing Pool with {_processes} processes") - #Create a pool of workers, keep one cpu free for surfing the net. - #Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) - with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: - arcpy.AddMessage(f"\tPrepare arguments for processing") - # Use apply_async so we can handle exceptions gracefully - jobs={} - for i in range(0, len(table_names)): - try: - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - jobs[table_name] = pool.apply_async(worker, [region_gdb]) - del table_name, region_gdb - except: - pool.terminate() - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del i - all_finished = False - # Set a start time so that we can see how log things take - start_time = time() - result_completed = {} - while True: - all_finished = True - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - arcpy.AddMessage(f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"Have the workers finished?") - finish_time = strftime('%a %b %d %I:%M %p', localtime()) - time_elapsed = u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) - arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") - finish_time = f"{finish_time}.\n\t{time_elapsed}" - del time_elapsed - for table_name, result in jobs.items(): - if result.ready(): - if table_name not in result_completed: - result_completed[table_name] = finish_time - try: - # wait for and get the result from the task - result.get() - except SystemExit: - pool.terminate() - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: - pool.terminate() - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - pass - arcpy.AddMessage(f"Process {table_name}\n\tFinished on {result_completed[table_name]}") - else: - all_finished = False - arcpy.AddMessage(f"Process {table_name} is running. . .") - del table_name, result - del elapse_time, end_time, finish_time - if all_finished: - break - sleep(_processes * 7.5) - del result_completed - del start_time - del all_finished - arcpy.AddMessage(f"\tClose the process pool") - # close the process pool - pool.close() - # wait for all tasks to complete and processes to close - arcpy.AddMessage(f"\tWait for all tasks to complete and processes to close") - pool.join() - # Just in case - pool.terminate() - del pool - del jobs - del _processes - del time, multiprocessing, localtime, strftime, sleep, gmtime - - arcpy.AddMessage(f"\tDone with multiprocessing Pool") - - # Post-Processing - arcpy.AddMessage("Post-Processing Begins") - arcpy.AddMessage("Processing Results") - - datasets = list() - - walk = arcpy.da.Walk(scratch_folder, datatype="RasterDataset", type=[]) - for dirpath, dirnames, filenames in walk: - for filename in filenames: - datasets.append(os.path.join(dirpath, filename)) - del filename - del dirpath, dirnames, filenames - del walk - - for dataset in datasets: - dataset_short_path = f"{os.path.basename(os.path.dirname(os.path.dirname(dataset)))}\{os.path.basename(os.path.dirname(dataset))}\{os.path.basename(dataset)}" - #arcpy.AddMessage(fc_short_path) - dataset_name = os.path.basename(dataset) - region_gdb = os.path.dirname(dataset) - arcpy.AddMessage(f"\tDataset: '{dataset_name}'") - arcpy.AddMessage(f"\t\tPath: '{dataset_short_path}'") - arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") - - if arcpy.Exists(rf"{project_gdb}\{dataset_name}"): - arcpy.management.Delete(rf"{project_gdb}\{dataset_name}") - else: - pass - - arcpy.management.Copy(dataset, rf"{project_gdb}\{dataset_name}") - arcpy.AddMessage("\tCopy: {0} {1}\n".format(f"{dataset_name}", arcpy.GetMessages(0).replace("\n", '\n\t'))) - - desc = arcpy.da.Describe(dataset) - if desc["dataType"] in ["FeatureClass", "Table", "MosaicDataset"]: - dismap_tools.alter_fields(csv_data_folder, rf"{project_gdb}\{dataset_name}") - del desc - - del region_gdb, dataset_name, dataset_short_path, dataset - - del datasets - - arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") - arcpy.management.Compact(project_gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - - # Declared Variables - del csv_data_folder, preprocessing, scratch_folder - # Imports - del dismap_tools, worker - # Function Parameters - del project_gdb, Sequential, table_names - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - # Imports - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - # Clear Scratch Folder - ClearScratchFolder = False - if ClearScratchFolder: - import dismap_tools - dismap_tools.clear_folder(folder=scratch_folder) - del dismap_tools - else: - pass - del ClearScratchFolder - - try: - # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", - # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", - - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["HI_IDW"]) - else: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW", "HI_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW", "AI_IDW", "GOA_IDW", "WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW"]) - del Test - - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - - # Declared Varaiables - # Imports - - # Function Parameters - del project_gdb - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - if "Test" in locals().keys(): del Test - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_region_bathymetry_worker.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_region_bathymetry_worker.py deleted file mode 100644 index 941b51c..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_region_bathymetry_worker.py +++ /dev/null @@ -1,430 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: module1 -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 05/03/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback -import inspect - -import arcpy # third-parties second - -def worker(region_gdb=""): - try: - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(rf"{region_gdb}"): - sys.exit()(f"{os.path.basename(region_gdb)} is missing!!") - - # Imports - from arcpy import metadata as md - import dismap_tools - - # Set History and Metadata logs, set serverity and message level - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(2) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic workkpace variables - table_name = os.path.basename(region_gdb).replace(".gdb","") - scratch_folder = os.path.dirname(region_gdb) - project_folder = os.path.dirname(scratch_folder) - csv_data_folder = rf"{project_folder}\CSV_Data" - scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - - arcpy.AddMessage(f"Table Name: {table_name}\nProject Folder: {os.path.basename(project_folder)}\nScratch Folder: {os.path.basename(scratch_folder)}\n") - - # Set basic workkpace variables - arcpy.env.workspace = region_gdb - arcpy.env.scratchWorkspace = scratch_workspace - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - arcpy.env.compression = "LZ77" - #arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" - arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR LZ77 NO_SKIP" - arcpy.env.resamplingMethod = "BILINEAR" - arcpy.env.rasterStatistics = "STATISTICS 1 1" - #arcpy.env.XYResolution = "0.1 Meters" - #arcpy.env.XYResolution = "0.01 Meters" - #arcpy.env.cellAlignment = "ALIGN_WITH_PROCESSING_EXTENT" # Set the cell alignment environment using a keyword. - - # DatasetCode, CSVFile, TransformUnit, TableName, GeographicArea, CellSize, - # PointFeatureType, FeatureClassName, Region, Season, DateCode, Status, - # DistributionProjectCode, DistributionProjectName, SummaryProduct, - # FilterRegion, FilterSubRegion, FeatureServiceName, FeatureServiceTitle, - # MosaicName, MosaicTitle, ImageServiceName, ImageServiceTitle - - # Get values for table_name from Datasets table - #fields = ["TableName", "GeographicArea", "DatasetCode", "CellSize", "MosaicName", "MosaicTitle"] - #region_list = [row for row in arcpy.da.SearchCursor(rf"{region_gdb}\Datasets", fields, where_clause = f"TableName = '{table_name}'")][0] - #del fields - - # Assigning variables from items in the chosen table list - # ['AI_IDW', 'AI_IDW_Region', 'AI', 'Aleutian Islands', None, 'IDW'] - #table_name = region_list[0] - #geographic_area = region_list[1] - #datasetcode = region_list[2] - #cell_size = region_list[3] - #mosaic_name = region_list[4] - #mosaic_title = region_list[5] - #del region_list - - # Start of business logic for the worker function - arcpy.AddMessage(f"Processing: {table_name}") - - # Input - region_fishnet = rf"{region_gdb}\{table_name}_Fishnet" - region_raster_mask = rf"{region_gdb}\{table_name}_Raster_Mask" - region_fishnet_bathymetry = rf"{region_gdb}\{table_name}_Fishnet_Bathymetry" - # Output - region_bathymetry = rf"{region_gdb}\{table_name}_Bathymetry" - - # Get the reference system defined for the region in datasets - # Set the output coordinate system to what is needed for the - # DisMAP project - region_prj = arcpy.Describe(region_raster_mask).spatialReference - #arcpy.AddMessage(f"region_prj: {region_prj}") - if region_prj.linearUnitName == "Kilometer": - arcpy.env.cellSize = 1 - arcpy.env.XYResolution = 0.1 - arcpy.env.XYResolution = 1.0 - elif region_prj.linearUnitName == "Meter": - arcpy.env.cellSize = 1000 - arcpy.env.XYResolution = 0.0001 - arcpy.env.XYResolution = 0.001 - - # Process: Point to Raster Mask - arcpy.env.outputCoordinateSystem = region_prj - arcpy.env.cellSize = int(arcpy.Describe(f"{region_raster_mask}/Band_1").meanCellWidth) - arcpy.env.extent = arcpy.Describe(region_raster_mask).extent - arcpy.env.mask = region_raster_mask - arcpy.env.snapRaster = region_raster_mask - - del region_prj - - arcpy.AddMessage(f"\tCalculating Zonal Statistics using {os.path.basename(region_fishnet)} and {os.path.basename(region_fishnet_bathymetry)} to create {os.path.basename(region_bathymetry)}") - # Execute ZonalStatistics - #out_raster = arcpy.sa.ZonalStatistics(region_fishnet, "OID", region_fishnet_bathymetry, "MEDIAN", "NODATA") - #out_raster = arcpy.sa.ZonalStatistics(region_fishnet, "OID", region_fishnet_bathymetry, "MEDIAN", "DATA") - - with arcpy.EnvManager(scratchWorkspace = arcpy.env.scratchWorkspace): - #print(region_fishnet) - #rint(region_fishnet_bathymetry) - out_raster = arcpy.sa.ZonalStatistics( - in_zone_data = region_fishnet, - zone_field = "OID", - in_value_raster = region_fishnet_bathymetry, - statistics_type = "MEDIAN", - ignore_nodata = "DATA", - process_as_multidimensional = "CURRENT_SLICE", - percentile_value = 90, - percentile_interpolation_type = "AUTO_DETECT", - circular_calculation = "ARITHMETIC", - circular_wrap_value = 360 - ) - - arcpy.AddMessage("\tZonal Statistics: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # Save the output - out_raster.save(region_bathymetry) - arcpy.AddMessage("\tSave: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del out_raster - - dismap_tools.import_metadata(csv_data_folder, region_bathymetry) - - del region_bathymetry - - arcpy.management.Delete(rf"{region_gdb}\Datasets") - arcpy.AddMessage("\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - arcpy.management.Delete(region_raster_mask) - arcpy.AddMessage("\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - arcpy.management.Delete(region_fishnet) - arcpy.AddMessage("\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - arcpy.management.Delete(region_fishnet_bathymetry) - arcpy.AddMessage("\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del region_raster_mask, region_fishnet, region_fishnet_bathymetry - - arcpy.management.Compact(region_gdb) - - # Declared Variables for this function only - del scratch_folder, scratch_workspace - del table_name, project_folder, csv_data_folder - # Imports - del md, dismap_tools - # Function parameter - del region_gdb - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def preprocessing(project_gdb="", table_names="", clear_folder=True): - try: - import dismap_tools - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic arcpy.env variables - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - # Set varaibales - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - csv_data_folder = rf"{os.path.dirname(project_gdb)}\CSV_Data" - project_bathymetry_gdb = rf"{project_folder}\Bathymetry\Bathymetry.gdb" - - # Clear Scratch Folder - #ClearScratchFolder = True - #if ClearScratchFolder: - if clear_folder: - dismap_tools.clear_folder(folder=rf"{os.path.dirname(project_gdb)}\Scratch") - else: - pass - #del ClearScratchFolder - del clear_folder - - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - del project_folder, scratch_workspace - - if not table_names: - table_names = [row[0] for row in arcpy.da.SearchCursor(f"{project_gdb}\Datasets", - "TableName", - where_clause = "TableName LIKE '%_IDW'")] - else: - pass - - for table_name in table_names: - arcpy.AddMessage(f"Pre-Processing: {table_name}") - - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - - # Create Scratch Workspace for Region - if not arcpy.Exists(region_scratch_workspace): - os.makedirs(rf"{scratch_folder}\{table_name}") - if not arcpy.Exists(region_scratch_workspace): - arcpy.AddMessage(f"Create File GDB: '{table_name}'") - arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del region_scratch_workspace - # # # CreateFileGDB - arcpy.AddMessage(f"Creating File GDB: '{table_name}'") - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # CreateFileGDB - - # # # Datasets - # Process: Make Table View (Make Table View) (management) - datasets = rf'{project_gdb}\Datasets' - arcpy.AddMessage(f"'{os.path.basename(datasets)}' has {arcpy.management.GetCount(datasets)[0]} records") - arcpy.management.Copy(datasets, rf"{region_gdb}\Datasets") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del datasets - # # # Datasets - - # # # Fishnet - region_fishnet = rf"{project_gdb}\{table_name}_Fishnet" - arcpy.AddMessage(f"The table '{table_name}_Fishnet' has {arcpy.management.GetCount(region_fishnet)[0]} records") - arcpy.management.Copy(region_fishnet, rf"{region_gdb}\{table_name}_Fishnet") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del region_fishnet - # # # Fishnet - - # # # Raster_Mask - arcpy.AddMessage(f"Copy Raster Mask for '{table_name}'") - arcpy.management.Copy(rf"{project_gdb}\{table_name}_Raster_Mask", rf"{region_gdb}\{table_name}_Raster_Mask") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # Raster_Mask - - # # # Bathymetry - arcpy.AddMessage(f"Copy Bathymetry for '{table_name}'") - arcpy.management.Copy(rf"{project_bathymetry_gdb}\{table_name}_Bathymetry", rf"{region_gdb}\{table_name}_Fishnet_Bathymetry") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # # # Bathymetry - - # Declared Variables - del table_name - - # Declared Variables - del scratch_folder, region_gdb - del csv_data_folder, project_bathymetry_gdb - # Imports - del dismap_tools - # Function Parameters - del project_gdb, table_names - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - ## # Set worker parameters - ## #table_name = "AI_IDW" - ## table_name = "HI_IDW" - ## #table_name = "NBS_IDW" - ## #table_name = "ENBS_IDW" - - table_names = ["HI_IDW",] - - preprocessing(project_gdb=project_gdb, table_names=table_names, clear_folder=True) - - for table_name in table_names: - region_gdb = rf"{os.path.dirname(project_gdb)}\Scratch\{table_name}.gdb" - try: - pass - worker(region_gdb=region_gdb) - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del table_name, region_gdb - del table_names - - # Declared Varaiables - # Imports - # Function Parameters - del project_gdb - - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_region_fishnets_director.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_region_fishnets_director.py deleted file mode 100644 index a1637dc..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_region_fishnets_director.py +++ /dev/null @@ -1,401 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: create_region_fishnets_director.py -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 25/02/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback - -import inspect - -import arcpy # third-parties second - -def director(project_gdb="", Sequential=True, table_names=[]): - try: - # Imports - import dismap_tools - from create_region_fishnets_worker import worker - - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(project_gdb): - sys.exit()(f"{os.path.basename(project_gdb)} is missing!!") - - # Set History and Metadata logs, set serverity and message level - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic workkpace variables - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - csv_data_folder = rf"{project_folder}\CSV_Data" - - # Clear Scratch Folder - dismap_tools.clear_folder(folder=scratch_folder) - - # Create Scratch Workspace for Project - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - if not arcpy.Exists(scratch_folder): - os.makedirs(rf"{scratch_folder}") - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"scratch") - - # Set basic workkpace variables - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - del project_folder - - if not table_names: - table_names = [row[0] for row in arcpy.da.SearchCursor(f"{project_gdb}\Datasets", - "TableName", - where_clause = "TableName LIKE '%_IDW'")] - else: - pass - - # Pre Processing - for table_name in table_names: - arcpy.AddMessage(f"Pre-Processing: {table_name}") - - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - - # Create Scratch Workspace for Region - if not arcpy.Exists(region_scratch_workspace): - os.makedirs(rf"{scratch_folder}\{table_name}") - if not arcpy.Exists(region_scratch_workspace): - arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") - del region_scratch_workspace - - datasets = [rf"{project_gdb}\Datasets", rf"{project_gdb}\{table_name}_Region"] - if not any(arcpy.management.GetCount(d)[0] == 0 for d in datasets): - if not arcpy.Exists(rf"{scratch_folder}\{table_name}.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - else: - pass - - arcpy.management.Copy(rf"{project_gdb}\Datasets", rf"{region_gdb}\Datasets") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.management.Copy(rf"{project_gdb}\{table_name}_Region", rf"{region_gdb}\{table_name}_Region") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - else: - arcpy.AddWarning(f"One or more datasets contains zero records!!") - for d in datasets: - arcpy.AddMessage(f"\t{os.path.basename(d)} has {arcpy.management.GetCount(d)[0]} records") - del d - arcpy.AddError(f"SystemExit at line number: '{traceback.extract_stack()[-1].lineno}'") - sys.exit() - - if "datasets" in locals().keys(): del datasets - - del region_gdb, table_name - - del scratch_workspace - - # Sequential Processing - if Sequential: - arcpy.AddMessage(f"Sequential Processing") - for i in range(0, len(table_names)): - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - try: - pass - worker(region_gdb=region_gdb) - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del region_gdb, table_name - del i - - # Non-Sequential Processing - if not Sequential: - import multiprocessing - from time import time, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"Start multiprocessing using the ArcGIS Pro pythonw.exe.") - #Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS - #get_install_path() uses a registry query to figure out 64bit python exe if available - multiprocessing.set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe')) - # Get CPU count and then take 2 away for other process - _processes = multiprocessing.cpu_count() - 2 - _processes = _processes if len(table_names) >= _processes else len(table_names) - arcpy.AddMessage(f"Creating the multiprocessing Pool with {_processes} processes") - #Create a pool of workers, keep one cpu free for surfing the net. - #Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) - with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: - arcpy.AddMessage(f"\tPrepare arguments for processing") - # Use apply_async so we can handle exceptions gracefully - jobs={} - for i in range(0, len(table_names)): - try: - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - jobs[table_name] = pool.apply_async(worker, [region_gdb]) - del table_name, region_gdb - except: - pool.terminate() - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del i - all_finished = False - # Set a start time so that we can see how log things take - start_time = time() - result_completed = {} - while True: - all_finished = True - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - arcpy.AddMessage(f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"Have the workers finished?") - arcpy.AddMessage(f"Have the workers finished?") - finish_time = strftime('%a %b %d %I:%M %p', localtime()) - time_elapsed = u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) - arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") - finish_time = f"{finish_time}.\n\t{time_elapsed}" - del time_elapsed - for table_name, result in jobs.items(): - if result.ready(): - if table_name not in result_completed: - result_completed[table_name] = finish_time - try: - # wait for and get the result from the task - result.get() - except SystemExit: - pool.terminate() - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: - pool.terminate() - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - pass - arcpy.AddMessage(f"Process {table_name}\n\tFinished on {result_completed[table_name]}") - else: - all_finished = False - arcpy.AddMessage(f"Process {table_name} is running. . .") - del table_name, result - del elapse_time, end_time, finish_time - if all_finished: - break - sleep(_processes * 7.5) - del result_completed - del start_time - del all_finished - arcpy.AddMessage(f"\tClose the process pool") - # close the process pool - pool.close() - # wait for all tasks to complete and processes to close - arcpy.AddMessage(f"\tWait for all tasks to complete and processes to close") - pool.join() - # Just in case - pool.terminate() - del pool - del jobs - del _processes - del time, multiprocessing, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"\tDone with multiprocessing Pool") - - arcpy.AddMessage("Post-Processing") - arcpy.AddMessage("Processing Results") - datasets = list() - #walk = arcpy.da.Walk(scratch_folder, datatype="FeatureClass", type=["Polyline", "Polygon"]) - walk = arcpy.da.Walk(scratch_folder) - for dirpath, dirnames, filenames in walk: - for filename in filenames: - datasets.append(os.path.join(dirpath, filename)) - del filename - del dirpath, dirnames, filenames - del walk - for dataset in datasets: - datasets_short_path = f"{os.path.basename(os.path.dirname(os.path.dirname(dataset)))}\{os.path.basename(os.path.dirname(dataset))}\{os.path.basename(dataset)}" - dataset_name = os.path.basename(dataset) - region_gdb = os.path.dirname(dataset) - arcpy.AddMessage(f"\tDataset: '{dataset_name}'") - arcpy.AddMessage(f"\t\tPath: '{datasets_short_path}'") - arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") - arcpy.management.Copy(dataset, rf"{project_gdb}\{dataset_name}") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - arcpy.management.Delete(dataset) - arcpy.AddMessage("\tDelete: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - arcpy.management.Compact(region_gdb) - arcpy.AddMessage("\tCompact: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del region_gdb - del dataset - del dataset_name - del datasets_short_path - del datasets - arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") - arcpy.management.Compact(project_gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - # Declared Variables assigned in function - del scratch_folder, csv_data_folder - # Imports - del dismap_tools, worker - # Function Parameters - del project_gdb, Sequential, table_names - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - # Imports - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - # Set varaibales - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - del project_folder - - # Create project scratch workspace, if missing - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - if not arcpy.Exists(scratch_folder): - os.makedirs(rf"{scratch_folder}") - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"scratch") - del scratch_folder - - # Set basic arcpy.env variables - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - try: - pass - # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", - # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", - - test = False - if test: - #director(project_gdb=project_gdb, Sequential=True, table_names=["HI_IDW"]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "HI_IDW"]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "SEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=True, table_names=["NBS_IDW", "SEUS_FAL_IDW"]) - else: - #director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW", "HI_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW"]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW", "AI_IDW", "GOA_IDW", "WC_ANN_IDW"]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW", "NEUS_FAL_IDW", "SEUS_SUM_IDW"]) - del test - - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - - # Declared Varaiables - # Imports - # Function Parameters - del project_gdb - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_region_fishnets_worker.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_region_fishnets_worker.py deleted file mode 100644 index a0f3dbe..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_region_fishnets_worker.py +++ /dev/null @@ -1,653 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: create_region_fishnets_worker.py -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 25/02/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback - -import inspect - -import arcpy # third-parties second - -def worker(region_gdb=""): - try: - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(rf"{region_gdb}"): - sys.exit()(f"{os.path.basename(region_gdb)} is missing!!") - - # Imports - from arcpy import metadata as md - import dismap_tools - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - table_name = os.path.basename(region_gdb).replace(".gdb","") - scratch_folder = os.path.dirname(region_gdb) - project_folder = os.path.dirname(scratch_folder) - csv_data_folder = rf"{project_folder}\CSV_Data" - scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - - #arcpy.AddMessage(f"Table Name: {table_name}\nProject Folder: {os.path.basename(project_folder)}\nScratch Folder: {os.path.basename(scratch_folder)}\n") - - del scratch_folder, project_folder - - arcpy.env.workspace = region_gdb - arcpy.env.scratchWorkspace = scratch_workspace - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - arcpy.env.compression = "LZ77" - #arcpy.env.geographicTransformations = "WGS_1984_(ITRF08)_To_NAD_1983_2011" - arcpy.env.pyramid = "PYRAMIDS -1 BILINEAR DEFAULT 75 NO_SKIP NO_SIPS" - arcpy.env.resamplingMethod = "BILINEAR" - arcpy.env.rasterStatistics = "STATISTICS 1 1" - #arcpy.env.XYTolerance = "0.1 Meters" - #arcpy.env.XYResolution = "0.01 Meters" - - # DatasetCode, CSVFile, TransformUnit, TableName, GeographicArea, CellSize, - # PointFeatureType, FeatureClassName, Region, Season, DateCode, Status, - # DistributionProjectCode, DistributionProjectName, SummaryProduct, - # FilterRegion, FilterSubRegion, FeatureServiceName, FeatureServiceTitle, - # MosaicName, MosaicTitle, ImageServiceName, ImageServiceTitle - - fields = ["TableName", "CellSize",] - region_list = [row for row in arcpy.da.SearchCursor(rf"{region_gdb}\Datasets", fields, where_clause = f"TableName = '{table_name}'")][0] - del fields - - # Assigning variables from items in the chosen table list - # ['AI_IDW', 'AI_IDW_Region', 'AI', 'Aleutian Islands', None, 'IDW'] - table_name = region_list[0] - cell_size = region_list[1] - del region_list - - process_region = rf"{region_gdb}\{table_name}_Region" - region_raster_mask = rf"{table_name}_Raster_Mask" - region_extent_points = rf"{table_name}_Extent_Points" - region_fishnet = rf"{table_name}_Fishnet" - region_lat_long = rf"{table_name}_Lat_Long" - region_latitude = rf"{table_name}_Latitude" - region_longitude = rf"{table_name}_Longitude" - region_name = rf"{table_name}_Region" - - arcpy.AddMessage(f"Region: {region_name}") - arcpy.AddMessage(f"Region GDB: {os.path.basename(arcpy.env.workspace)}") - arcpy.AddMessage(f"Scratch GDB: {os.path.basename(arcpy.env.scratchWorkspace)}") - - psr = arcpy.Describe(process_region).spatialReference - arcpy.env.outputCoordinateSystem = psr - arcpy.AddMessage(f"\t\tSpatial Reference: {psr.name}") - # Set coordinate system of the output fishnet - # 4326 - World Geodetic System 1984 (WGS 84) and 3857 - Web Mercator - # Spatial Reference factory code of 4326 is : GCS_WGS_1984 - # Spatial Reference factory code of 5714 is : Mean Sea Level (Height) - # sr = arcpy.SpatialReference(4326, 5714) - #gsr = arcpy.SpatialReference(4326, 5714) - gsr = arcpy.SpatialReference(4326) - - #arcpy.AddMessage("process_region") - #arcpy.AddMessage(f"Spatial Reference: {str(arcpy.Describe(process_region).spatialReference.name)}") - #arcpy.AddMessage(f"Extent: {str(arcpy.Describe(process_region).extent).replace(' NaN', '')}") - #arcpy.AddMessage(f"Output Coordinate System: {arcpy.env.outputCoordinateSystem.name}") - #arcpy.AddMessage(f"Geographic Transformations: {arcpy.env.geographicTransformations}") - - # Creating Raster Mask - arcpy.AddMessage(f"Creating Raster Mask: {table_name}_Raster_Mask") - - cell_size = [row[0] for row in arcpy.da.SearchCursor(rf"{region_gdb}\Datasets", "CellSize", where_clause = f"GeographicArea = '{region_name}'")][0] - - arcpy.management.CalculateField(rf"{process_region}", "ID", 1) - arcpy.AddMessage("\tCalculate Field 'ID' for {0}:\n\t\t{1}\n".format(f"{region_name}", arcpy.GetMessages(0).replace("\n", "\n\t\t"))) - - arcpy.conversion.FeatureToRaster(rf"{process_region}", "ID", rf"{region_gdb}\{region_raster_mask}", cell_size) - arcpy.AddMessage("\tFeature To Raster for {0}:\n\t\t{1}\n".format(f"{region_name}", arcpy.GetMessages(0).replace("\n", "\n\t\t"))) - - arcpy.management.DeleteField(rf"{process_region}", "ID") - arcpy.AddMessage("\tDelete Field 'ID' field in {0}:\n\t\t{1}\n".format(f"{region_name}", arcpy.GetMessages(0).replace("\n", "\n\t\t"))) - - #del edit - - # Creating Extent Points - arcpy.AddMessage(f"Creating Extent Points: {region_extent_points}") - - extent = arcpy.Describe(process_region).extent - X_Min, Y_Min, X_Max, Y_Max = extent.XMin, extent.YMin, extent.XMax, extent.YMax - del extent - - arcpy.AddMessage(f"\t{region_name} Extent:\n\t\tX_Min: {X_Min}\n\t\tY_Min: {Y_Min}\n\t\tX_Max: {X_Max}\n\t\tY_Max: {Y_Max}\n") - - # A list of coordinate pairs - pointList = [[X_Min, Y_Min], [X_Min, Y_Max], [X_Max, Y_Max]] - # Create an empty Point object - point = arcpy.Point() - # A list to hold the PointGeometry objects - pointGeometryList = [] - # For each coordinate pair, populate the Point object and create a new - # PointGeometry object - for pt in pointList: - point.X = pt[0] - point.Y = pt[1] - pointGeometry = arcpy.PointGeometry(point, arcpy.Describe(process_region).spatialReference) - pointGeometryList.append(pointGeometry) - del pt, pointGeometry - # Delete after last use - del pointList, point - - # Create a copy of the PointGeometry objects, by using pointGeometryList as - # input to the CopyFeatures tool. - arcpy.management.CopyFeatures(pointGeometryList, rf"{region_gdb}\{region_extent_points}") - arcpy.AddMessage("\tCopy Features to {0}:\n\t\t{1}\n".format(region_extent_points, arcpy.GetMessages(0).replace("\n", "\n\t\t"))) - - del pointGeometryList - - # arcpy.AddMessage("tmp_region_extent_points") - # tmp_region_extent_points = rf"{region_gdb}\{region_extent_points}" - # arcpy.AddMessage(f"Spatial Reference: {str(arcpy.Describe(tmp_region_extent_points).spatialReference.name)}") - # arcpy.AddMessage(f"Extent: {str(arcpy.Describe(tmp_region_extent_points).extent).replace(' NaN', '')}") - # arcpy.AddMessage(f"Output Coordinate System: {arcpy.env.outputCoordinateSystem.name}") - # arcpy.AddMessage(f"Geographic Transformations: {arcpy.env.geographicTransformations}") - # del tmp_region_extent_points - - with arcpy.EnvManager(outputCoordinateSystem = psr): - arcpy.management.AddXY(in_features = rf"{region_gdb}\{region_extent_points}") - arcpy.AddMessage("\tAdd XY:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - arcpy.management.AlterField( - in_table = rf"{region_gdb}\{region_extent_points}", - field = "POINT_X", - new_field_name = "Easting", - new_field_alias = "Easting", - field_type = "", - field_length = None, - field_is_nullable = "NULLABLE", - clear_field_alias = "DO_NOT_CLEAR" - ) - arcpy.AddMessage("\tAlter Field:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - arcpy.management.AlterField( - in_table = rf"{region_gdb}\{region_extent_points}", - field = "POINT_Y", - new_field_name = "Northing", - new_field_alias = "Northing", - field_type = "", - field_length = None, - field_is_nullable = "NULLABLE", - clear_field_alias = "DO_NOT_CLEAR" - ) - arcpy.AddMessage("\tAlter Field:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - tmp_outputCoordinateSystem = arcpy.env.outputCoordinateSystem - arcpy.env.outputCoordinateSystem = gsr - - with arcpy.EnvManager(outputCoordinateSystem = gsr, geographicTransformations = dismap_tools.check_transformation(rf"{region_gdb}\{region_extent_points}", gsr)): - arcpy.management.AddXY(in_features = rf"{region_gdb}\{region_extent_points}") - arcpy.AddMessage("\tAdd XY:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - arcpy.env.outputCoordinateSystem = tmp_outputCoordinateSystem - del tmp_outputCoordinateSystem - - arcpy.management.AlterField( - in_table = rf"{region_gdb}\{region_extent_points}", - field = "POINT_X", - new_field_name = "Longitude", - new_field_alias = "Longitude", - field_type = "", - field_length = None, - field_is_nullable = "NULLABLE", - clear_field_alias = "DO_NOT_CLEAR" - ) - arcpy.AddMessage("\tAlter Field:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - arcpy.management.AlterField( - in_table = rf"{region_gdb}\{region_extent_points}", - field = "POINT_Y", - new_field_name = "Latitude", - new_field_alias = "Latitude", - field_type = "", - field_length = None, - field_is_nullable = "NULLABLE", - clear_field_alias = "DO_NOT_CLEAR" - ) - arcpy.AddMessage("\tAlter Field:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - # Creating Fishnet - arcpy.AddMessage(f"Creating Fishnet: {region_fishnet}") - arcpy.AddMessage(f"\tCreate Fishnet for {region_name} with {cell_size} by {cell_size} cells") - arcpy.management.CreateFishnet( - os.path.join(rf"{region_gdb}\{region_fishnet}"), - f"{X_Min} {Y_Min}", - f"{X_Min} {Y_Max}", - cell_size, - cell_size, - None, - None, - f"{X_Max} {Y_Max}", - "NO_LABELS", - "DEFAULT", - "POLYGON" - ) - arcpy.AddMessage("\tCreate Fishnet for {0}:\n\t\t{1}\n".format(f"{region_name}", arcpy.GetMessages(0).replace("\n", "\n\t\t"))) - - del X_Min, Y_Min, X_Max, Y_Max - - arcpy.management.MakeFeatureLayer(rf"{region_gdb}\{region_fishnet}", f"{region_name}_Fishnet_Layer") - arcpy.AddMessage("\tMake Feature Layer for {0}:\n\t\t{1}\n".format(f"{region_fishnet}", arcpy.GetMessages(0).replace("\n", "\n\t\t"))) - arcpy.AddMessage(f"\t\tRecord Count: {int(arcpy.management.GetCount(f'{region_name}_Fishnet_Layer')[0]):,d}") - - arcpy.management.SelectLayerByLocation(f"{region_name}_Fishnet_Layer", "WITHIN_A_DISTANCE", process_region, 2 * int(cell_size), "NEW_SELECTION", "INVERT") - arcpy.AddMessage("\tSelect Layer By Location:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - arcpy.AddMessage(f"\t\tRecord Count: {int(arcpy.management.GetCount(f'{region_name}_Fishnet_Layer')[0]):,d}") - - arcpy.management.DeleteFeatures(f"{region_name}_Fishnet_Layer") - arcpy.AddMessage("\tDelete Features:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - arcpy.management.Delete(f"{region_name}_Fishnet_Layer") - arcpy.AddMessage("\tDelete {0}:\n\t\t{1}\n".format(f"{region_name}_Fishnet_Layer", arcpy.GetMessages(0).replace("\n", "\n\t\t"))) - - # Creating Lat-Long - arcpy.AddMessage(f"Creating Lat-Long: {region_lat_long}") - arcpy.management.FeatureToPoint(rf"{region_gdb}\{region_fishnet}", rf"{region_gdb}\{region_lat_long}", "CENTROID") - arcpy.AddMessage("\tFeature To Point:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - # Execute DeleteField - arcpy.management.DeleteField(rf"{region_gdb}\{region_lat_long}", ['ORIG_FID']) - arcpy.AddMessage("\tDelete Field:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - with arcpy.EnvManager(outputCoordinateSystem = psr): - arcpy.management.AddXY(in_features=rf"{region_gdb}\{region_lat_long}") - arcpy.AddMessage("\tAdd XY:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - arcpy.management.AlterField( - in_table = rf"{region_gdb}\{region_lat_long}", - field = "POINT_X", - new_field_name = "Easting", - new_field_alias = "Easting", - field_type = "", - field_length = None, - field_is_nullable = "NULLABLE", - clear_field_alias = "DO_NOT_CLEAR" - ) - arcpy.AddMessage("\tAlter Field:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - arcpy.management.AlterField( - in_table = rf"{region_gdb}\{region_lat_long}", - field = "POINT_Y", - new_field_name = "Northing", - new_field_alias = "Northing", - field_type = "", - field_length = None, - field_is_nullable = "NULLABLE", - clear_field_alias = "DO_NOT_CLEAR" - ) - arcpy.AddMessage("\tAlter Field:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - with arcpy.EnvManager(outputCoordinateSystem = gsr, geographicTransformations = dismap_tools.check_transformation(rf"{region_gdb}\{region_extent_points}", gsr)): - arcpy.management.AddXY(in_features=rf"{region_gdb}\{region_lat_long}") - arcpy.AddMessage("\tAdd XY:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - arcpy.management.AlterField( - in_table = rf"{region_gdb}\{region_lat_long}", - field = "POINT_X", - new_field_name = "Longitude", - new_field_alias = "Longitude", - field_type = "", - field_length = None, - field_is_nullable = "NULLABLE", - clear_field_alias = "DO_NOT_CLEAR" - ) - arcpy.AddMessage("\tAlter Field:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - arcpy.management.AlterField( - in_table = rf"{region_gdb}\{region_lat_long}", - field = "POINT_Y", - new_field_name = "Latitude", - new_field_alias = "Latitude", - field_type = "", - field_length = None, - field_is_nullable = "NULLABLE", - clear_field_alias = "DO_NOT_CLEAR" - ) - arcpy.AddMessage("\tAlter Field:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - # arcpy.management.CalculateFields( - # in_table = rf"{region_gdb}\{region_lat_long}", - # expression_type = "PYTHON3", - # fields = "Easting 'round(!Easting!, 8)' #;Northing 'round(!Northing!, 8)' #;Longitude 'round(!Longitude!, 8)' #;Latitude 'round(!Latitude!, 8)' #", - # code_block = "", - # enforce_domains = "NO_ENFORCE_DOMAINS" - # ) - # arcpy.AddMessage("\tCalculate Fields:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - arcpy.AddMessage(f"Generating {table_name} Latitude and Longitude Rasters") - - # arcpy.env.cellSize = cell_size - # arcpy.env.extent = arcpy.Describe(rf"{region_gdb}\{region_raster_mask}").extent - # arcpy.env.mask = rf"{region_gdb}\{region_raster_mask}" - # arcpy.env.snapRaster = rf"{region_gdb}\{region_raster_mask}" - - raster_mask_extent = arcpy.Describe(rf"{region_gdb}\{region_raster_mask}").extent - - arcpy.AddMessage(f"Point to Raster Conversion using {region_lat_long} to create {region_longitude}") - - region_longitude_tmp = rf"{region_gdb}\tmp_{region_longitude}" - - with arcpy.EnvManager(scratchWorkspace=scratch_workspace, workspace = region_gdb, cellSize = cell_size, extent = raster_mask_extent, mask = rf"{region_gdb}\{region_raster_mask}", snapRaster = rf"{region_gdb}\{region_raster_mask}"): - arcpy.conversion.PointToRaster(rf"{region_gdb}\{region_lat_long}", "Longitude", region_longitude_tmp, "MOST_FREQUENT", "NONE", cell_size) - arcpy.AddMessage("\tPoint To Raster:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - arcpy.AddMessage(f"Extract by Mask to create {region_longitude}") - - with arcpy.EnvManager(scratchWorkspace=scratch_workspace, workspace = region_gdb, - cellSize = cell_size, extent = raster_mask_extent, - mask = rf"{region_gdb}\{region_raster_mask}", - snapRaster = rf"{region_gdb}\{region_raster_mask}"): - # Execute ExtractByMask - outExtractByMask = arcpy.sa.ExtractByMask(region_longitude_tmp, rf"{region_gdb}\{region_raster_mask}", "INSIDE") - arcpy.AddMessage("\tExtract By Mask:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - # Save the output - outExtractByMask.save(rf"{region_gdb}\{region_longitude}") - del outExtractByMask - - arcpy.management.Delete(region_longitude_tmp) - del region_longitude_tmp - - region_latitude_tmp = rf"{region_gdb}\tmp_{region_latitude}" - - arcpy.AddMessage(f"Point to Raster Conversion using {region_lat_long} to create {region_latitude}") - - with arcpy.EnvManager(scratchWorkspace=scratch_workspace, workspace = region_gdb, - cellSize = cell_size, extent = raster_mask_extent, - mask = rf"{region_gdb}\{region_raster_mask}", - snapRaster = rf"{region_gdb}\{region_raster_mask}"): - # Process: Point to Raster Latitude - arcpy.conversion.PointToRaster(rf"{region_gdb}\{region_lat_long}", "Latitude", region_latitude_tmp, "MOST_FREQUENT", "NONE", cell_size, "BUILD") - arcpy.AddMessage("\tPoint To Raster:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - - arcpy.AddMessage(f"Extract by Mask to create {region_latitude}") - - with arcpy.EnvManager(scratchWorkspace=scratch_workspace, workspace = region_gdb, cellSize = cell_size, extent = raster_mask_extent, mask = rf"{region_gdb}\{region_raster_mask}", snapRaster = rf"{region_gdb}\{region_raster_mask}"): - # Execute ExtractByMask - outExtractByMask = arcpy.sa.ExtractByMask(region_latitude_tmp, rf"{region_gdb}\{region_raster_mask}", "INSIDE") - arcpy.AddMessage("\tExtract By Mask:\n\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t"))) - # Save the output - outExtractByMask.save(rf"{region_gdb}\{region_latitude}") - del outExtractByMask - - arcpy.management.Delete(region_latitude_tmp) - del region_latitude_tmp - - del raster_mask_extent - - arcpy.ClearEnvironment("cellSize") - arcpy.ClearEnvironment("extent") - arcpy.ClearEnvironment("mask") - arcpy.ClearEnvironment("snapRaster") - - # Reset environment settings to default settings. - arcpy.ResetEnvironments() - - arcpy.AddMessage(f"\t\tAlter Fields for: '{region_raster_mask}'") - #dismap_tools.alter_fields(csv_data_folder, rf"{region_gdb}\{region_raster_mask}") - dismap_tools.import_metadata(csv_data_folder, dataset = rf"{region_gdb}\{region_raster_mask}") - - # Create Metadata - dataset_md = md.Metadata(region_raster_mask) - dataset_md.synchronize("ALWAYS") - dataset_md.save() - del dataset_md - - arcpy.AddMessage(f"\t\tAlter Fields for: '{region_extent_points}'") - dismap_tools.alter_fields(csv_data_folder, rf"{region_gdb}\{region_extent_points}") - dismap_tools.import_metadata(csv_data_folder, dataset = rf"{region_gdb}\{region_extent_points}") - - # Create Metadata - dataset_md = md.Metadata(region_extent_points) - dataset_md.synchronize("ALWAYS") - dataset_md.save() - del dataset_md - - arcpy.AddMessage(f"\t\tAlter Fields for: '{region_fishnet}'") - dismap_tools.alter_fields(csv_data_folder, rf"{region_gdb}\{region_fishnet}") - dismap_tools.import_metadata(csv_data_folder, dataset = rf"{region_gdb}\{region_fishnet}") - - # Create Metadata - dataset_md = md.Metadata(region_fishnet) - dataset_md.synchronize("ALWAYS") - dataset_md.save() - del dataset_md - - arcpy.AddMessage(f"\t\tAlter Fields for: '{region_lat_long}'") - dismap_tools.alter_fields(csv_data_folder, rf"{region_gdb}\{region_lat_long}") - dismap_tools.import_metadata(csv_data_folder, dataset = rf"{region_gdb}\{region_lat_long}") - - # Create Metadata - dataset_md = md.Metadata(region_lat_long) - dataset_md.synchronize("ALWAYS") - dataset_md.save() - del dataset_md - - arcpy.AddMessage(f"\t\tAlter Fields for: '{region_latitude}'") - dismap_tools.import_metadata(csv_data_folder, dataset = rf"{region_gdb}\{region_latitude}") - - # Create Metadata - dataset_md = md.Metadata(region_latitude) - dataset_md.synchronize("ALWAYS") - dataset_md.save() - del dataset_md - - arcpy.AddMessage(f"\t\tAlter Fields for: '{region_longitude}'") - dismap_tools.import_metadata(csv_data_folder, dataset = rf"{region_gdb}\{region_longitude}") - - # Create Metadata - dataset_md = md.Metadata(region_longitude) - dataset_md.synchronize("ALWAYS") - dataset_md.save() - del dataset_md - - arcpy.management.Delete(process_region) - arcpy.management.Delete(rf"{region_gdb}\Datasets") - - del process_region, region_raster_mask, region_extent_points, region_fishnet - del region_lat_long, region_latitude, region_longitude - del psr, gsr - del cell_size - - arcpy.AddMessage(f"Compacting the {os.path.basename(region_gdb)} GDB") - arcpy.management.Compact(region_gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - - # End of business logic for the worker function - arcpy.AddMessage(f"Processing for: {table_name} complete") - - # Declared Variables - del region_name, table_name - del scratch_workspace, csv_data_folder - # Imports - del dismap_tools, md - # Function parameter - del region_gdb - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - import dismap_tools - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - # Set basic arcpy.env variables - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - # Set varaibales - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - del project_folder - - # Clear Scratch Folder - dismap_tools.clear_folder(folder=scratch_folder) - - # Create project scratch workspace, if missing - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - if not arcpy.Exists(scratch_folder): - os.makedirs(rf"{scratch_folder}") - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"scratch") - - # Set worker parameters - table_name = "AI_IDW" - #table_name = "GMEX_IDW" - #table_name = "HI_IDW" - #table_name = "SEUS_FAL_IDW" - #table_name = "NBS_IDW" - - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - - if not arcpy.Exists(scratch_workspace): - os.makedirs(rf"{scratch_folder}\{table_name}") - if not arcpy.Exists(scratch_workspace): - arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") - del scratch_workspace - - # Setup worker workspace and copy data - #datasets = [rf"{project_gdb}\Datasets", rf"{project_gdb}\{table_name}_Region"] - #if not any(arcpy.management.GetCount(d)[0] == 0 for d in datasets): - - if not arcpy.Exists(rf"{scratch_folder}\{table_name}.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - else: - pass - arcpy.management.Copy(rf"{project_gdb}\Datasets", rf"{region_gdb}\Datasets") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.management.Copy(rf"{project_gdb}\{table_name}_Region", rf"{region_gdb}\{table_name}_Region") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - #else: - # arcpy.AddWarning(f"One or more datasets contains zero records!!") - # for d in datasets: - # arcpy.AddMessage(f"\t{os.path.basename(d)} has {arcpy.management.GetCount(d)[0]} records") - # del d - # sys.exit() - #if "datasets" in locals().keys(): del datasets - - try: - pass - #worker(region_gdb=region_gdb) - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - - # Declared Varaiables - del region_gdb, table_name, scratch_folder - # Imports - del dismap_tools - # Function Parameters - del project_gdb - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_region_sample_locations_director.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_region_sample_locations_director.py deleted file mode 100644 index 5cd659d..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_region_sample_locations_director.py +++ /dev/null @@ -1,364 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: module1 -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 25/02/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback - -import inspect - -import arcpy # third-parties second - -def director(project_gdb="", Sequential=True, table_names=[]): - try: - # Imports - import dismap_tools - from create_region_sample_locations_worker import worker - from arcpy import metadata as md - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(project_gdb): - sys.exit()(f"{os.path.basename(project_gdb)} is missing!!") - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - csv_data_folder = rf"{project_folder}\CSV Data" - - # Clear Scratch Folder - dismap_tools.clear_folder(folder=scratch_folder) - - # Create Scratch Workspace for Project - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - if not arcpy.Exists(scratch_folder): - os.makedirs(rf"{scratch_folder}") - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"scratch") - - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - del project_folder, scratch_workspace - - if not table_names: - table_names = [row[0] for row in arcpy.da.SearchCursor(f"{project_gdb}\Datasets", - "TableName", - where_clause = "TableName LIKE '%_IDW'")] - else: - pass - - # Pre Processing - for table_name in table_names: - arcpy.AddMessage(f"Pre-Processing: {table_name}") - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - # Create Scratch Workspace for Region - if not arcpy.Exists(region_scratch_workspace): - os.makedirs(rf"{scratch_folder}\{table_name}") - if not arcpy.Exists(region_scratch_workspace): - arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") - del region_scratch_workspace - #datasets = [rf"{project_gdb}\Datasets", rf"{project_gdb}\{table_name}_Region"] - #if not any(arcpy.management.GetCount(d)[0] == 0 for d in datasets): - - if not arcpy.Exists(rf"{scratch_folder}\{table_name}.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - else: - pass - - arcpy.management.Copy(rf"{project_gdb}\Datasets", rf"{region_gdb}\Datasets") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.management.Copy(rf"{project_gdb}\{table_name}_Region", rf"{region_gdb}\{table_name}_Region") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - del region_gdb, table_name - - # Sequential Processing - if Sequential: - arcpy.AddMessage(f"Sequential Processing") - for i in range(0, len(table_names)): - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - try: - worker(region_gdb=region_gdb) - except: - traceback.print_exc() - sys.exit() - del region_gdb, table_name - del i - else: - pass - - # Non-Sequential Processing - if not Sequential: - arcpy.AddMessage(f"Non-Sequential Processing") - # Imports - import multiprocessing - from time import time, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"Start multiprocessing using the ArcGIS Pro pythonw.exe.") - #Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS - #get_install_path() uses a registry query to figure out 64bit python exe if available - multiprocessing.set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe')) - # Get CPU count and then take 2 away for other process - _processes = multiprocessing.cpu_count() - 2 - _processes = _processes if len(table_names) >= _processes else len(table_names) - arcpy.AddMessage(f"Creating the multiprocessing Pool with {_processes} processes") - #Create a pool of workers, keep one cpu free for surfing the net. - #Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) - with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: - arcpy.AddMessage(f"\tPrepare arguments for processing") - # Use apply_async so we can handle exceptions gracefully - jobs={} - for i in range(0, len(table_names)): - try: - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - jobs[table_name] = pool.apply_async(worker, [region_gdb]) - del table_name, region_gdb - except: - pool.terminate() - traceback.print_exc() - sys.exit() - del i - all_finished = False - # Set a start time so that we can see how log things take - start_time = time() - result_completed = {} - while True: - all_finished = True - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - arcpy.AddMessage(f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"Have the workers finished?") - arcpy.AddMessage(f"Have the workers finished?") - finish_time = strftime('%a %b %d %I:%M %p', localtime()) - time_elapsed = u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) - arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") - finish_time = f"{finish_time}.\n\t{time_elapsed}" - del time_elapsed - for table_name, result in jobs.items(): - if result.ready(): - if table_name not in result_completed: - result_completed[table_name] = finish_time - try: - # wait for and get the result from the task - result.get() - except SystemExit: - pool.terminate() - traceback.print_exc() - sys.exit() - else: - pass - arcpy.AddMessage(f"Process {table_name}\n\tFinished on {result_completed[table_name]}") - else: - all_finished = False - arcpy.AddMessage(f"Process {table_name} is running. . .") - del table_name, result - del elapse_time, end_time, finish_time - if all_finished: - break - sleep(_processes * 7.5) - del result_completed - del start_time - del all_finished - arcpy.AddMessage(f"\tClose the process pool") - # close the process pool - pool.close() - # wait for all tasks to complete and processes to close - arcpy.AddMessage(f"\tWait for all tasks to complete and processes to close") - pool.join() - # Just in case - pool.terminate() - del pool - del jobs - del _processes - del time, multiprocessing, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"\tDone with multiprocessing Pool") - - # Post-Processing - arcpy.AddMessage("Post-Processing Begins") - arcpy.AddMessage("Processing Results") - datasets = list() - walk = arcpy.da.Walk(scratch_folder, datatype=["Table", "FeatureClass"]) - for dirpath, dirnames, filenames in walk: - for filename in filenames: - datasets.append(os.path.join(dirpath, filename)) - del filename - del dirpath, dirnames, filenames - del walk - for dataset in datasets: - datasets_short_path = f"{os.path.basename(os.path.dirname(os.path.dirname(dataset)))}\{os.path.basename(os.path.dirname(dataset))}\{os.path.basename(dataset)}" - dataset_name = os.path.basename(dataset) - region_gdb = os.path.dirname(dataset) - arcpy.AddMessage(f"\tDataset: '{dataset_name}'") - arcpy.AddMessage(f"\t\tPath: '{datasets_short_path}'") - arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") - arcpy.management.Copy(dataset, rf"{project_gdb}\{dataset_name}") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - #arcpy.management.Delete(dataset) - #arcpy.AddMessage(f"\t\tAlter Fields for: '{dataset}'") - #dismap_tools.alter_fields(csv_data_folder, rf"{project_gdb}\{dataset}") - del region_gdb, dataset_name, datasets_short_path - del dataset - del datasets - arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") - arcpy.management.Compact(project_gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - # Declared Variables assigned in function - del scratch_folder, csv_data_folder - # Imports - del dismap_tools, worker, md - # Function Parameters - del project_gdb, Sequential, table_names - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - # Imports - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - #arcpy.AddMessage(project_gdb) - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(project_gdb): - arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") - sys.exit() - else: - pass - - try: - # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", - # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", - Test = True - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["GMEX_IDW"]) - #director(project_gdb=project_gdb, Sequential=True, table_names=["NBS_IDW", "HI_IDW"]) - elif not Test: - #director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW"]) - director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "ENBS_IDW",]) - else: - pass - del Test - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - - # Declared Variables - # Imports - # Function Parameters - del project_gdb - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_regions_from_shapefiles_director.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_regions_from_shapefiles_director.py deleted file mode 100644 index d8d20d3..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_regions_from_shapefiles_director.py +++ /dev/null @@ -1,458 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: module1 -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 03/03/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback -import inspect -import shutil - -import arcpy # third-parties second - -def create_dismap_regions(project_gdb=""): - try: - import dismap_tools - - project_folder = os.path.dirname(project_gdb) - csv_data_folder = rf"{project_folder}\CSV_Data" - - arcpy.env.overwriteOutput = True - - if arcpy.Exists(rf"{project_gdb}\DisMAP_Regions"): - arcpy.management.Delete(rf"{project_gdb}\DisMAP_Regions") - - arcpy.AddMessage(f"Creating: 'DisMAP_Regions'") - # Execute Tool - # Spatial Reference factory code of 4326 is : GCS_WGS_1984 - # Spatial Reference factory code of 5714 is : Mean Sea Level (Height) - # sr = arcpy.SpatialReference(4326, 5714) - sp_ref = arcpy.SpatialReference('WGS_1984_Web_Mercator_Auxiliary_Sphere') - arcpy.management.CreateFeatureclass( - out_path = project_gdb, - out_name = "DisMAP_Regions", - geometry_type = "POLYLINE", - template = "", - has_m = "DISABLED", - has_z = "DISABLED", - spatial_reference = sp_ref, - config_keyword = "", - spatial_grid_1 = "0", - spatial_grid_2 = "0", - spatial_grid_3 = "0" - ) - arcpy.AddMessage("\tCreate Featureclass: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del sp_ref - dismap_tools.add_fields(csv_data_folder, os.path.join(project_gdb, "DisMAP_Regions")) - dismap_tools.import_metadata(dataset=rf"{project_gdb}\DisMAP_Regions") - - # Imports - del dismap_tools - # Function Parameter - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - arcpy.management.ClearWorkspaceCache() - -def director(project_gdb="", Sequential=True, table_names=[]): - try: - # Imports - from arcpy import metadata as md - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(project_gdb): - sys.exit()(f"{os.path.basename(project_gdb)} is missing!!") - # Imports - import dismap_tools - from create_regions_from_shapefiles_worker import worker - - arcpy.env.overwriteOutput = True - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - csv_data_folder = rf"{project_folder}\CSV_Data" - - # Clear Scratch Folder - dismap_tools.clear_folder(folder=scratch_folder) - - # Create Scratch Workspace for Project - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - if not arcpy.Exists(scratch_folder): - os.makedirs(rf"{scratch_folder}") - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"scratch") - - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - del project_folder, scratch_workspace - - create_dismap_regions(project_gdb) - - if not table_names: - table_names = [row[0] for row in arcpy.da.SearchCursor(f"{project_gdb}\Datasets", - "TableName", - where_clause = "TableName LIKE '%_IDW'")] - else: - pass - - # Pre Processing - for table_name in table_names: - arcpy.AddMessage(f"Pre-Processing: {table_name}") - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" - # Create Scratch Workspace for Region - if not arcpy.Exists(region_scratch_workspace): - os.makedirs(rf"{scratch_folder}\{table_name}") - if not arcpy.Exists(region_scratch_workspace): - arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") - del region_scratch_workspace - - #datasets = [rf"{project_gdb}\Datasets"] - #if not any(arcpy.management.GetCount(d)[0] == 0 for d in datasets): - if not arcpy.Exists(rf"{scratch_folder}\{table_name}.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") - arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - else: - pass - - arcpy.management.Copy(rf"{project_gdb}\Datasets", rf"{region_gdb}\Datasets") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - arcpy.management.CreateFeatureclass(rf"{region_gdb}", "DisMAP_Regions", "POLYLINE", rf"{project_gdb}\DisMAP_Regions") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - - dismap_regions_md = md.Metadata(rf"{project_gdb}\DisMAP_Regions") - dataset_md = md.Metadata(rf"{region_gdb}\DisMAP_Regions") - dataset_md.copy(dismap_regions_md) - dataset_md.save() - dataset_md.synchronize("OVERWRITE") - dataset_md.save() - dataset_md.synchronize("ALWAYS") - dataset_md.save() - del dataset_md, dismap_regions_md - #else: - # arcpy.AddWarning(f"One or more datasets contains zero records!!") - # for d in datasets: - # arcpy.AddMessage(f"\t{os.path.basename(d)} has {arcpy.management.GetCount(d)[0]} records") - # del d - # se = f"SystemExit at line number: '{traceback.extract_stack()[-1].lineno}'" - # sys.exit()(se) - #if "datasets" in locals().keys(): del datasets - del region_gdb - del table_name - - # Sequential Processing - if Sequential: - arcpy.AddMessage(f"Sequential Processing") - for i in range(0, len(table_names)): - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - try: - worker(region_gdb=region_gdb) - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del region_gdb, table_name - del i - else: - pass - - # Non-Sequential Processing - if not Sequential: - arcpy.AddMessage(f"Non-Sequential Processing") - # Imports - import multiprocessing - from time import time, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"Start multiprocessing using the ArcGIS Pro pythonw.exe.") - #Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS - #get_install_path() uses a registry query to figure out 64bit python exe if available - multiprocessing.set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe')) - # Get CPU count and then take 2 away for other process - _processes = multiprocessing.cpu_count() - 2 - _processes = _processes if len(table_names) >= _processes else len(table_names) - arcpy.AddMessage(f"Creating the multiprocessing Pool with {_processes} processes") - #Create a pool of workers, keep one cpu free for surfing the net. - #Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) - with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: - arcpy.AddMessage(f"\tPrepare arguments for processing") - # Use apply_async so we can handle exceptions gracefully - jobs={} - for i in range(0, len(table_names)): - try: - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - jobs[table_name] = pool.apply_async(worker, [region_gdb]) - del table_name, region_gdb - except: - pool.terminate() - traceback.print_exc() - sys.exit() - del i - all_finished = False - # Set a start time so that we can see how log things take - start_time = time() - result_completed = {} - while True: - all_finished = True - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - arcpy.AddMessage(f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"Have the workers finished?") - finish_time = strftime('%a %b %d %I:%M %p', localtime()) - time_elapsed = u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) - arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") - finish_time = f"{finish_time}.\n\t{time_elapsed}" - del time_elapsed - for table_name, result in jobs.items(): - if result.ready(): - if table_name not in result_completed: - result_completed[table_name] = finish_time - try: - # wait for and get the result from the task - result.get() - except SystemExit: - pool.terminate() - traceback.print_exc() - sys.exit() - else: - pass - arcpy.AddMessage(f"Process {table_name}\n\tFinished on {result_completed[table_name]}") - else: - all_finished = False - arcpy.AddMessage(f"Process {table_name} is running. . .") - del table_name, result - del elapse_time, end_time, finish_time - if all_finished: - break - sleep(_processes * 7.5) - del result_completed - del start_time - del all_finished - arcpy.AddMessage(f"\tClose the process pool") - # close the process pool - pool.close() - # wait for all tasks to complete and processes to close - arcpy.AddMessage(f"\tWait for all tasks to complete and processes to close") - pool.join() - # Just in case - pool.terminate() - del pool - del jobs - del _processes - del time, multiprocessing, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"\tDone with multiprocessing Pool") - - # Post-Processing - arcpy.AddMessage("Post-Processing Begins") - arcpy.AddMessage("Processing Results") - datasets = list() - walk = arcpy.da.Walk(scratch_folder, datatype="FeatureClass", type=["Polyline", "Polygon"]) - for dirpath, dirnames, filenames in walk: - for filename in filenames: - datasets.append(os.path.join(dirpath, filename)) - del filename - del dirpath, dirnames, filenames - del walk - for dataset in datasets: - #print(dataset) - datasets_short_path = f"{os.path.basename(os.path.dirname(os.path.dirname(dataset)))}\{os.path.basename(os.path.dirname(dataset))}\{os.path.basename(dataset)}" - dataset_name = os.path.basename(dataset) - region_gdb = os.path.dirname(dataset) - arcpy.AddMessage(f"\tDataset: '{dataset_name}'") - arcpy.AddMessage(f"\t\tPath: '{datasets_short_path}'") - arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") - arcpy.management.Copy(dataset, rf"{project_gdb}\{dataset_name}") - arcpy.AddMessage("\tCopy: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - if dataset_name.endswith("_Boundary"): - arcpy.AddMessage(f"\tAppending the {dataset_name} Dataset to the DisMAP Regions Dataset") - # Process: Append - arcpy.management.Append(inputs = rf"{project_gdb}\{dataset_name}", - target = rf"{project_gdb}\DisMAP_Regions", - schema_type = "NO_TEST", - field_mapping = "", - subtype = "") - arcpy.AddMessage("\tAppend: {0} {1}\n".format(os.path.basename(dataset), arcpy.GetMessages(0).replace("\n", '\n\t'))) - else: - pass - #arcpy.AddMessage(f"\t\tAlter Fields for: '{dataset_name}'") - #dismap_tools.alter_fields(csv_data_folder, rf"{project_gdb}\{dataset_name}") - #dismap_tools.import_metadata(dataset=rf"{project_gdb}\{dataset_name}") - del region_gdb, dataset_name, datasets_short_path - del dataset - del datasets - arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") - arcpy.management.Compact(project_gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - # Declared Variables - del scratch_folder, csv_data_folder - # Imports - del dismap_tools, worker, md - # Function Parameters - del project_gdb, Sequential, table_names - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - # Imports - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - try: - pass - # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", - # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", - test = False - if test: - #director(project_gdb=project_gdb, Sequential=True, table_names=["HI_IDW"]) - director(project_gdb=project_gdb, Sequential=True, table_names=["SEUS_SPR_IDW", "HI_IDW"]) - #create_dismap_regions(project_gdb) - elif not test: - #director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW", "HI_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW", "AI_IDW", "GOA_IDW", "WC_ANN_IDW", "NEUS_FAL_IDW",]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW"]) - director(project_gdb=project_gdb, Sequential=False, table_names=[]) - del test - except: - traceback.print_exc() - sys.exit() - - # Declared Varaiables - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_species_richness_rasters_director.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_species_richness_rasters_director.py deleted file mode 100644 index e910e68..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_species_richness_rasters_director.py +++ /dev/null @@ -1,300 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: create_species_year_image_name_table_director -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 09/03/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback -import inspect - -import arcpy # third-parties second - -def director(project_gdb="", Sequential=True, table_names=[]): - try: - from create_species_richness_rasters_worker import preprocessing, worker - - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(rf"{project_gdb}"): - arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") - arcpy.AddError(arcpy.GetMessages(2)) - sys.exit() - else: - pass - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - preprocessing(project_gdb=project_gdb, table_names=table_names, clear_folder=True) - -## project_folder = os.path.dirname(project_gdb) -## scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" -## scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" -## -## arcpy.env.workspace = project_gdb -## arcpy.env.scratchWorkspace = scratch_workspace -## del project_folder, scratch_workspace - - # Sequential Processing - if Sequential: - arcpy.AddMessage(f"Sequential Processing") - for i in range(0, len(table_names)): - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{os.path.dirname(project_gdb)}\Scratch\{table_name}.gdb" - try: - pass - worker(region_gdb=region_gdb) - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del region_gdb, table_name - del i - else: - pass - - # Non-Sequential Processing - if not Sequential: - import multiprocessing - from time import time, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"Start multiprocessing using the ArcGIS Pro pythonw.exe.") - #Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS - #get_install_path() uses a registry query to figure out 64bit python exe if available - multiprocessing.set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe')) - # Get CPU count and then take 2 away for other process - _processes = multiprocessing.cpu_count() - 2 - _processes = _processes if len(table_names) >= _processes else len(table_names) - arcpy.AddMessage(f"Creating the multiprocessing Pool with {_processes} processes") - #Create a pool of workers, keep one cpu free for surfing the net. - #Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) - with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: - arcpy.AddMessage(f"\tPrepare arguments for processing") - # Use apply_async so we can handle exceptions gracefully - jobs={} - for i in range(0, len(table_names)): - try: - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{os.path.dirname(project_gdb)}\Scratch\{table_name}.gdb" - jobs[table_name] = pool.apply_async(worker, [region_gdb]) - del table_name, region_gdb - except: - pool.terminate() - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del i - all_finished = False - # Set a start time so that we can see how log things take - start_time = time() - result_completed = {} - while True: - all_finished = True - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - arcpy.AddMessage(f"\nHave the workers finished?") - finish_time = strftime('%a %b %d %I:%M %p', localtime()) - time_elapsed = u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) - arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - finish_time = f"{finish_time}.\n\t{time_elapsed}" - del time_elapsed - for table_name, result in jobs.items(): - if result.ready(): - if table_name not in result_completed: - result_completed[table_name] = finish_time - try: - # wait for and get the result from the task - result.get() - except: - pool.terminate() - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - pass - arcpy.AddMessage(f"Process {table_name}\n\tFinished on {result_completed[table_name]}") - else: - all_finished = False - arcpy.AddMessage(f"Process {table_name} is running. . .") - del table_name, result - del elapse_time, end_time, finish_time - if all_finished: - break - sleep(_processes * 7.5) - del result_completed - del start_time - del all_finished - arcpy.AddMessage(f"\tClose the process pool") - # close the process pool - pool.close() - # wait for all tasks to complete and processes to close - arcpy.AddMessage(f"\tWait for all tasks to complete and processes to close") - pool.join() - # Just in case - pool.terminate() - del pool - del jobs - del _processes - del time, multiprocessing, localtime, strftime, sleep, gmtime - - arcpy.AddMessage(f"\tDone with multiprocessing Pool") - - arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") - arcpy.management.Compact(project_gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - - # Declared Variables assigned in function - #del scratch_folder - # Imports - del worker, preprocessing - # Function Parameters - del project_gdb, Sequential, table_names - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - # Imports - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - try: - pass - # "AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", - # "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW", - - Test = True - if Test: - pass - director(project_gdb=project_gdb, Sequential=True, table_names=["SEUS_FAL_IDW"]) - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "EBS_IDW", "GOA_IDW"]) - director(project_gdb=project_gdb, Sequential=False, table_names=["ENBS_IDW", "GOA_IDW", "NBS_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["HI_IDW", "WC_ANN_IDW", "WC_TRI_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW",]) - else: - pass - del Test - #except SystemExit: - except: - pass - #arcpy.AddError(arcpy.GetMessages(2)) - #traceback.print_exc() - #sys.exit() - - # Declared Variables - - # Function - del project_gdb - - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/create_species_year_image_name_table_director.py b/ArcGIS-Analysis-Python/src/dismap_tools/create_species_year_image_name_table_director.py deleted file mode 100644 index 815cb46..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/create_species_year_image_name_table_director.py +++ /dev/null @@ -1,483 +0,0 @@ -# -*- coding: utf-8 -*- -#------------------------------------------------------------------------------- -# Name: create_species_year_image_name_table_director -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 09/03/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -#------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback - -import inspect - -import arcpy # third-parties second - -def director(project_gdb="", Sequential=True, table_names=[]): - try: - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(project_gdb): - sys.exit()(f"{os.path.basename(project_gdb)} is missing!!") - - import dismap_tools - from create_species_year_image_name_table_worker import preprocessing, worker - - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - del project_folder - - #scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - #csv_data_folder = rf"{project_folder}\CSV_Data" - #arcpy.env.workspace = project_gdb - #arcpy.env.scratchWorkspace = scratch_workspace - #del project_folder, scratch_workspace -## # Clear Scratch Folder -## ClearScratchFolder = True -## if ClearScratchFolder: -## dismap_tools.clear_folder(folder=scratch_folder) -## else: -## pass -## del ClearScratchFolder - - preprocessing(project_gdb=project_gdb, table_names=table_names, clear_folder=True) - -## # Create Scratch Workspace for Project -## if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): -## if not arcpy.Exists(scratch_folder): -## os.makedirs(rf"{scratch_folder}") -## if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): -## arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"scratch") - - -# # # # Moved to preprocessing -## if not table_names: -## table_names = [row[0] for row in arcpy.da.SearchCursor(f"{project_gdb}\Datasets", -## "TableName", -## where_clause = "TableName LIKE '%_IDW'")] -## else: -## pass - -## #print(table_names) -## #sys.exit() -## -## # Pre Processing -## for table_name in table_names: -## arcpy.AddMessage(f"Pre-Processing: {table_name}") -## -## region_gdb = rf"{scratch_folder}\{table_name}.gdb" -## region_scratch_workspace = rf"{scratch_folder}\{table_name}\scratch.gdb" -## -## # Create Scratch Workspace for Region -## if not arcpy.Exists(region_scratch_workspace): -## os.makedirs(rf"{scratch_folder}\{table_name}") -## if not arcpy.Exists(region_scratch_workspace): -## arcpy.management.CreateFileGDB(rf"{scratch_folder}\{table_name}", f"scratch") -## del region_scratch_workspace -## -## arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"{table_name}") -## arcpy.AddMessage("\tCreate File GDB: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) -## -## # Process: Make Table View (Make Table View) (management) -## datasets = rf'{project_gdb}\Datasets' -## arcpy.AddMessage(f"\t{os.path.basename(datasets)} has {arcpy.management.GetCount(datasets)[0]} records") -## -## table_name_view = "Dataset Table View" -## arcpy.management.MakeTableView(in_table = datasets, -## out_view = table_name_view, -## where_clause = f"TableName = '{table_name}'" -## ) -## arcpy.AddMessage(f"\t{table_name_view} has {arcpy.management.GetCount(table_name_view)[0]} records") -## arcpy.management.CopyRows(table_name_view, rf"{region_gdb}\Datasets") -## arcpy.AddMessage("\tCopy Rows: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) -## -## filter_subregion = [row[0] for row in arcpy.da.SearchCursor(rf"{region_gdb}\Datasets", "FilterSubRegion")][0].replace("'", "''") -## -## arcpy.management.Delete(table_name_view) -## del table_name_view - -## region_table = rf"{project_gdb}\{table_name}" -## arcpy.AddMessage(f"\t{os.path.basename(region_table)} has {arcpy.management.GetCount(region_table)[0]} records") -## # Process: Make Table View (Make Table View) (management) -## table_name_view = "IDW Table View" -## arcpy.management.MakeTableView(in_table = region_table, -## out_view = table_name_view, -## where_clause = "DistributionProjectName = 'NMFS/Rutgers IDW Interpolation'" -## ) -## # Process: Copy Rows (Copy Rows) (management) -## arcpy.AddMessage(f"\t{table_name_view} has {arcpy.management.GetCount(table_name_view)[0]} records") -## arcpy.management.CopyRows(in_rows = table_name_view, out_table = rf"{region_gdb}\{table_name}") -## arcpy.AddMessage("\tCopy Rows: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) -## -## arcpy.management.Delete(table_name_view) -## -## # Process: Make Table View (Make Table View) (management) -## #arcpy.AddMessage(filter_subregion) -## species_filter = rf"{project_gdb}\Species_Filter" -## arcpy.AddMessage(f"\t{os.path.basename(species_filter)} has {arcpy.management.GetCount(species_filter)[0]} records") -## table_name_view = "Species Filter Table View" -## arcpy.management.MakeTableView(in_table = species_filter, -## out_view = table_name_view, -## #where_clause = f"FilterSubRegion = '{filter_subregion}'", -## where_clause = f"FilterSubRegion = '{filter_subregion}' AND DistributionProjectName = 'NMFS/Rutgers IDW Interpolation'", -## workspace=region_gdb, -## field_info="OBJECTID OBJECTID VISIBLE NONE;Species Species VISIBLE NONE;CommonName CommonName VISIBLE NONE;TaxonomicGroup TaxonomicGroup VISIBLE NONE;FilterRegion FilterRegion VISIBLE NONE;FilterSubRegion FilterSubRegion VISIBLE NONE;ManagementBody ManagementBody VISIBLE NONE;ManagementPlan ManagementPlan VISIBLE NONE;DistributionProjectName DistributionProjectName VISIBLE NONE" -## ) -## -## arcpy.AddMessage(f"\t{table_name_view} has {arcpy.management.GetCount(table_name_view)[0]} records") -## arcpy.management.CopyRows(in_rows = table_name_view, out_table = rf"{region_gdb}\Species_Filter") -## arcpy.AddMessage("\tCopy Rows: {0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) -## -## arcpy.management.Delete(table_name_view) -## del table_name_view -## # -## del datasets, region_table, species_filter -## del filter_subregion -# # # # Moved to preprocessing - - # Sequential Processing - if Sequential: - arcpy.AddMessage(f"Sequential Processing") - for i in range(0, len(table_names)): - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - try: - worker(region_gdb=region_gdb) - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del region_gdb, table_name - del i - else: - pass - - # Non-Sequential Processing - if not Sequential: - arcpy.AddMessage(f"Non-Sequential Processing") - # Imports - import multiprocessing - from time import time, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"Start multiprocessing using the ArcGIS Pro pythonw.exe.") - #Set multiprocessing exe in case we're running as an embedded process, i.e ArcGIS - #get_install_path() uses a registry query to figure out 64bit python exe if available - multiprocessing.set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe')) - # Get CPU count and then take 2 away for other process - _processes = multiprocessing.cpu_count() - 2 - _processes = _processes if len(table_names) >= _processes else len(table_names) - arcpy.AddMessage(f"Creating the multiprocessing Pool with {_processes} processes") - #Create a pool of workers, keep one cpu free for surfing the net. - #Let each worker process only handle 1 task before being restarted (in case of nasty memory leaks) - with multiprocessing.Pool(processes=_processes, maxtasksperchild=1) as pool: - arcpy.AddMessage(f"\tPrepare arguments for processing") - # Use apply_async so we can handle exceptions gracefully - jobs={} - for i in range(0, len(table_names)): - try: - arcpy.AddMessage(f"Processing: {table_names[i]}") - table_name = table_names[i] - region_gdb = rf"{scratch_folder}\{table_name}.gdb" - jobs[table_name] = pool.apply_async(worker, [region_gdb]) - del table_name, region_gdb - except: - pool.terminate() - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - del i - all_finished = False - # Set a start time so that we can see how log things take - start_time = time() - result_completed = {} - while True: - all_finished = True - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - arcpy.AddMessage(f"\nStart Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"Have the workers finished?") - arcpy.AddMessage(f"Have the workers finished?") - finish_time = strftime('%a %b %d %I:%M %p', localtime()) - time_elapsed = u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time))) - arcpy.AddMessage(f"It's {finish_time}\n{time_elapsed}") - finish_time = f"{finish_time}.\n\t{time_elapsed}" - del time_elapsed - for table_name, result in jobs.items(): - if result.ready(): - if table_name not in result_completed: - result_completed[table_name] = finish_time - try: - # wait for and get the result from the task - result.get() - except SystemExit: - pool.terminate() - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - pass - arcpy.AddMessage(f"Process {table_name}\n\tFinished on {result_completed[table_name]}") - else: - all_finished = False - arcpy.AddMessage(f"Process {table_name} is running. . .") - del table_name, result - del elapse_time, end_time, finish_time - if all_finished: - break - sleep(_processes * 7.5) - del result_completed - del start_time - del all_finished - arcpy.AddMessage(f"\tClose the process pool") - # close the process pool - pool.close() - # wait for all tasks to complete and processes to close - arcpy.AddMessage(f"\tWait for all tasks to complete and processes to close") - pool.join() - # Just in case - pool.terminate() - del pool - del jobs - del _processes - del time, multiprocessing, localtime, strftime, sleep, gmtime - arcpy.AddMessage(f"\tDone with multiprocessing Pool") - - # Post-Processing - arcpy.AddMessage("Post-Processing Begins") - arcpy.AddMessage("Processing Results") - datasets = list() - walk = arcpy.da.Walk(scratch_folder, datatype=["Table", "FeatureClass"]) - for dirpath, dirnames, filenames in walk: - for filename in filenames: - if filename.endswith("LayerSpeciesYearImageName"): - datasets.append(os.path.join(dirpath, filename)) - else: - pass - del filename - del dirpath, dirnames, filenames - del walk - for dataset in datasets: - datasets_short_path = f"{os.path.basename(os.path.dirname(os.path.dirname(dataset)))}\{os.path.basename(os.path.dirname(dataset))}\{os.path.basename(dataset)}" - dataset_name = os.path.basename(dataset) - region_gdb = os.path.dirname(dataset) - arcpy.AddMessage(f"\tDataset: '{dataset_name}'") - arcpy.AddMessage(f"\t\tPath: '{datasets_short_path}'") - arcpy.AddMessage(f"\t\tRegion GDB: '{os.path.basename(region_gdb)}'") - arcpy.AddMessage(f"\tCopying the {dataset_name} Table to the project GDB Table") - arcpy.management.Copy(rf"{region_gdb}\{dataset_name}", rf"{project_gdb}\{dataset_name}") - arcpy.AddMessage("\tCopy: {0} {1}\n".format(dataset_name, arcpy.GetMessages(0).replace("\n", '\n\t'))) - - arcpy.AddMessage(f"\t\tUpdating field values to replace None with empty string") - fields = [f.name for f in arcpy.ListFields(rf"{project_gdb}\{dataset_name}") if f.type == "String"] - # Create update cursor for feature class - with arcpy.da.UpdateCursor(rf"{project_gdb}\{dataset_name}", fields) as cursor: - for row in cursor: - #arcpy.AddMessage(row) - for field_value in row: - #arcpy.AddMessage(field_value) - if field_value is None: - row[row.index(field_value)] = "" - cursor.updateRow(row) - del field_value - del row - del fields, cursor - - del region_gdb, dataset_name, datasets_short_path - del dataset - del datasets - - arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") - arcpy.management.Compact(project_gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages(0).replace("\n", "\n\t")) - - # Declared Variables assigned in function - del scratch_folder - # Imports - del dismap_tools, preprocessing, worker - # Function Parameters - del project_gdb, Sequential, table_names - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - # Imports - import dismap_tools - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - # Set varaibales - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" - del project_folder - - # Clear Scratch Folder - ClearScratchFolder = False - if ClearScratchFolder: - #if clear_folder: - _scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" - dismap_tools.clear_folder(folder=_scratch_folder) - del _scratch_folder - else: - pass - del ClearScratchFolder - #del clear_folder - - # Create project scratch workspace, if missing - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - if not arcpy.Exists(scratch_folder): - os.makedirs(rf"{scratch_folder}") - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"scratch") - del scratch_folder - - # Set basic arcpy.env variables - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - try: - # table_names = ["AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW",] - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["GMEX_IDW", "HI_IDW", "WC_ANN_IDW", "WC_TRI_IDW"]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "HI_IDW"]) - elif not Test: - pass - #director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "EBS_IDW", "ENBS_IDW", "GOA_IDW", "NBS_IDW",]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["HI_IDW", "WC_ANN_IDW", "WC_TRI_IDW",]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW",]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - #director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "EBS_IDW", "ENBS_IDW", "GMEX_IDW", "GOA_IDW", "HI_IDW", "NBS_IDW", "NEUS_FAL_IDW", "NEUS_SPR_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_ANN_IDW", "WC_TRI_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_FAL_IDW", "NEUS_SPR_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - - else: - pass - del Test - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - - # Clear Scratch Folder - ClearScratchFolder = False - if ClearScratchFolder: - #if clear_folder: - _scratch_folder = rf"{os.path.dirname(project_gdb)}\Scratch" - dismap_tools.clear_folder(folder=_scratch_folder) - del _scratch_folder - else: - pass - del ClearScratchFolder - #del clear_folder - - # Declared Variables - del dismap_tools - # Function Parameters - del project_gdb - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/dismap_project_setup.py b/ArcGIS-Analysis-Python/src/dismap_tools/dismap_project_setup.py deleted file mode 100644 index 05fefea..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/dismap_project_setup.py +++ /dev/null @@ -1,136 +0,0 @@ -""" -Script documentation -- Tool parameters are accessed using arcpy.GetParameter() or - arcpy.GetParameterAsText() -- Update derived parameter values using arcpy.SetParameter() or - arcpy.SetParameterAsText() -""" -import os -import arcpy -import traceback - -def script_tool(new_project_folder, project_folders): - """Script code goes below""" - try: - arcpy.env.overwriteOutput = True - aprx = arcpy.mp.ArcGISProject("CURRENT") - aprx.save() - home_folder = aprx.homeFolder - if not arcpy.Exists(rf"{home_folder}\{new_project_folder}"): - arcpy.AddMessage(f"Creating Home Folder: '{os.path.basename(home_folder)}'") - arcpy.management.CreateFolder(home_folder, new_project_folder) - arcpy.AddMessage(arcpy.GetMessages()) - else: - arcpy.AddMessage(f"Home Folder: '{os.path.basename(home_folder)}' Exists") - if not arcpy.Exists(rf"{home_folder}\{new_project_folder}\{new_project_folder}.gdb"): - arcpy.AddMessage(f"Creating Project GDB: '{os.path.basename(home_folder)}.gdb'") - arcpy.management.CreateFileGDB(rf"{home_folder}\{new_project_folder}", f"{new_project_folder}") - arcpy.AddMessage(arcpy.GetMessages()) - else: - arcpy.AddMessage(f"Project GDB: {new_project_folder}.gdb exists") - if not arcpy.Exists(rf"{home_folder}\{new_project_folder}\Scratch"): - arcpy.AddMessage("Creating the Scratch Folder") - arcpy.management.CreateFolder(rf"{home_folder}\{new_project_folder}", "Scratch") - arcpy.AddMessage(arcpy.GetMessages()) - else: - arcpy.AddMessage(f"Scratch Folder: {new_project_folder} exists") - if not arcpy.Exists(rf"{home_folder}\{new_project_folder}\Scratch\scratch.gdb"): - arcpy.AddMessage("Creating the Scratch GDB") - arcpy.management.CreateFileGDB(rf"{home_folder}\{new_project_folder}\Scratch", "scratch") - arcpy.AddMessage(arcpy.GetMessages()) - else: - arcpy.AddMessage("Scratch GDB Exists") - for _project_folder in project_folders.split(";"): - if not arcpy.Exists(rf"{home_folder}\{new_project_folder}\{_project_folder}"): - arcpy.AddMessage(f"Creating Folder: {_project_folder}") - arcpy.management.CreateFolder(rf"{home_folder}\{new_project_folder}", _project_folder) - arcpy.AddMessage(arcpy.GetMessages()) - else: - arcpy.AddMessage(f"Folder: '{_project_folder}' Exists") - del _project_folder - if not arcpy.Exists(rf"{home_folder}\{new_project_folder}\{new_project_folder}.aprx"): - aprx.saveACopy(rf"{home_folder}\{new_project_folder}\{new_project_folder}.aprx") - arcpy.AddMessage(arcpy.GetMessages()) - else: - pass - - _aprx = arcpy.mp.ArcGISProject(rf"{home_folder}\{new_project_folder}\{new_project_folder}.aprx") - # Remove maps - _maps = _aprx.listMaps() - if len(_maps) > 0: - for _map in _maps: - arcpy.AddMessage(_map.name) - aprx.deleteItem(_map) - del _map - del _maps - _aprx.save() - - databases = [] - databases.append({"databasePath": rf"{home_folder}\{new_project_folder}\{new_project_folder}.gdb", "isDefaultDatabase": True}) - _aprx.updateDatabases(databases) - arcpy.AddMessage(f"Databases: {databases}") - del databases - _aprx.save() - - toolboxes = [] - toolboxes.append({"toolboxPath": rf"{home_folder}\DisMAP.atbx", "isDefaultToolbox": True}) - _aprx.updateToolboxes(toolboxes) - arcpy.AddMessage(f"Toolboxes: {toolboxes}") - del toolboxes - _aprx.save() - del _aprx - - # Declared variables - del home_folder, aprx - # Function parameters - del new_project_folder, project_folders - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - #raise SystemExit - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - #raise SystemExit - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - #raise SystemExit - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - #raise SystemExit - else: - pass - return True - finally: - pass -if __name__ == "__main__": - try: - new_project_folder = arcpy.GetParameterAsText(0) - project_folders = arcpy.GetParameterAsText(1) - - if not new_project_folder: - new_project_folder = "February 1 2026" - else: - pass - - if not project_folders: - project_folders = "CRFs;CSV_Data;Dataset_Shapefiles;Images;Layers;Metadata_Export;Publish" - else: - pass - - script_tool(new_project_folder, project_folders) - arcpy.SetParameterAsText(3, "Result") - - del new_project_folder, project_folders - - except: # noqa: E722 - arcpy.AddMessage(arcpy.GetMessages(0)) - traceback.print_exc() - else: - pass - finally: - pass diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/dismap_project_version_setup.py b/ArcGIS-Analysis-Python/src/dismap_tools/dismap_project_version_setup.py deleted file mode 100644 index b704905..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/dismap_project_version_setup.py +++ /dev/null @@ -1,466 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------- -# Name: dismap.py -# Purpose: Common DisMAP functions -# -# Author: john.f.kennedy -# -# Created: 12/01/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -# ------------------------------------------------------------------------------- -import os -import sys # built-ins first -import traceback -import inspect - -import arcpy # third-parties second # noqa: F401 - -def main(project_gdb=""): - try: - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"{'-' * 80}\n") - - # Set varaibales - project_folder = os.path.dirname(project_gdb) - project_name = os.path.basename(project_folder) - base_project_folder = os.path.dirname(project_folder) - - # - # Step 0 - create an ArcGIS Project - # - - # ########################################################################## - # Step 1 - update ArcGIS Project with the databases and folders for a given - # ########################################################################## - # project version - DisMapProjectSetup = False - if DisMapProjectSetup: - import dev_dismap_project_setup - base_project_file = rf"{base_project_folder}\DisMAP.aprx" - dev_dismap_project_setup.project_folders(base_project_file, project_name) - # Declared variables - del base_project_file - #Imports - del dev_dismap_project_setup - else: - pass - del DisMapProjectSetup - # ########################################################################## - # Step 2 - zip and unzip the region shapefiles and the CSV data for a given - # ########################################################################## - # project version - ZipAndUnzipCsvData = False - if ZipAndUnzipCsvData: - # Imports - import dev_zip_and_unzip_csv_data - # If "project" is the same, then an archieve file is created. - # If different, then the archieve is created and upzipped in the new - # location - # In Data Path - in_data_path = rf"{project_folder}\CSV Data" - out_data_path = rf"{project_folder}\CSV Data" - selected_files = ["AI_IDW.csv", "Datasets.csv", "EBS_IDW.csv", - "ENBS_IDW.csv", "GMEX_IDW.csv", - "GOA_IDW.csv", "HI_IDW.csv", "NBS_IDW.csv", - "NEUS_FAL_IDW.csv", "NEUS_SPR_IDW.csv", - "SEUS_FAL_IDW.csv", "SEUS_SPR_IDW.csv", - "SEUS_SUM_IDW.csv", "Species_Filter.csv", - "WC_ANN_IDW.csv", "WC_GLMME.csv", - "WC_TRI_IDW.csv", "field_definitions.json", - "metadata_dictionary.json", "table_definitions.json" - ] - selected_files = ";".join(selected_files) - dev_zip_and_unzip_csv_data.main(in_data_path, out_data_path, selected_files) - # Declared variables - del in_data_path, out_data_path, selected_files - # Imports - del dev_zip_and_unzip_csv_data - else: - pass - del ZipAndUnzipCsvData - - ZipAndUnzipShapefileData = False - if ZipAndUnzipShapefileData: - # Imports - import dev_zip_and_unzip_shapefile_data - # If "project_name" is the same, then an archieve file is created. - # If different, then the archieve is created and upzipped in the new - # location - in_data_path = rf"{project_folder}\Dataset_Shapefiles" - out_data_path = rf"{project_folder}\Dataset_Shapefiles" - selected_files = ['AI_IDW_Region.shp', 'EBS_IDW_Region.shp', - 'ENBS_IDW_Region.shp', 'GMEX_IDW_Region.shp', - 'GOA_IDW_Region.shp', 'HI_IDW_Region.shp', - 'NBS_IDW_Region.shp', 'NEUS_FAL_IDW_Region.shp', - 'NEUS_SPR_IDW_Region.shp', 'SEUS_FAL_IDW_Region.shp', - 'SEUS_SPR_IDW_Region.shp', 'SEUS_SUM_IDW_Region.shp', - 'WC_ANN_IDW_Region.shp', 'WC_GFDL_Region.shp', - 'WC_GLMME_Region.shp', 'WC_TRI_IDW_Region.shp',] - selected_files = ";".join(selected_files) - dev_zip_and_unzip_shapefile_data.main(in_data_path, out_data_path, selected_files) - # Declared variables - del in_data_path, out_data_path, selected_files - # Imports - del dev_zip_and_unzip_shapefile_data - del ZipAndUnzipShapefileData - - # ###--->>> - # Write script that checks CSV file headers and updates as necessary - # ###--->>> - # ########################################################################## - # Step 3 - Create base bathymetry datasets in project folder - # ########################################################################## - # ToDo1 CreateBaseBathymetry = False - CreateBaseBathymetry = False - if CreateBaseBathymetry: - # Imports - from dev_create_base_bathymetry import create_alasaka_bathymetry, create_hawaii_bathymetry, gebco_bathymetry - # Process base Alasak bathymetry - create_alasaka_bathymetry(project_gdb) - # Process base Hawaii bathymetry - create_hawaii_bathymetry(project_gdb) - # Process base GEBCO bathymetry - gebco_bathymetry(project_gdb) - # Declared variables - # Imports - del create_alasaka_bathymetry, create_hawaii_bathymetry, gebco_bathymetry - else: - pass - del CreateBaseBathymetry - # ########################################################################## - # Step 4 - import the "Datasets" and the "Species_Filter" table into the - # ########################################################################## - # project GDB - ImportDatasetsSpeciesFilterCsvData = False - if ImportDatasetsSpeciesFilterCsvData: - # Imports - from dev_import_datasets_species_filter_csv_data import update_datecode, worker - from dev_create_table_and_field_definitions_json import generate_data_dictionary - datasets_csv = rf"{project_folder}\CSV_Data\Datasets.csv" - species_filter_csv = rf"{project_folder}\CSV_Data\Species_Filter.csv" - survey_metadata_csv = rf"{project_folder}\CSV_Data\DisMAP_Survey_Info.csv" - # Update DateCode - update_datecode(csv_file=datasets_csv, project_name=project_name) - # Datasets CSV File - worker(project_gdb=project_gdb, csv_file=datasets_csv) - # Species Filter CSV File - worker(project_gdb=project_gdb, csv_file=species_filter_csv) - # DisMAP Survey Info CSV File - worker(project_gdb=project_gdb, csv_file=survey_metadata_csv) - # Generate Table and Field Definitions JSON - generate_data_dictionary(project_gdb) - # Declared variables - del datasets_csv, species_filter_csv, survey_metadata_csv - # Imports - del update_datecode, worker, generate_data_dictionary - else: - pass - del ImportDatasetsSpeciesFilterCsvData - # ########################################################################## - # Step 5 - Create regions from shapefiles - # ########################################################################## - CreateRegionsFromShapefiles = False - if CreateRegionsFromShapefiles: - # Imports - from dev_create_regions_from_shapefiles_director import director - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["WC_TRI_IDW", "AI_IDW"]) - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=[]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateRegionsFromShapefiles - # ########################################################################## - # Step 6 - Create region fishnets - # ########################################################################## - CreateRegionFishnets = False - if CreateRegionFishnets: - from dev_create_region_fishnets_director import director - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["WC_TRI_IDW", "AI_IDW"]) - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW", "HI_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW", "AI_IDW", "GOA_IDW", "WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW"]) - #director(project_gdb=project_gdb, Sequential=False, table_names=[]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateRegionFishnets - # ########################################################################## - # Step 7 - Create Region Bathymetry - # ########################################################################## - CreateRegionBathymetry = False - if CreateRegionBathymetry: - # Imports - from dev_create_region_bathymetry_director import director - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["WC_TRI_IDW", "AI_IDW"]) - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW", "HI_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW", "AI_IDW", "GOA_IDW", "WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW"]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateRegionBathymetry - # ########################################################################## - # Step 8 - create_region_sample_locations_director - # ########################################################################## - CreateRegionSampleLocations = True - if CreateRegionSampleLocations: - # Imports - from dev_create_region_sample_locations_director import director - - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["WC_TRI_IDW", "AI_IDW"]) - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW", "HI_IDW", "SEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_TRI_IDW", "GMEX_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "GOA_IDW", "WC_ANN_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_FAL_IDW", "NEUS_SPR_IDW", "EBS_IDW"]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateRegionSampleLocations - - # ########################################################################## - # Step 9 - Create species year image name table - # ########################################################################## - CreateSpeciesYearImageNameTable = False - if CreateSpeciesYearImageNameTable: - # Imports - from dev_create_species_year_image_name_table_director import director, process_image_name_tables - - Test = False - if Test: - # Debug - director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW",]) - # Debug - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=[]) - else: - pass - del Test - # Combine Image Name Tables - #process_image_name_tables(project_gdb=project_gdb, project=project_name) - - # Declared variables - # Imports - del director, process_image_name_tables - else: - pass - del CreateSpeciesYearImageNameTable - - # ########################################################################## - # Step 10 - Create Rasters - # ########################################################################## - CreateRasters = False - if CreateRasters: - # Imports - from dev_create_rasters_director import director - - Test = False - if Test: - # Debug - director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW",]) - # Debug - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW", "HI_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "AI_IDW", "GMEX_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["GOA_IDW", "WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW",]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateRasters - - # ########################################################################## - # Step 11 - Create Indicators Table - # ########################################################################## - CreateIndicatorsTable = False - if CreateIndicatorsTable: - # Imports - from dev_create_indicators_table_director import director, process_indicator_tables - - Test = False - if Test: - # Debug - director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW",]) - # Debug - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["HI_IDW", "SEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "GOA_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW",]) - - # Combine Indicator Tables - else: - pass - del Test - #process_indicator_tables(project_gdb=project_gdb, project=project) - # Declared variables - # Imports - del director, process_indicator_tables - else: - pass - del CreateIndicatorsTable - - # dataset_comparison - rasters - # dataset_comparison - feature classes - # dataset_comparison - tables - - # Step 12 - Create Species Richness Rasters - CreateSpeciesRichnessRasters = False - if CreateSpeciesRichnessRasters: - # Imports - from dev_create_species_richness_rasters_director import director - - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW",]) - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["HI_IDW", "SEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "GOA_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW",]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateSpeciesRichnessRasters - - # create_mosaics_director - # Step 12 - Create Mosaics - CreateMosaics = False - if CreateMosaics: - # Imports - from dev_create_mosaics_director import director - - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW",]) - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["HI_IDW", "SEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "GOA_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW",]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateMosaics - - # publish_to_portal_director - - # Declared Varaiables - del project_name, project_folder - # Imports - # Function Parameters - del project_gdb - - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}") - arcpy.AddMessage(u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time)))) - arcpy.AddMessage(f"{'-' * 80}") - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - except: # noqa: E722 - traceback.print_exc() - raise SystemExit - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: - arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##") - del rk - return True - finally: - pass - -if __name__ == '__main__': - try: - # Append the location of this scrip to the System Path - sys.path.append(os.path.dirname(os.path.dirname(__file__))) - # Imports - base_project_folder = rf"{os.path.dirname(os.path.dirname(__file__))}" - #project = "May 1 2024" - #project_name = "July 1 2024" - #project_name = "December 1 2024" - #project_name = "June 1 2025" - #for project_name in ["June 1 2025"]: - for project_name in ["February 1 2026",]: - project_folder = rf"{base_project_folder}" - project_gdb = rf"{project_folder}\{project_name}\{project_name}.gdb" - main(project_gdb=project_gdb) - del project_gdb, project_folder, project_name - # Decated Variables - del base_project_folder - # Imports - except SystemExit: - pass - except: # noqa: E722 - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/dismap_tools.py b/ArcGIS-Analysis-Python/src/dismap_tools/dismap_tools.py deleted file mode 100644 index 12f6ed6..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/dismap_tools.py +++ /dev/null @@ -1,3355 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------- -# Name: py -# Purpose: Common DisMAP functions -# -# Author: john.f.kennedy -# -# Created: 12/01/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -# ------------------------------------------------------------------------------- -# built-ins first -import os -import sys -import traceback -#import importlib -import inspect - -import arcpy # third-parties second - -def parse_xml_file_format_and_save(csv_data_folder="", xml_file="", sort=False): - try: - - import json - json_path = rf"{csv_data_folder}\root_dict.json" - #print(csv_data_folder) - with open(json_path, "r") as json_file: - root_dict = json.load(json_file) - del json_file - del json_path - del json - -## root_dict = {"Esri" : 0, "dataIdInfo" : 1, "mdChar" : 2, -## "mdContact" : 3, "mdDateSt" : 4, "mdFileID" : 5, -## "mdLang" : 6, "mdMaint" : 7, "mdHrLv" : 8, -## "mdHrLvName" : 9, "refSysInfo" : 10, "spatRepInfo" : 11, -## "spdoinfo" : 12, "dqInfo" : 13, "distInfo" : 14, -## "eainfo" : 15, "contInfo" : 16, "spref" : 17, -## "spatRepInfo" : 18, "dataSetFn" : 19, "Binary" : 100,} - - from lxml import etree - - parser = etree.XMLParser(encoding='UTF-8', remove_blank_text=True) - tree = etree.parse(xml_file, parser=parser) # To parse from a string, use the fromstring() function instead. - del parser - - if sort: - root = tree.getroot() - for child in root.xpath("."): - child[:] = sorted(child, key=lambda x: root_dict[x.tag]) - del child - del root - del sort - etree.indent(tree, space=' ') - tree.write(xml_file, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True) - del tree - del xml_file, etree - del root_dict - del csv_data_folder - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def print_xml_file(xml_file="", sort=False): - try: - root_dict = {"Esri" : 0, "dataIdInfo" : 1, "mdChar" : 2, - "mdContact" : 3, "mdDateSt" : 4, "mdFileID" : 5, - "mdLang" : 6, "mdMaint" : 7, "mdHrLv" : 8, - "mdHrLvName" : 9, "refSysInfo" : 10, "spatRepInfo" : 11, - "spdoinfo" : 12, "dqInfo" : 13, "distInfo" : 14, - "eainfo" : 15, "contInfo" : 16, "spref" : 17, - "spatRepInfo" : 18, "dataSetFn" : 19, "Binary" : 100,} - - from lxml import etree - parser = etree.XMLParser(encoding='UTF-8', remove_blank_text=True) - tree = etree.parse(xml_file, parser=parser) # To parse from a string, use the fromstring() function instead. - del parser - - if sort: - root = tree.getroot() - for child in root.xpath("."): - child[:] = sorted(child, key=lambda x: root_dict[x.tag]) - del child - del root - del sort - etree.indent(tree, space=' ') - arcpy.AddMessage(etree.tostring(tree, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True).decode()) - del tree - del xml_file, etree - del root_dict - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def add_fields(csv_data_folder="", in_table=""): - try: - # Import this Python module - #import dev_dismap_tools - #importlib.reload(dev_dismap_tools) - - table = os.path.basename(in_table) - project_gdb = os.path.dirname(in_table) - - _field_definitions = field_definitions(csv_data_folder, "") - _table_definitions = table_definitions(csv_data_folder, "") - del csv_data_folder - - # set workspace environment - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = rf"Scratch\scratch.gdb" - arcpy.SetLogMetadata(True) - - if "_IDW_Region" in table: - table = "IDW_Data" - elif "GFDL_Region" in table: - table = "GFDL_Data" - elif "GLMME_Region" in table: - table = "GLMME_Data" - elif "Indicators" in table: - table = "Indicators" - else: - table = table - - fields = _table_definitions[table] - del _table_definitions - - field_definition_list = [] - for field in fields: - field_definition_list.append([ - _field_definitions[field]["field_name"], - _field_definitions[field]["field_type"], - _field_definitions[field]["field_aliasName"], - _field_definitions[field]["field_length"], - ]) - del field - del fields - - arcpy.AddMessage(f"Adding Fields to Table: {table}") - # arcpy.AddMessage(in_table) - # arcpy.AddMessage(field_definition_list) - arcpy.management.AddFields(in_table=in_table, field_description=field_definition_list, template="") - arcpy.AddMessage("\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t"))) - - # Declared Variables - del field_definition_list, _field_definitions - del project_gdb, table - # Imports - #del dev_dismap_tools - # Function parameters - del in_table - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def alter_fields(csv_data_folder="", in_table=""): - try: - project_gdb = os.path.dirname(in_table) - - _field_definitions = field_definitions(csv_data_folder, "") - del csv_data_folder - - arcpy.env.workspace = project_gdb - arcpy.SetLogMetadata(True) - - if arcpy.Exists(in_table): - arcpy.AddMessage(f"Altering Field Aliases for Table: {os.path.basename(in_table)}") - #arcpy.AddMessage(f"{table}") - - fields = [f for f in arcpy.ListFields(in_table) if f.type not in ["Geometry", "OID"] and f.name not in ["Shape_Area", "Shape_Length"]] - - for field in fields: - field_name = field.name - arcpy.AddMessage(f"\tAltering Field: {field_name} {field.type}") - - if field_name in _field_definitions: - - arcpy.AddMessage(f"\t\tAltering Field: {field_name} to: {_field_definitions[field_name]['field_aliasName']}") - - try: - arcpy.management.AlterField( - in_table=in_table, - field=_field_definitions[field_name]["field_name"], - new_field_name=_field_definitions[field_name]["field_name"], - new_field_alias=_field_definitions[field_name]["field_aliasName"], - field_length=_field_definitions[field_name]["field_length"], - field_is_nullable="NULLABLE", - clear_field_alias="DO_NOT_CLEAR", - ) - arcpy.AddMessage("\t\t\t{0}\n".format(arcpy.GetMessages().replace("\n", "\n\t\t\t"))) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - - elif field_name not in _field_definitions: - arcpy.AddWarning(f"###--->>> Field: {field_name} is not in fieldDefinitions <<<---###") - else: - pass - del field, field_name - del fields - else: - arcpy.AddWarning(f"###--->>> Alter fields: {os.path.basename(in_table)} not found <<<---###") - - del _field_definitions, project_gdb, in_table - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def backup_gdb(project_gdb=""): - try: - - arcpy.AddMessage("Making a backup") - arcpy.management.Copy(project_gdb, project_gdb.replace(".gdb", f"_Backup.gdb")) - arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) - - arcpy.AddMessage("Compacting the backup") - arcpy.management.Compact(project_gdb.replace(".gdb", f"_Backup.gdb")) - arcpy.AddMessage("\t" + arcpy.GetMessages(0).replace("\n", "\n\t")) - - del project_gdb - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def basic_metadata(csv_data_folder="", in_table=""): - # Deprecated - try: - - table = os.path.basename(in_table) - project_gdb = os.path.dirname(in_table) - - metadata_dictionary = metadata_dictionary_json(csv_data_folder, "") - del csv_data_folder - - # set workspace environment - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - arcpy.env.scratchWorkspace = rf"Scratch\scratch.gdb" - arcpy.env.workspace = project_gdb - arcpy.SetLogMetadata(True) - - if arcpy.Exists(table): - arcpy.AddMessage(f"Adding metadata to: {table}") - - if table.endswith(".crf"): - table = table.replace(".crf", "_Mosaic") - - # from arcpy import metadata as md - # # https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm - # dataset_md = md.Metadata(in_table) - # dataset_md.synchronize("ALWAYS", 0) - # dataset_md.save() - # dataset_md.reload() - - # dataset_md.synchronize("NOT_CREATED", 0) - # dataset_md.title = metadata_dictionary[table]["md_title"] - # dataset_md.tags = metadata_dictionary[table]["md_tags"] - # dataset_md.summary = metadata_dictionary[table]["md_summary"] - # dataset_md.description = metadata_dictionary[table]["md_description"] - # dataset_md.credits = metadata_dictionary[table]["md_credits"] - # dataset_md.accessConstraints = metadata_dictionary[table]["md_access_constraints"] - # dataset_md.save() - # dataset_md.reload() - - # arcpy.AddMessage(metadata_dictionary[table]["md_title"]) - # arcpy.AddMessage(metadata_dictionary[table]["md_tags"]) - # arcpy.AddMessage(metadata_dictionary[table]["md_summary"]) - # arcpy.AddMessage(metadata_dictionary[table]["md_description"]) - # arcpy.AddMessage(metadata_dictionary[table]["md_credits"]) - # arcpy.AddMessage(metadata_dictionary[table]["md_access_constraints"]) - - arcpy.AddMessage(f"Adding metadata to: {table} completed") - - #del dataset_md, md - - else: - arcpy.AddWarning(f"Adding Metadata: {table} not found") - - del metadata_dictionary, table, project_gdb, in_table - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def check_datasets(datasets=[]): - try: - - def formatDateTime(dateTime): - from datetime import datetime, timezone - - d = datetime.strptime(dateTime, "%Y-%m-%dT%H:%M:%S.%f") - d = d.replace(tzinfo=timezone.utc) - d = d.astimezone() - return d.strftime("%b %d %Y %I:%M:%S %p") - - for dataset in datasets: - # Create a Describe object from the feature class - # - desc = arcpy.da.Describe(dataset) - # Print some feature class properties - # baseName - # catalogPath - # children - # childrenExpanded - # Examine children and print their name and dataType - # - # arcpy.AddMessage("Children:") - # for child in desc.children: - # arcpy.AddMessage("\t%s = %s" % (child.name, child.dataType)) - # dataElementType - # dataType - # extension - # file - # fullPropsRetrieved - # metadataRetrieved - - arcpy.AddMessage(f"Dataset Name: {desc['name']}") - arcpy.AddMessage(f"\tDataset Path: {desc['path']}") - arcpy.AddMessage(f"\tDataset Type: {desc['dataType']}") - - if desc["dataType"] == "FeatureClass": - # arcpy.AddMessage(f"\tFeature Type: {desc['featureType']}") - arcpy.AddMessage(f"\tData Type: {desc['dataType']}") - # arcpy.AddMessage(f"\tDataset Type: {desc['datasetType']}") - arcpy.AddMessage(f"\tShape Type: {desc['shapeType']}") - arcpy.AddMessage(f"\tDate Created: {formatDateTime(desc['dateCreated'])}") - arcpy.AddMessage(f"\tDate Accessed: {formatDateTime(desc['dateAccessed'])}") - arcpy.AddMessage(f"\tDate Modified: {formatDateTime(desc['dateModified'])}") - arcpy.AddMessage(f"\tSize: {round(desc['size'] * 0.000001, 2)} MB") - arcpy.AddMessage(f"\tSpatial Reference: {desc['spatialReference'].name}") - # arcpy.AddMessage(f"Spatial Index: {str(desc.hasSpatialIndex)}") - # arcpy.AddMessage(f"Has M: {desc.hasM}") - # arcpy.AddMessage(f"Has Z: {desc.hasZ}") - # arcpy.AddMessage(f"Shape Field Name: {desc.shapeFieldName}") - # arcpy.AddMessage(f"Split Model: {str(desc.hasSpatialIndex)}") - # arcpy.AddMessage(desc["fields"]) - fields = [f.name for f in desc["fields"]] - oid = desc["OIDFieldName"] - # Use SQL TOP to sort field values - arcpy.AddMessage(f"\t{', '.join(fields)}") - for row in arcpy.da.SearchCursor(dataset, fields, f"{oid} <= 5"): - arcpy.AddMessage(f"\t{row}") - del row - del oid, fields - - ## fields = [f.name for f in desc["fields"]] - ## oid_field_name = desc["OIDFieldName"] - ## # Use SQL TOP to sort field values - ## arcpy.AddMessage(f"\t{', '.join(fields)}") - ## oids = [oid for oid in arcpy.da.SearchCursor(dataset, f"{oid_field_name}")] - ## from random import sample - ## random_indices = sample(oids, 5) - ## del sample - ## for row in arcpy.da.SearchCursor(dataset, fields, f"{oid_field_name} in {random_indices}"): - ## arcpy.AddMessage(f"\t{row}") - ## del row - ## del oids, random_indices, oid_field_name, fields - - elif desc["dataType"] == "RasterDataset": - arcpy.AddMessage(f"\tData Type: {desc['dataType']}") - arcpy.AddMessage(f"\tCell Size: {desc['meanCellHeight']} x {desc['meanCellWidth']}") - arcpy.AddMessage(f"\tExtent: {desc['extent']}") - arcpy.AddMessage(f"\tHeight & Width: {desc['height']} x {desc['width']}") - arcpy.AddMessage(f"\tSpatial Reference: {desc['spatialReference'].name}") - - # for key in sorted(desc): - # value = str(desc[key]) - # arcpy.AddMessage(f"Key: '{key:<30}' Value: '{value:<25}'") - # del value, key - - elif desc["dataType"] == "Table": - arcpy.AddMessage(f"\tData Type: {desc['dataType']}") - arcpy.AddMessage(f"\tDate Created: {formatDateTime(desc['dateCreated'])}") - arcpy.AddMessage(f"\tDate Accessed: {formatDateTime(desc['dateAccessed'])}") - arcpy.AddMessage(f"\tDate Modified: {formatDateTime(desc['dateModified'])}") - arcpy.AddMessage(f"\tSize: {round(desc['size'] * 0.000001, 2)} MB") - # arcpy.AddMessage(desc["fields"]) - fields = [f.name for f in desc["fields"]] - oid = desc["OIDFieldName"] - # Use SQL TOP to sort field values - arcpy.AddMessage(f"\t{', '.join(fields)}") - for row in arcpy.da.SearchCursor(dataset, fields, f"{oid} <= 5"): - arcpy.AddMessage(f"\t{row}") - del row - del oid, fields - - elif desc["dataType"] == "MosaicDataset": - arcpy.AddMessage(f"\t DSID: {desc['DSID']}") - arcpy.AddMessage(f"\t JPEGQuality: {desc['JPEGQuality']}") - arcpy.AddMessage(f"\t LERCTolerance: {desc['LERCTolerance']}") - arcpy.AddMessage(f"\t MExtent: {desc['MExtent']}") - arcpy.AddMessage(f"\t OIDFieldName: {desc['OIDFieldName']}") - arcpy.AddMessage(f"\t ZExtent: {desc['ZExtent']}") - arcpy.AddMessage(f"\t allowedCompressionMethods: {desc['allowedCompressionMethods']}") - arcpy.AddMessage(f"\t allowedFields: {desc['allowedFields']}") - arcpy.AddMessage(f"\t allowedMensurationCapabilities: {desc['allowedMensurationCapabilities']}") - arcpy.AddMessage(f"\t allowedMosaicMethods: {desc['allowedMosaicMethods']}") - arcpy.AddMessage(f"\t bandCount: {desc['bandCount']}") - arcpy.AddMessage(f"\t baseName: {desc['baseName']}") - arcpy.AddMessage(f"\t blendWidth: {desc['blendWidth']}") - arcpy.AddMessage(f"\t blendWidthUnits: {desc['blendWidthUnits']}") - arcpy.AddMessage(f"\t catalogPath: {desc['catalogPath']}") - arcpy.AddMessage(f"\t cellSizeToleranceFactor: {desc['cellSizeToleranceFactor']}") - arcpy.AddMessage(f"\t children: {desc['children']}") - arcpy.AddMessage(f"\t childrenExpanded: {desc['childrenExpanded']}") - arcpy.AddMessage(f"\t childrenNames: {desc['childrenNames']}") - arcpy.AddMessage(f"\t clipToBoundary: {desc['clipToBoundary']}") - arcpy.AddMessage(f"\t compressionType: {desc['compressionType']}") - arcpy.AddMessage(f"\t dataElementType: {desc['dataElementType']}") - arcpy.AddMessage(f"\t dataType: {desc['dataType']}") - arcpy.AddMessage(f"\t datasetType: {desc['datasetType']}") - arcpy.AddMessage(f"\t defaultCompressionMethod: {desc['defaultCompressionMethod']}") - arcpy.AddMessage(f"\t defaultMensurationCapability: {desc['defaultMensurationCapability']}") - arcpy.AddMessage(f"\t defaultMosaicMethod: {desc['defaultMosaicMethod']}") - arcpy.AddMessage(f"\t defaultResamplingMethod: {desc['defaultResamplingMethod']}") - arcpy.AddMessage(f"\t defaultSubtypeCode: {desc['defaultSubtypeCode']}") - arcpy.AddMessage(f"\t endTimeField: {desc['endTimeField']}") - arcpy.AddMessage(f"\t extent: {desc['extent']}") - arcpy.AddMessage(f"\t featureType: {desc['featureType']}") - arcpy.AddMessage(f"\t fields: {desc['fields']}") - arcpy.AddMessage(f"\t file: {desc['file']}") - arcpy.AddMessage(f"\t footprintMayContainNoData: {desc['footprintMayContainNoData']}") - arcpy.AddMessage(f"\t format: {desc['format']}") - arcpy.AddMessage(f"\t fullPropsRetrieved: {desc['fullPropsRetrieved']}") - arcpy.AddMessage(f"\t hasOID: {desc['hasOID']}") - arcpy.AddMessage(f"\t hasSpatialIndex: {desc['hasSpatialIndex']}") - arcpy.AddMessage(f"\t indexes: {desc['indexes']}") - arcpy.AddMessage(f"\t isInteger: {desc['isInteger']}") - arcpy.AddMessage(f"\t isTimeInUTC: {desc['isTimeInUTC']}") - arcpy.AddMessage(f"\t maxDownloadImageCount: {desc['maxDownloadImageCount']}") - arcpy.AddMessage(f"\t maxDownloadSizeLimit: {desc['maxDownloadSizeLimit']}") - arcpy.AddMessage(f"\t maxRastersPerMosaic: {desc['maxRastersPerMosaic']}") - arcpy.AddMessage(f"\t maxRecordsReturned: {desc['maxRecordsReturned']}") - arcpy.AddMessage(f"\t maxRequestSizeX: {desc['maxRequestSizeX']}") - arcpy.AddMessage(f"\t maxRequestSizeY: {desc['maxRequestSizeY']}") - arcpy.AddMessage(f"\t minimumPixelContribution: {desc['minimumPixelContribution']}") - arcpy.AddMessage(f"\t mosaicOperator: {desc['mosaicOperator']}") - arcpy.AddMessage(f"\t name: {desc['name']}") - arcpy.AddMessage(f"\t orderField: {desc['orderField']}") - arcpy.AddMessage(f"\t path: {desc['path']}") - arcpy.AddMessage(f"\t permanent: {desc['permanent']}") - arcpy.AddMessage(f"\t rasterFieldName: {desc['rasterFieldName']}") - arcpy.AddMessage(f"\t rasterMetadataLevel: {desc['rasterMetadataLevel']}") - arcpy.AddMessage(f"\t shapeFieldName: {desc['shapeFieldName']}") - arcpy.AddMessage(f"\t shapeType: {desc['shapeType']}") - arcpy.AddMessage(f"\t sortAscending: {desc['sortAscending']}") - arcpy.AddMessage(f"\t spatialReference: {desc['spatialReference']}") - arcpy.AddMessage(f"\t startTimeField: {desc['startTimeField']}") - arcpy.AddMessage(f"\t supportsBigInteger: {desc['supportsBigInteger']}") - arcpy.AddMessage(f"\t supportsBigObjectID: {desc['supportsBigObjectID']}") - arcpy.AddMessage(f"\t supportsDateOnly: {desc['supportsDateOnly']}") - arcpy.AddMessage(f"\t supportsTimeOnly: {desc['supportsTimeOnly']}") - arcpy.AddMessage(f"\t supportsTimestampOffset: {desc['supportsTimestampOffset']}") - arcpy.AddMessage(f"\t timeValueFormat: {desc['timeValueFormat']}") - arcpy.AddMessage(f"\t useTime: {desc['useTime']}") - arcpy.AddMessage(f"\t viewpointSpacingX: {desc['viewpointSpacingX']}") - arcpy.AddMessage(f"\t viewpointSpacingY: {desc['viewpointSpacingY']}") - arcpy.AddMessage(f"\t workspace: {desc['workspace']}") - - # arcpy.AddMessage(desc["fields"]) - fields = [f.name for f in desc["fields"]] - oid = desc["OIDFieldName"] - # Use SQL TOP to sort field values - arcpy.AddMessage(f"\t{', '.join(fields)}") - for row in arcpy.da.SearchCursor(dataset, fields, f"{oid} <= 5"): - arcpy.AddMessage(f"\t{row}") - del row - del oid, fields - - elif desc["dataType"]: - arcpy.AddWarning(desc["dataType"]) - - else: - arcpy.AddWarning("No data to describe!!") - - del desc, dataset - - del formatDateTime, datasets - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def check_transformation(ds, cs): - dsc_in = arcpy.Describe(ds) - insr = dsc_in.spatialReference - - # if output coordinate system is set and is different than the input coordinate system - if cs and (cs.name != insr.name): - translist = arcpy.ListTransformations(insr, cs, dsc_in.extent) - trans = translist[0] if translist else "" - # arcpy.AddMessage(f"\t{trans}\n") - # for trans in translist: - # arcpy.AddMessage(f"\t{trans}") - return trans - -def clear_folder(folder=""): - try: - import shutil - - for filename in os.listdir(folder): - file_path = os.path.join(folder, filename) - try: - if os.path.isfile(file_path) or os.path.islink(file_path): - arcpy.AddMessage(f"Removing: {os.path.basename(file_path)}") - os.unlink(file_path) - elif os.path.isdir(file_path): - arcpy.AddMessage(f"Removing: {os.path.basename(file_path)}") - shutil.rmtree(file_path) - except Exception as e: - arcpy.AddError(f"Failed to delete {os.path.basename(file_path)}. Reason: {e}") - del filename, file_path - - # Imports - del shutil - # Function Parameter - del folder - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def compare_metadata_xml(file1="", file2=""): - """This requires the use of the clone ArcGIS Pro env and the installation of xmldiff.""" - # https://buildmedia.readthedocs.org/media/pdf/xmldiff/latest/xmldiff.pdf - try: - # Test if passed workspace exists, if not raise Exception - if not os.path.exists(rf"{file1}") or not os.path.exists(rf"{file2}"): - raise Exception(f"{os.path.basename(file1)} or {os.path.basename(file2)} is missing!!") - - from lxml import etree - from xmldiff import main, formatting - - # Examples - # diff = main.diff_files(file1, file2, formatter=formatting.XMLFormatter()) - # diff = main.diff_files(file1, file2, formatter=formatting.XMLFormatter(normalize=formatting.WS_BOTH, pretty_print=True)) - # The DiffFormatter creates a script of steps to take to make file2 like file1 - __diff = main.diff_files(file1, file2, formatter=formatting.DiffFormatter()) - # If there are differences - if __diff: - __diff = main.diff_files(file1, file2, formatter=formatting.XMLFormatter()) - return __diff - else: - return None - - # Declared Variables - del __diff - # Imports - del etree, main, formatting - # Function Parameters - del file1, file2 - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return __diff - finally: - if "__diff" in locals().keys(): del __diff - # Imports - del etree, main, formatting - # Function Parameters - del file1, file2 - -def convertSeconds(seconds): - try: - _min, _sec = divmod(seconds, 60) - _hour, _min = divmod(_min, 60) - return f"{int(_hour)}:{int(_min)}:{_sec:.3f}" - - except: # noqa: E722 - traceback.print_exc() - -##def calculate_core_species(table): -## try: -## -## region_gdb = os.path.dirname(table) -## -## arcpy.env.workspace = region_gdb -## arcpy.env.scratchWorkspace = region_gdb -## arcpy.env.parallelProcessingFactor = "100%" -## arcpy.env.overwriteOutput = True -## arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History -## arcpy.SetLogMetadata(True) -## arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. -## # 1—If a tool produces a warning or an error, it will throw an exception. -## # 2—If a tool produces an error, it will throw an exception. This is the default. -## arcpy.SetMessageLevels(["NORMAL"]) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION -## del region_gdb -## -## # def unique_years(table): -## # with arcpy.da.SearchCursor(table, ["Year"]) as cursor: -## # return sorted({row[0] for row in cursor}) -## -## def unique_values(table, field): -## with arcpy.da.SearchCursor(table, [field]) as cursor: -## return sorted({row[0] for row in cursor}) # Uses list comprehension -## -## # Get unique list of years from the table -## all_years = unique_values(table, "Year") -## -## PrintListOfYears = False -## if PrintListOfYears: -## # Print list of years -## arcpy.AddMessage(f"--> Years: {', '.join([str(y) for y in all_years])}") -## -## # Get minimum year (first year) and maximum year (last year) -## min_year, max_year = min(all_years), max(all_years) -## -## # Print min year -## arcpy.AddMessage(f"--> Min Year: {min_year} and Max Year: {max_year}") -## -## del min_year, max_year -## -## del PrintListOfYears -## -## arcpy.AddMessage(f"\t Creating {os.path.basename(table)} Table View") -## -## species_table_view = arcpy.management.MakeTableView(table, f"{os.path.basename(table)} Table View") -## -## unique_species = unique_values(species_table_view, "Species") -## -## for unique_specie in unique_species: -## arcpy.AddMessage(f"\t\t Unique Species: {unique_specie}") -## -## # Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script -## # The following inputs are layers or table views: "ai_csv" -## arcpy.management.SelectLayerByAttribute(in_layer_or_view=species_table_view, selection_type="NEW_SELECTION", where_clause=f"Species = '{unique_specie}' AND WTCPUE > 0.0 AND DistributionProjectName = 'NMFS/Rutgers IDW Interpolation'") -## -## all_specie_years = unique_values(species_table_view, "Year") -## -## # arcpy.AddMessage(f"\t\t\t Years: {', '.join([str(y) for y in all_specie_years])}") -## -## # arcpy.AddMessage(f"\t\t Select Species ({unique_specie}) by attribute") -## -## arcpy.management.SelectLayerByAttribute(in_layer_or_view=species_table_view, selection_type="NEW_SELECTION", where_clause=f"Species = '{unique_specie}'") -## -## # arcpy.AddMessage(f"\t Set CoreSpecies to Yes or No") -## -## if all_years == all_specie_years: -## arcpy.AddMessage(f"\t\t\t {unique_specie} is a Core Species") -## arcpy.management.CalculateField(in_table=species_table_view, field="CoreSpecies", expression="'Yes'", expression_type="PYTHON", code_block="") -## else: -## arcpy.AddMessage(f"\t\t\t @@@@ {unique_specie} is not a Core Species @@@@") -## arcpy.management.CalculateField(in_table=species_table_view, field="CoreSpecies", expression="'No'", expression_type="PYTHON", code_block="") -## -## arcpy.management.SelectLayerByAttribute(species_table_view, "CLEAR_SELECTION") -## del unique_specie, all_specie_years -## -## arcpy.management.Delete(f"{os.path.basename(table)} Table View") -## del species_table_view, unique_species, all_years -## del unique_values -## del table -## -## except KeyboardInterrupt: -## raise SystemExit -## except arcpy.ExecuteWarning: -## arcpy.AddWarning(arcpy.GetMessages(1)) -## except arcpy.ExecuteError: -## arcpy.AddError(arcpy.GetMessages(2)) -## traceback.print_exc() -## raise SystemExit -## except Exception: -## arcpy.AddError(arcpy.GetMessages(2)) -## traceback.print_exc() -## raise SystemExit -## except: # noqa: E722 -## arcpy.AddError(arcpy.GetMessages(2)) -## traceback.print_exc() -## raise SystemExit -## else: -## # While in development, leave here. For test, move to finally -## rk = [key for key in locals().keys() if not key.startswith('__')] -## if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk -## return True -## finally: -## pass - -def dataset_title_dict(project_gdb=""): - try: - # Test if passed workspace exists, if not raise Exception - if not arcpy.Exists(project_gdb): - arcpy.AddError(project_gdb) - arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") - sys.exit() - - if "Scratch" in project_gdb: - project = os.path.basename(os.path.dirname(os.path.dirname(project_gdb))) - else: - project = os.path.basename(os.path.dirname(project_gdb)) - - project_folder = os.path.dirname(project_gdb) - crf_folder = rf"{project_folder}\CRFs" - _credits = "These data were produced by NMFS OST." - access_constraints = "***No Warranty*** The user assumes the entire risk related to its use of these data. NMFS is providing these data 'as is' and NMFS disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose. No warranty expressed or implied is made regarding the accuracy or utility of the data on any other system or for general or scientific purposes, nor shall the act of distribution constitute any such warranty. It is strongly recommended that careful attention be paid to the contents of the metadata file associated with these data to evaluate dataset limitations, restrictions or intended use. In no event will NMFS be liable to you or to any third party for any direct, indirect, incidental, consequential, special or exemplary damages or lost profit resulting from any use or misuse of these data." - - __datasets_dict = {} - - dataset_codes = {row[0] : [row[1], row[2], row[3], row[4]] for row in arcpy.da.SearchCursor(rf"{project_gdb}\Datasets", ["DatasetCode", "PointFeatureType", "DistributionProjectCode", "Region", "Season"])} - #for dataset_code in dataset_codes: - # dataset_codes[dataset_code] = [s for s in dataset_codes[dataset_code] if s.strip()] - # #print(f"Dataset Code: {dataset_code}\n\t{dataset_codes[dataset_code]}") - - for dataset_code in dataset_codes: - point_feature_type = dataset_codes[dataset_code][0] if dataset_codes[dataset_code][0] else "" - distribution_project_code = dataset_codes[dataset_code][1] if dataset_codes[dataset_code][1] else "" - region = dataset_codes[dataset_code][2] if dataset_codes[dataset_code][2] else dataset_code.replace("_", " ") - season = dataset_codes[dataset_code][3] if dataset_codes[dataset_code][3] else "" - - tags = f"DisMap, {region}, {season}" if season else f"DisMap, {region}" - #tags = f"{tags}, distribution, seasonal distribution, fish, invertebrates, climate change, fishery-independent surveys, ecological dynamics, oceans, biosphere, earth science, species/population interactions, aquatic sciences, fisheries, range changes" - summary = "These data were created as part of the DisMAP project to enable visualization and analysis of changes in fish and invertebrate distributions" - - #arcpy.AddMessage(f"Dateset Code: {dataset_code}") - - if distribution_project_code == "IDW": - table_name = f"{dataset_code}_{distribution_project_code}" - table_name_s = f"{table_name}_{date_code(project)}" - table_name_st = f"{region} {season} Table {date_code(project)}".replace(' ',' ') - - #arcpy.AddMessage(f"\tProcessing: {table_name}") - - __datasets_dict[table_name] = {"Dataset Service" : table_name_s, - "Dataset Service Title" : table_name_st, - "Tags" : tags, - "Summary" : summary, - "Description" : f"This table represents the CSV Data files in ArcGIS format", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - del table_name, table_name_s, table_name_st - - table_name = f"{dataset_code}_{distribution_project_code}" - sample_locations_fc = f"{table_name}_{point_feature_type.replace(' ', '_')}" - sample_locations_fcs = f"{table_name.replace('_IDW', '')}_{point_feature_type.replace(' ', '_')}_{date_code(project)}" - feature_service_title = f"{region} {season} {point_feature_type} {date_code(project)}".replace(' ',' ') - sample_locations_fcst = f"{feature_service_title}" - del feature_service_title - - __datasets_dict[sample_locations_fc] = {"Dataset Service" : sample_locations_fcs, - "Dataset Service Title" : sample_locations_fcst, - "Tags" : tags, - "Summary" : f"{summary}. These layers provide information on the spatial extent/boundaries of the bottom trawl surveys. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", - "Description" : f"This survey points layer provides information on both the locations where species are caught in several NOAA Fisheries surveys and the amount (i.e., biomass weight catch per unit effort, standardized to kg/ha) of each species that was caught at each location. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tSample Locations FC: {sample_locations_fc}") - #arcpy.AddMessage(f"\tSample Locations FCS: {sample_locations_fcs}") - #arcpy.AddMessage(f"\tSample Locations FST: {sample_locations_fcst}") - - del table_name, sample_locations_fc, sample_locations_fcs, sample_locations_fcst - - dataset_code = f"{dataset_code}_{distribution_project_code}" if distribution_project_code not in dataset_code else dataset_code - - # Bathymetry - bathymetry_r = f"{dataset_code}_Bathymetry" - bathymetry_rs = f"{dataset_code}_Bathymetry_{date_code(project)}" - feature_service_title = f"{region} {season} Bathymetry {date_code(project)}".replace(' ',' ') - bathymetry_rst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {bathymetry_r}") - - __datasets_dict[bathymetry_r] = {"Dataset Service" : bathymetry_rs, - "Dataset Service Title" : bathymetry_rst, - "Tags" : tags, - "Summary" : summary, - "Description" : f"The bathymetry dataset represents the ocean depth at that grid cell.", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tBathymetry R: {bathymetry_r}") - #arcpy.AddMessage(f"\tBathymetry RS: {bathymetry_rs}") - #arcpy.AddMessage(f"\tBathymetry RST: {bathymetry_rst}") - - del bathymetry_r, bathymetry_rs, bathymetry_rst - - # Boundary - boundary_fc = f"{dataset_code}_Boundary" - boundary_fcs = f"{dataset_code}_Boundary_{date_code(project)}" - feature_service_title = f"{region} {season} Boundary {date_code(project)}".replace(' ',' ') - boundary_fcst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {boundary_fc}") - - __datasets_dict[boundary_fc] = {"Dataset Service" : boundary_fcs, - "Dataset Service Title" : boundary_fcst, - "Tags" : tags, - "Summary" : summary, - "Description" : f"These files contain the spatial boundaries of the NOAA Fisheries Bottom-trawl surveys. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Eastern Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tBoundary FC: {boundary_fc}") - #arcpy.AddMessage(f"\tBoundary FCS: {boundary_fcs}") - #arcpy.AddMessage(f"\tBoundary FCST: {boundary_fcst}") - - del boundary_fc, boundary_fcs, boundary_fcst - - # Boundary Line - boundary_line_fc = f"{dataset_code}_Boundary_Line" - boundary_line_fcs = f"{dataset_code}_Boundary_Line_{date_code(project)}" - feature_service_title = f"{region} {season} Boundary Line {date_code(project)}".replace(' ',' ') - boundary_line_fcst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {boundary_line_fc}") - - __datasets_dict[boundary_line_fc] = {"Dataset Service" : boundary_line_fcs, - "Dataset Service Title" : boundary_line_fcst, - "Tags" : tags, - "Summary" : summary, - "Description" : f"These files contain the spatial boundaries of the NOAA Fisheries Bottom-trawl surveys. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Eastern Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tBoundary FC: {boundary_line_fc}") - #arcpy.AddMessage(f"\tBoundary FCS: {boundary_line_fcs}") - #arcpy.AddMessage(f"\tBoundary FCST: {boundary_line_fcst}") - - del boundary_line_fc, boundary_line_fcs, boundary_line_fcst - - # Extent Points - extent_points_fc = f"{dataset_code}_Extent_Points" - extent_points_fcs = f"{dataset_code}_Extent_Points_{date_code(project)}" - feature_service_title = f"{region} {season} Extent Points {date_code(project)}".replace(' ',' ') - extent_points_fcst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {extent_points_fc}") - __datasets_dict[extent_points_fc] = {"Dataset Service" : extent_points_fcs, - "Dataset Service Title" : extent_points_fcst, - "Tags" : tags, - "Summary" : summary, - "Description" : f"The Extent Points layer represents the extent of the model region.", - "Credits" : _credits, - "Access Constraints" : access_constraints} - #arcpy.AddMessage(f"\tExtent Points FC: {extent_points_fc}") - #arcpy.AddMessage(f"\tExtent Points FCS: {extent_points_fcs}") - #arcpy.AddMessage(f"\tExtent Points FCST: {extent_points_fcst}") - del extent_points_fc, extent_points_fcs, extent_points_fcst - - fishnet_fc = f"{dataset_code}_Fishnet" - fishnet_fcs = f"{dataset_code}_Fishnet_{date_code(project)}" - feature_service_title = f"{region} {season} Fishnet {date_code(project)}".replace(' ',' ') - fishnet_fcst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {fishnet_fc}") - - __datasets_dict[fishnet_fc] = {"Dataset Service" : fishnet_fcs, - "Dataset Service Title" : fishnet_fcst, - "Tags" : tags, - "Summary" : summary, - "Description" : f"The Fishnet is used to create the latitude and longitude rasters.", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tFishnet FC: {fishnet_fc}") - #arcpy.AddMessage(f"\tFishnet FCS: {fishnet_fcs}") - #arcpy.AddMessage(f"\tFishnet FCST: {fishnet_fcst}") - - del fishnet_fc, fishnet_fcs, fishnet_fcst - - indicators_tb = f"{dataset_code}_Indicators" - indicators_tbs = f"{dataset_code}_Indicators_{date_code(project)}" - feature_service_title = f"{region} {season} Indicators Table {date_code(project)}".replace(' ',' ') - indicators_tbst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {indicators_tb}") - - __datasets_dict[indicators_tb] = {"Dataset Service" : indicators_tbs, - "Dataset Service Title" : indicators_tbst, - "Tags" : tags, - "Summary" : f"{summary}. This table provides the key metrics used to evaluate a species distribution shift. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", - "Description" : f"These data contain the key distribution metrics of center of gravity, range limits, and depth for each species in the portal. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tIndicators T: {indicators_tb}") - #arcpy.AddMessage(f"\tIndicators TS: {indicators_tbs}") - #arcpy.AddMessage(f"\tIndicators TST: {indicators_tbst}") - - del indicators_tb, indicators_tbs, indicators_tbst - - lat_long_fc = f"{dataset_code}_Lat_Long" - lat_long_fcs = f"{dataset_code}_Lat_Long_{date_code(project)}" - feature_service_title = f"{region} {season} Lat Long {date_code(project)}".replace(' ',' ') - lat_long_fcst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {lat_long_fc}") - - __datasets_dict[lat_long_fc] = {"Dataset Service" : lat_long_fcs, - "Dataset Service Title" : lat_long_fcst, - "Tags" : tags, - "Summary" : summary, - "Description" : f"The lat_long layer is used to get the latitude & longitude values to create these rasters", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tLat Long FC: {lat_long_fc}") - #arcpy.AddMessage(f"\tLat Long FCS: {lat_long_fcs}") - #arcpy.AddMessage(f"\tLat Long FCST: {lat_long_fcst}") - - del lat_long_fc, lat_long_fcs, lat_long_fcst - - latitude_r = f"{dataset_code}_Latitude" - latitude_rs = f"{dataset_code}_Latitude_{date_code(project)}" - feature_service_title = f"{region} {season} Latitude {date_code(project)}".replace(' ',' ') - latitude_rst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {latitude_r}") - - __datasets_dict[latitude_r] = {"Dataset Service" : latitude_rs, - "Dataset Service Title" : latitude_rst, - "Tags" : tags, - "Summary" : summary, - "Description" : f"The Latitude raster", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tLatitude R: {latitude_r}") - #arcpy.AddMessage(f"\tLatitude RS: {latitude_rs}") - #arcpy.AddMessage(f"\tLatitude RST: {latitude_rst}") - - del latitude_r, latitude_rs, latitude_rst - - layer_species_year_image_name_tb = f"{dataset_code}_LayerSpeciesYearImageName" - layer_species_year_image_name_tbs = f"{dataset_code}_LayerSpeciesYearImageName_{date_code(project)}" - feature_service_title = f"{region} {season} Layer Species Year Image Name Table {date_code(project)}" - layer_species_year_image_name_tbst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {layer_species_year_image_name_tb}") - - __datasets_dict[layer_species_year_image_name_tb] = {"Dataset Service" : layer_species_year_image_name_tbs, - "Dataset Service Title" : layer_species_year_image_name_tbst, - "Tags" : tags, - "Summary" : summary, - "Description" : f"Layer Species Year Image Name Table", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName T: {layer_species_year_image_name_tb}") - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName TS: {layer_species_year_image_name_tbs}") - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName TST: {layer_species_year_image_name_tbst}") - - del layer_species_year_image_name_tb, layer_species_year_image_name_tbs, layer_species_year_image_name_tbst - - longitude_r = f"{dataset_code}_Longitude" - longitude_rs = f"{dataset_code}_Longitude_{date_code(project)}" - feature_service_title = f"{region} {season} Longitude {date_code(project)}".replace(' ',' ') - longitude_rst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {longitude_r}") - - __datasets_dict[longitude_r] = {"Dataset Service" : longitude_rs, - "Dataset Service Title" : longitude_rst, - "Tags" : tags, - "Summary" : summary, - "Description" : f"The Longitude raster", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tLongitude R: {longitude_r}") - #arcpy.AddMessage(f"\tLongitude RS: {longitude_rs}") - #arcpy.AddMessage(f"\tLongitude RST: {longitude_rst}") - - del longitude_r, longitude_rs, longitude_rst - - mosaic_r = f"{dataset_code}_Mosaic" - mosaic_rs = f"{dataset_code}_Mosaic_{date_code(project)}" - feature_service_title = f"{region} {season} {dataset_code[dataset_code.rfind('_')+1:]} Mosaic {date_code(project)}".replace(' ',' ') - mosaic_rst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {mosaic_r}") - - __datasets_dict[mosaic_r] = {"Dataset Service" : mosaic_rs, - "Dataset Service Title" : mosaic_rst, - "Tags" : tags, - "Summary" : f"{summary}. These interpolated biomass layers provide information on the spatial distribution of species caught in the NOAA Fisheries fisheries-independent surveys. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", - "Description" : f"NOAA Fisheries and its partners conduct fisheries-independent surveys in 8 regions in the US (Northeast, Southeast, Gulf of Mexico, West Coast, Gulf of Alaska, Bering Sea, Aleutian Islands, Hawai’i Islands). These surveys are designed to collect information on the seasonal distribution, relative abundance, and biodiversity of fish and invertebrate species found in U.S. waters. Over 400 species of fish and invertebrates have been identified in these surveys.", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tMosaic R: {mosaic_r}") - #arcpy.AddMessage(f"\tMosaic RS: {mosaic_rs}") - #arcpy.AddMessage(f"\tMosaic RST: {mosaic_rst}") - - del mosaic_r, mosaic_rs, mosaic_rst - - crf_r = f"{dataset_code}.crf" - crf_rs = f"{dataset_code}_{date_code(project)}" - feature_service_title = f"{region} {season} {dataset_code[dataset_code.rfind('_')+1:]} {date_code(project)}".replace(' ',' ') - crf_rst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {crf_r}") - - __datasets_dict[crf_r] = {"Dataset Service" : crf_rs, - "Dataset Service Title" : crf_rst, - "Tags" : tags, - "Summary" : f"{summary}. These interpolated biomass layers provide information on the spatial distribution of species caught in the NOAA Fisheries fisheries-independent surveys. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", - "Description" : f"NOAA Fisheries and its partners conduct fisheries-independent surveys in 8 regions in the US (Northeast, Southeast, Gulf of Mexico, West Coast, Gulf of Alaska, Bering Sea, Aleutian Islands, Hawai’i Islands). These surveys are designed to collect information on the seasonal distribution, relative abundance, and biodiversity of fish and invertebrate species found in U.S. waters. Over 400 species of fish and invertebrates have been identified in these surveys.", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tCFR R: {crf_r}") - #arcpy.AddMessage(f"\tCFR RS: {crf_rs}") - #arcpy.AddMessage(f"\tCFR RST: {crf_rst}") - - del crf_r, crf_rs, crf_rst - - raster_mask_r = f"{dataset_code}_Raster_Mask" - raster_mask_rs = f"{dataset_code}_Raster_Mask_{date_code(project)}" - feature_service_title = f"{region} {season} Raster Mask {date_code(project)}".replace(' ',' ') - raster_mask_rst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {raster_mask_r}") - - __datasets_dict[raster_mask_r] = {"Dataset Service" : raster_mask_rs, - "Dataset Service Title" : raster_mask_rst, - "Tags" : tags, - "Summary" : summary, - "Description" : f"Raster Mask is used for image production", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tRaster_Mask R: {raster_mask_r}") - #arcpy.AddMessage(f"\tRaster_Mask RS: {raster_mask_rs}") - #arcpy.AddMessage(f"\tRaster_Mask RST: {raster_mask_rst}") - - del raster_mask_r, raster_mask_rs, raster_mask_rst - - region_fc = f"{dataset_code}_Region" - region_fcs = f"{dataset_code}_Region_{date_code(project)}" - feature_service_title = f"{region} {season} Region {date_code(project)}".replace(' ',' ') - region_fcst = f"{feature_service_title}" - del feature_service_title - - #arcpy.AddMessage(f"\tProcessing: {region_fc}") - - __datasets_dict[region_fc] = {"Dataset Service" : region_fcs, - "Dataset Service Title" : region_fcst, - "Tags" : tags, - "Summary" : summary, - "Description" : f"These files contain the spatial boundaries of the NOAA Fisheries Bottom-trawl surveys. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tRegion FC: {region_fc}") - #arcpy.AddMessage(f"\tRegion FCS: {region_fcs}") - #arcpy.AddMessage(f"\tRegion FCST: {region_fcst}") - - del region_fc, region_fcs, region_fcst - del tags - else: - pass - - if "Datasets" == dataset_code: - - #arcpy.AddMessage(f"\tProcessing: {dataset_code}") - - datasets_tb = dataset_code - datasets_tbs = f"{dataset_code}_{date_code(project)}" - datasets_tbst = f"{dataset_code} {date_code(project)}" - - __datasets_dict[datasets_tb] = {"Dataset Service" : datasets_tbs, - "Dataset Service Title" : datasets_tbst, - "Tags" : "DisMAP, Datasets", - "Summary" : summary, - "Description" : "This table functions as a look-up table of vales", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"{__datasets_dict[datasets_tb]}") - del datasets_tb, datasets_tbs, datasets_tbst - else: - pass - - if "DisMAP_Regions" == dataset_code: - - #arcpy.AddMessage(f"\tProcessing: {dataset_code}") - - regions_fc = dataset_code - regions_fcs = f"{dataset_code}_{date_code(project)}" - regions_fcst = f"DisMAP Regions {date_code(project)}" - - __datasets_dict[regions_fc] = {"Dataset Service" : regions_fcs, - "Dataset Service Title" : regions_fcst, - "Tags" : "DisMAP Regions", - "Summary" : summary, - "Description" : "These files contain the spatial boundaries of the NOAA Fisheries Bottom-trawl surveys. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Eastern Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - del regions_fc, regions_fcs, regions_fcst - - else: - pass - if "Indicators" == dataset_code: - - #arcpy.AddMessage(f"\tProcessing: {dataset_code}") - - indicators_tb = f"{dataset_code}" - indicators_tbs = f"{dataset_code}_{date_code(project)}" - indicators_tbst = f"{dataset_code} {date_code(project)}" - - __datasets_dict[indicators_tb] = {"Dataset Service" : indicators_tbs, - "Dataset Service Title" : indicators_tbst, - "Tags" : "DisMAP, Indicators", - "Summary" : f"{summary}. This table provides the key metrics used to evaluate a species distribution shift. Information on species distributions is of paramount importance for understanding and preparing for climate-change impacts, and plays a key role in climate-ready fisheries management.", - "Description" : f"These data contain the key distribution metrics of center of gravity, range limits, and depth for each species in the portal. This data set covers 8 regions of the United States: Northeast, Southeast, Gulf of Mexico, West Coast, Bering Sea, Aleutian Islands, Gulf of Alaska, and Hawai'i Islands.", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - del indicators_tb, indicators_tbs, indicators_tbst - else: - pass - - if "Species_Filter" == dataset_code: - - #arcpy.AddMessage(f"\tProcessing: {dataset_code}") - - species_filter_tb = dataset_code - species_filter_tbs = f"{dataset_code}_{date_code(project)}" - species_filter_tbst = f"Species Filter Table {date_code(project)}" - - __datasets_dict[species_filter_tb] = {"Dataset Service" : species_filter_tbs, - "Dataset Service Title" : species_filter_tbst, - "Tags" : "DisMAP, Species Filter Table", - "Summary" : summary, - "Description" : "This table functions as a look-up table of values", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName T: {species_filter_tb}") - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName TS: {species_filter_tbs}") - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName TST: {species_filter_tbst}") - - del species_filter_tb, species_filter_tbs, species_filter_tbst - - else: - pass - if "DisMAP_Survey_Info" == dataset_code: - - #arcpy.AddMessage(f"\tProcessing: {dataset_code}") - - tb = dataset_code - tbs = f"{dataset_code}_{date_code(project)}" - tbst = f"DisMAP Survey Info Table {date_code(project)}" - - __datasets_dict[tb] = {"Dataset Service" : tbs, - "Dataset Service Title" : tbst, - "Tags" : "DisMAP; DisMAP Survey Info Table", - "Summary" : summary, - "Description" : "This table functions as a look-up table of values", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName T: {tb}") - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName TS: {tbs}") - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName TST: {tbst}") - - del tb, tbs, tbst - - else: - pass - if "SpeciesPersistenceIndicatorPercentileBin" == dataset_code: - - #arcpy.AddMessage(f"\tProcessing: {dataset_code} DisMAP_Survey_Info") - - tb = dataset_code - tbs = f"{dataset_code}_{date_code(project)}" - tbst = f"Species Persistence Indicator Percentile Bin Table {date_code(project)}" - - __datasets_dict[tb] = {"Dataset Service" : tbs, - "Dataset Service Title" : tbst, - "Tags" : "DisMAP; Species Persistence Indicator Percentile Bin Table", - "Summary" : summary, - "Description" : "This table functions as a look-up table of values", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName T: {tb}") - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName TS: {tbs}") - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName TST: {tbst}") - - del tb, tbs, tbst - - else: - pass - if "SpeciesPersistenceIndicatorTrend" == dataset_code: - - #arcpy.AddMessage(f"\tProcessing: {dataset_code}") - - tb = dataset_code - tbs = f"{dataset_code}_{date_code(project)}" - tbst = f"Species Persistence Indicator Trend Table {date_code(project)}" - - __datasets_dict[tb] = {"Dataset Service" : tbs, - "Dataset Service Title" : tbst, - "Tags" : "DisMAP; Species Persistence Indicator Trend Table", - "Summary" : summary, - "Description" : "This table functions as a look-up table of values", - "Credits" : _credits, - "Access Constraints" : access_constraints} - - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName T: {tb}") - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName TS: {tbs}") - #arcpy.AddMessage(f"\tLayerSpeciesYearImageName TST: {tbst}") - - del tb, tbs, tbst - - else: - pass - #arcpy.AddMessage(f"\tProcessing: {dataset_code}") - #table = dataset_code - #table_s = f"{dataset_code}_{date_code(project)}" - #table_st = f"{table_s.replace('_',' ')} {date_code(project)}" - #arcpy.AddMessage(f"\tProcessing: {table_s}") - #__datasets_dict[table] = {"Dataset Service" : table_s, - # "Dataset Service Title" : table_st, - # "Tags" : f"DisMAP, {table}", - # "Summary" : summary, - # "Description" : "Unknown table", - # "Credits" : _credits, - # "Access Constraints" : access_constraints} - #arcpy.AddMessage(f"\tTable: {table}") - #arcpy.AddMessage(f"\tTable TS: {table_s}") - #arcpy.AddMessage(f"\tTable TST: {table_st}") - #del table, table_s, table_st - #arcpy.AddWarning(f"{dataset_code} is missing") - - del summary - del point_feature_type, distribution_project_code, region, season - del dataset_code - - del _credits, access_constraints - - del dataset_codes - del project_folder, crf_folder - del project, project_gdb - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit: - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - if "tags" in locals().keys(): del tags - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return __datasets_dict - finally: - if "__datasets_dict" in locals().keys(): del __datasets_dict - -def date_code(version): - try: - from datetime import datetime - from time import strftime - - _date_code = "" - - if version.isdigit(): - # The version value is 'YYYYMMDD' format (20230501) - # and is converted to 'Month Day and Year' (i.e. May 1 2023) - _date_code = datetime.strptime(version, "%Y%m%d").strftime("%B %#d %Y") - elif not version.isdigit(): - # The version value is 'Month Day and Year' (i.e. May 1 2023) - # and is converted to 'YYYYMMDD' format (20230501) - _date_code = datetime.strptime(version, "%B %d %Y").strftime("%Y%m%d") - else: - _date_code = "error" - # Imports - del datetime, strftime - del version - - import copy - __results = copy.deepcopy(_date_code) - del _date_code, copy - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return __results - finally: - if "__results" in locals().keys(): del __results - -def dTypesCSV(csv_data_folder="", table=""): - try: -## if "IDW" in table: -## table = "IDW_Data" -## elif "GLMME" in table: -## table = "GLMME_Data" -## elif "GFDL" in table: -## table = "GFDL_Data" -## elif "Indicators" in table: -## table = "Indicators" -## -## ## elif "DisMAP_Regions" in table: -## ## table = "DisMAP_Regions" -## ## -## ## elif "Datasets" in table: -## ## table = "Datasets" -## ## -## ## elif "Datasets" in table: -## ## table = "Datasets" -## ## -## ## elif "Datasets" in table: -## ## table = "Datasets" -## -## else: -## table = table - - _table_definitions = table_definitions(csv_data_folder, "") - for key in _table_definitions: - #arcpy.AddMessage(key, _table_definitions[key]) - del key - - fields = _table_definitions[table.replace(".csv", "")] - - field_csv_dtypes = {k.replace(" ", "_") : "str" for k in _table_definitions[table.replace(".csv", "")]} - - del fields, _table_definitions - del csv_data_folder, table - - # Import - import copy - __results = copy.deepcopy(field_csv_dtypes) - del field_csv_dtypes, copy - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return __results - finally: - if "__results" in locals().keys(): del __results - -def dTypesGDB(csv_data_folder="", table=""): - try: -## if "IDW" in table: -## table = "IDW_Data" -## elif "GLMME" in table: -## table = "GLMME_Data" -## elif "GFDL" in table: -## table = "GFDL_Data" -## else: -## pass - - _field_definitions = field_definitions(csv_data_folder, "") - _table_definitions = table_definitions(csv_data_folder, "") - - fields = _table_definitions[table.replace(".csv", "")] - - field_gdb_dtypes = [] - for field in fields: - field_definition = _field_definitions[field] - # arcpy.AddMessage(field_definition["field_type"]) - # fd = field_definition[:-2] - # del fd[2], field_definition - if field_definition["field_type"] == "TEXT" or field_definition["field_type"] == "String": - field_dtype = f"U{field_definition['field_length']}" - elif field_definition["field_type"] == "SHORT" or field_definition["field_type"] == "Integer": - # np.dtype('u4') == dtype('uint32') - #field_dtype = f"U4" - field_dtype = f"u4" - elif field_definition["field_type"] == "DOUBLE" or field_definition["field_type"] == "Double": - # np.dtype('d') == dtype('float64'), np.dtype('f') == dtype('float32'), np.dtype('f8') == dtype('float64') - field_dtype = f"d" - elif field_definition["field_type"] == "DATE" or field_definition["field_type"] == "Date": - field_dtype = f"M8[us]" - else: - field_dtype = "" - field_gdb_dtypes.append((f"{field}", f"{field_dtype}")) - del field_definition, field, field_dtype - del fields - - del _field_definitions, _table_definitions - - del table, csv_data_folder - - import copy - __results = copy.deepcopy(field_gdb_dtypes) - del field_gdb_dtypes, copy - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return __results - finally: - if "__results" in locals().keys(): del __results - -def export_metadata(csv_data_folder="", in_table=""): - # Deprecated - try: - table = os.path.basename(in_table) - ws = os.path.dirname(in_table) - project_folder = os.path.dirname(ws) - # csv_data_folder = os.path.join(project_folder, "CSV_Data") - project = os.path.basename(project_folder) - version = project[7:] - del in_table, project_folder, project, version, csv_data_folder - - ws_type = arcpy.Describe(ws).workspaceType - - if ws_type == "LocalDatabase": - os.chdir(os.path.dirname(ws)) - elif ws_type == "FileSystem": - os.chdir(ws) - elif ws_type == "RemoteDatabase": - pass - else: - pass - del ws_type - - cwd = os.getcwd() - - # ArcPy Environments - # Set the overwriteOutput to True - arcpy.env.overwriteOutput = True - # Use all of the cores on the machine. - arcpy.env.parallelProcessingFactor = "100%" - # Set the scratch workspace - arcpy.env.scratchWorkspace = rf"Scratch\scratch.gdb" - # Set the workspace to the workspace - arcpy.env.workspace = ws - - # Set Log Metadata to False in order to not record all geoprocessing - # steps in metadata - arcpy.SetLogMetadata(True) - - arcpy.AddMessage(f"Dataset: {table}") - - # Process: Export Metadata - arcpy.AddMessage(f"\tExporting Metadata Object for Dataset: {table}") - - # https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm - from arcpy import metadata as md - - dataset_md = md.Metadata(table) - dataset_md.synchronize("ALWAYS") - dataset_md.save() - dataset_md.reload() - - arcpy.AddMessage(f"\t\tStep 1: Saving the metadata file for: {table} as an EXACT_COPY") - out_xml = os.path.join(cwd, "Export Metadata", f"{table} Step 1 EXACT_COPY.xml") - dataset_md.saveAsXML(out_xml, "EXACT_COPY") - pretty_format_xml_file(out_xml) - del out_xml - - arcpy.AddMessage(f"\t\tStep 2: Saving the metadata file for: {table} as a TEMPLATE") - out_xml = os.path.join(cwd, "Export Metadata", f"{table} Step 2 TEMPLATE.xml") - dataset_md.saveAsXML(out_xml, "TEMPLATE") - pretty_format_xml_file(out_xml) - del out_xml - - del dataset_md, md - - # Declared variable - del ws, table, cwd - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return __results - finally: - if "__results" in locals().keys(): del __results - -def field_definitions(csv_data_folder="", field=""): - try: - import json, copy - - # Read a File - with open(os.path.join(csv_data_folder, "field_definitions.json"), "r") as json_file: - try: - _field_definitions = json.load(json_file) - except: # noqa: E722 - arcpy.AddError(f"CSV Data: {csv_data_folder}") - arcpy.AddError(f"Field Defs: {json_file.name}") - sys.exit(0) - del json_file - - if not field: # if "" - # Returns a dictionaty of field definitions - __results = copy.deepcopy(_field_definitions) - elif field: # If a field was passed, then return - if field in _field_definitions: - __results = copy.deepcopy(_field_definitions[field]) - else: - __results = False - else: - pass - del _field_definitions - # Imports copy - del json, copy - # Function parameters - del csv_data_folder, field - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return __results - finally: - if "__results" in locals().keys(): del __results - -def get_encoding_index_col(csv_file): - import chardet - import pandas as pd - from pathlib import Path - # Open the file in binary mode - with open(csv_file, 'rb') as f: - # Read the file's content - data = f.read() - # Detect the encoding using chardet.detect() - encoding_result = chardet.detect(data) - # Retrieve the encoding information - encoding = encoding_result['encoding'] - del f, data, encoding_result - # Print the detected encoding - #arcpy.AddMessage("Detected Encoding:", encoding) - - path = Path(csv_file) - path.write_text(path.read_text(encoding=encoding), encoding="utf8") - del path - - dtypes = {} - # Read the CSV file into a DataFrame - df = pd.read_csv(csv_file, encoding = encoding, delimiter = ",",) - # Analyze the data types and lengths - for column in df.columns: dtypes[column] = df[column].dtype; del column - first_column = list(dtypes.keys())[0] - index_column = 0 if first_column == "Unnamed: 0" else None - # Declared Variables - del df, dtypes, first_column - - # Import - del chardet, pd, Path - - return encoding, index_column - -def get_transformation(gsr_wkt="", psr_wkt=""): - gsr = arcpy.SpatialReference() - gsr.loadFromString(gsr_wkt) - # arcpy.AddMessage(f"\tGSR: {gsr.name}") - - psr = arcpy.SpatialReference() - psr.loadFromString(psr_wkt) - # arcpy.AddMessage(f"\tPSR: {psr.name}") - - transformslist = arcpy.ListTransformations(gsr, psr) - transform = transformslist[0] if transformslist else "" - # arcpy.AddMessage(f"\t\tTransformation: {transform}\n") - # for transform in transformslist: - # arcpy.AddMessage(f"\t{transform}") - - del gsr_wkt, psr_wkt - - return transform - -def import_metadata(csv_data_folder="", dataset=""): - try: - if len(csv_data_folder) == 0 or len(dataset) == 0: - arcpy.AddError(f"{os.path.basename(csv_data_folder)} or {os.path.basename(dataset)} is empty") - raise SystemExit - else: - pass - # Import - from arcpy import metadata as md - - #arcpy.AddMessage(f"{csv_data_folder}") - #arcpy.AddMessage(f"{dataset}") - - dataset_name = os.path.basename(dataset) - project_gdb = os.path.dirname(dataset) - - #arcpy.AddMessage(f"{dataset_name}") - #arcpy.AddMessage(f"{project_gdb}") - - #if dataset_name.endswith(".crf"): - # dataset_name = dataset_name.replace(".crf", "_CRF") - # #_project = os.path.basename(os.path.dirname(os.path.dirname(dataset))) - # #project_gdb = rf"{os.path.dirname(os.path.dirname(dataset))}\{_project}.gdb" - # #del _project - #else: - # pass - # #project_gdb = os.path.dirname(dataset) - - #arcpy.AddMessage(f"{'-' * 10}") - #arcpy.AddError(project_gdb) - #arcpy.AddError(csv_data_folder) - #arcpy.AddError(dataset) - #arcpy.AddMessage(f"{'-' * 10}") - #raise SystemExit - - # Test if passed workspace exists, if not raise Exception - if not arcpy.Exists(project_gdb): - arcpy.AddError(f"{os.path.basename(project_gdb)} is missing!!") - sys.exit() - raise SystemExit - - #arcpy.AddMessage(csv_data_folder) - - project_folder = os.path.dirname(csv_data_folder) - metadata_folder = rf"{project_folder}\Metadata_Export" - - # ArcPy Environments - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = rf"Scratch\scratch.gdb" - arcpy.SetLogMetadata(True) - - try: - arcpy.AddMessage(f"Create Metadata Dictionary") - metadata_dictionary = dataset_title_dict(project_gdb) - if metadata_dictionary: - pass - #for key in metadata_dictionary: - # arcpy.AddMessage(f"{key}, {metadata_dictionary[key]}") - # del key - elif not metadata_dictionary: - arcpy.AddWarning("Metadata Dictionary is empty") - else: - pass - except: # noqa: E722 - traceback.print_exc() - raise SystemExit - - arcpy.AddMessage(f"Metadata for: {dataset_name} dataset") - - # arcpy.AddMessage(f"\tDataset Service: {datasets_dict[dataset]['Dataset Service']}") - # arcpy.AddMessage(f"\tDataset Service Title: {datasets_dict[dataset]['Dataset Service Title']}") - - # Assign the Metadata object's content to a target item - dataset_md = md.Metadata(dataset) - #resource_citation_contacts = rf"{metadata_folder}\resource_citation_contacts.xml" - resource_citation_contacts = rf"{metadata_folder}\contacts.xml" - #arcpy.AddMessage(resource_citation_contacts) - dataset_md.importMetadata(resource_citation_contacts) - dataset_md.save() - dataset_md.synchronize("OVERWRITE") - dataset_md.save() - dataset_md.synchronize('ALWAYS') - dataset_md.save() - del resource_citation_contacts #, poc_template_md - # Create a new Metadata object and add some content to it - # https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm - dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] - dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] - dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] - dataset_md.description = metadata_dictionary[dataset_name]["Description"] - dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] - dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] - dataset_md.save() - dataset_md.synchronize('ALWAYS') - dataset_md.save() - dataset_md.reload() - out_xml = rf"{metadata_folder}\{dataset_md.title}.xml" - #dataset_md.saveAsXML(out_xml, "REMOVE_ALL_SENSITIVE_INFO") - #dataset_md.saveAsXML(out_xml, "REMOVE_MACHINE_NAMES") - dataset_md.saveAsXML(out_xml) - - parse_xml_file_format_and_save(csv_data_folder=csv_data_folder, xml_file=out_xml, sort=True) - del out_xml - - del dataset_md - - # Import - del md - # Declared variable - del metadata_dictionary - del dataset_name, project_gdb, metadata_folder, project_folder - - # Function parameters - del dataset, csv_data_folder - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit: - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def metadata_dictionary_json(csv_data_folder="", dataset_name=""): - try: - import json - - # Read a File - with open(rf"{csv_data_folder}\metadata_dictionary.json", "r") as json_file: - metadata_dictionary = json.load(json_file) - del json_file, json, csv_data_folder - - if not dataset_name: - __results = metadata_dictionary - elif dataset_name: - __results = metadata_dictionary[dataset_name] - else: - __results = None - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit: - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return __results - finally: - if "__results" in locals().keys(): del __results - -def pretty_format_xml_file(metadata=""): - try: - # xml.etree.ElementTree Imports - import xml.etree.ElementTree as ET - - #arcpy.AddMessage(f"###--->>> Converting metadata file: {os.path.basename(metadata)} to pretty format") - if os.path.isfile(metadata): - tree = ET.ElementTree(file=metadata) - root = tree.getroot() - tree = ET.ElementTree(root) - ET.indent(tree, space="\t", level=0) - xmlstr = ET.tostring(root, encoding='UTF-8').decode("UTF-8") - xmlstr = xmlstr.replace(' Sync="TRUE">\n', ' Sync="TRUE">') - xmlstr = xmlstr.replace(' Sync="FALSE">\n', ' Sync="FALSE">') - xmlstr = xmlstr.replace(' value="eng">\n', ' value="eng">') - xmlstr = xmlstr.replace(' value="US">\n', ' value="US">') - xmlstr = xmlstr.replace(' value="001">\n', ' value="001">') - xmlstr = xmlstr.replace(' value="002">\n', ' value="002">') - xmlstr = xmlstr.replace(' value="003">\n', ' value="003">') - xmlstr = xmlstr.replace(' value="004">\n', ' value="004">') - xmlstr = xmlstr.replace(' value="005">\n', ' value="005">') - xmlstr = xmlstr.replace(' value="006">\n', ' value="006">') - xmlstr = xmlstr.replace(' value="007">\n', ' value="007">') - xmlstr = xmlstr.replace(' value="008">\n', ' value="008">') - xmlstr = xmlstr.replace(' value="009">\n', ' value="009">') - xmlstr = xmlstr.replace(' value="010">\n', ' value="010">') - xmlstr = xmlstr.replace(' value="011">\n', ' value="011">') - xmlstr = xmlstr.replace(' value="012">\n', ' value="012">') - xmlstr = xmlstr.replace(' value="013">\n', ' value="013">') - xmlstr = xmlstr.replace(' value="014">\n', ' value="014">') - xmlstr = xmlstr.replace(' value="015">\n', ' value="015">') - xmlstr = xmlstr.replace(' code="0">\n', ' code="0">') - xmlstr = xmlstr.replace('\n', '',) - xmlstr = xmlstr.replace('\n', '') - - xmlstr = xmlstr.replace("", '') - xmlstr = xmlstr.replace("", '') - xmlstr = xmlstr.replace("", '') - - xmlstr = xmlstr.replace('Sync="FALSE"', 'Sync="TRUE"') - - try: - with open(metadata, "w") as f: - f.write(xmlstr) - del f - except: # noqa: E722 - arcpy.AddError(f"The metadata file: {os.path.basename(metadata)} can not be overwritten!!") - del xmlstr, tree, root - else: - arcpy.AddWarning(f"\t###--->>> {os.path.basename(metadata)} is missing!! <<<---###") - arcpy.AddWarning(f"\t###--->>> {metadata} <<<---###") - # Declared variable - del metadata, ET - - except KeyboardInterrupt: - raise SystemExit - except arcpy.ExecuteWarning: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def pretty_format_xml_files(metadata_folder=""): - try: - arcpy.env.overwriteOutput = True - arcpy.env.workspace = metadata_folder - - xml_files = [rf"{metadata_folder}\{xml}" for xml in arcpy.ListFiles("*.xml")] - for xml_file in xml_files: - arcpy.AddMessage(os.path.basename(xml_file)) - pretty_format_xml_file(xml_file) - del xml_file - - # Declared Variables declared in the function - del xml_files - - # Function paramters - del metadata_folder - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return __results - finally: - if "__results" in locals().keys(): del __results - -def table_definitions(csv_data_folder="", dataset_name=""): - try: - #arcpy.AddMessage(dataset_name) - #arcpy.AddMessage(csv_data_folder) - import json, copy - - # Read a File - with open(os.path.join(csv_data_folder, "table_definitions.json"), "r") as json_file: - _table_definitions = json.load(json_file) - del json_file - - if not dataset_name or dataset_name == "": - # Return a dictionary of all values - __results = copy.deepcopy(_table_definitions) - elif dataset_name: - arcpy.AddMessage(f"IN: {dataset_name}") -## if "_IDW" in dataset_name: -## dataset_name = "IDW_Data" -## elif "_GLMME" in dataset_name: -## dataset_name = "GLMME_Data" -## elif "_GFDL" in dataset_name: -## dataset_name = "GFDL_Data" -## else: -## dataset_name = dataset_name -## # arcpy.AddMessage(f"OUT: {dataset_name}") - __results = copy.deepcopy(_table_definitions[dataset_name]) - else: - arcpy.AddError("something wrong") - raise SystemExit - - # Declared Variables created in function - del _table_definitions - # Import - del json, copy - # Function parameters - del csv_data_folder, dataset_name - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return __results - finally: - if "__results" in locals().keys(): del __results - - -# # -# Function: unique_years -# Gets the unique years in a table -# @param string table: The name of the layer -# @return array: a sorted year array so we can go in order. -# # -def unique_values(table, field): - #arcpy.AddMessage(table) - with arcpy.da.SearchCursor(table, [field]) as cursor: - return sorted({row[0] for row in cursor}) # Uses list comprehension - -# # -# Function: unique_years -# Gets the unique years in a table -# @param string table: The name of the layer -# @return array: a sorted year array so we can go in order. -# # -def unique_years(table): - #arcpy.AddMessage(table) - arcpy.management.SelectLayerByAttribute( table, "CLEAR_SELECTION" ) - arcpy.management.SelectLayerByAttribute( table, "NEW_SELECTION", "Year IS NOT NULL") - with arcpy.da.SearchCursor(table, ["Year"]) as cursor: - return sorted({row[0] for row in cursor}) - -def test_bed_1(project_gdb=""): -## raise SystemExit(traceback.print_exc()) -## finally: -## if "results" in locals().keys(): del results - try: - - base_project_folder = os.path.dirname(os.path.dirname(__file__)) - - project_gdb = rf"{base_project_folder}\{project}\{project}.gdb" - - del base_project_folder - - # Test if passed workspace exists, if not raise SystemExit - if not arcpy.Exists(fr"{project_gdb}"): - raise SystemExit(f"{os.path.basename(project_gdb)} is missing!!") - else: - pass - - ## # Write to File - ## with open('fieldDefinitions.json', 'w') as json_file: - ## json.dump(fieldDefinitions(), json_file, indent=4) - ## del json_file - ## - ## # Write to File - ## with open('tableDefinitions.json', 'w') as json_file: - ## json.dump(tableDefinitions(), json_file, indent=4) - ## del json_file - - ## # Read a File - ## with open('fieldDefinitions.json', 'r') as json_file: - ## field_definitions = json.load(json_file) - ## for field_definition in field_definitions: - ## arcpy.AddMessage(f'Field: {field_definition}') - ## for key in field_definitions[field_definition]: - ## arcpy.AddMessage(f"\t{key:<17} : {field_definitions[field_definition][key]}") - ## del field_definition - ## #del _field_definitions - ## del json_file - - ## # Read a File - ## with open('tableDefinitions.json', 'r') as json_file: - ## table_definitions = json.load(json_file) - ## for table_definition in table_definitions: - ## arcpy.AddMessage(f"Table: {table_definition}") - ## table_fields = table_definitions[table_definition] - ## for table_field in table_fields: - ## #arcpy.AddMessage(f"\tField Name: {field}") - ## arcpy.AddMessage(f"\tField Name: {table_field:<17}") - ## for key in field_definitions[table_field]: - ## arcpy.AddMessage(f"\t\t{key:<17} : {field_definitions[table_field][key]}") - ## del key - ## del table_field - ## del table_fields - ## del table_definition - ## del _table_definitions - ## del json_file - ## del _field_definitions - ## - ## # Read a File - ## with open('fieldDefinitions.json', 'r') as json_file: - ## field_definitions = json.load(json_file) - ## del json_file - ## - ## # Read a File - ## with open('tableDefinitions.json', 'r') as json_file: - ## table_definitions = json.load(json_file) - ## del json_file - ## - ## # arcpy.AddMessage(field_definitions["Species"]["field_name"]) - ## arcpy.AddMessage(table_definitions["Datasets"]) - ## - ## del _field_definitions - ## del _table_definitions - - ## project_name = os.path.basename(os.path.dirname(csv_data_folder)) - ## arcpy.AddMessage(project_name) - ## arcpy.AddMessage(date_code(date_code(project_name))) - ## del project_name - - # # # ###--->>> - - ## tables = ["Datasets", "DisMAP_Regions", "AI_IDW"] - ## for table in tables: - ## field_csv_dtypes = dTypesCSV(csv_data_folder, table) - ## - ## arcpy.AddMessage(table) - ## for field_csv_dtype in field_csv_dtypes: - ## arcpy.AddMessage(f"\t{field_csv_dtype}"); del field_csv_dtype - ## del field_csv_dtypes - ## - ## field_gdb_dtypes = dTypesGDB(csv_data_folder, table) - ## for field_gdb_dtype in field_gdb_dtypes: - ## arcpy.AddMessage(f"\t{field_gdb_dtype}"); del field_gdb_dtype - ## del field_gdb_dtypes - ## - ## del table - ## del tables - - ## _field_definitions = fieldDefinitions(csv_data_folder, "") - ## for field in field_definitions: - ## arcpy.AddMessage(field) - ## arcpy.AddMessage(f"\t{field_definitions[field]}") - ## del field - ## del _field_definitions - -## # First Test -## _table_definitions = table_definitions(csv_data_folder, "") -## #arcpy.AddMessage(table_definitions) -## for table in table_definitions: -## arcpy.AddMessage(table) -## arcpy.AddMessage(f"\t{table_definitions[table]}"); -## del table -## del _table_definitions - - ## # Second Test - ## table_definition = tableDefinitions(csv_data_folder, "") - ## arcpy.AddMessage(table_definition); del table_definition - ## - ## #table = "DataSets" - ## #arcpy.AddMessage(table_definitions[table]) - ## #arcpy.AddMessage(f"\t"); del table - - ## # Third Test - ## tables = ["Datasets", "DisMAP_Regions", "AI_IDW",] - ## for table in tables: - ## table_definition = tableDefinitions(csv_data_folder, table) - ## arcpy.AddMessage(f"Table: {table}:\n\t{', '.join(table_definition)}"); del table_definition - ## del table - ## del tables - - ## field = "DMSLat" - ## _field_definitions = fieldDefinitions(csv_data_folder, field) - ## if field_definitions: - ## for field in field_definitions: - ## arcpy.AddMessage(field) - ## #arcpy.AddMessage(f"\t{field_definitions[field]}") - ## del field - ## else: - ## arcpy.AddMessage(f"Field: {field} is not in fieldDefinitions") - ## del _field_definitions, field - - ## import dev_dismap_tools - ## - ## csv_file=r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\April 1 2023\CSV_Data\Datasets.csv" - ## #csv_file=r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\April 1 2023\CSV_Data\Species_Filter.csv" - ## - ## table = os.path.basename(csv_file).replace(".csv", "") - ## csv_data_folder = os.path.dirname(csv_file) - ## project_folder = os.path.dirname(csv_data_folder) - ## project = os.path.basename(project_folder) - ## #version = project[7:] - ## - ## arcpy.AddMessage(f"\tProject GDB: DisMAP {project}.gdb") - ## gdb = os.path.join(project_folder, f"{project}.gdb") - ## - ## arcpy.env.overwriteOutput = True - ## arcpy.env.parallelProcessingFactor = "100%" - ## arcpy.env.scratchWorkspace = rf"Scratch\scratch.gdb" - ## arcpy.env.workspace = gdb - ## arcpy.SetLogMetadata(True) - ## - ## field_csv_dtypes = dTypesCSV(csv_data_folder, table) - ## field_gdb_dtypes = dTypesGDB(csv_data_folder, table) - ## - ## arcpy.AddMessage(f"\tCreating Table: {table}") - ## arcpy.management.CreateTable(gdb, f"{table}", "", "", table.replace("_", " ")) - ## - ## in_table = os.path.join(gdb, table) - ## - ## #add_fields(in_table) - ## #alterFields(in_table) - ## basic_metadata(in_table) - ## export_metadata(in_table) - ## - ## del csv_file, table, project_folder, project, gdb - ## del field_csv_dtypes, field_gdb_dtypes - ## del dev_dismap_tools, in_table - -## # ###--->>> -## dataset = r'{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\CRFs\NBS_IDW.crf' -## import_metadata(csv_data_folder, dataset) -## # ###--->>> - -## # ###--->>> -## # Update Dataset Metadata Dictionary -## datasets_dict = dataset_title_dict(project_gdb) -## -## # Write to File -## with open(rf"{csv_data_folder}\metadata_dictionary.json", "w") as json_file: -## json.dump(datasets_dict, json_file, indent=4) -## del json_file -## -## # Read a File -## with open(rf"{csv_data_folder}\metadata_dictionary.json", "r") as json_file: -## datasets_dict = json.load(json_file) -## del json_file -## -## for dataset in sorted(datasets_dict): -## arcpy.AddMessage(f"Table: {dataset}") -## arcpy.AddMessage(f"\tDataset Service: {datasets_dict[dataset]['Dataset Service']}") -## arcpy.AddMessage(f"\tDataset Service Title: {datasets_dict[dataset]['Dataset Service Title']}") -## arcpy.AddMessage(F"\tTags: {datasets_dict[dataset]['Tags']}") -## arcpy.AddMessage(F"\tSummary: {datasets_dict[dataset]['Summary']}") -## arcpy.AddMessage(F"\tDescription: {datasets_dict[dataset]['Description']}") -## #arcpy.AddMessage(F"\tCredits: {datasets_dict[dataset]['Credits']}") -## #arcpy.AddMessage(F"\tAccess Constraints: {datasets_dict[dataset]['Access Constraints']}") -## arcpy.AddMessage(f"{'-'*80}") -## -## # dataset_md.synchronize("NOT_CREATED", 0) -## # dataset_md.title = metadata_dictionary[table]["md_title"] -## # dataset_md.tags = metadata_dictionary[table]["md_tags"] -## # dataset_md.summary = metadata_dictionary[table]["md_summary"] -## # dataset_md.description = metadata_dictionary[table]["md_description"] -## # dataset_md.credits = metadata_dictionary[table]["md_credits"] -## # dataset_md.accessConstraints = metadata_dictionary[table]["md_access_constraints"] -## -## del dataset -## del datasets_dict -## -## # ###--->>> - -## # ###--->>> -## dataset = r'{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\May 1 2024.gdb\Datasets' -## import_metadata(csv_data_folder, dataset) -## del dataset - -## # ###--->>> - -## # ###--->>> -## from arcpy import metadata as md -## -## arcpy.env.overwriteOutput = True -## arcpy.env.workspace = rf"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\DisMAP.gdb" -## -## arcpy.management.CreateFeatureclass(arcpy.env.workspace, "temp_fc", "POLYGON") -## dataset = rf"{arcpy.env.workspace}\temp_fc" -## dataset_xml = r'{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\temp_fc.xml' -## new_md_xml = r'{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\new_md.xml' -## -## dataset_md = md.Metadata(dataset) -## dataset_md.saveAsXML(dataset_xml.replace(".xml", " no sync.xml")) -## pretty_format_xml_file(dataset_xml.replace(".xml", " no sync.xml")) -## -## new_md.saveAsXML(new_md_xml) -## pretty_format_xml_file(new_md_xml) -## #if not dataset_md.isReadOnly: -## dataset_md.copy(new_md) -## dataset_md.synchronize("ACCESSED") -## dataset_md.save() -## dataset_md.reload() -## del new_md, new_md_xml -## -## dataset_md.saveAsXML(dataset_xml.replace(".xml", " new data.xml")) -## pretty_format_xml_file(dataset_xml.replace(".xml", " new data.xml")) -## -## del dataset_md -## del dataset, dataset_xml -## del md - -## # Path to new metadata XML file -## new_dataset_path = r'{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\new_dataset.xml' -## poc_template_path = r'{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\poc_template.xml' -## -## # Create a new Metadata object, add some content to it, and then save -## new_md = md.Metadata() -## new_md.title = 'My Title' -## new_md.tags = 'Tag1, Tag2' -## new_md.summary = 'My Summary' -## new_md.description = 'My Description' -## new_md.credits = 'My Credits' -## new_md.accessConstraints = 'My Access Constraints' -## #new_md.saveAsXML(new_dataset_path, "TEMPLATE") -## #dataset_md.saveAsXML(new_dataset_path) -## #del dataset_md -## -## # Create the dataset metadata object -## dataset_md = md.Metadata(dataset) -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## dataset_md.reload() -## dataset_md.saveAsXML(dataset_xml) -## if not dataset_md.isReadOnly: -## dataset_md.copy(new_md) -## dataset_md.synchronize("NOT_CREATED") -## dataset_md.save() -## dataset_md.reload() -## dataset_md.synchronize("NOT_CREATED") -## dataset_md.copy(new_md) -## dataset_md.save() -## dataset_md.reload() -## # Create the POC metadata object -## #poc_template_md = md.Metadata(poc_template_path) -## -## #Copy the POC metadata to the dataset metadata object -## # Copy Start -## #dataset_md.synchronize("ACCESSED", 0) # With copy and ACCESSED the POC overwites all metadata content -## #dataset_md.synchronize("ALWAYS") # With copy and ALWAYS the POC overwites all metadata content -## #dataset_md.synchronize("CREATED") # With copy and CREATED the POC overwites all metadata content -## #dataset_md.synchronize("NOT_CREATED") # With copy and NOT_CREATED the POC overwites all metadata content -## #dataset_md.synchronize("OVERWRITE") # With copy and OVERWRITE the POC overwites all metadata content -## #dataset_md.synchronize("SELECTIVE") # With copy and SELECTIVE the POC overwites all metadata content -## # Copy End -## # Import Start -## #dataset_md.synchronize("ACCESSED", 0) # With import and ACCESSED the POC is mergeed, but with only the XML flag -## #dataset_md.synchronize("ALWAYS") # With import and ALWAYS the POC is mergeed, but with only the XML flag -## #dataset_md.synchronize("CREATED") # With import and CREATED the POC is mergeed, but with only the XML flag -## #dataset_md.synchronize("NOT_CREATED") # With import and NOT_CREATED POC is mergeed, but with only the XML flag -## #dataset_md.synchronize("OVERWRITE") # With import and OVERWRITE the POC is mergeed, but with only the XML flag -## #dataset_md.synchronize("SELECTIVE") # With import and SELECTIVE the POC is mergeed, but with only the XML flag -## # Import End -## #if not dataset_md.isReadOnly: -## # dataset_md.copy(poc_template_md) -## #dataset_md.importMetadata(poc_template_md) -## # Copy Start -## #dataset_md.synchronize("ACCESSED", 0) # With copy and ACCESSED the POC overwites all metadata content -## #dataset_md.synchronize("ALWAYS") # With copy and ALWAYS the POC overwites all metadata content -## #dataset_md.synchronize("CREATED") # With copy and CREATED the POC overwites all metadata content -## #dataset_md.synchronize("NOT_CREATED") # With copy and NOT_CREATED the POC overwites all metadata content -## #dataset_md.synchronize("OVERWRITE") # With copy and OVERWRITE the POC overwites all metadata content -## #dataset_md.synchronize("SELECTIVE") # With copy and SELECTIVE the POC overwites all metadata content -## # Copy End -## # Import Start -## #dataset_md.synchronize("ACCESSED", 0) # With import and ACCESSED the POC is mergeed, but with only the XML flag -## #dataset_md.synchronize("ALWAYS") # With import and ALWAYS the POC is mergeed, but with only the XML flag -## #dataset_md.synchronize("CREATED") # With import and CREATED the POC is mergeed, but with only the XML flag -## #dataset_md.synchronize("NOT_CREATED") # With import and NOT_CREATED POC is mergeed, but with only the XML flag -## #dataset_md.synchronize("OVERWRITE") # With import and OVERWRITE the POC is mergeed, but with only the XML flag -## #dataset_md.synchronize("SELECTIVE") # With import and SELECTIVE the POC is mergeed, but with only the XML flag -## # Import End -## #dataset_md.save() -## #dataset_md.reload() -## #out_xml = new_dataset_path.replace(".xml", " copy do nothing .xml") -## dataset_md.saveAsXML(new_dataset_path) -## #dataset_md.saveAsXML(new_dataset_path.replace(".xml", " import SELECTIVE after.xml")) -## del dataset_md, poc_template_path -## #del poc_template_md -## -## pretty_format_xml_file(new_dataset_path) -## pretty_format_xml_file(dataset_xml) -## #del out_xml -## -## del new_dataset_path, dataset_xml -## del md -## del dataset, new_md -## -## # ###--->>> - -## # ###--->>> COMPARE TWO XML DOCUMENTS -## # This requires use of the clone ArcGIS Pro arcpy.env. -## # https://buildmedia.readthedocs.org/media/pdf/xmldiff/latest/xmldiff.pdf -## table = "DisMAP_Regions" -## project_folder = os.path.dirname(project_gdb) -## export_metadata_folder = rf"{project_folder}\ArcGIS Metadata" -## -## in_xml = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\DisMAP_Regions.xml" -## out_xml = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\DisMAP Regions Current.xml" -## -## diff = compare_metadata_xml(in_xml, out_xml) -## if diff: -## diff_metadata = rf"{export_metadata_folder}\{table} EXACT_COPY DIFF of Import.xml" -## with open(diff_metadata, "w") as f: -## f.write(diff) -## del f -## del diff_metadata -## else: -## pass -## -## del diff -## -## del in_xml, out_xml -## del table, project_folder, export_metadata_folder -## # ###--->>> COMPARE TWO XML DOCUMENTS - - #pretty_format_xml_file(r"{os.environ['USERPROFILE']}\AppData\Local\ESRI\ArcGISPro\Staging\SharingProcesses\SharingMainLog - Copy.xml") - #pretty_format_xml_file(r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\July 1 2024\Export Metadata\EBS_IDW.crf.xml") - -## Doesn't really work -## # ###--->>> -## def xml_json_test(project_gdb, metadata_xml): -## -## from xml.dom import minidom -## import json -## -## project_folder = os.path.dirname(project_gdb) -## metadata_folder = rf"{project_folder}\ArcGIS Metadata" -## export_metadata_folder = rf"{project_folder}\Export Metadata" -## metadata_xml_path = rf"{metadata_folder}\{metadata_xml}" -## -## def parse_element(element): -## dict_data = dict() -## if element.nodeType == element.TEXT_NODE: -## dict_data['data'] = element.data -## if element.nodeType not in [element.TEXT_NODE, element.DOCUMENT_NODE, -## element.DOCUMENT_TYPE_NODE]: -## for item in element.attributes.items(): -## dict_data[item[0]] = item[1] -## if element.nodeType not in [element.TEXT_NODE, element.DOCUMENT_TYPE_NODE]: -## for child in element.childNodes: -## child_name, child_dict = parse_element(child) -## if child_name in dict_data: -## try: -## dict_data[child_name].append(child_dict) -## except AttributeError: -## dict_data[child_name] = [dict_data[child_name], child_dict] -## else: -## dict_data[child_name] = child_dict -## return element.nodeName, dict_data -## -## #dom = minidom.parse('data.xml') -## #f = open('data.json', 'w') -## dom = minidom.parse(metadata_xml_path) -## f = open(rf"{export_metadata_folder}\{metadata_xml.replace('.xml', '.json')}", "w") -## f.write(json.dumps(parse_element(dom), sort_keys=True, indent=4)) -## f.close() -## -## del minidom, json -## -## metadata_xml = "AI_Sample_Locations_20230401.xml" -## -## xml_json_test(project_gdb, metadata_xml) -## -## del metadata_xml, xml_json_test -## -## # ###--->>> - - -## # ###--->>> -## from arcpy import metadata as md -## -## arcpy.env.overwriteOutput = True -## arcpy.env.workspace = rf"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\DisMAP.gdb" -## -## arcpy.management.CreateFeatureclass(arcpy.env.workspace, "temp_fc", "POLYGON") -## dataset = rf"{arcpy.env.workspace}\temp_fc" -## dataset_xml = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\Export Metadata\temp_fc.xml" -## new_md_xml = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\Export Metadata\new_md.xml" -## -## poc_template = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\ArcGIS Metadata\poc_template.xml" -## -## # dataset_md = md.Metadata(dataset) -## # dataset_md.saveAsXML(dataset_xml.replace(".xml", " no sync.xml")) -## # pretty_format_xml_file(dataset_xml.replace(".xml", " no sync.xml")) -## # dataset_md.synchronize("ALWAYS") -## # dataset_md.save() -## # dataset_md.reload() -## # dataset_md.title = 'My Title' -## # dataset_md.tags = 'Tag1, Tag2' -## # dataset_md.summary = 'My Summary' -## # dataset_md.description = 'My Description' -## # dataset_md.credits = 'My Credits' -## # dataset_md.accessConstraints = 'My Access Constraints' -## # dataset_md.save() -## # dataset_md.reload() -## # dataset_md.saveAsXML(dataset_xml.replace(".xml", " ALWAYS sync.xml")) -## # pretty_format_xml_file(dataset_xml.replace(".xml", " ALWAYS sync.xml")) -## -## #del dataset_md -## #dataset_md = md.Metadata(dataset) -## -## # Create a new Metadata object, add some content to it, and then save -## new_md = md.Metadata() -## # new_md.title = 'My Title' -## # new_md.tags = 'Tag1, Tag2' -## # new_md.summary = 'My Summary' -## # new_md.description = 'My Description' -## # new_md.credits = 'My Credits' -## # new_md.accessConstraints = 'My Access Constraints' -## new_md.importMetadata(new_md_xml) -## new_md.importMetadata(poc_template) -## #new_md.save() -## #new_md.reload() -## new_md.saveAsXML(new_md_xml) -## pretty_format_xml_file(new_md_xml) -## -## del new_md -## -## # dataset_md.synchronize("ACCESSED") -## # dataset_md.importMetadata(new_md_xml) -## # dataset_md.synchronize("CREATED") -## # dataset_md.save() -## # dataset_md.reload() -## # -## # del dataset_md -## # dataset_md = md.Metadata(dataset) -## # -## # dataset_md.importMetadata(poc_template) -## # #dataset_md.save() -## # #dataset_md.reload() -## # #dataset_md.synchronize("ALWAYS") -## # #dataset_md.synchronize("SELECTIVE") -## # dataset_md.save() -## # dataset_md.reload() -## -## -## del new_md_xml -## del poc_template -## # -## # #dataset_md.saveAsXML(dataset_xml.replace(".xml", " new data.xml")) -## # dataset_md.saveAsXML(dataset_xml.replace(".xml", " new data.xml"), "REMOVE_MACHINE_NAMES") -## # pretty_format_xml_file(dataset_xml.replace(".xml", " new data.xml")) -## # -## # del dataset_md -## -## del dataset, dataset_xml -## del md -## # ###--->>> - -## # ###--->>> -## from arcpy import metadata as md -## -## metadata_folder = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\May 1 2024\Export Metadata" -## new_md_xml = rf"{metadata_folder}\new_md.xml" -## dataset_md_xml = rf"{metadata_folder}\dataset_md.xml" -## -## # Create a new Metadata object, add some content to it, and then save -## new_md = md.Metadata() -## new_md.title = 'My Title' -## new_md.tags = 'Tag1, Tag2' -## # new_md.summary = 'My Summary' -## # new_md.description = 'My Description' -## # new_md.credits = 'My Credits' -## # new_md.accessConstraints = 'My Access Constraints' -## new_md.saveAsXML(new_md_xml) -## pretty_format_xml_file(new_md_xml) -## new_md.saveAsXML(dataset_md_xml) -## pretty_format_xml_file(dataset_md_xml) -## del new_md -## -## dataset_md = md.Metadata(dataset_md_xml) -## dataset_md.importMetadata("""20240701000000001.0FALSE""") -## dataset_md.synchronize("NOT_CREATED") -## dataset_md.save() -## dataset_md.reload() -## dataset_md.saveAsXML(dataset_md_xml) -## pretty_format_xml_file(dataset_md_xml) -## del dataset_md -## -## # Declared Variables -## del dataset_md_xml -## del new_md_xml -## del metadata_folder -## -## # Imports -## del md -## -## # ###--->>> - -## # ###--->>> -## import datetime -## import pytz -## -## #unaware = datetime.datetime(2011, 8, 15, 8, 15, 12, 0) -## #aware = datetime.datetime(2011, 8, 15, 8, 15, 12, 0, pytz.UTC) -## -## unaware = datetime.datetime(2011, 1, 1, 0, 0, 0, 0) -## aware = datetime.datetime(2011, 1, 1, 0, 0, 0, 0, pytz.UTC) -## -## -## now_aware = pytz.utc.localize(unaware) -## assert aware == now_aware -## -## arcpy.AddMessage(now_aware) -## -## from datetime import datetime, timezone -## -## dt = datetime(2011, 1, 1, 0, 0, 0, 0) -## dt = dt.replace(tzinfo=timezone.utc) -## arcpy.AddMessage(dt.isoformat()) -## -## del datetime, timezone, dt -## -## -## import pandas as pd -## df = pd.DataFrame({"Year": [2014, 2015, 2016],}) -## #df.insert(df.columns.get_loc("Year")+1, "StdTime", pd.to_datetime(df["Year"], format="%Y").dt.tz_localize('Etc/GMT')) -## df.insert(df.columns.get_loc("Year")+1, "StdTime", pd.to_datetime(df["Year"], format="%Y", utc=True)) -## #df.insert(df.columns.get_loc("Year")+1, "StdTime", pd.to_datetime(df["Year"], format="%Y")) -## -## arcpy.AddMessage(df) -## -## del pd, df -## # ###--->>> - - # Function parameters - del project_gdb - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def test_bed_2(project=""): - try: - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - base_project_folder = os.path.dirname(os.path.dirname(__file__)) - project_gdb = rf"{base_project_folder}\{project}\{project}.gdb" - - del base_project_folder - - # Test if passed workspace exists, if not raise SystemExit - if not arcpy.Exists(project_gdb): - raise SystemExit(f"{os.path.basename(project_gdb)} is missing!!") - else: - pass - -## # ###--->>> -## from arcpy import metadata as md -## -## project_folder = os.path.dirname(project_gdb) -## -## metadata_folder = rf"{project_folder}\Export Metadata" -## new_md_xml = rf"{metadata_folder}\new_md.xml" -## dataset_md_xml = rf"{metadata_folder}\dataset_md.xml" -## -## # Create a new Metadata object, add some content to it, and then save -## new_md = md.Metadata() -## #new_md.title = 'My Title' -## new_md.tags = 'Tag1, Tag2' -## new_md.summary = 'My Summary' -## new_md.description = 'My Description' -## new_md.credits = 'My Credits' -## new_md.accessConstraints = 'My Access Constraints' -## # Save the original -## new_md.saveAsXML(new_md_xml) -## -## # Pretty Format -## pretty_format_xml_file(new_md_xml) -## -## # Save a copy to modify -## new_md.saveAsXML(dataset_md_xml) -## -## # Pretty Format -## pretty_format_xml_file(dataset_md_xml) -## del new_md -## -## dataset_md = md.Metadata(dataset_md_xml) -## #dataset_md.synchronize("ALWAYS") -## #dataset_md.importMetadata("""20240701000000001.0FALSE""") -## #dataset_md.importMetadata(md.Metadata("""My Title""")) -## -## #dataset_md.synchronize("SELECTIVE") -## #dataset_md.importMetadata(rf"{metadata_folder}\AI_IDW_Sample_Locations.xml") -## #dataset_md.synchronize("CREATED") -## -## #dataset_md.synchronize("CREATED") -## #dataset_md.save() -## #dataset_md.reload() -## dataset_md.importMetadata(rf"{metadata_folder}\poc_template.xml") -## dataset_md.save() -## dataset_md.synchronize("SELECTIVE") -## #arcpy.AddMessage(dataset_md.xml) -## #dataset_md.save() -## #dataset_md.reload() -## # Save the modified file -## #dataset_md.saveAsXML(dataset_md_xml) -## -## # Pretty Format -## pretty_format_xml_file(dataset_md_xml) -## -## del dataset_md -## -## # Declared Variables -## del dataset_md_xml -## del new_md_xml -## del metadata_folder, project_folder -## -## # Imports -## del md -## -## # ###--->>> - -## # ###--->>> -## -## project_folder = os.path.dirname(project_gdb) -## metadata_folder = rf"{project_folder}\Export Metadata" -## xml_file_1 = rf"{metadata_folder}\AI_IDW_Sample_Locations.xml" -## xml_file_2 = rf"{metadata_folder}\poc_template.xml" -## -## xml_combiner(project_gdb=project_gdb, xml_file_1=xml_file_1, xml_file_2=xml_file_2) -## -## del project_folder, metadata_folder -## del xml_file_1, xml_file_2 -## -## # ###--->>> - -## # ###--->>> -## -## from arcpy import metadata as md -## -## project_folder = os.path.dirname(project_gdb) -## metadata_folder = rf"{project_folder}\Export Metadata" -## -## # ArcPy Environments -## arcpy.env.overwriteOutput = True -## arcpy.env.parallelProcessingFactor = "100%" -## arcpy.env.workspace = project_gdb -## arcpy.env.scratchWorkspace = rf"Scratch\scratch.gdb" -## arcpy.SetLogMetadata(True) -## -## metadata_dictionary = dataset_title_dict(project_gdb) -## -## dataset = rf"{project_gdb}\DisMAP_Regions" -## table = os.path.basename(dataset) -## -## # #arcpy.conversion.FeaturesToJSON( -## # # in_features = dataset, -## # # out_json_file = rf"{metadata_folder}\{table}.json", -## # # format_json = "FORMATTED", -## # # include_z_values = "NO_Z_VALUES", -## # # include_m_values = "NO_M_VALUES", -## # # geoJSON = "NO_GEOJSON", -## # # outputToWGS84 = "KEEP_INPUT_SR", -## # # use_field_alias = "USE_FIELD_NAME" -## # # ) - - -## arcpy.AddMessage(f"JSON To Features") -## -## arcpy.conversion.JSONToFeatures( -## in_json_file = rf"{metadata_folder}\{table}.json", -## out_features = dataset, -## geometry_type = "POLYLINE" -## ) - -## arcpy.AddMessage(f"Dataset: {table}") -## -## dataset_md = md.Metadata(dataset) -## #dataset_md.xml = '20240701000000001.0FALSE' -## dataset_md.synchronize("ALWAYS") -## out_xml = rf"{metadata_folder}\{table}_Step_1.xml" -## dataset_md.saveAsXML(out_xml) -## -## pretty_format_xml_file(out_xml) -## del out_xml -## -## dataset_md.importMetadata(rf"{metadata_folder}\poc_john.xml") -## dataset_md.synchronize("SELECTIVE") -## dataset_md.save() -## dataset_md.reload() -## out_xml = rf"{metadata_folder}\{table}_Step_2.xml" -## dataset_md.saveAsXML(out_xml) -## -## pretty_format_xml_file(out_xml) -## del out_xml -## -## dataset_md.title = metadata_dictionary[table]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[table]["Tags"] -## dataset_md.summary = metadata_dictionary[table]["Summary"] -## dataset_md.description = metadata_dictionary[table]["Description"] -## dataset_md.credits = metadata_dictionary[table]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[table]["Access Constraints"] -## dataset_md.save() -## dataset_md.reload() -## out_xml = rf"{metadata_folder}\{table}_Step_3.xml" -## dataset_md.saveAsXML(out_xml) -## -## pretty_format_xml_file(out_xml) -## del out_xml -## -## del dataset_md - - -## # arcpy.AddMessage(f"\tDataset Service: {datasets_dict[dataset]['Dataset Service']}") -## # arcpy.AddMessage(f"\tDataset Service Title: {datasets_dict[dataset]['Dataset Service Title']}") -## -## # # https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm -## # dataset_md = md.Metadata(dataset) -## # dataset_md.xml = '' -## # dataset_md.save() -## # #dataset_md.synchronize("ALWAYS") -## # dataset_md.save() -## # del dataset_md -## # -## # dataset_md = md.Metadata(dataset) -## # dataset_md.importMetadata(rf"{metadata_folder}\poc_template.xml") -## # dataset_md.save() -## # del dataset_md -## # -## # dataset_md = md.Metadata(dataset) -## # dataset_md.synchronize("ALWAYS") -## # dataset_md.importMetadata(rf"{metadata_folder}\dismap_regions_entity.xml") -## # dataset_md.save() -## # del dataset_md -## -## dataset_md = md.Metadata(dataset) -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## dataset_md.reload() -## #dataset_md.synchronize("SELECTIVE") -## dataset_md.title = metadata_dictionary[table]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[table]["Tags"] -## dataset_md.summary = metadata_dictionary[table]["Summary"] -## dataset_md.description = metadata_dictionary[table]["Description"] -## dataset_md.credits = metadata_dictionary[table]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[table]["Access Constraints"] -## dataset_md.save() -## del dataset_md -## -## dataset_md = md.Metadata(dataset) -## -## #out_xml = rf"{metadata_folder}\{dataset_md.title}.xml" -## out_xml = rf"{metadata_folder}\{table}.xml" -## dataset_md.saveAsXML(out_xml, "REMOVE_ALL_SENSITIVE_INFO") -## #dataset_md.saveAsXML(out_xml, "REMOVE_MACHINE_NAMES") -## #dataset_md.saveAsXML(out_xml) -## -## pretty_format_xml_file(out_xml) -## del out_xml -## -## del dataset_md -## -## # arcpy.AddMessage(f"Dataset: {table}") -## # dataset_md_path = rf"{metadata_folder}\{table}.xml" -## # if arcpy.Exists(dataset_md_path): -## # arcpy.AddMessage(f"\tMetadata File: {os.path.basename(dataset_md_path)}") -## # from arcpy import metadata as md -## # try: -## # dataset_md = md.Metadata(dataset) -## # # Import the standard-format metadata content to the target item -## # if not dataset_md.isReadOnly: -## # dataset_md.importMetadata(dataset_md_path, "ARCGIS_METADATA") -## # dataset_md.save() -## # dataset_md.reload() -## # dataset_md.title = title -## # dataset_md.save() -## # dataset_md.reload() -## # -## # arcpy.AddMessage(f"\tExporting metadata file from {table}") -## # -## # out_xml = rf"{project_folder}\Export Metadata\{title} EXACT_COPY.xml" -## # dataset_md.saveAsXML(out_xml, "EXACT_COPY") -## # -## # pretty_format_xml_file(out_xml) -## # del out_xml -## # -## # del dataset_md, md -## # -## # except: # noqa: E722 -## # arcpy.AddError(f"\tDataset metadata import error!! {arcpy.GetMessages()}") -## # else: -## # arcpy.AddWarning(f"\tDataset missing metadata file!!") - -## del md -## del project_folder, metadata_folder, metadata_dictionary -## del dataset, table -## -## # ###--->>> - - -## # ###--->>> -## from arcpy import metadata as md -## -## base_project_folder = os.path.dirname(os.path.dirname(__file__)) -## project_gdb = rf"{base_project_folder}\{project}\{project}.gdb" -## workspace = rf"{base_project_folder}\DisMAP.gdb" -## -## arcpy.env.overwriteOutput = True -## arcpy.env.workspace = workspace -## -## arcpy.management.CreateFeatureclass(arcpy.env.workspace, "temp_fc", "POLYGON") -## -## dataset = rf"{workspace}\temp_fc" -## dataset_xml = rf"{base_project_folder}\{project}\Export Metadata\temp_fc.xml" -## -## dataset_md = md.Metadata(dataset) -## dataset_md.saveAsXML(dataset_xml.replace(".xml", " no sync.xml"), "REMOVE_ALL_SENSITIVE_INFO") -## pretty_format_xml_file(dataset_xml.replace(".xml", " no sync.xml")) -## -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## dataset_md.saveAsXML(dataset_xml.replace(".xml", " ALWAYS.xml"), "REMOVE_ALL_SENSITIVE_INFO") -## pretty_format_xml_file(dataset_xml.replace(".xml", " ALWAYS.xml")) -## -## dataset_md.title = 'My Title' -## dataset_md.tags = 'Tag1, Tag2' -## dataset_md.summary = 'My Summary' -## dataset_md.description = 'My Description' -## dataset_md.credits = 'My Credits' -## dataset_md.accessConstraints = 'My Access Constraints' -## dataset_md.save() -## dataset_md.saveAsXML(dataset_xml.replace(".xml", " Title added.xml"), "REMOVE_ALL_SENSITIVE_INFO") -## pretty_format_xml_file(dataset_xml.replace(".xml", " Title added.xml")) -## -## del dataset, dataset_xml -## del dataset_md -## del md -## del base_project_folder, workspace -## # ###--->>> - - # Function parameters - del project_gdb - del project - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - #arcpy.AddError(arcpy.GetMessages(2)) - #traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"{'-' * 80}\n") - - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - project_folder = os.path.dirname(project_gdb) - - # Test if passed workspace exists, if not raise SystemExit - if not arcpy.Exists(project_gdb): - arcpy.AddMessage(f"{os.path.basename(project_gdb)} is missing!!") - else: - pass - - # ###--->>> dataset_title_dict Test #1 - DatasetTitleDict = False - if DatasetTitleDict: - md_dict = dataset_title_dict(project_gdb) - for key in sorted(md_dict): - arcpy.AddMessage(key) - #if "_CRF" in key: - arcpy.AddMessage(f"\tDataset Service Title: {md_dict[key]['Dataset Service Title']}") - arcpy.AddMessage(f"\tDataset Service: {md_dict[key]['Dataset Service']}") - arcpy.AddMessage(f"\tTags: {md_dict[key]['Tags']}") - del key - del md_dict - else: - pass - del DatasetTitleDict - # ###--->>> - - # ###--->>> Test table_definitions - TestTableDefinitions = False - if TestTableDefinitions: - arcpy.AddMessage(os.path.basename(project_gdb)) - from dev_create_table_definitions_json import get_list_of_table_fields - get_list_of_table_fields(project_gdb) - del get_list_of_table_fields - csv_data_folder = rf"{project_folder}\CSV_Data" - # First Test - _table_definitions = table_definitions(csv_data_folder, "HI_IDW") - arcpy.AddMessage(_table_definitions) - # Second Test - _table_definitions = table_definitions(csv_data_folder, "") - #arcpy.AddMessage(_table_definitions) - for table in _table_definitions: - arcpy.AddMessage(f"Table: {table}") -## #arcpy.AddMessage(f"\t{_table_definitions[table]}"); -## for field in _table_definitions[table]: -## arcpy.AddMessage(f"\tfield: {field}") -## _field_definitions = field_definitions(csv_data_folder, field) -## #arcpy.AddMessage(_field_definitions) - ## for field in field_definitions: - ## arcpy.AddMessage(field) - ## #arcpy.AddMessage(f"\t{field_definitions[field]}") - ## del field - ## else: - ## arcpy.AddMessage(f"Field: {field} is not in field_definitions") -## del _field_definitions, field - - - del table - del _table_definitions - del csv_data_folder - else: - pass - del TestTableDefinitions - # ###--->>> - - TestImportMetadata = True - if TestImportMetadata: - csv_data_folder = rf"{project_folder}\CSV_Data" - #table_name = "Datasets" - #table_name = "Species_Filter" - #table_name = "DisMAP_Survey_Info" - #table_name = "HI_IDW_Mosaic" - #table_name = "HI_IDW_Fishnet_Bathymetry" - table_name = "Indicators" - - try: - - import_metadata(csv_data_folder, dataset=rf"{project_gdb}\{table_name}") - #import_metadata(csv_data_folder, dataset=rf"{project_folder}\Scratch\HI_IDW.gdb\{table_name}") - - except: # noqa: E722 - pass - - del table_name, csv_data_folder - else: - pass - del TestImportMetadata - - # Declared variables - del project_folder - # Function parameters - del project_gdb - - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}") - arcpy.AddMessage(u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time)))) - arcpy.AddMessage(f"{'-' * 80}") - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - traceback.print_exc() - sys.exit() - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == "__main__": - try: - - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - - arcpy.AddMessage(f"Running Python script: {os.path.basename(__file__)}") - - script_tool(project_gdb) - - arcpy.SetParameterAsText(1, "Result") - - del project_gdb - - except SystemExit: - pass - except: # noqa: E722 - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - else: - pass - finally: - sys.exit() diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/import_datasets_species_filter_csv_data.py b/ArcGIS-Analysis-Python/src/dismap_tools/import_datasets_species_filter_csv_data.py deleted file mode 100644 index f4ec365..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/import_datasets_species_filter_csv_data.py +++ /dev/null @@ -1,456 +0,0 @@ -""" -Script documentation -- Tool parameters are accessed using arcpy.GetParameter() or - arcpy.GetParameterAsText() -- Update derived parameter values using arcpy.SetParameter() or - arcpy.SetParameterAsText() -""" -import os -import sys # built-ins first -import traceback -import inspect -import arcpy - -def get_encoding_index_col(csv_file): - try: - # Imports - import chardet - import pandas as pd - # Open the file in binary mode - with open(csv_file, 'rb') as f: - # Read the file's content - data = f.read() - # Detect the encoding using chardet.detect() - encoding_result = chardet.detect(data) - # Retrieve the encoding information - __encoding = encoding_result['encoding'] - del f, data, encoding_result - # arcpy.AddMessage the detected encoding - #arcpy.AddMessage("Detected Encoding:", __encoding) - dtypes = {} - # Read the CSV file into a DataFrame - df = pd.read_csv(csv_file, encoding = __encoding, delimiter = ",",) - # Analyze the data types and lengths - for column in df.columns: dtypes[column] = df[column].dtype; del column - first_column = list(dtypes.keys())[0] - __index_column = 0 if first_column == "Unnamed: 0" else None - # Declared Variables - del df, dtypes, first_column - # Import - del chardet, pd - # Function Parameter - del csv_file - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - raise SystemExit - except Exception: - traceback.print_exc() - arcpy.AddError(arcpy.GetMessages(2)) - raise SystemExit - except: - traceback.print_exc() - arcpy.AddError(arcpy.GetMessages(2)) - raise SystemExit - else: - return __encoding, __index_column - finally: - if "__encoding" in locals().keys(): del __encoding - if "__index_column" in locals().keys(): del __index_column -def worker(project_gdb="", csv_file=""): - try: - # Test if passed workspace exists, if not raise SystemExit - if not arcpy.Exists(project_gdb) or not arcpy.Exists(csv_file): - raise SystemExit(f"{os.path.basename(project_gdb)} OR {os.path.basename(csv_file)} is missing!!") - # Imports - from arcpy import metadata as md - import dismap_tools - # Set History and Metadata logs, set serverity and message level - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(2) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - # Set basic workkpace variables - table_name = os.path.basename(csv_file).replace(".csv", "") - csv_data_folder = os.path.dirname(csv_file) - project_folder = os.path.dirname(csv_data_folder) - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - # Set basic workkpace variables - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = r"Scratch\scratch.gdb" - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - #arcpy.AddMessage(table_name) - #arcpy.AddMessage(csv_data_folder) - field_csv_dtypes = dismap_tools.dTypesCSV(csv_data_folder, table_name) - field_gdb_dtypes = dismap_tools.dTypesGDB(csv_data_folder, table_name) - #arcpy.AddMessage(field_csv_dtypes) - #arcpy.AddMessage(field_gdb_dtypes) - arcpy.AddMessage(f"\tCreating Table: {table_name}") - arcpy.management.CreateTable(project_gdb, f"{table_name}", "", "", table_name.replace("_", " ")) - arcpy.AddMessage("\t{0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - import pandas as pd - import numpy as np - import warnings - arcpy.AddMessage(f"> Importing {table_name} CSV Table") - #csv_table = f"{table_name}.csv" - # https://pandas.pydata.org/pandas-docs/stable/getting_started/intro_tutorials/09_timeseries.html?highlight=datetime - # https://www.tutorialsandyou.com/python/numpy-data-types-66.html - #df = pd.read_csv('my_file.tsv', sep='\t', header=0) ## not setting the index_col - #df.set_index(['0'], inplace=True) - # C:\. . .\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\numpy\lib\arraysetops.py:583: - # FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison - # mask |= (ar1 == a) - # A fix: https://www.youtube.com/watch?v=TTeElATMpoI - # TLDR: pandas are Jedi; numpy are the hutts; and python is the galatic empire - #encoding, index_column = dismap_tools.get_encoding_index_col(csv_file) - encoding, index_column = get_encoding_index_col(csv_file) - with warnings.catch_warnings(): - warnings.simplefilter(action='ignore', category=FutureWarning) - # DataFrame - df = pd.read_csv( - csv_file, - index_col = index_column, - encoding = encoding, - delimiter = ",", - dtype = field_csv_dtypes, - ) - del encoding, index_column - #arcpy.AddMessage(field_csv_dtypes) - #arcpy.AddMessage(field_gdb_dtypes) - del field_csv_dtypes - #arcpy.AddMessage(df) - # Replace NaN with an empty string. When pandas reads a cell - # with missing data, it asigns that cell with a Null or nan - # value. So, we are changing that value to an empty string of ''. - # https://community.esri.com/t5/python-blog/those-pesky-null-things/ba-p/902664 - # https://community.esri.com/t5/python-blog/numpy-snippets-6-much-ado-about-nothing-nan-stuff/ba-p/893702 - df.fillna('', inplace=True) - #df.fillna(np.nan) - #df = df.replace({np.nan: None}) - # Alternatively, apply to all columns at once - df = df.apply(lambda x: x.str.strip() if x.dtype == "object" else x) - arcpy.AddMessage(f">-> Creating the {table_name} Geodatabase Table") - try: - array = np.array(np.rec.fromrecords(df.values), dtype = field_gdb_dtypes) - except: - traceback.print_exc() - raise SystemExit - del df - del field_gdb_dtypes - # Temporary table - tmp_table = rf"memory\{table_name.lower()}_tmp" - try: - arcpy.da.NumPyArrayToTable(array, tmp_table) - del array - # Captures ArcPy type of error - except: - traceback.print_exc() - raise SystemExit - arcpy.AddMessage(f">-> Copying the {table_name} Table from memory to the GDB") - fields = [f.name for f in arcpy.ListFields(tmp_table) if f.type == "String"] - for field in fields: - arcpy.management.CalculateField(tmp_table, field=field, expression=f"'' if !{field}! is None else !{field}!") - arcpy.AddMessage("Calculate Field:\t{0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - del field - del fields - dataset_path = rf"{project_gdb}\{table_name}" - arcpy.management.CopyRows(tmp_table, dataset_path, "") - arcpy.AddMessage("Copy Rows:\t{0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # Remove the temporary table - arcpy.management.Delete(tmp_table) - del tmp_table - #arcpy.conversion.ExportTable(in_table = dataset_path, out_table = rf"{csv_data_folder}\_{table_name}.csv", where_clause="", use_field_alias_as_name = "NOT_USE_ALIAS") - #arcpy.AddMessage("Export Table:\t{0}\n".format(arcpy.GetMessages().replace("\n", '\n\t'))) - # Alter Fields - dismap_tools.alter_fields(csv_data_folder, dataset_path) - dismap_tools.import_metadata(csv_data_folder=csv_data_folder,dataset=dataset_path) - # Load Metadata - #dataset_md = md.Metadata(dataset_path) - #dataset_md.synchronize("ALWAYS") - #dataset_md.save() - #del dataset_md - arcpy.AddMessage(f"Compacting the {os.path.basename(project_gdb)} GDB") - arcpy.management.Compact(project_gdb) - arcpy.AddMessage("\t"+arcpy.GetMessages().replace("\n", "\n\t")) - # Basic variables - del dataset_path - del table_name, csv_data_folder, project_folder, scratch_workspace - # Imports - del dismap_tools, md, pd, np, warnings - # Function parameters - del project_gdb, csv_file - except KeyboardInterrupt: - raise SystemExit - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - except SystemExit: - sys.exit() - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass -def update_datecode(csv_file="", project_name=""): - try: - #sys.path.append(os.path.abspath('../dev')) - # Imports - import dismap_tools - import pandas as pd - import warnings - # Set History and Metadata logs, set serverity and message level - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(2) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - table_name = os.path.basename(csv_file).replace(".csv", "") - csv_data_folder = os.path.dirname(csv_file) - # Set basic arcpy.env variables - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - field_csv_dtypes = dismap_tools.dTypesCSV(csv_data_folder, table_name) - arcpy.AddMessage(f"\tUpdating CSV file: {os.path.basename(csv_file)}") - #arcpy.AddMessage(f"\t\t{csv_file}") - # C:\. . .\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\numpy\lib\arraysetops.py:583: - # FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison - # mask |= (ar1 == a) - # A fix: https://www.youtube.com/watch?v=TTeElATMpoI - # TLDR: pandas are Jedi; numpy are the hutts; and python is the galatic empire - with warnings.catch_warnings(): - warnings.simplefilter(action='ignore', category=FutureWarning) - # DataFrame - df = pd.read_csv(csv_file, - index_col = 0, - encoding = "utf-8", - delimiter = ',', - dtype = field_csv_dtypes, - ) - old_date_code = df.DateCode.unique()[0] - arcpy.AddMessage(f"\tOld Date Code: {old_date_code}") - arcpy.AddMessage(f"\tNew Date Code: {dismap_tools.date_code(project_name)}") - df = df.replace(regex = old_date_code, value = dismap_tools.date_code(project_name)) - df.to_csv(path_or_buf = f"{csv_file}", sep = ',') - del df, pd, warnings - del old_date_code - arcpy.AddMessage(f"\tCompleted updating CSV file: {os.path.basename(csv_file)}") - # Declared Variables - del field_csv_dtypes, table_name, csv_data_folder - # Imports - del dismap_tools - # Function parameters - del csv_file, project_name - except KeyboardInterrupt: - raise SystemExit - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass -def script_tool(project_folder=""): - """Script code goes below""" - try: - from lxml import etree - from arcpy import metadata as md - from io import StringIO - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"{'-' * 80}\n") - # Imports - #from dev_import_datasets_species_filter_csv_data import worker - # Set basic arcpy.env variables - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - #project_folder = rf"{os.path.dirname(project_gdb)}" - project_name = rf"{os.path.basename(project_folder)}" - project_gdb = rf"{project_folder}\{project_name}.gdb" - home_folder = rf"{os.path.dirname(project_folder)}" - csv_data_folder = rf"{project_folder}\CSV_Data" - datasets_csv = rf"{csv_data_folder}\Datasets.csv" - species_filter_csv = rf"{csv_data_folder}\Species_Filter.csv" - survey_metadata_csv = rf"{csv_data_folder}\DisMAP_Survey_Info.csv" - SpeciesPersistenceIndicatorTrend = rf"{csv_data_folder}\SpeciesPersistenceIndicatorTrend.csv" - SpeciesPersistenceIndicatorPercentileBin = rf"{csv_data_folder}\SpeciesPersistenceIndicatorPercentileBin.csv" - arcpy.management.Copy(rf"{home_folder}\Datasets\Datasets_20250801.csv", datasets_csv) - arcpy.management.Copy(rf"{home_folder}\Datasets\Species_Filter_20250801.csv", species_filter_csv) - arcpy.management.Copy(rf"{home_folder}\Datasets\DisMAP_Survey_Info_20250801.csv", survey_metadata_csv) - arcpy.management.Copy(rf"{home_folder}\Datasets\SpeciesPersistenceIndicatorTrend_20250801.csv", SpeciesPersistenceIndicatorTrend) - arcpy.management.Copy(rf"{home_folder}\Datasets\SpeciesPersistenceIndicatorPercentileBin_20250801.csv", SpeciesPersistenceIndicatorPercentileBin) - import json - json_path = rf"{csv_data_folder}\root_dict.json" - with open(json_path, "r") as json_file: - root_dict = json.load(json_file) - del json_file - del json_path - del json - contacts = rf"{home_folder}\Datasets\DisMAP Contacts 2025 08 01.xml" - datasets = [datasets_csv, species_filter_csv, survey_metadata_csv, SpeciesPersistenceIndicatorTrend, SpeciesPersistenceIndicatorPercentileBin] - for dataset in datasets: - arcpy.AddMessage(rf"Metadata for: {os.path.basename(dataset)}") - dataset_md = md.Metadata(dataset) - dataset_md.synchronize("ALWAYS") - dataset_md.save() - dataset_md.importMetadata(contacts, "ARCGIS_METADATA") - dataset_md.save() - dataset_md.synchronize("OVERWRITE") - dataset_md.save() - dataset_md.synchronize("ALWAYS") - dataset_md.save() - target_tree = etree.parse(StringIO(dataset_md.xml), parser=etree.XMLParser(encoding='UTF-8', remove_blank_text=True)) - target_root = target_tree.getroot() - target_root[:] = sorted(target_root, key=lambda x: root_dict[x.tag]) - new_item_name = target_root.find("Esri/DataProperties/itemProps/itemName").text - #arcpy.AddMessage(new_item_name) - etree.indent(target_root, space=' ') - dataset_md.xml = etree.tostring(target_tree, encoding='UTF-8', method='xml', xml_declaration=True, pretty_print=True) - dataset_md.save() - dataset_md.synchronize("ALWAYS") - dataset_md.save() - #arcpy.AddMessage(dataset_md.xml) - del dataset_md - del dataset - del datasets - del project_folder, csv_data_folder - # - UpdateDatecode = True - if UpdateDatecode: - # Update DateCode - #arcpy.AddMessage(datasets_csv) - arcpy.AddMessage(project_name) - update_datecode(csv_file=datasets_csv, project_name=project_name) - del UpdateDatecode - # - DatasetsCSVFile = True - if DatasetsCSVFile: - worker(project_gdb=project_gdb, csv_file=datasets_csv) - del DatasetsCSVFile - # - SpeciesFilterCSVFile = True - if SpeciesFilterCSVFile: - worker(project_gdb=project_gdb, csv_file=species_filter_csv) - del SpeciesFilterCSVFile - # - DisMAPSurveyInfoFile = True - if DisMAPSurveyInfoFile: - worker(project_gdb=project_gdb, csv_file=survey_metadata_csv) - del DisMAPSurveyInfoFile - # - SpeciesPersistenceIndicatorPercentileBinFile = True - if SpeciesPersistenceIndicatorPercentileBinFile: - worker(project_gdb=project_gdb, csv_file=SpeciesPersistenceIndicatorPercentileBin) - del SpeciesPersistenceIndicatorPercentileBinFile - # - SpeciesPersistenceIndicatorTrendFile = True - if SpeciesPersistenceIndicatorTrendFile: - worker(project_gdb=project_gdb, csv_file=SpeciesPersistenceIndicatorTrend) - del SpeciesPersistenceIndicatorTrendFile - # # # # # # - # Declared Varaiables - del SpeciesPersistenceIndicatorPercentileBin, SpeciesPersistenceIndicatorTrend - del datasets_csv, species_filter_csv, survey_metadata_csv, home_folder, project_name - # Declared Variables - del contacts, target_tree, target_root, new_item_name, root_dict - # Imports - del etree, md, StringIO - # Function Parameters - del project_gdb - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}") - arcpy.AddMessage(u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time)))) - arcpy.AddMessage(f"{'-' * 80}") - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - except KeyboardInterrupt: - raise SystemExit - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - except Exception: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - raise SystemExit - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass -if __name__ == '__main__': - try: - - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025" - else: - pass - - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - - except SystemExit: - pass - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - else: - pass - finally: - sys.exit() diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/publish_to_portal_director.py b/ArcGIS-Analysis-Python/src/dismap_tools/publish_to_portal_director.py deleted file mode 100644 index d4c3116..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/publish_to_portal_director.py +++ /dev/null @@ -1,2986 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------- -# Name: module1 -# Purpose: -# -# Author: john.f.kennedy -# -# Created: 03/03/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -# ------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback -import inspect - -import arcpy # third-parties second - -def feature_sharing_draft_report(sd_draft=""): - try: - import xml.dom.minidom as DOM - - docs = DOM.parse(sd_draft) - key_list = docs.getElementsByTagName("Key") - value_list = docs.getElementsByTagName("Value") - - for i in range(key_list.length): - value = f"Value: {value_list[i].firstChild.nodeValue}" if value_list[i].firstChild else f"Value is missing" - - arcpy.AddMessage(f"\t\tKey: {key_list[i].firstChild.nodeValue:<45} {value}") - # arcpy.AddMessage(f"\t\tKey: {key_list[i].firstChild.nodeValue:<45} {value[:50]}") - del i, value - - del DOM, key_list, value_list, docs - del sd_draft - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def create_feature_class_layers(project_gdb=""): - try: - # Import - from arcpy import metadata as md - from dismap_tools import dataset_title_dict, parse_xml_file_format_and_save - - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(project_gdb): - sys.exit()(f"{os.path.basename(project_gdb)} is missing!!") - - # Set History and Metadata logs, set serverity and message level - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic workkpace variables - project_folder = os.path.dirname(project_gdb) - project_name = os.path.basename(project_folder) - csv_data_folder = rf"{project_folder}\CSV_Data" - scratch_folder = rf"{project_folder}\Scratch" - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - - # Clear Scratch Folder - dismap_tools.clear_folder(folder=scratch_folder) - - # Create Scratch Workspace for Project - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - if not arcpy.Exists(scratch_folder): - os.makedirs(rf"{scratch_folder}") - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"scratch") - - # Set basic workkpace variables - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - aprx = arcpy.mp.ArcGISProject(rf"{project_folder}\{project_name}.aprx") - - del scratch_folder, scratch_workspace - - arcpy.AddMessage("Loading the Dataset Title Dictionary. Please wait") - datasets_dict = dataset_title_dict(project_gdb) - - datasets = [] - - #datasets.extend(arcpy.ListFeatureClasses("AI_IDW_Sample_Locations")) - datasets.extend(arcpy.ListFeatureClasses("*Sample_Locations")) - datasets.extend(arcpy.ListFeatureClasses("DisMAP_Regions")) - datasets.extend(arcpy.ListTables("Indicators")) - datasets.extend(arcpy.ListTables("Species_Filter")) - datasets.extend(arcpy.ListTables("DisMAP_Survey_Info")) - datasets.extend(arcpy.ListTables("SpeciesPersistenceIndicatorPercentileBin")) - datasets.extend(arcpy.ListTables("SpeciesPersistenceIndicatorTrend")) - - for dataset in sorted(datasets): - - feature_service_title = datasets_dict[dataset]["Dataset Service Title"] - - arcpy.AddMessage(f"Dataset: {dataset}") - arcpy.AddMessage(f"\tTitle: {feature_service_title}") - - desc = arcpy.da.Describe(dataset) - - feature_class_path = rf"{project_gdb}\{dataset}" - - if desc["dataType"] == "FeatureClass": - - arcpy.AddMessage(f"\tMake Feature Layer") - feature_class_layer = arcpy.management.MakeFeatureLayer(feature_class_path, feature_service_title) - feature_class_layer_file = rf"{project_folder}\Layers\{feature_class_layer}.lyrx" - - arcpy.AddMessage(f"\tSave Layer File") - _result = arcpy.management.SaveToLayerFile( - in_layer = feature_class_layer, - out_layer = feature_class_layer_file, - is_relative_path = "RELATIVE", - version = "CURRENT" - ) - del _result - - arcpy.management.Delete(feature_class_layer) - del feature_class_layer - - elif desc["dataType"] == "Table": - - arcpy.AddMessage(f"\tMake Table View") - feature_class_layer = arcpy.management.MakeTableView( - in_table = feature_class_path, - out_view = feature_service_title, - where_clause = "", - workspace = project_gdb, - field_info = "OBJECTID OBJECTID VISIBLE NONE;DatasetCode DatasetCode VISIBLE NONE;Region Region VISIBLE NONE;Season Season VISIBLE NONE;DateCode DateCode VISIBLE NONE;Species Species VISIBLE NONE;CommonName CommonName VISIBLE NONE;CoreSpecies CoreSpecies VISIBLE NONE;Year Year VISIBLE NONE;DistributionProjectName DistributionProjectName VISIBLE NONE;DistributionProjectCode DistributionProjectCode VISIBLE NONE;SummaryProduct SummaryProduct VISIBLE NONE;CenterOfGravityLatitude CenterOfGravityLatitude VISIBLE NONE;MinimumLatitude MinimumLatitude VISIBLE NONE;MaximumLatitude MaximumLatitude VISIBLE NONE;OffsetLatitude OffsetLatitude VISIBLE NONE;CenterOfGravityLatitudeSE CenterOfGravityLatitudeSE VISIBLE NONE;CenterOfGravityLongitude CenterOfGravityLongitude VISIBLE NONE;MinimumLongitude MinimumLongitude VISIBLE NONE;MaximumLongitude MaximumLongitude VISIBLE NONE;OffsetLongitude OffsetLongitude VISIBLE NONE;CenterOfGravityLongitudeSE CenterOfGravityLongitudeSE VISIBLE NONE;CenterOfGravityDepth CenterOfGravityDepth VISIBLE NONE;MinimumDepth MinimumDepth VISIBLE NONE;MaximumDepth MaximumDepth VISIBLE NONE;OffsetDepth OffsetDepth VISIBLE NONE;CenterOfGravityDepthSE CenterOfGravityDepthSE VISIBLE NONE" - ) - feature_class_layer_file = rf"{project_folder}\Layers\{feature_class_layer}.lyrx" - - arcpy.AddMessage(f"\tSave Layer File") - _result = arcpy.management.SaveToLayerFile( - in_layer = feature_class_layer, - out_layer = feature_class_layer_file, - is_relative_path = "RELATIVE", - version = "CURRENT" - ) - del _result - - arcpy.management.Delete(feature_class_layer) - del feature_class_layer - - else: - pass - - if [f.name for f in arcpy.ListFields(feature_class_path) if f.name == "StdTime"]: - arcpy.AddMessage(f"\tSet Time Enabled if time field is in dataset") - # Get time information from a layer in a layer file - layer_file = arcpy.mp.LayerFile(feature_class_layer_file) - layer = layer_file.listLayers()[0] - layer.enableTime("StdTime", "StdTime", True) - layer.time.timeZone = arcpy.mp.ListTimeZones("(UTC) Coordinated Universal Time")[0] - layer_file.save() - del layer - - for layer in layer_file.listLayers(): - if layer.supports("TIME"): - if layer.isTimeEnabled: - lyrTime = layer.time - startTime = lyrTime.startTime - endTime = lyrTime.endTime - timeDelta = endTime - startTime - startTimeField = lyrTime.startTimeField - endTimeField = lyrTime.endTimeField - arcpy.AddMessage(f"\tLayer: {layer.name}") - arcpy.AddMessage(f"\t\tStart Time Field: {startTimeField}") - arcpy.AddMessage(f"\t\tEnd Time Field: {endTimeField}") - arcpy.AddMessage(f"\t\tStart Time: {str(startTime.strftime('%m-%d-%Y'))}") - arcpy.AddMessage(f"\t\tEnd Time: {str(endTime.strftime('%m-%d-%Y'))}") - arcpy.AddMessage(f"\t\tTime Extent: {str(timeDelta.days)} days") - arcpy.AddMessage(f"\t\tTime Zone: {str(layer.time.timeZone)}") - del lyrTime, startTime, endTime, timeDelta - del startTimeField, endTimeField - else: - arcpy.AddMessage("No time properties have been set on the layer") - else: - arcpy.AddMessage("Time is not supported on this layer") - del layer - del layer_file - else: - arcpy.AddMessage(f"\tDataset does not have a time field") - - layer_file = arcpy.mp.LayerFile(feature_class_layer_file) - - # aprx.listBasemaps() to get a list of available basemaps - # - # ['Charted Territory Map', - # 'Colored Pencil Map', - # 'Community Map', - # 'Dark Gray Canvas', - # 'Firefly Imagery Hybrid', - # 'GEBCO Basemap (NOAA NCEI Visualization)', - # 'GEBCO Basemap/Contours (NOAA NCEI Visualization)', - # 'GEBCO Gray Basemap (NOAA NCEI Visualization)', - # 'GEBCO Gray Basemap/Contours (NOAA NCEI Visualization)', - # 'Human Geography Dark Map', - # 'Human Geography Map', - # 'Imagery', - # 'Imagery Hybrid', - # 'Light Gray Canvas', - # 'Mid-Century Map', - # 'Modern Antique Map', - # 'National Geographic Style Map', - # 'Navigation', - # 'Navigation (Dark)', - # 'Newspaper Map', - # 'NOAA Charts', - # 'NOAA ENC® Charts', - # 'Nova Map', - # 'Oceans', - # 'OpenStreetMap', - # 'Streets', - # 'Streets (Night)', - # 'Terrain with Labels', - # 'Topographic'] - - if aprx.listMaps(feature_service_title): - aprx.deleteItem(aprx.listMaps(feature_service_title)[0]) - aprx.save() - else: - pass - - arcpy.AddMessage(f"\tCreating Map: {feature_service_title}") - aprx.createMap(f"{feature_service_title}", "Map") - aprx.save() - - current_map = aprx.listMaps(feature_service_title)[0] - - basemap = "Terrain with Labels" - current_map.addLayer(layer_file) - current_map.addBasemap(basemap) - aprx.save() - del basemap - - arcpy.AddMessage(f"\t\tCreate map thumbnail and update metadata") - current_map_view = current_map.defaultView - current_map_view.exportToPNG( - rf"{project_folder}\Layers\{feature_service_title}.png", - width=288, - height=192, - resolution=96, - color_mode="24-BIT_TRUE_COLOR", - embed_color_profile=True, - ) - del current_map_view - - fc_md = md.Metadata(feature_class_path) - fc_md.title = feature_service_title - fc_md.thumbnailUri = (rf"{project_folder}\Layers\{feature_service_title}.png") - fc_md.save() - fc_md.reload() - fc_md.saveAsXML(rf"{project_folder}\Metadata_Export\{feature_service_title}.xml") - del fc_md - - parse_xml_file_format_and_save(csv_data_folder=csv_data_folder, xml_file=rf"{project_folder}\Metadata_Export\{feature_service_title}.xml", sort=True) - #parse_xml_file_format_and_save(csv_data_folder=csv_data_folder, xml_file="", sort=True) - - in_md = md.Metadata(feature_class_path) - layer_file.metadata.copy(in_md) - layer_file.metadata.save() - layer_file.save() - current_map.metadata.copy(in_md) - current_map.metadata.save() - aprx.save() - del in_md - - arcpy.AddMessage(f"\t\tLayer File Path: {layer_file.filePath}") - arcpy.AddMessage(f"\t\tLayer File Version: {layer_file.version}") - arcpy.AddMessage(f"\t\tLayer File Metadata:") - arcpy.AddMessage(f"\t\t\tLayer File Title: {layer_file.metadata.title}") - #arcpy.AddMessage(f"\t\t\tLayer File Tags: {layer_file.metadata.tags}") - #arcpy.AddMessage(f"\t\t\tLayer File Summary: {layer_file.metadata.summary}") - #arcpy.AddMessage(f"\t\t\tLayer File Description: {layer_file.metadata.description}") - #arcpy.AddMessage(f"\t\t\tLayer File Credits: {layer_file.metadata.credits}") - #arcpy.AddMessage(f"\t\t\tLayer File Access Constraints: {layer_file.metadata.accessConstraints}") - - arcpy.AddMessage(f"\t\tList of layers or tables in Layer File:") - if current_map.listLayers(feature_service_title): - layer = current_map.listLayers(feature_service_title)[0] - elif current_map.listTables(feature_service_title): - layer = current_map.listTables(feature_service_title)[0] - else: - arcpy.AddWarning(f"Something wrong") - - in_md = md.Metadata(feature_class_path) - layer.metadata.copy(in_md) - layer.metadata.save() - layer_file.save() - aprx.save() - del in_md - - arcpy.AddMessage(f"\t\t\tLayer Name: {layer.name}") - arcpy.AddMessage(f"\t\t\tLayer Metadata:") - arcpy.AddMessage(f"\t\t\t\tLayer Title: {layer.metadata.title}") - #arcpy.AddMessage(f"\t\t\t\tLayer Tags: {layer.metadata.tags}") - #arcpy.AddMessage(f"\t\t\t\tLayer Summary: {layer.metadata.summary}") - #arcpy.AddMessage(f"\t\t\t\tLayer Description: {layer.metadata.description}") - #arcpy.AddMessage(f"\t\t\t\tLayer Credits: {layer.metadata.credits}") - #arcpy.AddMessage(f"\t\t\t\tLayer Access Constraints: {layer.metadata.accessConstraints}") - del layer - del layer_file - del feature_class_layer_file - del feature_class_path - - aprx.deleteItem(current_map) - del current_map - aprx.save() - - #del dataset_code, point_feature_type, feature_class_name, region, season - #del date_code, distribution_project_code - #del feature_class_path - - del desc - del feature_service_title - del dataset - - del datasets_dict - del datasets - - # Declared Variables set in function - del aprx - del csv_data_folder, project_folder, project_name - - # Imports - del dataset_title_dict, parse_xml_file_format_and_save, md - - # Function Parameters - del project_gdb - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def create_feature_class_services(project_gdb=""): - try: - # Import - from arcpy import metadata as md - from dismap_tools import dataset_title_dict - - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(project_gdb): - sys.exit()(f"{os.path.basename(project_gdb)} is missing!!") - - # Set History and Metadata logs, set serverity and message level - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Set basic workkpace variables - project_folder = os.path.dirname(project_gdb) - project_name = os.path.basename(project_folder) - csv_data_folder = rf"{project_folder}\CSV_Data" - scratch_folder = rf"{project_folder}\Scratch" - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - - # Create Scratch Workspace for Project - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - if not arcpy.Exists(scratch_folder): - os.makedirs(rf"{scratch_folder}") - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"scratch") - - # Set basic workkpace variables - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - aprx = arcpy.mp.ArcGISProject(rf"{project_folder}\{project_name}.aprx") - - del scratch_folder, scratch_workspace - - arcpy.AddMessage("Loading the Dataset Title Dictionary. Please wait") - datasets_dict = dataset_title_dict(project_gdb) - - datasets = [] - - #datasets.extend(arcpy.ListFeatureClasses("AI_IDW_Sample_Locations")) - datasets.extend(arcpy.ListFeatureClasses("*Sample_Locations")) - datasets.extend(arcpy.ListFeatureClasses("DisMAP_Regions")) - datasets.extend(arcpy.ListTables("Indicators")) - datasets.extend(arcpy.ListTables("Species_Filter")) - datasets.extend(arcpy.ListTables("DisMAP_Survey_Info")) - datasets.extend(arcpy.ListTables("SpeciesPersistenceIndicatorPercentileBin")) - datasets.extend(arcpy.ListTables("SpeciesPersistenceIndicatorTrend")) - - #LogInAGOL = False - #if LogInAGOL: - #try: - #portal = "https://noaa.maps.arcgis.com/" - #user = "John.F.Kennedy_noaa" - # Sign in to portal - # arcpy.SignInToPortal("https://www.arcgis.com", "MyUserName", "MyPassword") - # For example: 'http://www.arcgis.com/' - #arcpy.SignInToPortal(portal) - - #arcpy.AddMessage(f"###---> Signed into Portal: {arcpy.GetActivePortalURL()} <---###") - #del portal, user - #except: - #arcpy.AddError(f"###---> Signed into Portal faild <---###") - #del LogInAGOL - - for dataset in sorted(datasets): - - feature_service = datasets_dict[dataset]["Dataset Service"] - feature_service_title = datasets_dict[dataset]["Dataset Service Title"] - - arcpy.AddMessage(f"Dataset: {dataset}") - arcpy.AddMessage(f"\tFS: {feature_service}") - arcpy.AddMessage(f"\tFST: {feature_service_title}") - - feature_class_layer_file = rf"{project_folder}\Layers\{feature_service_title}.lyrx" - - layer_file = arcpy.mp.LayerFile(feature_class_layer_file) - - del feature_class_layer_file - - # aprx.listBasemaps() to get a list of available basemaps - # - # ['Charted Territory Map', - # 'Colored Pencil Map', - # 'Community Map', - # 'Dark Gray Canvas', - # 'Firefly Imagery Hybrid', - # 'GEBCO Basemap (NOAA NCEI Visualization)', - # 'GEBCO Basemap/Contours (NOAA NCEI Visualization)', - # 'GEBCO Gray Basemap (NOAA NCEI Visualization)', - # 'GEBCO Gray Basemap/Contours (NOAA NCEI Visualization)', - # 'Human Geography Dark Map', - # 'Human Geography Map', - # 'Imagery', - # 'Imagery Hybrid', - # 'Light Gray Canvas', - # 'Mid-Century Map', - # 'Modern Antique Map', - # 'National Geographic Style Map', - # 'Navigation', - # 'Navigation (Dark)', - # 'Newspaper Map', - # 'NOAA Charts', - # 'NOAA ENC® Charts', - # 'Nova Map', - # 'Oceans', - # 'OpenStreetMap', - # 'Streets', - # 'Streets (Night)', - # 'Terrain with Labels', - # 'Topographic'] - - if aprx.listMaps(feature_service_title): - aprx.deleteItem(aprx.listMaps(feature_service_title)[0]) - aprx.save() - - arcpy.AddMessage(f"\tCreating Map: {feature_service_title}") - aprx.createMap(feature_service_title, "Map") - aprx.save() - - current_map = aprx.listMaps(feature_service_title)[0] - - in_md = md.Metadata(rf"{project_gdb}\{dataset}") - current_map.metadata.copy(in_md) - current_map.metadata.save() - aprx.save() - del in_md - - current_map.addLayer(layer_file) - aprx.save() - - del layer_file - - arcpy.AddMessage(f"\t\tList of layers or tables in Layer File:") - if current_map.listLayers(feature_service_title): - lyr = current_map.listLayers(feature_service_title)[0] - elif current_map.listTables(feature_service_title): - lyr = current_map.listTables(feature_service_title)[0] - else: - arcpy.AddWarning(f"Something wrong") - - in_md = md.Metadata(rf"{project_gdb}\{dataset}") - lyr.metadata.copy(in_md) - lyr.metadata.save() - aprx.save() - del in_md - - arcpy.AddMessage(f"\tGet Web Layer Sharing Draft") - # Get Web Layer Sharing Draft - server_type = "HOSTING_SERVER" # FEDERATED_SERVER - # m.getWebLayerSharingDraft (server_type, service_type, service_name, {layers_and_tables}) - # sddraft = m.getWebLayerSharingDraft(server_type, "FEATURE", service_name, [selected_layer, selected_table]) - # https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/featuresharingdraft-class.htm#GUID-8E27A3ED-A705-4ACF-8C7D-AA861327AD26 - sddraft = current_map.getWebLayerSharingDraft(server_type=server_type, service_type="FEATURE", service_name=feature_service, layers_and_tables=lyr) - del server_type - - sddraft.allowExporting = False - sddraft.offline = False - sddraft.offlineTarget = None - sddraft.credits = lyr.metadata.credits - sddraft.description = lyr.metadata.description - sddraft.summary = lyr.metadata.summary - sddraft.tags = lyr.metadata.tags - sddraft.useLimitations = lyr.metadata.accessConstraints - sddraft.overwriteExistingService = True - sddraft.portalFolder = f"DisMAP {project_name}" - - del lyr - - arcpy.AddMessage(f"\t\tAllow Exporting: {sddraft.allowExporting}") - arcpy.AddMessage(f"\t\tCheck Unique ID Assignment: {sddraft.checkUniqueIDAssignment}") - arcpy.AddMessage(f"\t\tOffline: {sddraft.offline}") - arcpy.AddMessage(f"\t\tOffline Target: {sddraft.offlineTarget}") - arcpy.AddMessage(f"\t\tOverwrite Existing Service: {sddraft.overwriteExistingService}") - arcpy.AddMessage(f"\t\tPortal Folder: {sddraft.portalFolder}") - arcpy.AddMessage(f"\t\tServer Type: {sddraft.serverType}") - arcpy.AddMessage(f"\t\tService Name: {sddraft.serviceName}") - #arcpy.AddMessage(f"\t\tCredits: {sddraft.credits}") - #arcpy.AddMessage(f"\t\tDescription: {sddraft.description}") - #arcpy.AddMessage(f"\t\tSummary: {sddraft.summary}") - #arcpy.AddMessage(f"\t\tTags: {sddraft.tags}") - #arcpy.AddMessage(f"\t\tUse Limitations: {sddraft.useLimitations}") - - arcpy.AddMessage(f"\tExport to SD Draft") - # Create Service Definition Draft file - sddraft.exportToSDDraft(rf"{project_folder}\Publish\{feature_service}.sddraft") - - del sddraft - - sd_draft = rf"{project_folder}\Publish\{feature_service}.sddraft" - - arcpy.AddMessage(f"\tModify SD Draft") - # https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/featuresharingdraft-class.htm - # https://www.esri.com/arcgis-blog/products/arcgis-pro/mapping/streamline-your-code-with-new-properties-in-arcpy-sharing - import xml.dom.minidom as DOM - - docs = DOM.parse(sd_draft) - key_list = docs.getElementsByTagName("Key") - value_list = docs.getElementsByTagName("Value") - - for i in range(key_list.length): - if key_list[i].firstChild.nodeValue == "maxRecordCount": - arcpy.AddMessage(f"\t\tUpdating maxRecordCount from 2000 to 10000") - value_list[i].firstChild.nodeValue = 2000 - if key_list[i].firstChild.nodeValue == "ServiceTitle": - arcpy.AddMessage(f"\t\tUpdating ServiceTitle from {value_list[i].firstChild.nodeValue} to {feature_service_title}") - value_list[i].firstChild.nodeValue = feature_service_title - # Doesn't work - #if key_list[i].firstChild.nodeValue == "GeodataServiceName": - # arcpy.AddMessage(f"\t\tUpdating GeodataServiceName from {value_list[i].firstChild.nodeValue} to {feature_service}") - # value_list[i].firstChild.nodeValue = feature_service - del i - - # Write to the .sddraft file - f = open(sd_draft, "w") - docs.writexml(f) - f.close() - del f - - del DOM, docs, key_list, value_list - - FeatureSharingDraftReport = True - if FeatureSharingDraftReport: - arcpy.AddMessage(f"\tReport for {os.path.basename(sd_draft)} SD File") - feature_sharing_draft_report(sd_draft) - del FeatureSharingDraftReport - - arcpy.AddMessage(f"\tCreate/Stage {os.path.basename(sd_draft)} SD File") - arcpy.server.StageService(in_service_definition_draft=sd_draft, out_service_definition=sd_draft.replace("sddraft", "sd"), staging_version=5) - - UploadServiceDefinition = True - if UploadServiceDefinition: - #if project != "April 1 2023": - arcpy.AddMessage(f"\tUpload {os.path.basename(sd_draft).replace('sddraft', 'sd')} Service Definition") - arcpy.server.UploadServiceDefinition( - in_sd_file = sd_draft.replace("sddraft", "sd"), - in_server = "HOSTING_SERVER", # in_service_name = "", #in_cluster = "", - in_folder_type = "FROM_SERVICE_DEFINITION", # EXISTING #in_folder = "", - in_startupType = "STARTED", - in_override = "OVERRIDE_DEFINITION", - in_my_contents = "NO_SHARE_ONLINE", - in_public = "PRIVATE", - in_organization = "NO_SHARE_ORGANIZATION", # in_groups = "" - ) - #else: - # arcpy.AddWarning(f"Project is {project}") - del UploadServiceDefinition - - del sd_draft - - #aprx.deleteItem(current_map) - del current_map - aprx.save() - - del feature_service, feature_service_title - del dataset - del datasets - del datasets_dict - - # TODO: Possibly create a dictionary that can be saved to JSON - - aprx.save() - - current_maps = aprx.listMaps() - - if current_maps: - arcpy.AddMessage(f"\nCurrent Maps\n") - for current_map in current_maps: - arcpy.AddMessage(f"\tProject Map: {current_map.name}") - del current_map - else: - arcpy.AddWarning("No maps in Project") - - del current_maps - - # Declared Variables set in function for aprx - - # Save aprx one more time and then delete - aprx.save() - del aprx - - # Declared Variables set in function - del project_folder, project_name, csv_data_folder - - # Imports - del dataset_title_dict, md - - # Function Parameters - del project_gdb - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -##def update_metadata_from_published_md(project_gdb=""): -## try: -## # Import -## import dismap_tools -## -## arcpy.env.overwriteOutput = True -## arcpy.env.parallelProcessingFactor = "100%" -## arcpy.SetLogMetadata(True) -## arcpy.SetSeverityLevel(2) -## arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION -## -## LogInAGOL = False -## if LogInAGOL: -## try: -## portal = "https://noaa.maps.arcgis.com/" -## user = "John.F.Kennedy_noaa" -## -## # Sign in to portal -## #arcpy.SignInToPortal("https://www.arcgis.com", "MyUserName", "MyPassword") -## # For example: 'http://www.arcgis.com/' -## arcpy.SignInToPortal(portal) -## -## arcpy.AddMessage(f"###---> Signed into Portal: {arcpy.GetActivePortalURL()} <---###") -## del portal, user -## except: -## arcpy.AddError(f"###---> Signed into Portal faild <---###") -## del LogInAGOL -## -## aprx = arcpy.mp.ArcGISProject(base_project_file) -## home_folder = aprx.homeFolder -## del aprx -## -## project_gdb = rf"{project_folder}\{project}.gdb" -## -## -## -## # DatasetCode, CSVFile, TransformUnit, TableName, GeographicArea, CellSize, -## # PointFeatureType, FeatureClassName, Region, Season, DateCode, Status, -## # DistributionProjectCode, DistributionProjectName, SummaryProduct, -## # FilterRegion, FilterSubRegion, FeatureServiceName, FeatureServiceTitle, -## # MosaicName, MosaicTitle, ImageServiceName, ImageServiceTitle -## -## # Get values for table_name from Datasets table -## #fields = ["FeatureClassName", "FeatureServiceName", "FeatureServiceTitle"] -## fields = ["DatasetCode", "PointFeatureType", "FeatureClassName", "Region", "Season", "DateCode", "DistributionProjectCode"] -## datasets = [row for row in arcpy.da.SearchCursor(rf"{project_gdb}\Datasets", fields, where_clause = f"FeatureClassName IS NOT NULL AND DistributionProjectCode NOT IN ('GLMME', 'GFDL')")] -## #datasets = [row for row in arcpy.da.SearchCursor(rf"{project_gdb}\Datasets", fields, where_clause = f"FeatureClassName IN ('AI_IDW_Sample_Locations', 'DisMAP_Regions')")] -## del fields -## -## for dataset in datasets: -## dataset_code, point_feature_type, feature_class_name, region_latitude, season, date_code, distribution_project_code = dataset -## -## feature_service_name = f"{dataset_code}_{point_feature_type}_{date_code}".replace("None", "").replace(" ", "_").replace("__", "_") -## -## if distribution_project_code == "IDW": -## feature_service_title = f"{region_latitude} {season} {point_feature_type} {date_code}".replace("None", "").replace(" ", " ") -## #elif distribution_project_code in ["GLMME", "GFDL"]: -## # feature_service_title = f"{region_latitude} {distribution_project_code} {point_feature_type} {date_code}".replace("None", "").replace(" ", " ") -## else: -## feature_service_title = f"{feature_service_name}".replace("_", " ") -## -## map_title = feature_service_title.replace("GRID Points", "").replace("Sample Locations", "").replace(" ", " ") -## -## feature_class_path = f"{project_gdb}\{feature_class_name}" -## -## arcpy.AddMessage(f"Dataset Code: {dataset_code}") -## arcpy.AddMessage(f"\tFeature Service Name: {feature_service_name}") -## arcpy.AddMessage(f"\tFeature Service Title: {feature_service_title}") -## arcpy.AddMessage(f"\tMap Title: {map_title}") -## arcpy.AddMessage(f"\tLayer Title: {feature_service_title}") -## arcpy.AddMessage(f"\tFeature Class Name: {feature_class_name}") -## arcpy.AddMessage(f"\tFeature Class Path: {feature_class_path}") -## -## if arcpy.Exists(rf"{project_folder}\Publish\{feature_service_name}.xml"): -## arcpy.AddMessage(f"\t###--->>> {feature_service_name}.xml Exists <<<---###") -## -## from arcpy import metadata as md -## in_md = md.Metadata(rf"{project_folder}\Publish\{feature_service_name}.xml") -## fc_md = md.Metadata(feature_class_path) -## fc_md.copy(in_md) -## fc_md.save() -## del in_md, fc_md -## del md -## -## else: -## arcpy.AddWarning(f"\t###--->>> {feature_service_name}.xml Does Not Exist <<<---###") -## -## del dataset_code, point_feature_type, feature_class_name, region_latitude, season -## del date_code, distribution_project_code -## -## del feature_service_name, feature_service_title -## del map_title, feature_class_path -## del dataset -## del datasets -## -## arcpy.AddMessage(f"\n{'-' * 90}\n") -## -## # Declared Variables set in function -## del project_gdb -## del home_folder -## -## # Imports -## del dismap -## -## # Function Parameters -## del base_project_file, project -## -## except SystemExit: -## sys.exit() -## except: -## traceback.print_exc() -## sys.exit() -## else: -## try: -## leave_out_keys = ["leave_out_keys", "remaining_keys", "results"] -## remaining_keys = [key for key in locals().keys() if not key.startswith('__') and key not in leave_out_keys] -## if remaining_keys: -## arcpy.AddWarning(f"Remaining Keys in '{inspect.stack()[0][3]}': ##--> '{', '.join(remaining_keys)}' <--## Line Number: {traceback.extract_stack()[-1].lineno}") -## del leave_out_keys, remaining_keys -## -## return results if "results" in locals().keys() else ["NOTE!! The 'results' variable not yet set!!"] -## -## except: -## traceback.print_exc() -## finally: -## try: -## if "results" in locals().keys(): del results -## except UnboundLocalError: -## pass - -def create_image_services(project_gdb=""): - try: - # Import - import dismap_tools - from arcpy import metadata as md - - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(base_project_file): - sys.exit()(f"{os.path.basename(base_project_file)} is missing!!") - - # Set History and Metadata logs, set serverity and message level - arcpy.SetLogHistory(True) # Look in %AppData%\Roaming\Esri\ArcGISPro\ArcToolbox\History - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(1) # 0—A tool will not throw an exception, even if the tool produces an error or warning. - # 1—If a tool produces a warning or an error, it will throw an exception. - # 2—If a tool produces an error, it will throw an exception. This is the default. - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - aprx = arcpy.mp.ArcGISProject(base_project_file) - home_folder = aprx.homeFolder - - project_gdb = rf"{project_folder}\{project}.gdb" - - # Test if passed workspace exists, if not sys.exit() - if not arcpy.Exists(project_gdb): - sys.exit()(f"{os.path.basename(project_gdb)} is missing!!") - - # Set basic workkpace variables - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - scratch_workspace = rf"{project_folder}\Scratch\scratch.gdb" - - # Create Scratch Workspace for Project - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - if not arcpy.Exists(scratch_folder): - os.makedirs(rf"{scratch_folder}") - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"scratch") - - # Set basic workkpace variables - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = scratch_workspace - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - del scratch_folder, scratch_workspace - - LogIntoPortal = False - if LogIntoPortal: - try: - portal = "https://noaa.maps.arcgis.com/" - user = "John.F.Kennedy_noaa" - - #portal = "https://maps.fisheries.noaa.gov/portal/home" - #portal = "https://maps.fisheries.noaa.gov" - #user = "John.F.Kennedy_noaa" - - # Sign in to portal - # arcpy.SignInToPortal("https://www.arcgis.com", "MyUserName", "MyPassword") - # For example: 'http://www.arcgis.com/' - arcpy.SignInToPortal(portal) - - arcpy.AddMessage(f"###---> Signed into Portal: {arcpy.GetActivePortalURL()} <---###") - del portal, user - except: - arcpy.AddError(f"###---> Signed into Portal faild <---###") - sys.exit() - del LogIntoPortal - - arcpy.AddMessage(f"\n{'-' * 90}\n") - - # Publishes an image service to a machine "myserver" from a folder of ortho images - # this code first author a mosaic dataset from the images, then publish it as an image service. - # A connection to ArcGIS Server must be established in the Catalog window of ArcMap - # before running this script - - #import time - #import arceditor # this is required to create a mosaic dataset from images - - # - # Define local variables: - #ImageSource=r"\\myserver\data\SourceData\Portland" # the folder of input images - #MyWorkspace=r"\\myserver\Data\DemoData\ArcPyPublishing" # the folder for mosaic dataset and the service defintion draft file - #GdbName="fgdb1.gdb" - #GDBpath = os.path.join(MyWorkspace,GdbName) #File geodatabase used to store a mosaic dataset - #Name = "OrthoImages" - #Md = os.path.join(GDBpath, Name) - #Sddraft = os.path.join(MyWorkspace,Name+".sddraft") - #Sd = os.path.join(MyWorkspace,Name+".sd") - #con = os.path.join(MyWorkspace, "arcgis on myserver_6080 (admin).ags") - con = r"{os.environ['USERPROFILE']}\Documents\ArcGIS\Projects\DisMAP-ArcGIS-Analysis\server on maps.fisheries.noaa.gov.ags" - - mosiac_name = "SEUS_FAL_Mosaic" - mosiac_path = rf"{project_gdb}\{mosiac_name}" - mosiac_sddraft = rf"{project_folder}\Publish\{mosiac_name}.sddraft" - -## SrsLookup = { -## 'Mercator': "PROJCS['World_Mercator',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137,298.257223563]],PRIMEM['Greenwich',0],UNIT['Degree',0.017453292519943295]],PROJECTION['Mercator'],PARAMETER['False_Easting',0],PARAMETER['False_Northing',0],PARAMETER['Central_Meridian',0],PARAMETER['Standard_Parallel_1',0],UNIT['Meter',1]]", -## 'WGS84': "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137,298.257223563]],PRIMEM['Greenwich',0],UNIT['Degree',0.017453292519943295]]", -## 'GZ4': "PROJCS['Germany_Zone_4',GEOGCS['GCS_Deutsches_Hauptdreiecksnetz',DATUM['D_Deutsches_Hauptdreiecksnetz',SPHEROID['Bessel_1841',6377397.155,299.1528128]],PRIMEM['Greenwich',0],UNIT['Degree',0.017453292519943295]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',4500000],PARAMETER['False_Northing',0],PARAMETER['Central_Meridian',12],PARAMETER['Scale_Factor',1],PARAMETER['Latitude_Of_Origin',0],UNIT['Meter',1]]", -## 'GCS_NAD83': "GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137,298.257222101]],PRIMEM['Greenwich',0],UNIT['Degree',0.017453292519943295]]", -## 'PUG': "PROJCS['PUG1',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',1640416.666666667],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-87.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Foot_US',0.3048006096012192]]", -## 'Florida_East': "PROJCS['NAD_1983_StatePlane_Florida_East_FIPS_0901_Feet',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137,298.257222101]],PRIMEM['Greenwich',0],UNIT['Degree',0.0174532925199432955]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',656166.6666666665],PARAMETER['False_Northing',0],PARAMETER['Central_Meridian',-81],PARAMETER['Scale_Factor',0.9999411764705882],PARAMETER['Latitude_Of_Origin',24.33333333333333],UNIT['Foot_US',0.304800609601219241]]", -## 'SoCalNad83': "PROJCS['NAD_1983_StatePlane_California_V_FIPS_0405',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137,298.257222101]],PRIMEM['Greenwich',0],UNIT['Degree',0.0174532925199432955]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting',2000000],PARAMETER['False_Northing',500000],PARAMETER['Central_Meridian',-118],PARAMETER['Standard_Parallel_1',34.03333333333333],PARAMETER['Standard_Parallel_2',35.46666666666667],PARAMETER['Latitude_Of_Origin',33.5],UNIT['Meter',1]]" -## } - -## # First author a mosaic dataset from a folder of images -## try: -## arcpy.AddMessage("Creating fgdb") -## arcpy.CreateFileGDB_management(MyWorkspace, GdbName) -## -## arcpy.AddMessage("Creating mosaic dataset") -## #arcpy.CreateMosaicDataset_management(GDBpath, Name, SrsLookup['Mercator'], "", "", "NONE", "") -## arcpy.CreateMosaicDataset_management(project_gdb, mosiac_name, SrsLookup['Mercator'], "", "", "NONE", "") -## -## arcpy.AddMessage("Adding images to mosaic dataset") # also caculate cell size range, build boundary, and build overviews -## #arcpy.AddRastersToMosaicDataset_management(Md, "Raster Dataset", ImageSource, "UPDATE_CELL_SIZES", "UPDATE_BOUNDARY", "UPDATE_OVERVIEWS", "#", "0", "1500", "#", "#", "SUBFOLDERS", "ALLOW_DUPLICATES", "NO_PYRAMIDS", "NO_STATISTICS", "NO_THUMBNAILS", "", "NO_FORCE_SPATIAL_REFERENCE") -## arcpy.AddRastersToMosaicDataset_management(mosiac_path, "Raster Dataset", ImageSource, "UPDATE_CELL_SIZES", "UPDATE_BOUNDARY", "UPDATE_OVERVIEWS", "#", "0", "1500", "#", "#", "SUBFOLDERS", "ALLOW_DUPLICATES", "NO_PYRAMIDS", "NO_STATISTICS", "NO_THUMBNAILS", "", "NO_FORCE_SPATIAL_REFERENCE") -## except: -## arcpy.AddError(arcpy.GetMessages()+ "\n\n") -## sys.exit("Failed in authoring a mosaic dataset") - - # Create service definition draft - try: - arcpy.AddMessage("Creating SD draft") - #arcpy.CreateImageSDDraft(Md, Sddraft, Name, 'ARCGIS_SERVER', con, False, None, "Ortho Images","ortho images,image service") - arcpy.CreateImageSDDraft(mosiac_path, mosiac_sddraft, mosiac_name, 'ARCGIS_SERVER', con, False, None, "Ortho Images", "ortho images,image service") - except: - arcpy.AddError(arcpy.GetMessages()+ "\n\n") - sys.exit("Failed in creating SD draft") - -## # Analyze the service definition draft -## analysis = arcpy.mapping.AnalyzeForSD(Sddraft) -## arcpy.AddMessage("The following information was returned during analysis of the image service:") -## for key in ('messages', 'warnings', 'errors'): -## arcpy.AddMessage('----' + key.upper() + '---') -## vars = analysis[key] -## for ((message, code), layerlist) in vars.iteritems(): -## arcpy.AddMessage(' ', message, ' (CODE %i)' % code) -## arcpy.AddMessage(' applies to:'), -## for layer in layerlist: -## arcpy.AddMessage(layer.name), -## arcpy.AddMessage() -## -## # Stage and upload the service if the sddraft analysis did not contain errors -## if analysis['errors'] == {}: -## try: -## arcpy.AddMessage("Adding data path to data store to avoid data copy") -## arcpy.AddDataStoreItem(con, "FOLDER","Images", MyWorkspace, MyWorkspace) -## -## arcpy.AddMessage("Staging service to create service definition") -## arcpy.StageService_server(Sddraft, Sd) -## -## arcpy.AddMessage("Uploading the service definition and publishing image service") -## arcpy.UploadServiceDefinition_server(Sd, con) -## -## arcpy.AddMessage("Service successfully published") -## except: -## arcpy.AddError(arcpy.GetMessages()+ "\n\n") -## sys.exit("Failed to stage and upload service") -## else: -## arcpy.AddError("Service could not be published because errors were found during analysis.") -## arcpy.AddError(arcpy.GetMessages(2)) - - arcpy.AddMessage(f"\n{'-' * 90}\n") - - del project_gdb - - # Declared Variables set in function for aprx - del home_folder - # Save aprx one more time and then delete - aprx.save() - del aprx - - # Declared Variables set in function - - # Imports - - # Function Parameters - del base_project_file, project - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -##def create_basic_template_xml_files(project_gdb=""): -## try: -## # Import -## from arcpy import metadata as md -## from dismap_tools import dataset_title_dict, parse_xml_file_format_and_save -## -## arcpy.env.overwriteOutput = True -## arcpy.env.parallelProcessingFactor = "100%" -## arcpy.SetLogMetadata(True) -## arcpy.SetSeverityLevel(2) -## arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION -## -## # Map Cleanup -## MapCleanup = False -## if MapCleanup: -## map_cleanup(base_project_file) -## del MapCleanup -## -## base_project_folder = rf"{os.path.dirname(base_project_file)}" -## base_project_file = rf"{base_project_folder}\DisMAP.aprx" -## project_folder = rf"{base_project_folder}\{project}" -## project_gdb = rf"{project_folder}\{project}.gdb" -## metadata_folder = rf"{project_folder}\Export Metadata" -## crfs_folder = rf"{project_folder}\CRFs" -## scratch_folder = rf"{project_folder}\Scratch" -## -## metadata_dictionary = dataset_title_dict(project_gdb) -## -## workspaces = [project_gdb, crfs_folder] -## -## for workspace in workspaces: -## -## arcpy.env.workspace = workspace -## arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" -## -## datasets = list() -## -## walk = arcpy.da.Walk(workspace) -## -## for dirpath, dirnames, filenames in walk: -## for filename in filenames: -## datasets.append(os.path.join(dirpath, filename)) -## del filename -## del dirpath, dirnames, filenames -## del walk -## -## for dataset_path in sorted(datasets): -## #arcpy.AddMessage(dataset_path) -## dataset_name = os.path.basename(dataset_path) -## -## arcpy.AddMessage(f"Dataset Name: {dataset_name}") -## -## if "Datasets" == dataset_name: -## -## arcpy.AddMessage(f"\tDataset Table") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## datasets_table_template = rf"{project_folder}\Metadata_Export\datasets_table_template.xml" -## dataset_md.saveAsXML(datasets_table_template) -## parse_xml_file_format_and_save(csv_data_folder=csv_data_folder, xml_file=datasets_table_template, sort=True) -## del datasets_table_template -## -## del dataset_md -## -## elif "Species_Filter" == dataset_name: -## -## arcpy.AddMessage(f"\tSpecies Filter Table") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## -## dataset_md.synchronize("ALWAYS") -## -## species_filter_table_template = rf"{metadata_folder}\species_filter_table_template.xml" -## dataset_md.saveAsXML(species_filter_table_template) -## parse_xml_file_format_and_save(csv_data_folder=csv_data_folder, xml_file=species_filter_table_template, sort=True) -## del species_filter_table_template -## -## del dataset_md -## -## elif "Indicators" in dataset_name: -## -## arcpy.AddMessage(f"\tIndicators") -## -## if dataset_name == "Indicators": -## dataset_name = f"{dataset_name}_Table" -## else: -## pass -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## -## dataset_md.synchronize("ALWAYS") -## -## indicators_template = rf"{metadata_folder}\indicators_template.xml" -## dataset_md.saveAsXML(indicators_template) -## parse_xml_file_format_and_save(indicators_template) -## parse_xml_file_format_and_save(csv_data_folder=csv_data_folder, xml_file=indicators_template, sort=True) -## del indicators_template -## -## del dataset_md -## -## elif "LayerSpeciesYearImageName" in dataset_name: -## -## arcpy.AddMessage(f"\tLayer Species Year Image Name") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## -## dataset_md.synchronize("ALWAYS") -## -## layer_species_year_image_name_template = rf"{metadata_folder}\layer_species_year_image_name_template.xml" -## dataset_md.saveAsXML(layer_species_year_image_name_template) -## parse_xml_file_format_and_save(csv_data_folder=csv_data_folder, xml_file=layer_species_year_image_name_template, sort=True) -## del layer_species_year_image_name_template -## -## del dataset_md -## -## elif dataset_name.endswith("Boundary"): -## -## arcpy.AddMessage(f"\tBoundary") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## -## dataset_md.synchronize("ALWAYS") -## -## boundary_template = rf"{metadata_folder}\boundary_template.xml" -## dataset_md.saveAsXML(boundary_template) -## parse_xml_file_format_and_save(csv_data_folder=csv_data_folder, xml_file=boundary_template, sort=True) -## del boundary_template -## -## del dataset_md -## -## elif dataset_name.endswith("Extent_Points"): -## -## arcpy.AddMessage(f"\tExtent_Points") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## extent_points_template = rf"{metadata_folder}\extent_points_template.xml" -## dataset_md.saveAsXML(extent_points_template) -## parse_xml_file_format_and_save(csv_data_folder=csv_data_folder, xml_file=extent_points_template, sort=True) -## del extent_points_template -## -## del dataset_md -## -## elif dataset_name.endswith("Fishnet"): -## -## arcpy.AddMessage(f"\tFishnet") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## fishnet_template = rf"{metadata_folder}\fishnet_template.xml" -## dataset_md.saveAsXML(fishnet_template) -## parse_xml_file_format_and_save(fishnet_template) -## del fishnet_template -## -## del dataset_md -## -## elif dataset_name.endswith("Lat_Long"): -## -## arcpy.AddMessage(f"\tLat_Long") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## lat_long_template = rf"{metadata_folder}\lat_long_template.xml" -## dataset_md.saveAsXML(lat_long_template) -## parse_xml_file_format_and_save(lat_long_template) -## del lat_long_template -## -## del dataset_md -## -## elif dataset_name.endswith("Region"): -## -## arcpy.AddMessage(f"\tRegion") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## region_template = rf"{metadata_folder}\region_template.xml" -## dataset_md.saveAsXML(region_template) -## parse_xml_file_format_and_save(region_template) -## del region_template -## -## del dataset_md -## -## elif dataset_name.endswith("Sample_Locations"): -## -## arcpy.AddMessage(f"\tSample_Locations") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## sample_locations_template = rf"{metadata_folder}\sample_locations_template.xml" -## dataset_md.saveAsXML(sample_locations_template) -## parse_xml_file_format_and_save(sample_locations_template) -## del sample_locations_template -## -## del dataset_md -## -## elif dataset_name.endswith("GRID_Points"): -## -## arcpy.AddMessage(f"\tGRID_Points") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## grid_points_template = rf"{metadata_folder}\grid_points_template.xml" -## dataset_md.saveAsXML(grid_points_template) -## parse_xml_file_format_and_save(grid_points_template) -## del grid_points_template -## -## del dataset_md -## -## elif "DisMAP_Regions" == dataset_name: -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## dismap_regions_template = rf"{metadata_folder}\dismap_regions_template.xml" -## dataset_md.saveAsXML(dismap_regions_template) -## parse_xml_file_format_and_save(dismap_regions_template) -## del dismap_regions_template -## -## del dataset_md -## -## elif dataset_name.endswith("Bathymetry"): -## -## arcpy.AddMessage(f"\tBathymetry") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## bathymetry_template = rf"{metadata_folder}\bathymetry_template.xml" -## dataset_md.saveAsXML(bathymetry_template) -## parse_xml_file_format_and_save(bathymetry_template) -## del bathymetry_template -## -## del dataset_md -## -## elif dataset_name.endswith("Latitude"): -## -## arcpy.AddMessage(f"\tLatitude") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## latitude_template = rf"{metadata_folder}\latitude_template.xml" -## dataset_md.saveAsXML(latitude_template) -## parse_xml_file_format_and_save(latitude_template) -## del latitude_template -## -## del dataset_md -## -## elif dataset_name.endswith("Longitude"): -## -## arcpy.AddMessage(f"\tLongitude") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## longitude_template = rf"{metadata_folder}\longitude_template.xml" -## dataset_md.saveAsXML(longitude_template) -## parse_xml_file_format_and_save(longitude_template) -## del longitude_template -## -## del dataset_md -## -## elif dataset_name.endswith("Raster_Mask"): -## -## arcpy.AddMessage(f"\tRaster_Mask") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## raster_mask_template = rf"{metadata_folder}\raster_mask_template.xml" -## dataset_md.saveAsXML(raster_mask_template) -## parse_xml_file_format_and_save(raster_mask_template) -## del raster_mask_template -## -## del dataset_md -## -## elif dataset_name.endswith("Mosaic"): -## -## arcpy.AddMessage(f"\tMosaic") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## mosaic_template = rf"{metadata_folder}\mosaic_template.xml" -## dataset_md.saveAsXML(mosaic_template) -## parse_xml_file_format_and_save(mosaic_template) -## del mosaic_template -## -## del dataset_md -## -## elif dataset_name.endswith(".crf"): -## -## arcpy.AddMessage(f"\tCRF") -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[dataset_name.replace(".crf", "_CRF")]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name.replace(".crf", "_CRF")]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name.replace(".crf", "_CRF")]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name.replace(".crf", "_CRF")]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name.replace(".crf", "_CRF")]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name.replace(".crf", "_CRF")]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## crf_template = rf"{metadata_folder}\crf_template.xml" -## dataset_md.saveAsXML(crf_template) -## parse_xml_file_format_and_save(crf_template) -## del crf_template -## -## del dataset_md -## -## else: -## arcpy.AddMessage(f"\tRegion Table") -## -## if dataset_name.endswith("IDW"): -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## del empty_md -## -## dataset_md.title = metadata_dictionary[f"{dataset_name}"]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[f"{dataset_name}"]["Tags"] -## dataset_md.summary = metadata_dictionary[f"{dataset_name}"]["Summary"] -## dataset_md.description = metadata_dictionary[f"{dataset_name}"]["Description"] -## dataset_md.credits = metadata_dictionary[f"{dataset_name}"]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[f"{dataset_name}"]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## idw_region_table_template = rf"{metadata_folder}\idw_region_table_template.xml" -## dataset_md.saveAsXML(idw_region_table_template) -## parse_xml_file_format_and_save(idw_region_table_template) -## del idw_region_table_template -## -## del dataset_md -## else: -## pass -## del dataset_name, dataset_path -## del workspace -## -## del datasets -## -## # Declared Variables set in function -## del project_gdb, base_project_folder, metadata_folder -## del project_folder, scratch_folder, crfs_folder -## del metadata_dictionary, workspaces -## -## # Imports -## del dataset_title_dict, parse_xml_file_format_and_save -## del md -## -## # Function Parameters -## del base_project_file, project -## -## except KeyboardInterrupt: -## sys.exit() -## except arcpy.ExecuteWarning: -## arcpy.AddWarning(arcpy.GetMessages(1)) -## except arcpy.ExecuteError: -## arcpy.AddError(arcpy.GetMessages(2)) -## traceback.print_exc() -## sys.exit() -## except SystemExit: -## arcpy.AddError(arcpy.GetMessages(2)) -## traceback.print_exc() -## sys.exit() -## except Exception: -## arcpy.AddError(arcpy.GetMessages(2)) -## traceback.print_exc() -## sys.exit() -## except: -## arcpy.AddError(arcpy.GetMessages(2)) -## traceback.print_exc() -## sys.exit() -## else: -## # While in development, leave here. For test, move to finally -## rk = [key for key in locals().keys() if not key.startswith('__')] -## if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk -## return True -## finally: -## pass -## -##def import_basic_template_xml_files(project_gdb=""): -## try: -## # Import -## from arcpy import metadata as md -## -## from dismap_tools import dataset_title_dict, parse_xml_file_format_and_saves, unique_years -## -## arcpy.env.overwriteOutput = True -## arcpy.env.parallelProcessingFactor = "100%" -## arcpy.SetLogMetadata(True) -## arcpy.SetSeverityLevel(2) -## arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION -## -## # Map Cleanup -## MapCleanup = False -## if MapCleanup: -## map_cleanup(base_project_file) -## del MapCleanup -## -## base_project_folder = rf"{os.path.dirname(base_project_file)}" -## base_project_file = rf"{base_project_folder}\DisMAP.aprx" -## project_folder = rf"{base_project_folder}\{project}" -## project_gdb = rf"{project_folder}\{project}.gdb" -## metadata_folder = rf"{project_folder}\Current Metadata" -## crfs_folder = rf"{project_folder}\CRFs" -## scratch_folder = rf"{project_folder}\Scratch" -## -## #arcpy.AddMessage("Creating the Metadata Dictionary. Please wait!!") -## metadata_dictionary = dataset_title_dict(project_gdb) -## #arcpy.AddMessage("Creating the Metadata Dictionary. Completed") -## -## #workspaces = [project_gdb, crfs_folder] -## workspaces = [crfs_folder] -## -## for workspace in workspaces: -## -## arcpy.env.workspace = workspace -## arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" -## -## datasets = list() -## -## walk = arcpy.da.Walk(workspace) -## -## for dirpath, dirnames, filenames in walk: -## for filename in filenames: -## datasets.append(os.path.join(dirpath, filename)) -## del filename -## del dirpath, dirnames, filenames -## del walk -## -## for dataset_path in sorted(datasets): -## #arcpy.AddMessage(dataset_path) -## dataset_name = os.path.basename(dataset_path) -## -## arcpy.AddMessage(f"Dataset Name: {dataset_name}") -## -## if "Datasets" == dataset_name: -## -## arcpy.AddMessage(f"\tDataset Table") -## -## datasets_table_template = rf"{metadata_folder}\datasets_table_template.xml" -## template_md = md.Metadata(datasets_table_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del empty_md, template_md, datasets_table_template -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del dataset_md -## -## elif "Species_Filter" == dataset_name: -## -## arcpy.AddMessage(f"\tSpecies Filter Table") -## -## species_filter_table_template = rf"{metadata_folder}\species_filter_table_template.xml" -## template_md = md.Metadata(species_filter_table_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## del empty_md, template_md, species_filter_table_template -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del dataset_md -## -## elif "Indicators" in dataset_name: -## -## arcpy.AddMessage(f"\tIndicators") -## -## if dataset_name == "Indicators": -## indicators_template = rf"{metadata_folder}\indicators_template.xml" -## else: -## indicators_template = rf"{metadata_folder}\region_indicators_template.xml" -## -## template_md = md.Metadata(indicators_template) -## -## dataset_md = md.Metadata(dataset_path) -## dataset_md.copy(template_md) -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## del empty_md, template_md, indicators_template -## -## # Max-Min Year range table -## years_md = unique_years(dataset_path) -## _tags = f", {min(years_md)} to {max(years_md)}" -## del years_md -## -## #arcpy.AddMessage(metadata_dictionary[dataset_name]["Tags"]) -## #arcpy.AddMessage(_tags) -## -## if dataset_name == "Indicators": -## dataset_name = f"{dataset_name}_Table" -## else: -## pass -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del dataset_md, _tags -## -## elif "LayerSpeciesYearImageName" in dataset_name: -## -## arcpy.AddMessage(f"\tLayer Species Year Image Name") -## -## layer_species_year_image_name_template = rf"{metadata_folder}\layer_species_year_image_name_template.xml" -## template_md = md.Metadata(layer_species_year_image_name_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## del empty_md, template_md, layer_species_year_image_name_template -## -## # Max-Min Year range table -## years_md = unique_years(dataset_path) -## _tags = f", {min(years_md)} to {max(years_md)}" -## del years_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del dataset_md, _tags -## -## elif dataset_name.endswith("Boundary"): -## -## arcpy.AddMessage(f"\tBoundary") -## -## boundary_template = rf"{metadata_folder}\boundary_template.xml" -## template_md = md.Metadata(boundary_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## del empty_md, template_md, boundary_template -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del dataset_md -## -## elif dataset_name.endswith("Extent_Points"): -## -## arcpy.AddMessage(f"\tExtent_Points") -## -## extent_points_template = rf"{metadata_folder}\extent_points_template.xml" -## template_md = md.Metadata(extent_points_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## del empty_md, template_md, extent_points_template -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del dataset_md -## -## elif dataset_name.endswith("Fishnet"): -## -## arcpy.AddMessage(f"\tFishnet") -## -## fishnet_template = rf"{metadata_folder}\fishnet_template.xml" -## template_md = md.Metadata(fishnet_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## del empty_md, template_md, fishnet_template -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del dataset_md -## -## elif dataset_name.endswith("Lat_Long"): -## -## arcpy.AddMessage(f"\tLat_Long") -## -## lat_long_template = rf"{metadata_folder}\lat_long_template.xml" -## template_md = md.Metadata(lat_long_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## del empty_md, template_md, lat_long_template -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del dataset_md -## -## elif dataset_name.endswith("Region"): -## -## arcpy.AddMessage(f"\tRegion") -## -## region_template = rf"{metadata_folder}\region_template.xml" -## template_md = md.Metadata(region_template) -## -## dataset_md = md.Metadata(dataset_path) -## dataset_md.copy(template_md) -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del template_md, region_template -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del dataset_md -## -## elif dataset_name.endswith("Sample_Locations"): -## -## arcpy.AddMessage(f"\tSample_Locations") -## -## sample_locations_template = rf"{metadata_folder}\sample_locations_template.xml" -## template_md = md.Metadata(sample_locations_template) -## -## dataset_md = md.Metadata(dataset_path) -## dataset_md.copy(template_md) -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## del template_md, sample_locations_template -## -## # Max-Min Year range table -## years_md = unique_years(dataset_path) -## _tags = f", {min(years_md)} to {max(years_md)}" -## del years_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del dataset_md, _tags -## -#### elif dataset_name.endswith("GRID_Points"): -#### -#### arcpy.AddMessage(f"\tGRID_Points") -#### -#### grid_points_template = rf"{metadata_folder}\grid_points_template.xml" -#### template_md = md.Metadata(grid_points_template) -#### -#### dataset_md = md.Metadata(dataset_path) -#### empty_md = md.Metadata() -#### dataset_md.copy(empty_md) -#### dataset_md.save() -#### dataset_md.copy(template_md) -#### dataset_md.save() -#### del empty_md, template_md, grid_points_template -#### -#### # Max-Min Year range table -#### years_md = unique_years(dataset_path) -#### _tags = f", {min(years_md)} to {max(years_md)}" -#### del years_md -#### -#### dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -#### dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags -#### dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -#### dataset_md.description = metadata_dictionary[dataset_name]["Description"] -#### dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -#### dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -#### dataset_md.save() -#### -#### dataset_md.synchronize("ALWAYS") -#### -#### del dataset_md, _tags -## -## elif "DisMAP_Regions" == dataset_name: -## -## arcpy.AddMessage(f"\tDisMAP_Regions") -## -## dismap_regions_template = rf"{metadata_folder}\dismap_regions_template.xml" -## template_md = md.Metadata(dismap_regions_template) -## -## dataset_md = md.Metadata(dataset_path) -## dataset_md.copy(template_md) -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del template_md, dismap_regions_template -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## dataset_md.synchronize("ALWAYS") -## dataset_md.save() -## -## del dataset_md -## -## elif dataset_name.endswith("Bathymetry"): -## -## arcpy.AddMessage(f"\tBathymetry") -## -## bathymetry_template = rf"{metadata_folder}\bathymetry_template.xml" -## template_md = md.Metadata(bathymetry_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## del empty_md, template_md, bathymetry_template -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## -## dataset_md.synchronize("ALWAYS") -## -## del dataset_md -## -## elif dataset_name.endswith("Latitude"): -## -## arcpy.AddMessage(f"\tLatitude") -## -## latitude_template = rf"{metadata_folder}\latitude_template.xml" -## template_md = md.Metadata(latitude_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## del empty_md, template_md, latitude_template -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## -## dataset_md.synchronize("ALWAYS") -## -## del dataset_md -## -## elif dataset_name.endswith("Longitude"): -## -## arcpy.AddMessage(f"\tLongitude") -## -## longitude_template = rf"{metadata_folder}\longitude_template.xml" -## template_md = md.Metadata(longitude_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## del empty_md, template_md, longitude_template -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## -## dataset_md.synchronize("ALWAYS") -## -## del dataset_md -## -## elif dataset_name.endswith("Raster_Mask"): -## -## arcpy.AddMessage(f"\tRaster_Mask") -## -## raster_mask_template = rf"{metadata_folder}\raster_mask_template.xml" -## template_md = md.Metadata(raster_mask_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## del empty_md, template_md, raster_mask_template -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## -## dataset_md.synchronize("ALWAYS") -## -## del dataset_md -## -## elif dataset_name.endswith("Mosaic"): -## -## arcpy.AddMessage(f"\tMosaic") -## -## mosaic_template = rf"{metadata_folder}\mosaic_template.xml" -## template_md = md.Metadata(mosaic_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## del empty_md, template_md, mosaic_template -## -## # Max-Min Year range table -## years_md = unique_years(dataset_path) -## _tags = f", {min(years_md)} to {max(years_md)}" -## del years_md -## -## dataset_md.title = metadata_dictionary[dataset_name]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name]["Tags"] + _tags -## dataset_md.summary = metadata_dictionary[dataset_name]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name]["Access Constraints"] -## dataset_md.save() -## -## dataset_md.synchronize("ALWAYS") -## -## del dataset_md, _tags -## -## elif dataset_name.endswith(".crf"): -## -## arcpy.AddMessage(f"\tCRF") -## #arcpy.AddMessage(dataset_name) -## #arcpy.AddMessage(dataset_path) -## #dataset_path = dataset_path.replace(crfs_folder, project_gdb).replace(".crf", "_Mosaic") -## #arcpy.AddMessage(dataset_path) -## -## crf_template = rf"{metadata_folder}\crf_template.xml" -## template_md = md.Metadata(crf_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## del empty_md, template_md, crf_template -## -## # Max-Min Year range table -## years_md = unique_years(dataset_path.replace(crfs_folder, project_gdb).replace(".crf", "_Mosaic")) -## _tags = f", {min(years_md)} to {max(years_md)}" -## del years_md -## -## dataset_md.title = metadata_dictionary[dataset_name.replace(".crf", "_CRF")]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[dataset_name.replace(".crf", "_CRF")]["Tags"] + _tags -## dataset_md.summary = metadata_dictionary[dataset_name.replace(".crf", "_CRF")]["Summary"] -## dataset_md.description = metadata_dictionary[dataset_name.replace(".crf", "_CRF")]["Description"] -## dataset_md.credits = metadata_dictionary[dataset_name.replace(".crf", "_CRF")]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[dataset_name.replace(".crf", "_CRF")]["Access Constraints"] -## dataset_md.save() -## -## dataset_md.synchronize("ALWAYS") -## -## del dataset_md, _tags -## -## else: -## arcpy.AddMessage(f"\tRegion Table") -## -## if dataset_name.endswith("IDW"): -## -## idw_region_table_template = rf"{metadata_folder}\idw_region_table_template.xml" -## template_md = md.Metadata(idw_region_table_template) -## -## dataset_md = md.Metadata(dataset_path) -## empty_md = md.Metadata() -## dataset_md.copy(empty_md) -## dataset_md.save() -## dataset_md.copy(template_md) -## dataset_md.save() -## del empty_md, template_md, idw_region_table_template -## -## # Max-Min Year range table -## years_md = unique_years(dataset_path) -## _tags = f", {min(years_md)} to {max(years_md)}" -## del years_md -## -## dataset_md.title = metadata_dictionary[f"{dataset_name}"]["Dataset Service Title"] -## dataset_md.tags = metadata_dictionary[f"{dataset_name}"]["Tags"] + _tags -## dataset_md.summary = metadata_dictionary[f"{dataset_name}"]["Summary"] -## dataset_md.description = metadata_dictionary[f"{dataset_name}"]["Description"] -## dataset_md.credits = metadata_dictionary[f"{dataset_name}"]["Credits"] -## dataset_md.accessConstraints = metadata_dictionary[f"{dataset_name}"]["Access Constraints"] -## dataset_md.save() -## -## dataset_md.synchronize("ALWAYS") -## -## del dataset_md, _tags -## -#### elif dataset_name.endswith("GLMME"): -#### -#### glmme_region_table_template = rf"{metadata_folder}\glmme_region_table_template.xml" -#### template_md = md.Metadata(glmme_region_table_template) -#### -#### dataset_md = md.Metadata(dataset_path) -#### empty_md = md.Metadata() -#### dataset_md.copy(empty_md) -#### dataset_md.save() -#### dataset_md.copy(template_md) -#### dataset_md.save() -#### del empty_md, template_md, glmme_region_table_template -#### -#### # Max-Min Year range table -#### years_md = unique_years(dataset_path) -#### _tags = f", {min(years_md)} to {max(years_md)}" -#### del years_md -#### -#### dataset_md.title = metadata_dictionary[f"{dataset_name}"]["Dataset Service Title"] -#### dataset_md.tags = metadata_dictionary[f"{dataset_name}"]["Tags"] + _tags -#### dataset_md.summary = metadata_dictionary[f"{dataset_name}"]["Summary"] -#### dataset_md.description = metadata_dictionary[f"{dataset_name}"]["Description"] -#### dataset_md.credits = metadata_dictionary[f"{dataset_name}"]["Credits"] -#### dataset_md.accessConstraints = metadata_dictionary[f"{dataset_name}"]["Access Constraints"] -#### dataset_md.save() -#### -#### dataset_md.synchronize("ALWAYS") -#### -#### del dataset_md, _tags -## -## else: -## pass -## del dataset_name, dataset_path -## del workspace -## -## base_project_folder = os.path.dirname(os.path.dirname(__file__)) -## -## #parse_xml_file_format_and_saves(rf"{base_project_folder}\{project}\Current Metadata") -## -## del datasets -## -## # Declared Variables set in function -## del project_gdb, base_project_folder, metadata_folder -## del project_folder, scratch_folder, crfs_folder -## del metadata_dictionary, workspaces -## -## # Imports -## del dataset_title_dict, parse_xml_file_format_and_saves, unique_years -## del md -## -## # Function Parameters -## del base_project_file, project -## -## except KeyboardInterrupt: -## sys.exit() -## except arcpy.ExecuteWarning: -## arcpy.AddWarning(arcpy.GetMessages(1)) -## except arcpy.ExecuteError: -## arcpy.AddError(arcpy.GetMessages(2)) -## traceback.print_exc() -## sys.exit() -## except SystemExit: -## arcpy.AddError(arcpy.GetMessages(2)) -## traceback.print_exc() -## sys.exit() -## except Exception: -## arcpy.AddError(arcpy.GetMessages(2)) -## traceback.print_exc() -## sys.exit() -## except: -## arcpy.AddError(arcpy.GetMessages(2)) -## traceback.print_exc() -## sys.exit() -## else: -## # While in development, leave here. For test, move to finally -## rk = [key for key in locals().keys() if not key.startswith('__')] -## if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk -## return True -## finally: -## pass - -def create_maps(project_gdb=""): - try: - # Import - from arcpy import metadata as md - - from dismap_tools import dataset_title_dict, parse_xml_file_format_and_save - - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - arcpy.SetLogMetadata(True) - arcpy.SetSeverityLevel(2) - arcpy.SetMessageLevels(['NORMAL']) # NORMAL, COMMANDSYNTAX, DIAGNOSTICS, PROJECTIONTRANSFORMATION - - # Map Cleanup - MapCleanup = False - if MapCleanup: - map_cleanup(base_project_file) - del MapCleanup - - base_project_folder = rf"{os.path.dirname(base_project_file)}" - base_project_file = rf"{base_project_folder}\DisMAP.aprx" - project_folder = rf"{base_project_folder}\{project}" - project_gdb = rf"{project_folder}\{project}.gdb" - metadata_folder = rf"{project_folder}\Export Metadata" - scratch_folder = rf"{project_folder}\Scratch" - - arcpy.env.workspace = project_gdb - arcpy.env.scratchWorkspace = rf"{scratch_folder}\scratch.gdb" - - aprx = arcpy.mp.ArcGISProject(base_project_file) - home_folder = aprx.homeFolder - - #arcpy.AddMessage(f"\n{'-' * 90}\n") - - metadata_dictionary = dataset_title_dict(project_gdb) - - datasets = list() - - walk = arcpy.da.Walk(project_gdb) - - for dirpath, dirnames, filenames in walk: - for filename in filenames: - datasets.append(os.path.join(dirpath, filename)) - del filename - del dirpath, dirnames, filenames - del walk - - for dataset_path in sorted(datasets): - arcpy.AddMessage(dataset_path) - dataset_name = os.path.basename(dataset_path) - data_type = arcpy.Describe(dataset_path).dataType - if data_type == "Table": - #arcpy.AddMessage(f"Dataset Name: {dataset_name}") - #arcpy.AddMessage(f"\tData Type: {data_type}") - - if "IDW" in dataset_name: - arcpy.AddMessage(f"Dataset Name: {dataset_name}") - if "Indicators" in dataset_name: - arcpy.AddMessage(f"\tRegion Indicators") - - elif "LayerSpeciesYearImageName" in dataset_name: - arcpy.AddMessage(f"\tRegion Layer Species Year Image Name") - - else: - arcpy.AddMessage(f"\tRegion Table") - -## elif "GLMME" in dataset_name: -## arcpy.AddMessage(f"Dataset Name: {dataset_name}") -## if "Indicators" in dataset_name: -## arcpy.AddMessage(f"\tGLMME Region Indicators") -## -## elif "LayerSpeciesYearImageName" in dataset_name: -## arcpy.AddMessage(f"\tGLMME Layer Species Year Image Name") -## -## else: -## arcpy.AddMessage(f"\tGLMME Region Table") - - else: - arcpy.AddMessage(f"Dataset Name: {dataset_name}") - if "Indicators" in dataset_name: - arcpy.AddMessage(f"\tMain Indicators Table") - - elif "LayerSpeciesYearImageName" in dataset_name: - arcpy.AddMessage(f"\tLayer Species Year Image Name") - - elif "Datasets" in dataset_name: - arcpy.AddMessage(f"\tDataset Table") - - elif "Species_Filter" in dataset_name: - arcpy.AddMessage(f"\tSpecies Filter Table") - - else: - arcpy.AddMessage(f"\tDataset Name: {dataset_name}") - - elif data_type == "FeatureClass": - #arcpy.AddMessage(f"\tData Type: {data_type}") - - if "IDW" in dataset_name: - arcpy.AddMessage(f"Dataset Name: {dataset_name}") - if dataset_name.endswith("Boundary"): - arcpy.AddMessage(f"\tBoundary") - - elif dataset_name.endswith("Extent_Points"): - arcpy.AddMessage(f"\tExtent_Points") - - elif dataset_name.endswith("Fishnet"): - arcpy.AddMessage(f"\tFishnet") - - elif dataset_name.endswith("Lat_Long"): - arcpy.AddMessage(f"\tLat_Long") - - elif dataset_name.endswith("Region"): - arcpy.AddMessage(f"\tRegion") - - elif dataset_name.endswith("Sample_Locations"): - arcpy.AddMessage(f"\tSample_Locations") - - else: - pass - -## elif "GLMME" in dataset_name: -## arcpy.AddMessage(f"Dataset Name: {dataset_name}") -## if dataset_name.endswith("Boundary"): -## arcpy.AddMessage(f"\tBoundary") -## -## elif dataset_name.endswith("Extent_Points"): -## arcpy.AddMessage(f"\tExtent_Points") -## -## elif dataset_name.endswith("Fishnet"): -## arcpy.AddMessage(f"\tFishnet") -## -## elif dataset_name.endswith("Lat_Long"): -## arcpy.AddMessage(f"\tLat_Long") -## -## elif dataset_name.endswith("Region"): -## arcpy.AddMessage(f"\tRegion") -## -## elif dataset_name.endswith("GRID_Points"): -## arcpy.AddMessage(f"\tGRID_Points") -## -## else: -## pass - - elif "DisMAP_Regions" == dataset_name: - arcpy.AddMessage(f"Dataset Name: {dataset_name}") - if dataset_name.endswith("Regions"): - arcpy.AddMessage(f"\tDisMAP Regions") - - else: - arcpy.AddMessage(f"Else Dataset Name: {dataset_name}") - - elif data_type == "RasterDataset": - - if "IDW" in dataset_name: - arcpy.AddMessage(f"Dataset Name: {dataset_name}") - if dataset_name.endswith("Bathymetry"): - arcpy.AddMessage(f"\tBathymetry") - - elif dataset_name.endswith("Latitude"): - arcpy.AddMessage(f"\tLatitude") - - elif dataset_name.endswith("Longitude"): - arcpy.AddMessage(f"\tLongitude") - - elif dataset_name.endswith("Raster_Mask"): - arcpy.AddMessage(f"\tRaster_Mask") - -## elif "GLMME" in dataset_name: -## arcpy.AddMessage(f"Dataset Name: {dataset_name}") -## if dataset_name.endswith("Bathymetry"): -## arcpy.AddMessage(f"\tBathymetry") -## -## elif dataset_name.endswith("Latitude"): -## arcpy.AddMessage(f"\tLatitude") -## -## elif dataset_name.endswith("Longitude"): -## arcpy.AddMessage(f"\tLongitude") -## -## elif dataset_name.endswith("Raster_Mask"): -## arcpy.AddMessage(f"\tRaster_Mask") - else: - pass - - elif data_type == "MosaicDataset": - - if "IDW" in dataset_name: - arcpy.AddMessage(f"Dataset Name: {dataset_name}") - if dataset_name.endswith("Mosaic"): - arcpy.AddMessage(f"\tMosaic") - -## elif "GLMME" in dataset_name: -## arcpy.AddMessage(f"Dataset Name: {dataset_name}") -## if dataset_name.endswith("Mosaic"): -## arcpy.AddMessage(f"\tMosaic") - - elif "CRF" in dataset_name: - arcpy.AddMessage(f"Dataset Name: {dataset_name}") - if dataset_name.endswith("CRF"): - arcpy.AddMessage(f"\tCRF") - - else: - pass - else: - pass - - del data_type - - del dataset_name, dataset_path - del datasets - -## # DatasetCode, CSVFile, TransformUnit, TableName, GeographicArea, CellSize, -## # PointFeatureType, FeatureClassName, Region, Season, DateCode, Status, -## # DistributionProjectCode, DistributionProjectName, SummaryProduct, -## # FilterRegion, FilterSubRegion, FeatureServiceName, FeatureServiceTitle, -## # MosaicName, MosaicTitle, ImageServiceName, ImageServiceTitle -## -## # Get values for table_name from Datasets table -## #fields = ["FeatureClassName", "FeatureServiceName", "FeatureServiceTitle"] -## fields = ["DatasetCode", "PointFeatureType", "FeatureClassName", "Region", "Season", "DateCode", "DistributionProjectCode"] -## datasets = [row for row in arcpy.da.SearchCursor(rf"{project_gdb}\Datasets", fields, where_clause = f"FeatureClassName IS NOT NULL AND DistributionProjectCode NOT IN ('GLMME', 'GFDL')")] -## #datasets = [row for row in arcpy.da.SearchCursor(rf"{project_gdb}\Datasets", fields, where_clause = f"FeatureClassName IS NOT NULL and TableName = 'AI_IDW'")] -## del fields -## -## for dataset in datasets: -## dataset_code, point_feature_type, feature_class_name, region_latitude, season, date_code, distribution_project_code = dataset -## -## feature_service_name = f"{dataset_code}_{point_feature_type}_{date_code}".replace("None", "").replace(" ", "_").replace("__", "_") -## -## if distribution_project_code == "IDW": -## feature_service_title = f"{region_latitude} {season} {point_feature_type} {date_code}".replace("None", "").replace(" ", " ") -## elif distribution_project_code in ["GLMME", "GFDL"]: -## feature_service_title = f"{region_latitude} {distribution_project_code} {point_feature_type} {date_code}".replace("None", "").replace(" ", " ") -## else: -## feature_service_title = f"{feature_service_name}".replace("_", " ") -## -## map_title = feature_service_title.replace("GRID Points", "").replace("Sample Locations", "").replace(" ", " ") -## -## feature_class_path = f"{project_gdb}\{feature_class_name}" -## -## arcpy.AddMessage(f"Dataset Code: {dataset_code}") -## arcpy.AddMessage(f"\tFeature Service Name: {feature_service_name}") -## arcpy.AddMessage(f"\tFeature Service Title: {feature_service_title}") -## arcpy.AddMessage(f"\tMap Title: {map_title}") -## arcpy.AddMessage(f"\tFeature Class Name: {feature_class_name}") -## arcpy.AddMessage(f"\tFeature Class Path: {feature_class_path}") -## -## height = arcpy.Describe(feature_class_path).extent.YMax - arcpy.Describe(feature_class_path).extent.YMin -## width = arcpy.Describe(feature_class_path).extent.XMax - arcpy.Describe(feature_class_path).extent.XMin -## -## # map_width, map_height -## map_width, map_height = 2, 3 -## #map_width, map_height = 8.5, 11 -## -## if height > width: -## page_height = map_height; page_width = map_width -## elif height < width: -## page_height = map_width; page_width = map_height -## else: -## page_width = map_width; page_height = map_height -## -## del map_width, map_height -## del height, width -## -## if map_title not in [cm.name for cm in aprx.listMaps()]: -## arcpy.AddMessage(f"Creating Map: {map_title}") -## aprx.createMap(f"{map_title}", "Map") -## aprx.save() -## -## if map_title not in [cl.name for cl in aprx.listLayouts()]: -## arcpy.AddMessage(f"Creating Layout: {map_title}") -## aprx.createLayout(page_width, page_height, "INCH", f"{map_title}") -## aprx.save() -## -## del feature_service_name, feature_service_title -## del dataset_code, point_feature_type, feature_class_name, region_latitude, season -## del date_code, distribution_project_code -## -## current_map = [cm for cm in aprx.listMaps() if cm.name == map_title][0] -## arcpy.AddMessage(f"Current Map: {current_map.name}") -## -## feature_class_layer = arcpy.management.MakeFeatureLayer(feature_class_path, f"{map_title}") -## -## feature_class_layer_file = arcpy.management.SaveToLayerFile(feature_class_layer, rf"{project_folder}\Layers\{feature_class_layer}.lyrx") -## del feature_class_layer_file -## -## feature_class_layer_file = arcpy.mp.LayerFile(rf"{project_folder}\Layers\{feature_class_layer}.lyrx") -## -## arcpy.management.Delete(feature_class_layer) -## del feature_class_layer -## -## current_map.addLayer(feature_class_layer_file) -## del feature_class_layer_file -## -## #aprx_basemaps = aprx.listBasemaps() -## #basemap = 'GEBCO Basemap/Contours (NOAA NCEI Visualization)' -## basemap = "Terrain with Labels" -## -## current_map.addBasemap(basemap) -## del basemap -## -## #current_map_view = current_map.defaultView -## #current_map_view.exportToPNG(rf"{project_folder}\Layers\{map_title}.png", width=200, height=133, resolution = 96, color_mode="24-BIT_TRUE_COLOR", embed_color_profile=True) -## #del current_map_view -## -## # # from arcpy import metadata as md -## # # -## # # fc_md = md.Metadata(feature_class_path) -## # # fc_md.thumbnailUri = rf"{project_folder}\Layers\{map_title}.png" -## # # fc_md.save() -## # # del fc_md -## # # del md -## -## aprx.save() -## -## current_layout = [cl for cl in aprx.listLayouts() if cl.name == map_title][0] -## arcpy.AddMessage(f"Current Layout: {current_layout.name}") -## -## current_layout.openView() -## -## arcpy.AddMessage(f"Create a new map frame using a point geometry") -## #Create a new map frame using a point geometry -## mf1 = current_layout.createMapFrame(arcpy.Point(0.01,0.01), current_map, 'New MF - Point') -## #mf1.elementWidth = 10 -## #mf1.elementHeight = 7.5 -## mf1.elementWidth = page_width - 0.01 -## mf1.elementHeight = page_height - 0.01 -## -## lyr = current_map.listLayers(f"{map_title}")[0] -## -## #Zoom to ALL selected features and export to PDF -## arcpy.SelectLayerByAttribute_management(lyr, 'NEW_SELECTION') -## mf1.zoomToAllLayers(True) -## arcpy.SelectLayerByAttribute_management(lyr, 'CLEAR_SELECTION') -## -## #Set the map frame extent to the extent of a layer and export to PDF -## mf1.camera.setExtent(mf1.getLayerExtent(lyr, False, True)) -## mf1.camera.scale = mf1.camera.scale * 1.1 #add a slight buffer -## -## del lyr -## -## arcpy.AddMessage(f"Create a new bookmark set to the map frame's default extent") -## #Create a new bookmark set to the map frame's default extent -## bkmk = mf1.createBookmark('Default Extent', "The map's default extent") -## bkmk.updateThumbnail() -## del mf1 -## del bkmk -## -## #Create point text element using a system style item -## #txtStyleItem = aprx.listStyleItems('ArcGIS 2D', 'TEXT', 'Title (Serif)')[0] -## #ptTxt = aprx.createTextElement(current_layout, arcpy.Point(5.5, 4.25), 'POINT', f'{map_title}', 10, style_item=txtStyleItem) -## #del txtStyleItem -## -## #Change the anchor position and reposition the text to center -## #ptTxt.setAnchor('Center_Point') -## #ptTxt.elementPositionX = page_width / 2.0 -## #ptTxt.elementPositionY = page_height - 0.25 -## #del ptTxt -## -## #arcpy.AddMessage(f"Using CIM to update border") -## #current_layout_cim = current_layout.getDefinition('V3') -## #for elm in current_layout_cim.elements: -## # if type(elm).__name__ == 'CIMMapFrame': -## # if elm.graphicFrame.borderSymbol.symbol.symbolLayers: -## # sym = elm.graphicFrame.borderSymbol.symbol.symbolLayers[0] -## # sym.width = 5 -## # sym.color.values = [255, 0, 0, 100] -## # else: -## # arcpy.AddWarning(elm.name + ' has NO symbol layers') -## #current_layout.setDefinition(current_layout_cim) -## #del current_layout_cim, elm, sym -## -## ExportLayout = True -## if ExportLayout: -## #Export the resulting imported layout and changes to JPEG -## arcpy.AddMessage(f"Exporting '{current_layout.name}'") -## current_layout.exportToJPEG(rf"{project_folder}\Layouts\{current_layout.name}.jpg") -## del ExportLayout -## -## -## from arcpy import metadata as md -## -## fc_md = md.Metadata(feature_class_path) -## #fc_md.thumbnailUri = rf"{project_folder}\Layers\{map_title}.png" -## fc_md.thumbnailUri = rf"{project_folder}\Layouts\{current_layout.name}.jpg" -## fc_md.save() -## del fc_md -## del md -## -## aprx.save() -## -## aprx.deleteItem(current_map); del current_map -## aprx.deleteItem(current_layout); del current_layout -## -## del page_width, page_height -## del map_title, feature_class_path -## del dataset -## del datasets -## -## # TODO: Possibly create a dictionary that can be saved to JSON -## -## aprx.save() -## -## arcpy.AddMessage(f"\nCurrent Maps & Layouts") -## -## current_maps = aprx.listMaps() -## current_layouts = aprx.listLayouts() -## -## if current_maps: -## arcpy.AddMessage(f"\nCurrent Maps\n") -## for current_map in current_maps: -## arcpy.AddMessage(f"\tProject Map: {current_map.name}") -## del current_map -## else: -## arcpy.AddWarning("No maps in Project") -## -## if current_layouts: -## arcpy.AddMessage(f"\nCurrent Layouts\n") -## for current_layout in current_layouts: -## arcpy.AddMessage(f"\tProject Layout: {current_layout.name}") -## del current_layout -## else: -## arcpy.AddWarning("No layouts in Project") -## -## arcpy.AddMessage(f"\n{'-' * 90}\n") -## -## del current_layouts, current_maps - - # Declared Variables set in function for aprx - del home_folder - # Save aprx one more time and then delete - aprx.save() - del aprx - - # Declared Variables set in function - del base_project_folder, metadata_folder - del project_folder, scratch_folder - del metadata_dictionary - - # Imports - del dismap_tools, dataset_title_dict, md - - # Function Parameters - del project_gdb - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -def script_tool(project_gdb=""): - try: - # Imports - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - arcpy.AddMessage(f"{'-' * 80}") - arcpy.AddMessage(f"Python Script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - arcpy.AddMessage(f"Python Version: {sys.version}") - arcpy.AddMessage(f"Environment: {os.path.basename(sys.exec_prefix)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"{'-' * 80}\n") - - # Set varaibales - project_folder = os.path.dirname(project_gdb) - scratch_folder = rf"{project_folder}\Scratch" - del project_folder - - # Create project scratch workspace, if missing - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - if not arcpy.Exists(scratch_folder): - os.makedirs(rf"{scratch_folder}") - if not arcpy.Exists(rf"{scratch_folder}\scratch.gdb"): - arcpy.management.CreateFileGDB(rf"{scratch_folder}", f"scratch") - del scratch_folder - - # Set basic arcpy.env variables - arcpy.env.overwriteOutput = True - arcpy.env.parallelProcessingFactor = "100%" - - try: - - CreateFeatureClassLayers = False - if CreateFeatureClassLayers: - create_feature_class_layers(project_gdb=project_gdb) - del CreateFeatureClassLayers - - CreateFeaturClasseServices = False - if CreateFeaturClasseServices: - create_feature_class_services(project_gdb=project_gdb) - del CreateFeaturClasseServices - - CreateImagesServices = False - if CreateImagesServices: - create_image_services(project_gdb=project_gdb) - del CreateImagesServices - - # UpdateMetadataFromPublishedMd = False - # if UpdateMetadataFromPublishedMd: - # update_metadata_from_published_md(project_gdb=project_gdb) - # del UpdateMetadataFromPublishedMd - - CreateMaps = False - if CreateMaps: - create_maps(project_gdb=project_gdb) - del CreateMaps - -## CreateBasicTemplateXMLFiles = False -## if CreateBasicTemplateXMLFiles: -## create_basic_template_xml_files(project_gdb=project_gdb) -## del CreateBasicTemplateXMLFiles -## -## ImportBasicTemplateXmlFiles = False -## if ImportBasicTemplateXmlFiles: -## import_basic_template_xml_files(project_gdb=project_gdb) -## del ImportBasicTemplateXmlFiles - - except SystemExit: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - - # Variable created in function - # - # Function Parameters - del project_gdb - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - hours, rem = divmod(end_time-start_time, 3600) - minutes, seconds = divmod(rem, 60) - arcpy.AddMessage(f"\n{'-' * 80}") - arcpy.AddMessage(f"Python script: {os.path.basename(__file__)}") - arcpy.AddMessage(f"Start Time: {strftime('%a %b %d %I:%M %p', localtime(start_time))}") - arcpy.AddMessage(f"End Time: {strftime('%a %b %d %I:%M %p', localtime(end_time))}") - arcpy.AddMessage(f"Elapsed Time {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f} (H:M:S)") - arcpy.AddMessage(f"{'-' * 80}") - del hours, rem, minutes, seconds - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - - except KeyboardInterrupt: - sys.exit() - except arcpy.ExecuteWarning: - arcpy.AddWarning(f"Caught an arcpy.ExecuteWarning error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(f"Caught an arcpy.ExecuteError error in the '{inspect.stack()[0][3]}' function.") - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - sys.exit() - except SystemExit as se: - arcpy.AddError(f"Caught an SystemExit error: {se} in the '{inspect.stack()[0][3]}' function.") - sys.exit() - except Exception as e: - arcpy.AddError(f"Caught an Exception error: {e} in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - except: - arcpy.AddError(f"Caught an except error in the '{inspect.stack()[0][3]}' function.") - traceback.print_exc() - sys.exit() - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: arcpy.AddMessage(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == '__main__': - try: - project_gdb = arcpy.GetParameterAsText(0) - if not project_gdb: - project_gdb = rf"{os.path.expanduser('~')}\Documents\ArcGIS\Projects\DisMAP\ArcGIS-Analysis-Python\August 1 2025\August 1 2025.gdb" - else: - pass - script_tool(project_gdb) - arcpy.SetParameterAsText(1, "Result") - del project_gdb - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/ArcGIS-Analysis-Python/src/dismap_tools/zip_and_unzip_shapefile_data.py b/ArcGIS-Analysis-Python/src/dismap_tools/zip_and_unzip_shapefile_data.py deleted file mode 100644 index 8e8b613..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools/zip_and_unzip_shapefile_data.py +++ /dev/null @@ -1,61 +0,0 @@ -""" -Script documentation -- Tool parameters are accessed using arcpy.GetParameter() or - arcpy.GetParameterAsText() -- Update derived parameter values using arcpy.SetParameter() or - arcpy.SetParameterAsText() -""" -import traceback -import arcpy -def script_tool(home_folder="", source_zip_file=""): - """Script code goes below""" - try: - import os - import copy - from zipfile import ZipFile - #aprx = arcpy.mp.ArcGISProject("CURRENT") - #aprx.save() - #home_folder = aprx.homeFolder - arcpy.AddMessage(home_folder) - out_data_path = rf"{home_folder}\Dataset_Shapefiles" - arcpy.AddMessage(out_data_path) - # Change Directory - os.chdir(out_data_path) - arcpy.AddMessage(f"Un-Zipping files from {os.path.basename(source_zip_file)}") - with ZipFile(source_zip_file, mode="r") as archive: - for file in archive.namelist(): - archive.extract(file, ".") - del file - del archive - arcpy.AddMessage(f"Done Un-Zipping files from {os.path.basename(source_zip_file)}") - del home_folder - del source_zip_file - return out_data_path - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - else: - pass - finally: - pass - #del out_data_path -if __name__ == "__main__": - try: - home_folder = arcpy.GetParameterAsText(0) - source_zip_file = arcpy.GetParameterAsText(1) - script_tool(home_folder, source_zip_file) - arcpy.SetParameterAsText(2, "Result") - del home_folder, source_zip_file - except arcpy.ExecuteWarning: - arcpy.AddWarning(arcpy.GetMessages(1)) - except arcpy.ExecuteError: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() - except: - arcpy.AddError(arcpy.GetMessages(2)) - traceback.print_exc() diff --git a/ArcGIS-Analysis-Python/src/dismap_tools_dev/dev_dismap_director.py b/ArcGIS-Analysis-Python/src/dismap_tools_dev/dev_dismap_director.py deleted file mode 100644 index 713e42a..0000000 --- a/ArcGIS-Analysis-Python/src/dismap_tools_dev/dev_dismap_director.py +++ /dev/null @@ -1,464 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------- -# Name: dismap.py -# Purpose: Common DisMAP functions -# -# Author: john.f.kennedy -# -# Created: 12/01/2024 -# Copyright: (c) john.f.kennedy 2024 -# Licence: -# ------------------------------------------------------------------------------- -import os, sys # built-ins first -import traceback -import importlib -import inspect - -import arcpy # third-parties second - -def main(project_gdb=""): - try: - from time import gmtime, localtime, strftime, time - # Set a start time so that we can see how log things take - start_time = time() - print(f"{'-' * 80}") - print(f"Python Script: {os.path.basename(__file__)}") - print(f"Location: ..\Documents\ArcGIS\Projects\..\{os.path.basename(os.path.dirname(__file__))}\{os.path.basename(__file__)}") - print(f"Python Version: {sys.version}") - print(f"Environment: {os.path.basename(sys.exec_prefix)}") - print(f"{'-' * 80}\n") - - # Set varaibales - project_folder = os.path.dirname(project_gdb) - project_name = os.path.basename(project_folder) - base_project_folder = os.path.dirname(project_folder) - - # - # Step 0 - create an ArcGIS Project - # - - # ########################################################################## - # Step 1 - update ArcGIS Project with the databases and folders for a given - # ########################################################################## - # project version - DisMapProjectSetup = False - if DisMapProjectSetup: - import dev_dismap_project_setup - base_project_file = rf"{base_project_folder}\DisMAP.aprx" - dev_dismap_project_setup.project_folders(base_project_file, project_name) - # Declared variables - del base_project_file - #Imports - del dev_dismap_project_setup - else: - pass - del DisMapProjectSetup - # ########################################################################## - # Step 2 - zip and unzip the region shapefiles and the CSV data for a given - # ########################################################################## - # project version - ZipAndUnzipCsvData = False - if ZipAndUnzipCsvData: - # Imports - import dev_zip_and_unzip_csv_data - # If "project" is the same, then an archieve file is created. - # If different, then the archieve is created and upzipped in the new - # location - # In Data Path - in_data_path = rf"{project_folder}\CSV Data" - out_data_path = rf"{project_folder}\CSV Data" - selected_files = ["AI_IDW.csv", "Datasets.csv", "EBS_IDW.csv", - "ENBS_IDW.csv", "GMEX_IDW.csv", - "GOA_IDW.csv", "HI_IDW.csv", "NBS_IDW.csv", - "NEUS_FAL_IDW.csv", "NEUS_SPR_IDW.csv", - "SEUS_FAL_IDW.csv", "SEUS_SPR_IDW.csv", - "SEUS_SUM_IDW.csv", "Species_Filter.csv", - "WC_ANN_IDW.csv", "WC_GLMME.csv", - "WC_TRI_IDW.csv", "field_definitions.json", - "metadata_dictionary.json", "table_definitions.json" - ] - selected_files = ";".join(selected_files) - dev_zip_and_unzip_csv_data.main(in_data_path, out_data_path, selected_files) - # Declared variables - del in_data_path, out_data_path, selected_files - # Imports - del dev_zip_and_unzip_csv_data - else: - pass - del ZipAndUnzipCsvData - - ZipAndUnzipShapefileData = False - if ZipAndUnzipShapefileData: - # Imports - import dev_zip_and_unzip_shapefile_data - # If "project_name" is the same, then an archieve file is created. - # If different, then the archieve is created and upzipped in the new - # location - in_data_path = rf"{project_folder}\Dataset_Shapefiles" - out_data_path = rf"{project_folder}\Dataset_Shapefiles" - selected_files = ['AI_IDW_Region.shp', 'EBS_IDW_Region.shp', - 'ENBS_IDW_Region.shp', 'GMEX_IDW_Region.shp', - 'GOA_IDW_Region.shp', 'HI_IDW_Region.shp', - 'NBS_IDW_Region.shp', 'NEUS_FAL_IDW_Region.shp', - 'NEUS_SPR_IDW_Region.shp', 'SEUS_FAL_IDW_Region.shp', - 'SEUS_SPR_IDW_Region.shp', 'SEUS_SUM_IDW_Region.shp', - 'WC_ANN_IDW_Region.shp', 'WC_GFDL_Region.shp', - 'WC_GLMME_Region.shp', 'WC_TRI_IDW_Region.shp',] - selected_files = ";".join(selected_files) - dev_zip_and_unzip_shapefile_data.main(in_data_path, out_data_path, selected_files) - # Declared variables - del in_data_path, out_data_path, selected_files - # Imports - del dev_zip_and_unzip_shapefile_data - del ZipAndUnzipShapefileData - - # ###--->>> - # Write script that checks CSV file headers and updates as necessary - # ###--->>> - # ########################################################################## - # Step 3 - Create base bathymetry datasets in project folder - # ########################################################################## - # ToDo1 CreateBaseBathymetry = False - CreateBaseBathymetry = False - if CreateBaseBathymetry: - # Imports - from dev_create_base_bathymetry import create_alasaka_bathymetry, create_hawaii_bathymetry, gebco_bathymetry - # Process base Alasak bathymetry - create_alasaka_bathymetry(project_gdb) - # Process base Hawaii bathymetry - create_hawaii_bathymetry(project_gdb) - # Process base GEBCO bathymetry - gebco_bathymetry(project_gdb) - # Declared variables - # Imports - del create_alasaka_bathymetry, create_hawaii_bathymetry, gebco_bathymetry - else: - pass - del CreateBaseBathymetry - # ########################################################################## - # Step 4 - import the "Datasets" and the "Species_Filter" table into the - # ########################################################################## - # project GDB - ImportDatasetsSpeciesFilterCsvData = False - if ImportDatasetsSpeciesFilterCsvData: - # Imports - from dev_import_datasets_species_filter_csv_data import update_datecode, worker - from dev_create_table_and_field_definitions_json import generate_data_dictionary - datasets_csv = rf"{project_folder}\CSV_Data\Datasets.csv" - species_filter_csv = rf"{project_folder}\CSV_Data\Species_Filter.csv" - survey_metadata_csv = rf"{project_folder}\CSV_Data\DisMAP_Survey_Info.csv" - # Update DateCode - update_datecode(csv_file=datasets_csv, project_name=project_name) - # Datasets CSV File - worker(project_gdb=project_gdb, csv_file=datasets_csv) - # Species Filter CSV File - worker(project_gdb=project_gdb, csv_file=species_filter_csv) - # DisMAP Survey Info CSV File - worker(project_gdb=project_gdb, csv_file=survey_metadata_csv) - # Generate Table and Field Definitions JSON - generate_data_dictionary(project_gdb) - # Declared variables - del datasets_csv, species_filter_csv, survey_metadata_csv - # Imports - del update_datecode, worker, generate_data_dictionary - else: - pass - del ImportDatasetsSpeciesFilterCsvData - # ########################################################################## - # Step 5 - Create regions from shapefiles - # ########################################################################## - CreateRegionsFromShapefiles = False - if CreateRegionsFromShapefiles: - # Imports - from dev_create_regions_from_shapefiles_director import director - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["WC_TRI_IDW", "AI_IDW"]) - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=[]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateRegionsFromShapefiles - # ########################################################################## - # Step 6 - Create region fishnets - # ########################################################################## - CreateRegionFishnets = False - if CreateRegionFishnets: - from dev_create_region_fishnets_director import director - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["WC_TRI_IDW", "AI_IDW"]) - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW", "HI_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW", "AI_IDW", "GOA_IDW", "WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW"]) - #director(project_gdb=project_gdb, Sequential=False, table_names=[]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateRegionFishnets - # ########################################################################## - # Step 7 - Create Region Bathymetry - # ########################################################################## - CreateRegionBathymetry = False - if CreateRegionBathymetry: - # Imports - from dev_create_region_bathymetry_director import director - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["WC_TRI_IDW", "AI_IDW"]) - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW", "HI_IDW", "SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW", "AI_IDW", "GOA_IDW", "WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW"]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateRegionBathymetry - # ########################################################################## - # Step 8 - create_region_sample_locations_director - # ########################################################################## - CreateRegionSampleLocations = True - if CreateRegionSampleLocations: - # Imports - from dev_create_region_sample_locations_director import director - - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=True, table_names=["WC_TRI_IDW", "AI_IDW"]) - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW", "HI_IDW", "SEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "SEUS_SUM_IDW", "WC_TRI_IDW", "GMEX_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "GOA_IDW", "WC_ANN_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_FAL_IDW", "NEUS_SPR_IDW", "EBS_IDW"]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateRegionSampleLocations - - # ########################################################################## - # Step 9 - Create species year image name table - # ########################################################################## - CreateSpeciesYearImageNameTable = False - if CreateSpeciesYearImageNameTable: - # Imports - from dev_create_species_year_image_name_table_director import director, process_image_name_tables - - Test = False - if Test: - # Debug - director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW",]) - # Debug - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=[]) - else: - pass - del Test - # Combine Image Name Tables - #process_image_name_tables(project_gdb=project_gdb, project=project_name) - - # Declared variables - # Imports - del director, process_image_name_tables - else: - pass - del CreateSpeciesYearImageNameTable - - # ########################################################################## - # Step 10 - Create Rasters - # ########################################################################## - CreateRasters = False - if CreateRasters: - # Imports - from dev_create_rasters_director import director - - Test = False - if Test: - # Debug - director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW",]) - # Debug - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW", "HI_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_FAL_IDW", "SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "AI_IDW", "GMEX_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["GOA_IDW", "WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW",]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateRasters - - # ########################################################################## - # Step 11 - Create Indicators Table - # ########################################################################## - CreateIndicatorsTable = False - if CreateIndicatorsTable: - # Imports - from dev_create_indicators_table_director import director, process_indicator_tables - - Test = False - if Test: - # Debug - director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW",]) - # Debug - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["HI_IDW", "SEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "GOA_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW",]) - - # Combine Indicator Tables - else: - pass - del Test - #process_indicator_tables(project_gdb=project_gdb, project=project) - # Declared variables - # Imports - del director, process_indicator_tables - else: - pass - del CreateIndicatorsTable - - # dataset_comparison - rasters - # dataset_comparison - feature classes - # dataset_comparison - tables - - # Step 12 - Create Species Richness Rasters - CreateSpeciesRichnessRasters = False - if CreateSpeciesRichnessRasters: - # Imports - from dev_create_species_richness_rasters_director import director - - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW",]) - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["HI_IDW", "SEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "GOA_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW",]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateSpeciesRichnessRasters - - # create_mosaics_director - # Step 12 - Create Mosaics - CreateMosaics = False - if CreateMosaics: - # Imports - from dev_create_mosaics_director import director - - Test = False - if Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["GMEX_IDW",]) - elif not Test: - director(project_gdb=project_gdb, Sequential=False, table_names=["NBS_IDW", "ENBS_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["HI_IDW", "SEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["SEUS_SPR_IDW", "SEUS_SUM_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_TRI_IDW", "GMEX_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["AI_IDW", "GOA_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["WC_ANN_IDW", "NEUS_FAL_IDW",]) - director(project_gdb=project_gdb, Sequential=False, table_names=["NEUS_SPR_IDW", "EBS_IDW",]) - else: - pass - del Test - # Declared variables - # Imports - del director - else: - pass - del CreateMosaics - - # publish_to_portal_director - - # Declared Varaiables - del project_name, project_folder - # Imports - # Function Parameters - del project_gdb - - # Elapsed time - end_time = time() - elapse_time = end_time - start_time - print(f"\n{'-' * 80}") - print(f"Python script: {os.path.basename(__file__)}\nCompleted: {strftime('%a %b %d %I:%M %p', localtime())}") - print(u"Elapsed Time {0} (H:M:S)".format(strftime("%H:%M:%S", gmtime(elapse_time)))) - print(f"{'-' * 80}") - del elapse_time, end_time, start_time - del gmtime, localtime, strftime, time - except: - traceback.print_exc() - raise SystemExit - else: - # While in development, leave here. For test, move to finally - rk = [key for key in locals().keys() if not key.startswith('__')] - if rk: print(f"WARNING!! Remaining Keys in the '{inspect.stack()[0][3]}' function at line number {inspect.stack()[0][2]}\n\t##--> '{', '.join(rk)}' <--##"); del rk - return True - finally: - pass - -if __name__ == '__main__': - try: - # Append the location of this scrip to the System Path - sys.path.append(os.path.dirname(os.path.dirname(__file__))) - # Imports - base_project_folder = rf"{os.path.dirname(os.path.dirname(__file__))}" - #project = "May 1 2024" - #project_name = "July 1 2024" - #project_name = "December 1 2024" - #project_name = "June 1 2025" - #for project_name in ["June 1 2025"]: - for project_name in ["December 1 2024", "June 1 2025"]: - project_folder = rf"{base_project_folder}" - project_gdb = rf"{project_folder}\{project_name}\{project_name}.gdb" - main(project_gdb=project_gdb) - del project_gdb, project_folder, project_name - # Decated Variables - del base_project_folder - # Imports - except SystemExit: - pass - except: - traceback.print_exc() - else: - pass - finally: - pass \ No newline at end of file diff --git a/DisMAP.Rproj b/DisMAP.Rproj deleted file mode 100644 index e83436a..0000000 --- a/DisMAP.Rproj +++ /dev/null @@ -1,16 +0,0 @@ -Version: 1.0 - -RestoreWorkspace: Default -SaveWorkspace: Default -AlwaysSaveHistory: Default - -EnableCodeIndexing: Yes -UseSpacesForTab: Yes -NumSpacesForTab: 2 -Encoding: UTF-8 - -RnwWeave: Sweave -LaTeX: pdfLaTeX - -AutoAppendNewline: Yes -StripTrailingWhitespace: Yes diff --git a/README.md b/README.md index 126c271..068162f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# [The Distribution Mapping and Analysis Portal (DisMAP)](https://github.com/nmfs-fish-tools/DisMAP) +# [The Distribution Mapping and Analysis Portal (DisMAP)](https://github.com/nmfs-fish-tools/DisMAP) > This code is always in development. Find code used for various reports in the code [releases](https://github.com/nmfs-fish-tools/DisMAP/releases). @@ -7,14 +7,37 @@ The NOAA Fisheries Distribution Mapping and Analysis Portal (DisMAP) provides ea * Center of biomass * Range limits -This repository provides the data processing and analysis code used to develop the spatial distribution and indicators presented in the portal. For more information and to launch the portal visit: https://apps-st.fisheries.noaa.gov/dismap/index.html. +This repository provides the data processing and analysis code used to develop the spatial distribution and indicators presented in the portal. For more information and to launch the portal visit: https://apps-st.fisheries.noaa.gov/dismap/index.html. Explanation of Folders: 1. data_processing_rcode This folder holds all the R scripts needed to download and process the regional bottom trawl survey data. Opening up the DisMAP_Project Rproject file will open all necessary Rscripts to run the analysis and set up the appropriate directory structure. You will need to follow the instructions in each of the "download_x.R" scripts for each to download or obtain from a regional POC the raw survey data. Once the data is downloaded and in the "data" folder, you may run the Compile_Dismap_Current.R script to process and clean the data. After running Compile_Dismap_Current.R, run the create_data_for_map_generation.R to get the data in the needed file format for use in the Python script and generte the interpolated biomass and indicators (as described below) 2. ArcGIS Analysis - Python -This folder houses the scripts for generating the interpolated biomass and calculating the distribution indicators (latitude, depth, range limits, etc). +This folder houses the scripts for generating the interpolated biomass and calculating the distribution indicators (latitude, depth, range limits, etc). + +## Utility Scripts + +This repository includes utility scripts to help with data management and preparation. + +### `rename_spaces_to_hyphens.py` + +A utility script is provided to rename files and folders by replacing spaces with hyphens. This can be useful for ensuring file path compatibility with certain tools or shell environments that may not handle spaces well. + +- **Location:** `ArcGIS-Analysis-Python/src/dismap_tools/rename_spaces_to_hyphens.py` +- **Purpose:** Recursively finds and renames files and directories under a specified path, replacing spaces in their names with hyphens (`-`). + +**Usage** + +Run the script from your command line, providing the path to the directory you want to process. To see which files and folders would be renamed without actually performing the rename operation, use the `--dry-run` flag. This is recommended before running the script for the first time. + +```bash +# Perform a dry run to preview changes +python ArcGIS-Analysis-Python/src/dismap_tools/rename_spaces_to_hyphens.py --dry-run "C:\path\to\your\data folder" + +# Execute the renaming process +python ArcGIS-Analysis-Python/src/dismap_tools/rename_spaces_to_hyphens.py "C:\path\to\your\data folder" +``` ## Suggestions and Comments @@ -56,4 +79,3 @@ works of the Software outside of the United States. [U.S. Department of Commerce](https://www.commerce.gov/) \| [National Oceanographic and Atmospheric Administration](https://www.noaa.gov) \| [NOAA Fisheries](https://www.fisheries.noaa.gov/) - diff --git a/data_processing_rcode/.gitignore b/data_processing_rcode/.gitignore deleted file mode 100644 index 8259665..0000000 --- a/data_processing_rcode/.gitignore +++ /dev/null @@ -1,43 +0,0 @@ -# History files -.Rhistory -.Rapp.history -.RDataTmp - -# Session Data files -.RData - -# User-specific files -.Ruserdata - -# Example code in package build process -*-Ex.R - -# Output files from R CMD build -/*.tar.gz - -# Output files from R CMD check -/*.Rcheck/ - -# RStudio files -.Rproj.user/ - -# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 -.httr-oauth - -# knitr and R markdown default cache directories -*_cache/ -/cache/ - -# Temporary files created by R markdown -*.utf8.md -*.knit.md - -# R Environment Variables -.Renviron - -/code/.quarto/ -*.zip -*.tex -*.log -*.markdown -*.rmarkdown diff --git a/data_processing_rcode/Add_managed_spp.csv b/data_processing_rcode/Add_managed_spp.csv deleted file mode 100644 index 64fde89..0000000 --- a/data_processing_rcode/Add_managed_spp.csv +++ /dev/null @@ -1,25 +0,0 @@ -region,spp,common -Northeast US Fall,Limulus polyphemus,Horseshoe crab -Northeast US Spring,Limulus polyphemus,Horseshoe crab -Northeast US Fall,Micropogonias undulatus,Atlantic croaker -Northeast US Spring,Micropogonias undulatus,Atlantic croaker -Northeast US Fall,Rhizoprionodon terraenovae,Atlantic sharpnose shark -Gulf of Mexico,Rhizoprionodon terraenovae,Atlantic sharpnose shark -Northeast US Fall,Anarhichas lupus,Atlantic wolffish -Northeast US Spring,Anarhichas lupus,Atlantic wolffish -Northeast US Spring,Chaceon quinquedens,Red deepsea crab -Northeast US Fall,Chaceon quinquedens,Red deepsea crab -Northeast US Spring,Dipturus laevis,Barndoor skate -Northeast US Fall,Dipturus laevis,Barndoor skate -Northeast US Fall,Hippoglossus hippoglossus,Atlantic halibut -Northeast US Spring,Hippoglossus hippoglossus,Atlantic halibut -Northeast US Fall,Leucoraja garmani,Rosette skate -Northeast US Spring,Leucoraja garmani,Rosette skate -Northeast US Fall,Merluccius albidus,Offshore hake -Northeast US Spring,Merluccius albidus,Offshore hake -Northeast US Fall,Phycis chesteri,Longfin hake -Northeast US Spring,Phycis chesteri,Longfin hake -Northeast US Fall,Rostroraja eglanteria,Clearnose skate -Northeast US Spring,Rostroraja eglanteria,Clearnose skate -Gulf of Mexico,Rostroraja eglanteria,Clearnose skate -Gulf of Mexico,Epinephelus morio,Red grouper diff --git a/data_processing_rcode/DisMAP_Tech_Report_2024.pdf b/data_processing_rcode/DisMAP_Tech_Report_2024.pdf deleted file mode 100644 index 93010a3..0000000 Binary files a/data_processing_rcode/DisMAP_Tech_Report_2024.pdf and /dev/null differ diff --git a/data_processing_rcode/Filter_list_Expanded_Survey.csv b/data_processing_rcode/Filter_list_Expanded_Survey.csv deleted file mode 100644 index f81a3aa..0000000 --- a/data_processing_rcode/Filter_list_Expanded_Survey.csv +++ /dev/null @@ -1,1103 +0,0 @@ -,Species,CommonName,TaxonomicGrouping,FilterRegion,FilterSubRegion,ManagementBody,ManagementPlan,DistributionProjectName -1,Abietinaria sp. A (Clark 2006),white tangled hydroid,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Aleutian Islands,,,Not for IDW -2,Albatrossia pectoralis,Giant grenadier,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Aleutian Islands,,,Not for IDW -3,Amphisbetia greenei,Fibre optic hydroid,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Aleutian Islands,,,Not for IDW -4,Anoplopoma fimbria,Sablefish,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -5,Aphrocallistes vastus,Cloud sponge,Porifera (sponges),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -6,Aplidium soldatovi,Sand-grain imbedded ascidian,"Tunicata (sea squirts, tunicates, salps) ",Alaska,Aleutian Islands,,,Not for IDW -7,Aplidium sp. A (Clark 2006),sea glob,"Tunicata (sea squirts, tunicates, salps) ",Alaska,Aleutian Islands,,,Not for IDW -8,Aptocyclus ventricosus,Smooth lumpsucker,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,,,Not for IDW -9,Arctoraja parmifera,Alaska skate,"Elasmobranchii: Batoidea (skates, rays)",Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,Not for IDW -10,Atheresthes stomias and A. evermanni,Arrowtooth and kamchatka flounders,Pleuronectiformes (Flatfishes) ,Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -11,Axinella blanca,Firm finger sponge,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -12,Bathymaster signatus,Searcher,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -13,Bathyraja spp.,Skate complex,"Elasmobranchii: Batoidea (skates, rays)",Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -14,Berryteuthis magister,Magister armhook squid,"Cephalopoda (squid, octopus)",Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -15,Bonneviella sp. A (Clark 2006),champagne flute hydroid,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Aleutian Islands,,,Not for IDW -16,Calcigorgia spiculifera,Pink gorgonian,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Aleutian Islands,,,Not for IDW -17,Callogorgia compressa,NA,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Aleutian Islands,,,Not for IDW -18,Careproctus rastrinus,Salmon snailfish,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,,,Not for IDW -19,Careproctus sp. cf. melanurus (Orr et al.),scorched snailfish,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,,,Not for IDW -20,Ceramaster japonicus,Red cookie star,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,Not for IDW -21,Ceramaster patagonicus,Cookie star,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,Not for IDW -22,Cheiraster (Luidiaster) dawsoni,NA,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,Not for IDW -23,Chionoecetes bairdi,Tanner crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Aleutian Islands,NPFMC,Bering Sea/Aleutian Islands King and Tanner Crabs,NMFS/Rutgers IDW Interpolation -24,Chirona evermanni,Deepwater giant barnacle,Balanomorpha (barnacles),Alaska,Aleutian Islands,,,Not for IDW -25,Chlamys albida,White scallop,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Aleutian Islands,,,Not for IDW -26,Chlamys rubida,Reddish scallop,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Aleutian Islands,,,Not for IDW -27,Chrysaora melanaster,NA,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Aleutian Islands,,,Not for IDW -28,Cladocroce attu,Rough hat sponge,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -29,Crossaster papposus,Common sunstar,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -30,Cucumaria fallax,Sea football,Holothuroidea (sea cucumbers),Alaska,Aleutian Islands,,,Not for IDW -31,Cucumaria frondosa,Orange footed sea cucumber,Holothuroidea (sea cucumbers),Alaska,Aleutian Islands,,,Not for IDW -32,Diplopteraster multipes,Pincushion star,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -33,Elassochirus cavimanus,Purple hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -34,Elassochirus tenuimanus,Widehand hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Aleutian Islands,,,Not for IDW -35,Enteroctopus dofleini,North pacific giant octopus,"Cephalopoda (squid, octopus)",Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -36,Erimacrus isenbeckii,Hair crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Aleutian Islands,,,Not for IDW -37,Eucratea loricata,Feathery bryozoan,Bryozoa,Alaska,Aleutian Islands,,,Not for IDW -38,Eumicrotremus orbis,Pacific spiny lumpsucker,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -39,Eunoe nodosa,Giant scale worm,Polychaeta (brittle worms) ,Alaska,Aleutian Islands,,,Not for IDW -40,Fusitriton oregonensis,Oregon triton,Gastropoda (sea snails and slugs),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -41,Gadus chalcogrammus,Walleye pollock,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -42,Gadus macrocephalus,Pacific cod,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -43,Geodia carolae,calcareous finger sponge,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -44,Glyptocephalus zachirus,Rex sole,Pleuronectiformes (Flatfishes) ,Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -45,Gorgonocephalus eucnemis,Basket star,Ophiuroidea (brittle stars),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -46,Gymnocanthus galeatus,Armorhead sculpin,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -47,Halichondria (Halichondria) panicea,Breadcrumb sponge,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -48,Halocynthia aurantium,Sea peach,"Tunicata (sea squirts, tunicates, salps) ",Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -49,Hemilepidotus jordani,Yellow irish lord,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -50,Hemilepidotus zapus,Longfin irish lord,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,,,Not for IDW -51,Hemitripterus bolini,Bigmouth sculpin,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,,,Not for IDW -52,Henricia asthenactis,NA,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,Not for IDW -53,Henricia leviuscula,Pacific blood star,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,Not for IDW -54,Hippasteria phrygiana,Arctic cushion star,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,Not for IDW -55,Hippoglossoides elassodon,Flathead sole,Pleuronectiformes (Flatfishes) ,Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -56,Hippoglossus stenolepis,Pacific halibut,Pleuronectiformes (Flatfishes) ,Alaska,Aleutian Islands,NPFMC,Species Managed Under International Agreement - IPHC,NMFS/Rutgers IDW Interpolation -57,Histodermella kagigunensis,Spud sponge,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -58,Hyas lyratus,Pacific lyre crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -59,Isodictya rigida,Orange finger sponge,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -60,Latrunculia (Uniannulata) oparinae,NA,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -61,Lebbeus groenlandicus,Spiny lebbeid,Decapoda (Crabs/Lobster/Shrimp),Alaska,Aleutian Islands,,,Not for IDW -62,Lepidopsetta sp.,Rock soles,Pleuronectiformes (Flatfishes) ,Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -63,Leptasterias coei truculenta,Giant Aleutian six-rayed star,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,Not for IDW -64,Lethasterias nanimensis,Black spined sea star,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -65,Lethotremus muticus,Docked snailfish,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,,,Not for IDW -66,Lithodes aequispinus,Golden king crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Aleutian Islands,NPFMC,Bering Sea/Aleutian Islands King and Tanner Crabs,NMFS/Rutgers IDW Interpolation -67,Lycodes concolor,Ebony eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Aleutian Islands,,,Not for IDW -68,Malacocottus zonurus,Darkfin sculpin,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -69,Microstomus pacificus,Dover sole,Pleuronectiformes (Flatfishes) ,Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -70,Modiolus modiolus,Northern horsemussel,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Aleutian Islands,,,Not for IDW -71,Monanchora pulchra,Yellow leafy sponge,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -72,Muriceides nigra,NA,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Aleutian Islands,,,Not for IDW -73,Mycale (Mycale) loveni,Loven's horny sponge,Porifera (sponges),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -74,Myoxocephalus polyacanthocephalus,Great sculpin,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -75,Myxilla brunnea,soft brown sponge,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -76,Ophiopholis aculeata,Daisy brittle star,Ophiuroidea (brittle stars),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -77,Ophiopholis longispina,NA,Ophiuroidea (brittle stars),Alaska,Aleutian Islands,,,Not for IDW -78,Oregonia gracilis,Graceful decorator crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -79,Pagurus aleuticus,Aleutian hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Aleutian Islands,,,Not for IDW -80,Pagurus brandti,Sponge hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -81,Pagurus trigonocheirus,Fuzzy hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Aleutian Islands,,,Not for IDW -82,Pandalus eous,Northern shrimp,Decapoda (Crabs/Lobster/Shrimp),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -83,Pandalus tridens,Yellowleg pandalid,Decapoda (Crabs/Lobster/Shrimp),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -84,Paragorgia arborea,Bubblegum coral,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Aleutian Islands,,,Not for IDW -85,Phacellophora camtschatica,Fried egg jellyfish,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Aleutian Islands,,,Not for IDW -86,Plakina tanaga,White convoluted sponge,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -87,Pleurogrammus monopterygius,Atka mackerel,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -88,Plumarella superba,Bushy coral,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Aleutian Islands,,,Not for IDW -89,Pododesmus macrochisma,Green falsejingle,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -90,Podothecus accipenserinus,Sturgeon poacher,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -91,Polymastia fluegeli,Flugel nippled sponge,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -92,Polymastia sp. A (Clark 2006),prolific nipple sponge,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -93,Porella compressa,Flattened bryozoan,Bryozoa,Alaska,Aleutian Islands,,,Not for IDW -94,Primnoa pacifica var. willeyi,Red tree coral,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Aleutian Islands,,,Not for IDW -95,Pseudarchaster parelii,Northern scarlet star,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,Not for IDW -96,Pteraster marsippus,Prickly cushion star,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,Not for IDW -97,Pteraster militaris,Wrinkled sea star,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -98,Pteraster sp. A (Clark 1999),NA,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,Not for IDW -99,Pteraster tesselatus,Tesselated slime star,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,Not for IDW -100,Reinhardtius hippoglossoides,Greenland halibut,Pleuronectiformes (Flatfishes) ,Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,Not for IDW -101,Rossia pacifica,Eastern pacific bobtail,"Cephalopoda (squid, octopus)",Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -102,Sarritor frenatus,Sawback poacher,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -103,Sebastes alutus,Pacific ocean perch,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -104,Sebastes borealis,Shortraker rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -105,Sebastes melanostictus and S. aleutianus,Blackspotted and rougheye rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -106,Sebastes polyspinis,Northern rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -107,Sebastes variabilis and S. ciliatus,Dusky and dark rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -108,Sebastolobus alascanus,Shortspine thornyhead,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -109,Solaster dawsoni,Morning sun star,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,Not for IDW -110,Solaster sp. A (Clark 1997),NA,Asteroidea (starfishes) ,Alaska,Aleutian Islands,,,Not for IDW -111,Stegophiura ponderosa,NA,Ophiuroidea (brittle stars),Alaska,Aleutian Islands,,,Not for IDW -112,Stelodoryx oxeata,Scapula sponge,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -113,Stenobrachius leucopsarus,Northern lampfish,Myctophiformes (Lanternfishes),Alaska,Aleutian Islands,,,Not for IDW -114,Strongylocentrotus droebachiensis,Green sea urchin,"Echinoidea (sea urchins, sand dollars) ",Alaska,Aleutian Islands,,,Not for IDW -115,Strongylocentrotus polyacanthus,NA,"Echinoidea (sea urchins, sand dollars) ",Alaska,Aleutian Islands,,,Not for IDW -116,Styela rustica,Sea potato,"Tunicata (sea squirts, tunicates, salps) ",Alaska,Aleutian Islands,,,Not for IDW -117,Suberites ficus,Fig sponge,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -118,Synallactes challengeri,Challenger cucumber,Holothuroidea (sea cucumbers),Alaska,Aleutian Islands,,,Not for IDW -119,Tedania (Tedania) kagalaskai,NA,Porifera (sponges),Alaska,Aleutian Islands,,,Not for IDW -120,Triglops forficatus,Scissortail sculpin,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -121,Triglops scepticus,Spectacled sculpin,Perciformes/Cottoidei (sculpins),Alaska,Aleutian Islands,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -122,Zaprora silenus,Prowfish,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Aleutian Islands,,,NMFS/Rutgers IDW Interpolation -123,Aforia circinata,Keeled aforia,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,Not for IDW -124,Anoplopoma fimbria,Sablefish,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,Not for IDW -125,Aphrodita negligens,Dishevelled sea-mouse,Polychaeta (brittle worms) ,Alaska,Eastern Bering Sea,,,Not for IDW -126,Aplidium sp. A (Clark 2006),sea glob,"Tunicata (sea squirts, tunicates, salps) ",Alaska,Eastern Bering Sea,,,Not for IDW -127,Arctoraja parmifera,Alaska skate,"Elasmobranchii: Batoidea (skates, rays)",Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,Not for IDW -128,Argis dentata,Arctic argid,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,Not for IDW -129,Argis lar,Kuro shrimp,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,Not for IDW -130,Aspidophoroides monopterygius,Alligatorfish,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,Not for IDW -131,Asterias amurensis,North pacific seastar,Asteroidea (starfishes) ,Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -132,Atheresthes stomias and A. evermanni,Arrowtooth and kamchatka flounders,Pleuronectiformes (Flatfishes) ,Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -133,Aulacofusus herendeeni,Thin-ribbed whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,Not for IDW -134,Aurelia limbata,Brownbranded moon jelly,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Eastern Bering Sea,,,Not for IDW -135,Bathymaster signatus,Searcher,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -136,Bathyraja spp.,Skate complex,"Elasmobranchii: Batoidea (skates, rays)",Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,Not for IDW -137,Beringius behringii,Behring's whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,Not for IDW -138,Boltenia ovifera,Stalked sea squirt,"Tunicata (sea squirts, tunicates, salps) ",Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -139,Boreogadus saida,Arctic cod,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Eastern Bering Sea,,,Not for IDW -140,Buccinum angulosum,Angular whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -141,Buccinum oedematum,Swollen whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,Not for IDW -142,Buccinum plectrum,Sinuous whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,Not for IDW -143,Buccinum polare,Polar whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -144,Buccinum scalariforme,Ladder whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -145,Careproctus phasma,Monster snailfish,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,Not for IDW -146,Careproctus rastrinus,Salmon snailfish,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,Not for IDW -147,Careproctus scottae,Peachskin snailfish,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,Not for IDW -148,Careproctus sp. cf. melanurus (Orr et al.),scorched snailfish,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,Not for IDW -149,Chionoecetes bairdi,Tanner crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,NPFMC,Bering Sea/Aleutian Islands King and Tanner Crabs,NMFS/Rutgers IDW Interpolation -150,Chionoecetes opilio,Snow crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,NPFMC,Bering Sea/Aleutian Islands King and Tanner Crabs,NMFS/Rutgers IDW Interpolation -151,Chrysaora melanaster,NA,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Eastern Bering Sea,,,Not for IDW -152,Ciliatocardium ciliatum,Hairy cockle,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Eastern Bering Sea,,,Not for IDW -153,Clinopegma magnum,Helmet whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -154,Clupea pallasii,Pacific herring,"Clupeiformes (Herrings, anchovy, shad)",Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -155,Crangon dalli,Ridged crangon,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,Not for IDW -156,Crossaster papposus,Common sunstar,Asteroidea (starfishes) ,Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -157,Cryptonatica russa,Russty moonsnail,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,Not for IDW -158,Ctenodiscus crispatus,Mud star,Asteroidea (starfishes) ,Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -159,Cucumaria fallax,Sea football,Holothuroidea (sea cucumbers),Alaska,Eastern Bering Sea,,,Not for IDW -160,Cyanea capillata,Lion's mane,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Eastern Bering Sea,,,Not for IDW -161,Dasycottus setiger,Spinyhead sculpin,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -162,Echinarachnius parma,Common sand dollar,"Echinoidea (sea urchins, sand dollars) ",Alaska,Eastern Bering Sea,,,Not for IDW -163,Elassochirus cavimanus,Purple hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,Not for IDW -164,Eleginus gracilis,Saffron cod,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Eastern Bering Sea,,,Not for IDW -165,Enteroctopus dofleini,North pacific giant octopus,"Cephalopoda (squid, octopus)",Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,Not for IDW -166,Erimacrus isenbeckii,Hair crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -167,Eunoe depressa,Depressed scale worm,Polychaeta (brittle worms) ,Alaska,Eastern Bering Sea,,,Not for IDW -168,Eunoe nodosa,Giant scale worm,Polychaeta (brittle worms) ,Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -169,Euspira pallida,Pale moonsnail,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,Not for IDW -170,Evasterias echinosoma,Giant sea star,Asteroidea (starfishes) ,Alaska,Eastern Bering Sea,,,Not for IDW -171,Fusitriton oregonensis,Oregon triton,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -172,Gadus chalcogrammus,Walleye pollock,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -173,Gadus macrocephalus,Pacific cod,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -174,Gersemia rubiformis,Sea strawberry,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Eastern Bering Sea,,,Not for IDW -175,Glebocarcinus oregonensis,Pygmy rock crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,Not for IDW -176,Glyptocephalus zachirus,Rex sole,Pleuronectiformes (Flatfishes) ,Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -177,Gorgonocephalus eucnemis,Basket star,Ophiuroidea (brittle stars),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -178,Gymnocanthus galeatus,Armorhead sculpin,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,Not for IDW -179,Gymnocanthus pistilliger,Threaded sculpin,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,Not for IDW -180,Halocynthia aurantium,Sea peach,"Tunicata (sea squirts, tunicates, salps) ",Alaska,Eastern Bering Sea,,,Not for IDW -181,Hemilepidotus jordani,Yellow irish lord,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -182,Hemilepidotus papilio,Butterfly sculpin,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -183,Hemitripterus bolini,Bigmouth sculpin,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -184,Hexagrammos stelleri,Whitespotted greenling,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,Not for IDW -185,Hiatella arctica,Arctic hiatella,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Eastern Bering Sea,,,Not for IDW -186,Hippoglossoides elassodon and H. robustus,Flathead sole-bering flounder,Pleuronectiformes (Flatfishes) ,Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -187,Hippoglossus stenolepis,Pacific halibut,Pleuronectiformes (Flatfishes) ,Alaska,Eastern Bering Sea,NPFMC,Species Managed Under International Agreement - IPHC,NMFS/Rutgers IDW Interpolation -188,Hyas coarctatus,Arctic lyre crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -189,Hyas lyratus,Pacific lyre crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -190,Icelus spatula,Spatulate sculpin,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,Not for IDW -191,Icelus spiniger,Thorny sculpin,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -192,Isopsetta isolepis,Butter sole,Pleuronectiformes (Flatfishes) ,Alaska,Eastern Bering Sea,NPFMC,NA,Not for IDW -193,Labidochirus splendescens,Splendid hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -194,Lepidopsetta sp.,Rock soles,Pleuronectiformes (Flatfishes) ,Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -195,Leptasterias (Hexasterias) polaris,Polar six-rayed star,Asteroidea (starfishes) ,Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -196,Leptasterias arctica,Arctic star,Asteroidea (starfishes) ,Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -197,Leptasterias groenlandica,Greenland star,Asteroidea (starfishes) ,Alaska,Eastern Bering Sea,,,Not for IDW -198,Leptoclinus maculatus,Daubed shanny,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Eastern Bering Sea,,,Not for IDW -199,Lethasterias nanimensis,Black spined sea star,Asteroidea (starfishes) ,Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -200,Limanda aspera,Yellowfin sole,Pleuronectiformes (Flatfishes) ,Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -201,Limanda sakhalinensis,Sakhalin sole,Pleuronectiformes (Flatfishes) ,Alaska,Eastern Bering Sea,,,Not for IDW -202,Liparis gibbus,Variegated snailfish,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,Not for IDW -203,Liponema brevicorne,Tentacle shedding anemone,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Eastern Bering Sea,,,Not for IDW -204,Lumpenus sagitta,Snake prickleback,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Eastern Bering Sea,,,Not for IDW -205,Lycodes brevipes,Shortfin eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -206,Lycodes palearis,Wattled eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -207,Lycodes raridens,Marbled eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Eastern Bering Sea,,,Not for IDW -208,Mactromeris polynyma,Arctic surfclam,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -209,Mallotus villosus,Capelin,"Osmeriformes (caplin, freshwater smelt)",Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -210,Megangulus luteus,Alaskan great tellin,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Eastern Bering Sea,,,Not for IDW -211,Metridium farcimen,Giant plumose anemone,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Eastern Bering Sea,,,Not for IDW -212,Musculus discors,Discordant mussel,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Eastern Bering Sea,,,Not for IDW -213,Myoxocephalus jaok,Plain sculpin,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -214,Myoxocephalus polyacanthocephalus,Great sculpin,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -215,Myoxocephalus scorpius,Shorthorn sculpin,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,Not for IDW -216,Myzopsetta proboscidea,Longhead dab,Pleuronectiformes (Flatfishes) ,Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -217,Neocrangon communis,Gray shrimp,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,Not for IDW -218,Neptunea borealis,NA,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,Not for IDW -219,Neptunea heros,Northern neptune whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -220,Neptunea lyrata,Lyre whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -221,Neptunea pribiloffensis,Pribilof whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -222,Neptunea ventricosa,Fat whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -223,Occella dodecaedron,Bering poacher,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -224,Ophiura sarsii,Notched brittle star,Ophiuroidea (brittle stars),Alaska,Eastern Bering Sea,,,Not for IDW -225,Oregonia gracilis,Graceful decorator crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -226,Pagurus aleuticus,Aleutian hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -227,Pagurus brandti,Sponge hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,Not for IDW -228,Pagurus capillatus,Hairy hermit crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,Not for IDW -229,Pagurus confragosus,Knobbyhand hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,Not for IDW -230,Pagurus ochotensis,Alaskan hermit crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -231,Pagurus rathbuni,Longfinger hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,Not for IDW -232,Pagurus trigonocheirus,Fuzzy hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,Not for IDW -233,Pandalus eous,Northern shrimp,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -234,Pandalus goniurus,Humpy shrimp,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,Not for IDW -235,Paralithodes camtschaticus,Red king crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,NPFMC,Bering Sea/Aleutian Islands King and Tanner Crabs,NMFS/Rutgers IDW Interpolation -236,Paralithodes platypus,Blue king crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,NPFMC,Bering Sea/Aleutian Islands King and Tanner Crabs,NMFS/Rutgers IDW Interpolation -237,Patinopecten caurinus,Weathervane scallop,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Eastern Bering Sea,,,Not for IDW -238,Platichthys stellatus,Starry flounder,Pleuronectiformes (Flatfishes) ,Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -239,Pleuronectes quadrituberculatus,Alaska plaice,Pleuronectiformes (Flatfishes) ,Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -240,Plicifusus kroyeri,Arctic whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -241,Podothecus accipenserinus,Sturgeon poacher,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -242,Pteraster obscurus,Obscure cushion star,Asteroidea (starfishes) ,Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -243,Pyrulofusus deformis,Warped whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,Not for IDW -244,Pyrulofusus melonis,Giant melon whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,Not for IDW -245,Reinhardtius hippoglossoides,Greenland halibut,Pleuronectiformes (Flatfishes) ,Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -246,Rhamphostomella costata,Ribbed bryozoan,Bryozoa,Alaska,Eastern Bering Sea,,,Not for IDW -247,Sarritor frenatus,Sawback poacher,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -248,Serratiflustra serrulata,Leafy bryozoan,Bryozoa,Alaska,Eastern Bering Sea,,,Not for IDW -249,Serripes groenlandicus,Greenland cockle,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Eastern Bering Sea,,,Not for IDW -250,Serripes notabilis,Oblique smoothcockle,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Eastern Bering Sea,,,Not for IDW -251,Siliqua alta,Alaska razor,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Eastern Bering Sea,,,Not for IDW -252,Stomphia coccinea,Swimming anemone,"Cnidaria (jellyfish, corals, anenomes) ",US East Coast,Eastern Bering Sea,,,Not for IDW -253,Strongylocentrotus droebachiensis,Green sea urchin,"Echinoidea (sea urchins, sand dollars) ",Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -254,Styela rustica,Sea potato,"Tunicata (sea squirts, tunicates, salps) ",Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -255,Telmessus cheiragonus,Helmet crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Eastern Bering Sea,,,NMFS/Rutgers IDW Interpolation -256,Thaleichthys pacificus,Eulachon,"Osmeriformes (caplin, freshwater smelt)",Alaska,Eastern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -257,Triglops pingelii,Ribbed sculpin,Perciformes/Cottoidei (sculpins),Alaska,Eastern Bering Sea,,,Not for IDW -258,Tritonia tetraquetra,Large orange peel nudibranch,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,Not for IDW -259,Urticina crassicornis,Mottled anemone,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Eastern Bering Sea,,,Not for IDW -260,Volutopsius fragilis,Fragile whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,Not for IDW -261,Volutopsius middendorffi,Tulip whelk,Gastropoda (sea snails and slugs),Alaska,Eastern Bering Sea,,,Not for IDW -262,Acantholumpenus mackayi,Pighead prickleback,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -263,Alcyonidium enteromorpha,Noodle bryozoan,Bryozoa,Alaska,Northern Bering Sea,,,Not for IDW -264,Alcyonidium pedunculatum,Smooth leather bryozoan,Bryozoa,Alaska,Northern Bering Sea,,,Not for IDW -265,Arctoraja parmifera,Alaska skate,"Elasmobranchii: Batoidea (skates, rays)",Alaska,Northern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -266,Argis dentata,Arctic argid,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,Not for IDW -267,Aspidophoroides olrikii,Arctic alligatorfish,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -268,Asterias amurensis,North pacific seastar,Asteroidea (starfishes) ,Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -269,Atheresthes stomias and A. evermanni,Arrowtooth and kamchatka flounders,Pleuronectiformes (Flatfishes) ,Alaska,Northern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,Not for IDW -270,Boltenia ovifera,Stalked sea squirt,"Tunicata (sea squirts, tunicates, salps) ",Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -271,Boreogadus saida,Arctic cod,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -272,Buccinum angulosum,Angular whelk,Gastropoda (sea snails and slugs),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -273,Buccinum plectrum,Sinuous whelk,Gastropoda (sea snails and slugs),Alaska,Northern Bering Sea,,,Not for IDW -274,Buccinum polare,Polar whelk,Gastropoda (sea snails and slugs),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -275,Buccinum scalariforme,Ladder whelk,Gastropoda (sea snails and slugs),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -276,Chionoecetes opilio,Snow crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -277,Chirona evermanni,Deepwater giant barnacle,Balanomorpha (barnacles),Alaska,Northern Bering Sea,,,Not for IDW -278,Chrysaora melanaster,NA,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Northern Bering Sea,,,Not for IDW -279,Clupea pallasii,Pacific herring,"Clupeiformes (Herrings, anchovy, shad)",Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -280,Crangon septemspinosa,Sevenspine bay shrimp,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,Not for IDW -281,Crossaster papposus,Common sunstar,Asteroidea (starfishes) ,Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -282,Cryptonatica russa,Russty moonsnail,Gastropoda (sea snails and slugs),Alaska,Northern Bering Sea,,,Not for IDW -283,Cyanea capillata,Lion's mane,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Northern Bering Sea,,,Not for IDW -284,Echinarachnius parma,Common sand dollar,"Echinoidea (sea urchins, sand dollars) ",Alaska,Northern Bering Sea,,,Not for IDW -285,Eleginus gracilis,Saffron cod,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -286,Enophrys diceraus,Antlered sculpin,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -287,Erimacrus isenbeckii,Hair crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -288,Eunoe depressa,Depressed scale worm,Polychaeta (brittle worms) ,Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -289,Eunoe nodosa,Giant scale worm,Polychaeta (brittle worms) ,Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -290,Euspira pallida,Pale moonsnail,Gastropoda (sea snails and slugs),Alaska,Northern Bering Sea,,,Not for IDW -291,Evasterias echinosoma,Giant sea star,Asteroidea (starfishes) ,Alaska,Northern Bering Sea,,,Not for IDW -292,Gadus chalcogrammus,Walleye pollock,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -293,Gadus macrocephalus,Pacific cod,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -294,Gersemia rubiformis,Sea strawberry,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Northern Bering Sea,,,Not for IDW -295,Gorgonocephalus eucnemis,Basket star,Ophiuroidea (brittle stars),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -296,Gymnocanthus pistilliger,Threaded sculpin,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -297,Gymnocanthus tricuspis,Arctic staghorn sculpin,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,Not for IDW -298,Halocynthia aurantium,Sea peach,"Tunicata (sea squirts, tunicates, salps) ",Alaska,Northern Bering Sea,,,Not for IDW -299,Hemilepidotus papilio,Butterfly sculpin,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,Not for IDW -300,Hexagrammos stelleri,Whitespotted greenling,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -301,Hiatella arctica,Arctic hiatella,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Northern Bering Sea,,,Not for IDW -302,Hippoglossoides elassodon and H. robustus,Flathead sole-bering flounder,Pleuronectiformes (Flatfishes) ,Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -303,Hippoglossus stenolepis,Pacific halibut,Pleuronectiformes (Flatfishes) ,Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -304,Hyas coarctatus,Arctic lyre crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -305,Labidochirus splendescens,Splendid hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -306,Lepidopsetta sp.,Rock soles,Pleuronectiformes (Flatfishes) ,Alaska,Northern Bering Sea,,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -307,Leptasterias (Hexasterias) polaris,Polar six-rayed star,Asteroidea (starfishes) ,Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -308,Leptasterias arctica,Arctic star,Asteroidea (starfishes) ,Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -309,Leptasterias groenlandica,Greenland star,Asteroidea (starfishes) ,Alaska,Northern Bering Sea,,,Not for IDW -310,Lethasterias nanimensis,Black spined sea star,Asteroidea (starfishes) ,Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -311,Limanda aspera,Yellowfin sole,Pleuronectiformes (Flatfishes) ,Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -312,Limanda sakhalinensis,Sakhalin sole,Pleuronectiformes (Flatfishes) ,Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -313,Liparis gibbus,Variegated snailfish,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -314,Liparis tunicatus,Kelp snailfish,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,Not for IDW -315,Lumpenus fabricii,Slender eelblenny,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -316,Lumpenus sagitta,Snake prickleback,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Northern Bering Sea,,,Not for IDW -317,Lycodes palearis,Wattled eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -318,Lycodes raridens,Marbled eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Northern Bering Sea,,,Not for IDW -319,Lycodes turneri,Polar eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -320,Mactromeris polynyma,Arctic surfclam,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Northern Bering Sea,,,Not for IDW -321,Mallotus villosus,Capelin,"Osmeriformes (caplin, freshwater smelt)",Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -322,Metridium farcimen,Giant plumose anemone,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Northern Bering Sea,,,Not for IDW -323,Modiolus modiolus,Northern horsemussel,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Northern Bering Sea,,,Not for IDW -324,Musculus discors,Discordant mussel,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Northern Bering Sea,,,Not for IDW -325,Myoxocephalus jaok,Plain sculpin,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -326,Myoxocephalus polyacanthocephalus,Great sculpin,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -327,Myoxocephalus scorpius,Shorthorn sculpin,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -328,Myzopsetta proboscidea,Longhead dab,Pleuronectiformes (Flatfishes) ,Alaska,Northern Bering Sea,NPFMC,Groundfish of the Bering Sea and Aleutian Islands Management Area,NMFS/Rutgers IDW Interpolation -329,Nautichthys pribilovius,Eyeshade sculpin,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,Not for IDW -330,Neptunea borealis,NA,Gastropoda (sea snails and slugs),Alaska,Northern Bering Sea,,,Not for IDW -331,Neptunea heros,Northern neptune whelk,Gastropoda (sea snails and slugs),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -332,Neptunea ventricosa,Fat whelk,Gastropoda (sea snails and slugs),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -333,Occella dodecaedron,Bering poacher,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -334,Ophiura sarsii,Notched brittle star,Ophiuroidea (brittle stars),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -335,Osmerus mordax,Rainbow smelt,"Osmeriformes (caplin, freshwater smelt)",Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -336,Pagurus capillatus,Hairy hermit crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -337,Pagurus ochotensis,Alaskan hermit crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -338,Pagurus rathbuni,Longfinger hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -339,Pagurus trigonocheirus,Fuzzy hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -340,Pallasina barbata,Tubenose poacher,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -341,Pandalus goniurus,Humpy shrimp,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -342,Paralithodes camtschaticus,Red king crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -343,Paralithodes platypus,Blue king crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -344,Platichthys stellatus,Starry flounder,Pleuronectiformes (Flatfishes) ,Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -345,Pleuronectes quadrituberculatus,Alaska plaice,Pleuronectiformes (Flatfishes) ,Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -346,Podothecus accipenserinus,Sturgeon poacher,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -347,Podothecus veternus,Veteran poacher,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,Not for IDW -348,Psolus fabricii,Scarlet psolus,Holothuroidea (sea cucumbers),Alaska,Northern Bering Sea,,,Not for IDW -349,Pteraster obscurus,Obscure cushion star,Asteroidea (starfishes) ,Alaska,Northern Bering Sea,,,Not for IDW -350,Sclerocrangon boreas,Sculptured shrimp,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -351,Serripes notabilis,Oblique smoothcockle,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -352,Strongylocentrotus droebachiensis,Green sea urchin,"Echinoidea (sea urchins, sand dollars) ",Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -353,Styela rustica,Sea potato,"Tunicata (sea squirts, tunicates, salps) ",Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -354,Telmessus cheiragonus,Helmet crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -355,Triglops pingelii,Ribbed sculpin,Perciformes/Cottoidei (sculpins),Alaska,Northern Bering Sea,,,NMFS/Rutgers IDW Interpolation -356,Tritonia festiva,Diamondback tritonia,Gastropoda (sea snails and slugs),Alaska,Northern Bering Sea,,,Not for IDW -357,Acanthostracion quadricornis,Scrawled cowfish,Tetraodontiformes (puffers and filefishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -358,Achelous gibbesii,Iridescent swimming crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -359,Achelous ordwayi,Silvery-clawed swimming crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -360,Achelous spinicarpus,Longspine swimming crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -361,Achelous spinimanus,Blotched swimming crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -362,Aluterus heudelotii,Dotterel filefish,Tetraodontiformes (puffers and filefishes),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -363,Aluterus schoepfii,Orange filefish,Tetraodontiformes (puffers and filefishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -364,Anadara secernenda,Skewed ark,"Bivalvia (clams, muscles, oyster, arks, etc)",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -365,Anasimus latus,Stilt spider crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -366,Anchoa hepsetus,Striped anchovy,"Clupeiformes (Herrings, anchovy, shad)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -367,Anchoa mitchilli,Bay anchovy,"Clupeiformes (Herrings, anchovy, shad)",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -368,Ancylopsetta dilecta,Three-eye flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,Not for IDW -369,Ancylopsetta quadrocellata,Ocellated flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -370,Apogon pseudomaculatus,Twospot cardinalfish,"Kurtiformes(Nurseryfishes, cardinalfishes.)",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -371,Apogon quadrisquamatus,Sawcheek cardinalfish,"Kurtiformes(Nurseryfishes, cardinalfishes.)",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -372,Arbacia punctulata,Purple-spined sea urchin,"Echinoidea (sea urchins, sand dollars) ",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -373,Argopecten gibbus,Calico scallop,"Bivalvia (clams, muscles, oyster, arks, etc)",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -374,Ariopsis felis,Hardhead catfish,Siluriformes (catfishes),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -375,Balistes capriscus,Gray triggerfish,Tetraodontiformes (puffers and filefishes),Gulf of Mexico,Gulf of Mexico,GMFMC,Reef Fish Resources of the Gulf of Mexico,NMFS/Rutgers IDW Interpolation -376,Bellator militaris,Horned searobin,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -377,Bollmannia communis,Ragged goby,Gobiiformes (Gobies),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -378,Bothus robinsi,Twospot flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -379,Brevoortia patronus,Gulf menhaden,"Clupeiformes (Herrings, anchovy, shad)",Gulf of Mexico,Gulf of Mexico,GSMFC,Gulf Menhaden Fishery Regional Management Plan,Not for IDW -380,Brotula barbata,Bearded brotula,Ophidiiformes (Cusk eels) ,Gulf of Mexico,Gulf of Mexico,,,Not for IDW -381,Calamus arctifrons,Grass porgy,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -382,Calamus nodosus,Knobbed porgy,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -383,Calamus proridens,Littlehead porgy,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -384,Calappa flammea,Flame box crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -385,Calappa sulcata,Yellow box crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -386,Callinectes sapidus,Blue crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,GSMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -387,Callinectes similis,Lesser blue crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -388,Centropristis ocyurus,Bank sea bass,Perciformes/Serranoidei (Groupers),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -389,Centropristis philadelphica,Rock sea bass,Perciformes/Serranoidei (Groupers),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -390,Chaetodipterus faber,Atlantic spadefish,Acanthuriformes (Surgeonfishes),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -391,Chaetodon ocellatus,Spotfin butterflyfish,Acanthuriformes (Surgeonfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -392,Chaetodon sedentarius,Reef butterflyfish,Acanthuriformes (Surgeonfishes),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -393,Chilomycterus schoepfii,Striped burrfish,Tetraodontiformes (puffers and filefishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -394,Chloroscombrus chrysurus,Atlantic bumper,Carangiformes (Jacks),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -395,Chrysaora quinquecirrha,Sea nettle,"Cnidaria (jellyfish, corals, anenomes) ",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -396,Citharichthys macrops,Spotted whiff,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -397,Citharichthys spilopterus,Bay whiff,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -398,Coryrhynchus sidneyi,Shortfinger neck crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -399,Cyclopsetta chittendeni,Mexican flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -400,Cyclopsetta fimbriata,Spotfin flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -401,Cynoscion arenarius,Sand weakfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,GSMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -402,Cynoscion nothus,Silver seatrout,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,GSMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -403,Decapterus punctatus,Round scad,Carangiformes (Jacks),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -404,Diplectrum bivittatum,Dwarf sand perch,Perciformes/Serranoidei (Groupers),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -405,Diplectrum formosum,Sand perch,Perciformes/Serranoidei (Groupers),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -406,Doryteuthis sp,Inshore Squid sp.,"Cephalopoda (squid, octopus)",Gulf of Mexico,Gulf of Mexico,GMFMC,,NMFS/Rutgers IDW Interpolation -407,Echiophis intertinctus,Spotted spoon-nose eel,Anguilliformes (Eels and morays),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -408,Encope aberrans,NA,"Echinoidea (sea urchins, sand dollars) ",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -409,Engyophrys senta,Spiny flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,Not for IDW -410,Epinephelus morio,Red grouper,Perciformes/Serranoidei (Groupers),Gulf of Mexico,Gulf of Mexico,GMFMC,Reef Fish Resources of the Gulf of Mexico,NMFS/Rutgers IDW Interpolation -411,Eques lanceolatus,Jackknife-fish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -412,Etropus crossotus,Fringed flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -413,Etropus rimosus,Gray flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,Not for IDW -414,Eucidaris tribuloides,Slate pencil urchin,"Echinoidea (sea urchins, sand dollars) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -415,Eucinostomus gula,Silver jenny,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -416,Eucinostomus harengulus,Tidewater mojarra,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -417,Euvola marensis,Paper scallop,"Bivalvia (clams, muscles, oyster, arks, etc)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -418,Euvola raveneli,Round rib scallop,"Bivalvia (clams, muscles, oyster, arks, etc)",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -419,Fowlerichthys radiosus,Singlespot frogfish,Lophiiformes (Anglerfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -420,Gastropsetta frontalis,Shrimp flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,Not for IDW -421,Gymnothorax saxicola,Honeycomb moray,Anguilliformes (Eels and morays),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -422,Haemulon aurolineatum,Tomtate grunt,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -423,Haemulon plumierii,White grunt,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -424,Halieutichthys sp,Batfishes,Lophiiformes (Anglerfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -425,Harengula jaguana,Scaled sardine,"Clupeiformes (Herrings, anchovy, shad)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -426,Hepatus epheliticus,Calico box crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -427,Hippocampus erectus,Lined seahorse,Syngnathiformes (Seahorses),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -428,Holacanthus bermudensis,Blue angelfish,Acanthuriformes (Surgeonfishes),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -429,Iliacantha liodactylus,NA,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -430,Kathetostoma albigutta,Lancer stargazer,Perciformes/Uranoscopoidei (Sand dwellers),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -431,Laevicardium mortoni,Yellow eggcockle,"Bivalvia (clams, muscles, oyster, arks, etc)",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -432,Lagocephalus laevigatus,Smooth puffer,Tetraodontiformes (puffers and filefishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -433,Lagodon rhomboides,Pinfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -434,Larimus fasciatus,Banded drum,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -435,Leiolambrus nitidus,White elbow crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -436,Leiostomus xanthurus,Spot,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -437,Lepophidium brevibarbe,Blackedge cusk-eel,Ophidiiformes (Cusk eels) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -438,Lepophidium jeannae,Mottled cusk-eel,Ophidiiformes (Cusk eels) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -439,Lolliguncula brevis,Atlantic brief squid,"Cephalopoda (squid, octopus)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -440,Luidia alternata,Banded sea star,Asteroidea (starfishes) ,Gulf of Mexico,Gulf of Mexico,,,Not for IDW -441,Luidia clathrata,Lined sea star,Asteroidea (starfishes) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -442,Luidia lawrencei,NA,Asteroidea (starfishes) ,Gulf of Mexico,Gulf of Mexico,,,Not for IDW -443,Lutjanus campechanus,Red snapper,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,GMFMC,Reef Fish Resources of the Gulf of Mexico,NMFS/Rutgers IDW Interpolation -444,Lutjanus griseus,Gray snapper,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,GMFMC,Reef Fish Resources of the Gulf of Mexico,NMFS/Rutgers IDW Interpolation -445,Lutjanus synagris,Lane snapper,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,GMFMC,Reef Fish Resources of the Gulf of Mexico,NMFS/Rutgers IDW Interpolation -446,Lytechinus variegatus,Variegated sea urchin,"Echinoidea (sea urchins, sand dollars) ",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -447,Lytechinus variegatus carolinus,NA,"Echinoidea (sea urchins, sand dollars) ",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -448,Menticirrhus americanus,Southern kingfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -449,Metapenaeopsis goodei,Caribbean velvet shrimp,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -450,Micropogonias undulatus,Atlantic croaker,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -451,Mithrax pleuracanthus,Shaggy clinging crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -452,Monacanthus ciliatus,Fringed filefish,Tetraodontiformes (puffers and filefishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -453,Moreiradromia antillensis,Hairy sponge crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -454,Mullus auratus,Red goatfish,Mulliformes (Goatfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -455,Nicholsina usta,Emerald parrotfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -456,Octopus joubini,Atlantic pygmy octopus,"Cephalopoda (squid, octopus)",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -457,Octopus vulgaris,Common octopus,"Cephalopoda (squid, octopus)",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -458,Ogcocephalus corniger,Longnose batfish,Lophiiformes (Anglerfishes),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -459,Ogcocephalus cubifrons,NA,Lophiiformes (Anglerfishes),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -460,Ogcocephalus declivirostris,Slantbrow batfish,Lophiiformes (Anglerfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -461,Ogcocephalus pantostictus,Spotted batfish,Lophiiformes (Anglerfishes),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -462,Ogcocephalus parvus,Roughback batfish,Lophiiformes (Anglerfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -463,Ogcocephalus radiatus,Polka-dot batfish,Lophiiformes (Anglerfishes),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -464,Ophidion holbrookii,Bank cusk-eel,Ophidiiformes (Cusk eels) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -465,Ophiolepis elegans,Elegant brittle star,Ophiuroidea (brittle stars),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -466,Ophiothrix (Ophiothrix) angulata,Angular brittle star,Ophiuroidea (brittle stars),Alaska,Gulf of Mexico,,,Not for IDW -467,Opisthonema oglinum,Atlantic thread herring,"Clupeiformes (Herrings, anchovy, shad)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -468,Orthopristis chrysoptera,Pigfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -469,Ovalipes floridanus,Florida lady crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -470,Pagrus pagrus,Red porgy,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -471,Paguristes sericeus,Blue-eyed hermit,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -472,Paralichthys albigutta,Gulf flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,Not for IDW -473,Paralichthys lethostigma,Southern flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,Not for IDW -474,Parapenaeus politus,Rose shrimp,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -475,Pareques umbrosus,Cubbyu,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -476,Penaeus aztecus,Brown shrimp,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,GMFMC,Shrimp Fishery of the Gulf of Mexico,NMFS/Rutgers IDW Interpolation -477,Penaeus aztecus,Brown shrimp,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,GSMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -478,Penaeus duorarum,Pink shrimp,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,GMFMC,Shrimp Fishery of the Gulf of Mexico,NMFS/Rutgers IDW Interpolation -479,Penaeus duorarum,Pink shrimp,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,GSMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -480,Penaeus setiferus,Northern white shrimp,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,GMFMC,Shrimp Fishery of the Gulf of Mexico,NMFS/Rutgers IDW Interpolation -481,Penaeus setiferus,Northern white shrimp,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,GSMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -482,Peprilus burti,Gulf butterfish,Scombriformes (Mackerels),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -483,Peprilus paru,Harvestfish,Scombriformes (Mackerels),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -484,Pitarenus cordatus,Corded pitar,"Bivalvia (clams, muscles, oyster, arks, etc)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -485,Platylambrus granulatus,Bladetooth elbow crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -486,Polydactylus octonemus,Atlantic threadfin,"Carangaria/misc (barracuda, threadfins)",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -487,Polystira albida,White giant-turris,Gastropoda (sea snails and slugs),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -488,Porichthys plectrodon,Atlantic midshipman,Batrachoidiformes (Toadfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -489,Priacanthus arenatus,Atlantic bigeye,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -490,Prionotus alatus,Spiny searobin,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -491,Prionotus longispinosus,Bigeye searobin,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -492,Prionotus martis,Gulf of mexico barred searobin,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -493,Prionotus ophryas,Bandtail searobin,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -494,Prionotus paralatus,Mexican searobin,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -495,Prionotus roseus,Bluespotted searobin,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -496,Prionotus rubio,Blackwing searobin,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -497,Prionotus scitulus,Leopard searobin,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -498,Prionotus stearnsi,Shortwing searobin,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -499,Prionotus tribulus,Bighead searobin,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -500,Pristipomoides aquilonaris,Wenchman,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -501,Pseudorhombila quadridentata,Flecked squareback crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -502,Raninoides louisianensis,Gulf frog crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -503,Renilla muelleri,Mueller's sea pansy,"Cnidaria (jellyfish, corals, anenomes) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -504,Rhizoprionodon terraenovae,Atlantic sharpnose shark,Elasmobranchii: Selachii (sharks),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -505,Rhomboplites aurorubens,Vermilion snapper,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,GMFMC,Reef Fish Resources of the Gulf of Mexico,NMFS/Rutgers IDW Interpolation -506,Rhynchoconger flavus,Yellow conger,Anguilliformes (Eels and morays),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -507,Rostroraja eglanteria,Clearnose skate,"Elasmobranchii: Batoidea (skates, rays)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -508,Rostroraja texana,Roundel skate,"Elasmobranchii: Batoidea (skates, rays)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -509,Sardinella aurita,Spanish sardine,"Clupeiformes (Herrings, anchovy, shad)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -510,Saurida brasiliensis,Largescale lizardfish,"Aulopiformes (Grinners, lizardfish)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -511,Saurida normani,Shortjaw lizardfish,"Aulopiformes (Grinners, lizardfish)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -512,Scomberomorus maculatus,Spanish mackerel,Scombriformes (Mackerels),Gulf of Mexico,Gulf of Mexico,GMFMC,Coastal Migratory Pelagic Resources of the Gulf of Mexico and South Atlantic,Not for IDW -513,Scorpaena agassizii,Longfin scorpionfish,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -514,Scorpaena brasiliensis,Barbfish,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -515,Scorpaena calcarata,Smoothhead scorpionfish,Perciformes/Scorpaenoidei (Scorpionfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -516,Scyllarides nodifer,Ridged slipper lobster,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -517,Scyllarus chacei,Chace slipper lobster,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -518,Selene setapinnis,Atlantic moonfish,Carangiformes (Jacks),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -519,Serranus atrobranchus,Blackear bass,Perciformes/Serranoidei (Groupers),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -520,Serranus notospilus,Saddle bass,Perciformes/Serranoidei (Groupers),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -521,Serranus phoebe,Tattler,Perciformes/Serranoidei (Groupers),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -522,Sicyonia brevirostris,Brown rock shrimp,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,GMFMC,Shrimp Fishery of the Gulf of Mexico,NMFS/Rutgers IDW Interpolation -523,Sicyonia dorsalis,Lesser rock shrimp,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,GMFMC,Shrimp Fishery of the Gulf of Mexico,NMFS/Rutgers IDW Interpolation -524,Solenocera atlantidis,Dwarf humpback shrimp,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -525,Solenocera vioscai,Humpback shrimp,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -526,Sphoeroides dorsalis,Marbled puffer,Tetraodontiformes (puffers and filefishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -527,Sphoeroides parvus,Least puffer,Tetraodontiformes (puffers and filefishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -528,Sphoeroides spengleri,Bandtail puffer,Tetraodontiformes (puffers and filefishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -529,Squilla chydaea,Offshore mantis shrimp,Stomatopoda (mantis shrimp),Gulf of Mexico,Gulf of Mexico,GMFMC,Shrimp Fishery of the Gulf of Mexico,NMFS/Rutgers IDW Interpolation -530,Squilla empusa,Mantis shrimp,Stomatopoda (mantis shrimp),Gulf of Mexico,Gulf of Mexico,GMFMC,Shrimp Fishery of the Gulf of Mexico,NMFS/Rutgers IDW Interpolation -531,Stellifer lanceolatus,Star drum,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -532,Stenocionops coelatus,Furcate spider crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -533,Stenocionops furcatus,Furcate spider crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -534,Stenorhynchus seticornis,Yellowline arrow crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -535,Stenorhynchus yangi,Red arrow crab,Decapoda (Crabs/Lobster/Shrimp),Gulf of Mexico,Gulf of Mexico,,,Not for IDW -536,Stenotomus caprinus,Longspine porgy,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -537,Stephanolepis hispida,Planehead filefish,Tetraodontiformes (puffers and filefishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -538,Stylocidaris affinis,Pencil urchin,"Echinoidea (sea urchins, sand dollars) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -539,Syacium gunteri,Shoal flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -540,Syacium papillosum,Dusky flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -541,Symphurus diomedeanus,Spottedfin tonguefish,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -542,Symphurus plagiusa,Blackcheek tonguefish,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,Not for IDW -543,Synodus foetens,Inshore lizardfish,"Aulopiformes (Grinners, lizardfish)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -544,Synodus intermedius,Sand diver,"Aulopiformes (Grinners, lizardfish)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -545,Synodus macrostigmus,Largespot lizardfish,"Aulopiformes (Grinners, lizardfish)",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -546,Synodus poeyi,Offshore lizardfish,"Aulopiformes (Grinners, lizardfish)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -547,Trachinocephalus myops,Snakefish,"Aulopiformes (Grinners, lizardfish)",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -548,Trachurus lathami,Rough scad,Carangiformes (Jacks),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -549,Trichiurus lepturus,Atlantic cutlassfish,Scombriformes (Mackerels),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -550,Trichopsetta ventralis,Sash flounder,Pleuronectiformes (Flatfishes) ,Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -551,Upeneus parvus,Dwarf goatfish,Mulliformes (Goatfishes),Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -552,Urophycis cirrata,Gulf hake,"Gadiformes (Cods, genadiers, pollock) ",Gulf of Mexico,Gulf of Mexico,,,Not for IDW -553,Urophycis floridana,Southern hake,"Gadiformes (Cods, genadiers, pollock) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -554,Xyrichtys novacula,Pearly razorfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Gulf of Mexico,Gulf of Mexico,,,NMFS/Rutgers IDW Interpolation -555,Actinauge verrillii,Reticulate anemone,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -556,Albatrossia pectoralis,Giant grenadier,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Gulf of Alaska,,,Not for IDW -557,Anoplopoma fimbria,Sablefish,Perciformes/Cottoidei (sculpins),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -558,Aphrocallistes vastus,Cloud sponge,Porifera (sponges),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -559,Aphrodita negligens,Dishevelled sea-mouse,Polychaeta (brittle worms) ,Alaska,Gulf of Alaska,,,Not for IDW -560,Atheresthes stomias,Arrowtooth flounder,Pleuronectiformes (Flatfishes) ,Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -561,Balticina willemoesi,Willemoes's white sea pen,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Gulf of Alaska,,,Not for IDW -562,Bathymaster signatus,Searcher,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -563,Bathyraja spp.,Skate complex,"Elasmobranchii: Batoidea (skates, rays)",Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -564,Beringraja binoculata,Big skate,"Elasmobranchii: Batoidea (skates, rays)",Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -565,Beringraja rhina,Longnose skate,"Elasmobranchii: Batoidea (skates, rays)",Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -566,Berryteuthis magister,Magister armhook squid,"Cephalopoda (squid, octopus)",Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -567,Brisaster latifrons,Northern heart urchin,"Echinoidea (sea urchins, sand dollars) ",Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -568,Ceramaster patagonicus,Cookie star,Asteroidea (starfishes) ,Gulf of Mexico,Gulf of Alaska,,,Not for IDW -569,Cheiraster (Luidiaster) dawsoni,NA,Asteroidea (starfishes) ,Alaska,Gulf of Alaska,,,Not for IDW -570,Chionoecetes bairdi,Tanner crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -571,Chlamys rubida,Reddish scallop,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Gulf of Alaska,,,Not for IDW -572,Chrysaora melanaster,NA,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Gulf of Alaska,,,Not for IDW -573,Clupea pallasii,Pacific herring,"Clupeiformes (Herrings, anchovy, shad)",Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -574,Crossaster papposus,Common sunstar,Asteroidea (starfishes) ,Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -575,Ctenodiscus crispatus,Mud star,Asteroidea (starfishes) ,Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -576,Cyanea capillata,Lion's mane,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -577,Dasycottus setiger,Spinyhead sculpin,Perciformes/Cottoidei (sculpins),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -578,Dipsacaster borealis,Northern sand star,Asteroidea (starfishes) ,Alaska,Gulf of Alaska,,,Not for IDW -579,Elassochirus cavimanus,Purple hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,Not for IDW -580,Elassochirus tenuimanus,Widehand hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -581,Enteroctopus dofleini,North pacific giant octopus,"Cephalopoda (squid, octopus)",Alaska,Gulf of Alaska,,,Not for IDW -582,Fusitriton oregonensis,Oregon triton,Gastropoda (sea snails and slugs),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -583,Gadus chalcogrammus,Walleye pollock,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -584,Gadus macrocephalus,Pacific cod,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -585,Glyptocephalus zachirus,Rex sole,Pleuronectiformes (Flatfishes) ,Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -586,Gorgonocephalus eucnemis,Basket star,Ophiuroidea (brittle stars),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -587,Halocynthia igaboja,Bristly tunicate,"Tunicata (sea squirts, tunicates, salps) ",Alaska,Gulf of Alaska,,,Not for IDW -588,Hemilepidotus jordani,Yellow irish lord,Perciformes/Cottoidei (sculpins),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -589,Hemitripterus bolini,Bigmouth sculpin,Perciformes/Cottoidei (sculpins),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -590,Hexagrammos decagrammus,Kelp greenling,Perciformes/Cottoidei (sculpins),Alaska,Gulf of Alaska,,,Not for IDW -591,Hippoglossoides elassodon,Flathead sole,Pleuronectiformes (Flatfishes) ,Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -592,Hippoglossus stenolepis,Pacific halibut,Pleuronectiformes (Flatfishes) ,Alaska,Gulf of Alaska,NPFMC,Species Managed Under International Agreement - IPHC,NMFS/Rutgers IDW Interpolation -593,Histodermella kagigunensis,Spud sponge,Porifera (sponges),Alaska,Gulf of Alaska,,,Not for IDW -594,Hyas lyratus,Pacific lyre crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -595,Hydrolagus colliei,Spotted ratfish,Chimaeriformes (Chimaeras),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -596,Isopsetta isolepis,Butter sole,Pleuronectiformes (Flatfishes) ,Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -597,Laqueus erythraeus,California lamp shell,Terebratulida (lamp shells),Alaska,Gulf of Alaska,,,Not for IDW -598,Lepidopsetta sp.,Rock soles,Pleuronectiformes (Flatfishes) ,Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -599,Lethasterias nanimensis,Black spined sea star,Asteroidea (starfishes) ,Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -600,Limanda aspera,Yellowfin sole,Pleuronectiformes (Flatfishes) ,Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -601,Lycodes brevipes,Shortfin eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -602,Lycodes palearis,Wattled eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -603,Lyopsetta exilis,Slender sole,Pleuronectiformes (Flatfishes) ,Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -604,Malacocottus zonurus,Darkfin sculpin,Perciformes/Cottoidei (sculpins),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -605,Mallotus villosus,Capelin,"Osmeriformes (caplin, freshwater smelt)",Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -606,Merluccius productus,Pacific hake,"Gadiformes (Cods, genadiers, pollock) ",Alaska,Gulf of Alaska,,,Not for IDW -607,Metridium farcimen,Giant plumose anemone,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Gulf of Alaska,,,Not for IDW -608,Microstomus pacificus,Dover sole,Pleuronectiformes (Flatfishes) ,Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -609,Modiolus modiolus,Northern horsemussel,"Bivalvia (clams, muscles, oyster, arks, etc)",Alaska,Gulf of Alaska,,,Not for IDW -610,Mycale (Mycale) loveni,Loven's horny sponge,Porifera (sponges),Alaska,Gulf of Alaska,,,Not for IDW -611,Myoxocephalus polyacanthocephalus,Great sculpin,Perciformes/Cottoidei (sculpins),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -612,Oncorhynchus keta,Chum salmon,Salmoniformes (Salmons),Alaska,Gulf of Alaska,,,Not for IDW -613,Oncorhynchus tshawytscha,Chinook salmon,Salmoniformes (Salmons),Alaska,Gulf of Alaska,,,Not for IDW -614,Ophiodon elongatus,Lingcod,Perciformes/Cottoidei (sculpins),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -615,Ophiopholis aculeata,Daisy brittle star,Ophiuroidea (brittle stars),Alaska,Gulf of Alaska,,,Not for IDW -616,Ophiura sarsii,Notched brittle star,Ophiuroidea (brittle stars),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -617,Oregonia gracilis,Graceful decorator crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -618,Orthasterias koehleri,Rainbow star,Asteroidea (starfishes) ,Alaska,Gulf of Alaska,,,Not for IDW -619,Pagurus aleuticus,Aleutian hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -620,Pagurus brandti,Sponge hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,Not for IDW -621,Pagurus capillatus,Hairy hermit crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,Not for IDW -622,Pagurus confragosus,Knobbyhand hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,Not for IDW -623,Pagurus kennerlyi,Bluespine hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,Not for IDW -624,Pagurus ochotensis,Alaskan hermit crab,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,Not for IDW -625,Pagurus trigonocheirus,Fuzzy hermit,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,Not for IDW -626,Pandalus dispar,Sidestripe shrimp,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -627,Pandalus eous,Northern shrimp,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -628,Pandalus jordani,Ocean shrimp,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -629,Pandalus platyceros,Spot shrimp,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,Not for IDW -630,Parophrys vetulus,English sole,Pleuronectiformes (Flatfishes) ,Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -631,Pasiphaea pacifica,Pacific glass shrimp,Decapoda (Crabs/Lobster/Shrimp),Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -632,Phacellophora camtschatica,Fried egg jellyfish,"Cnidaria (jellyfish, corals, anenomes) ",Alaska,Gulf of Alaska,,,Not for IDW -633,Platichthys stellatus,Starry flounder,Pleuronectiformes (Flatfishes) ,Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -634,Pleurogrammus monopterygius,Atka mackerel,Perciformes/Cottoidei (sculpins),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -635,Pleuronectes quadrituberculatus,Alaska plaice,Pleuronectiformes (Flatfishes) ,Alaska,Gulf of Alaska,,,Not for IDW -636,Podothecus accipenserinus,Sturgeon poacher,Perciformes/Cottoidei (sculpins),Alaska,Gulf of Alaska,,,Not for IDW -637,Pseudarchaster parelii,Northern scarlet star,Asteroidea (starfishes) ,Alaska,Gulf of Alaska,,,Not for IDW -638,Pseudostichopus mollis,Sandy sea cucumber,Holothuroidea (sea cucumbers),Alaska,Gulf of Alaska,,,Not for IDW -639,Pteraster tesselatus,Tesselated slime star,Asteroidea (starfishes) ,Alaska,Gulf of Alaska,,,Not for IDW -640,Pycnopodia helianthoides,Sunflower sea star,Asteroidea (starfishes) ,Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -641,Rocinela angustata,Sea cockroach,Isopoda ,Alaska,Gulf of Alaska,,,Not for IDW -642,Rossia pacifica,Eastern pacific bobtail,"Cephalopoda (squid, octopus)",Alaska,Gulf of Alaska,,,Not for IDW -643,Sebastes alutus,Pacific ocean perch,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -644,Sebastes babcocki,Redbanded rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -645,Sebastes borealis,Shortraker rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -646,Sebastes brevispinis,Silvergray rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -647,Sebastes melanostictus and S. aleutianus,Blackspotted and rougheye rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -648,Sebastes polyspinis,Northern rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -649,Sebastes proriger,Redstripe rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,Not for IDW -650,Sebastes variabilis and S. ciliatus,Dusky and dark rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -651,Sebastes variegatus,Harlequin rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,Not for IDW -652,Sebastes zacentrus,Sharpchin rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -653,Sebastolobus alascanus,Shortspine thornyhead,Perciformes/Scorpaenoidei (Scorpionfishes),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -654,Squalus suckleyi,Pacific spiny dogfish,Elasmobranchii: Selachii (sharks),Alaska,Gulf of Alaska,NPFMC,Groundfish of the Gulf of Alaska,NMFS/Rutgers IDW Interpolation -655,Stegophiura ponderosa,NA,Ophiuroidea (brittle stars),Alaska,Gulf of Alaska,,,Not for IDW -656,Stenobrachius leucopsarus,Northern lampfish,Myctophiformes (Lanternfishes),Alaska,Gulf of Alaska,,,Not for IDW -657,Strongylocentrotus droebachiensis,Green sea urchin,"Echinoidea (sea urchins, sand dollars) ",Alaska,Gulf of Alaska,,,Not for IDW -658,Strongylocentrotus fragilis,Fragile sea urchin,"Echinoidea (sea urchins, sand dollars) ",Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -659,Strongylocentrotus pallidus,Pale urchin,"Echinoidea (sea urchins, sand dollars) ",Alaska,Gulf of Alaska,,,Not for IDW -660,Strongylocentrotus polyacanthus,NA,"Echinoidea (sea urchins, sand dollars) ",Alaska,Gulf of Alaska,,,Not for IDW -661,Styela rustica,Sea potato,"Tunicata (sea squirts, tunicates, salps) ",Alaska,Gulf of Alaska,,,Not for IDW -662,Stylasterias forreri,Velcro star,Asteroidea (starfishes) ,Alaska,Gulf of Alaska,,,Not for IDW -663,Suberites domuncula,Sea orange,Porifera (sponges),Alaska,Gulf of Alaska,,,Not for IDW -664,Suberites ficus,Fig sponge,Porifera (sponges),Alaska,Gulf of Alaska,,,Not for IDW -665,Synallactes challengeri,Challenger cucumber,Holothuroidea (sea cucumbers),Alaska,Gulf of Alaska,,,Not for IDW -666,Terebratalia transversa,Common lamp shell,Terebratulida (lamp shells),Alaska,Gulf of Alaska,,,Not for IDW -667,Thaleichthys pacificus,Eulachon,"Osmeriformes (caplin, freshwater smelt)",Alaska,Gulf of Alaska,,,NMFS/Rutgers IDW Interpolation -668,Zaprora silenus,Prowfish,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),Alaska,Gulf of Alaska,,,Not for IDW -669,Alosa aestivalis,Blueback herring,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Northeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -670,Alosa pseudoharengus,Alewife,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Northeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -671,Alosa sapidissima,American shad,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Northeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -672,Amblyraja radiata,Thorny skate,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Northeast US,NEFMC,Northeast Skate Complex,NMFS/Rutgers IDW Interpolation -673,Ammodytes dubius,Northern sand lance,Perciformes/Uranoscopoidei (Sand dwellers),US East Coast,Northeast US,,,Not for IDW -674,Anarhichas lupus,Atlantic wolffish,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -675,Anchoa hepsetus,Striped anchovy,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Northeast US,,,Not for IDW -676,Anchoa mitchilli,Bay anchovy,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Northeast US,,,Not for IDW -677,Antigonia capros,Deepbody boarfish,Acanthuriformes (Surgeonfishes),US East Coast,Northeast US,,,Not for IDW -678,Aspidophoroides monopterygius,Alligatorfish,Perciformes/Cottoidei (sculpins),US East Coast,Northeast US,,,Not for IDW -679,Atlantopandalus propinqvus,Similar shrimp,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,,,Not for IDW -680,Bathypolypus arcticus,North atlantic octopus,"Cephalopoda (squid, octopus)",US East Coast,Northeast US,,,Not for IDW -681,Bathytoshia centroura,Roughtail stingray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Northeast US,,,Not for IDW -682,Brosme brosme,Cusk,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Northeast US,,,Not for IDW -683,Cancer borealis,Jonah crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -684,Cancer irroratus,Atlantic rock crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,,,NMFS/Rutgers IDW Interpolation -685,Caranx crysos,Blue runner,Carangiformes (Jacks),US East Coast,Northeast US,,,Not for IDW -686,Centropristis striata,Black sea bass,Perciformes/Serranoidei (Groupers),US East Coast,Northeast US,ASMFC,"Summer Flounder, Scup and Black Sea Bass",NMFS/Rutgers IDW Interpolation -687,Centropristis striata,Black sea bass,Perciformes/Serranoidei (Groupers),US East Coast,Northeast US,MAFMC,"Summer Flounder, Scup and Black Sea Bass",NMFS/Rutgers IDW Interpolation -688,Chaceon quinquedens,Red deepsea crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,NEFMC,Deep-sea red crab,NMFS/Rutgers IDW Interpolation -689,Chlorophthalmus agassizi,Shortnose greeneye,"Aulopiformes (Grinners, lizardfish)",US East Coast,Northeast US,,,Not for IDW -690,Citharichthys arctifrons,Gulf stream flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Northeast US,,,NMFS/Rutgers IDW Interpolation -691,Clupea harengus,Atlantic herring,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Northeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -692,Clupea harengus,Atlantic herring,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Northeast US,NEFMC,Atlantic Herring,NMFS/Rutgers IDW Interpolation -693,Cryptacanthodes maculatus,Wrymouth,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),US East Coast,Northeast US,,,Not for IDW -694,Cynoscion regalis,Weakfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Northeast US,ASMFC,Interstate Fishery Management Plan ,Not for IDW -695,Decapterus punctatus,Round scad,Carangiformes (Jacks),US East Coast,Northeast US,,,Not for IDW -696,Dichelopandalus leptocerus,Bristled longbeak,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,,,Not for IDW -697,Dipturus laevis,Barndoor skate,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Northeast US,NEFMC,Northeast Skate Complex,NMFS/Rutgers IDW Interpolation -698,Doryteuthis pealeii,Longfin inshore squid,"Cephalopoda (squid, octopus)",US East Coast,Northeast US,MAFMC,"Mackerel, Squid and Butterfish",NMFS/Rutgers IDW Interpolation -699,Enchelyopus cimbrius,Fourbeard rockling,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Northeast US,,,Not for IDW -700,Etrumeus sadina,Round herring,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Northeast US,,,Not for IDW -701,Gadus morhua,Atlantic cod,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -702,Glyptocephalus cynoglossus,Witch flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -703,Helicolenus dactylopterus,Blackbelly rosefish,Perciformes/Scorpaenoidei (Scorpionfishes),US East Coast,Northeast US,,,Not for IDW -704,Hemitripterus americanus,Sea raven,Perciformes/Cottoidei (sculpins),US East Coast,Northeast US,,,NMFS/Rutgers IDW Interpolation -705,Hippoglossina oblonga,American fourspot flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Northeast US,,,NMFS/Rutgers IDW Interpolation -706,Hippoglossoides platessoides,American plaice,Pleuronectiformes (Flatfishes) ,US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -707,Hippoglossus hippoglossus,Atlantic halibut,Pleuronectiformes (Flatfishes) ,US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -708,Homarus americanus,American lobster,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -709,Hypanus say,Bluntnose stingray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Northeast US,,,Not for IDW -710,Illex illecebrosus,Northern shortfin squid,"Cephalopoda (squid, octopus)",US East Coast,Northeast US,MAFMC,"Mackerel, Squid and Butterfish",NMFS/Rutgers IDW Interpolation -711,Larimus fasciatus,Banded drum,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Northeast US,,,Not for IDW -712,Leiostomus xanthurus,Spot,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Northeast US,ASMFC,Interstate Fishery Management Plan ,Not for IDW -713,Lepophidium profundorum,Fawn cusk-eel,Ophidiiformes (Cusk eels) ,US East Coast,Northeast US,,,NMFS/Rutgers IDW Interpolation -714,Leucoraja erinaceus,Little skate,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Northeast US,NEFMC,Northeast Skate Complex,NMFS/Rutgers IDW Interpolation -715,Leucoraja garmani,Rosette skate,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Northeast US,NEFMC,Northeast Skate Complex,NMFS/Rutgers IDW Interpolation -716,Leucoraja ocellata,Winter skate,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Northeast US,NEFMC,Northeast Skate Complex,NMFS/Rutgers IDW Interpolation -717,Limulus polyphemus,Horseshoe crab,Xiphosura (horseshoe crabs),US East Coast,Northeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -718,Lithodes maja,Norway king crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,,,Not for IDW -719,Lophius americanus,Monkfish,Lophiiformes (Anglerfishes),US East Coast,Northeast US,MAFMC,Monkfish,NMFS/Rutgers IDW Interpolation -720,Lophius americanus,Monkfish,Lophiiformes (Anglerfishes),US East Coast,Northeast US,NEFMC,Monkfish,NMFS/Rutgers IDW Interpolation -721,Malacoraja senta,Smooth skate,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Northeast US,NEFMC,Northeast Skate Complex,NMFS/Rutgers IDW Interpolation -722,Maurolicus weitzmani,Atlantic pearlside,Stomiiformes (Lightfishes and dragonfishes),US East Coast,Northeast US,,,Not for IDW -723,Melanogrammus aeglefinus,Haddock,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -724,Menticirrhus americanus,Southern kingfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Northeast US,,,Not for IDW -725,Menticirrhus saxatilis,Northern kingfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Northeast US,,,Not for IDW -726,Merluccius albidus,Offshore hake,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -727,Merluccius bilinearis,Silver hake,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -728,Micropogonias undulatus,Atlantic croaker,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Northeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -729,Mustelus canis,Smooth dogfish,Elasmobranchii: Selachii (sharks),US East Coast,Northeast US,Atlantic HMS,Consolidated Atlantic Highly Migratory Species,NMFS/Rutgers IDW Interpolation -730,Myliobatis freminvillei,Bullnose eagle ray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Northeast US,,,Not for IDW -731,Myoxocephalus octodecemspinosus,Longhorn sculpin,Perciformes/Cottoidei (sculpins),US East Coast,Northeast US,,,NMFS/Rutgers IDW Interpolation -732,Myxine glutinosa,Atlantic hagfish,Myxiniformes (Hagfishes),US East Coast,Northeast US,,,Not for IDW -733,Myzopsetta ferruginea,Yellowtail flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -734,Opisthonema oglinum,Atlantic thread herring,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Northeast US,,,Not for IDW -735,Ovalipes ocellatus,Ocellate lady crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,,,Not for IDW -736,Ovalipes stephensoni,Coarsehand lady crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,,,Not for IDW -737,Pandalus borealis,Atlantic northern shrimp,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -738,Pandalus montagui,Aesop shrimp,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,,,Not for IDW -739,Paralichthys dentatus,Summer flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Northeast US,ASMFC,"Summer Flounder, Scup and Black Sea Bass",NMFS/Rutgers IDW Interpolation -740,Paralichthys dentatus,Summer flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Northeast US,MAFMC,"Summer Flounder, Scup and Black Sea Bass",NMFS/Rutgers IDW Interpolation -741,Pasiphaea multidentata,Pink glass shrimp,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,,,Not for IDW -742,Peprilus triacanthus,American butterfish,Scombriformes (Mackerels),US East Coast,Northeast US,MAFMC,"Mackerel, Squid and Butterfish",NMFS/Rutgers IDW Interpolation -743,Peristedion miniatum,Armored searobin,Perciformes/Scorpaenoidei (Scorpionfishes),US East Coast,Northeast US,,,Not for IDW -744,Phycis chesteri,Longfin hake,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -745,Placopecten magellanicus,Atlantic sea scallop,"Bivalvia (clams, muscles, oyster, arks, etc)",US East Coast,Northeast US,NEFMC,Atlantic Sea Scallop,NMFS/Rutgers IDW Interpolation -746,Pollachius virens,Pollock,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -747,Polymixia lowei,Beardfish,Polymixiiformes (Beardfishes),US East Coast,Northeast US,,,Not for IDW -748,Pomatomus saltatrix,Bluefish,Scombriformes (Mackerels),US East Coast,Northeast US,ASMFC,Bluefish,NMFS/Rutgers IDW Interpolation -749,Pomatomus saltatrix,Bluefish,Scombriformes (Mackerels),US East Coast,Northeast US,MAFMC,Bluefish,NMFS/Rutgers IDW Interpolation -750,Pontophilus norvegicus,Norwegian shrimp,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,,,Not for IDW -751,Prionotus carolinus,Northern searobin,Perciformes/Scorpaenoidei (Scorpionfishes),US East Coast,Northeast US,,,NMFS/Rutgers IDW Interpolation -752,Prionotus evolans,Striped searobin,Perciformes/Scorpaenoidei (Scorpionfishes),US East Coast,Northeast US,,,Not for IDW -753,Pseudopleuronectes americanus,Winter flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Northeast US,ASMFC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -754,Pseudopleuronectes americanus,Winter flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -755,Rhizoprionodon terraenovae,Atlantic sharpnose shark,Elasmobranchii: Selachii (sharks),US East Coast,Northeast US,Atlantic HMS,Consolidated Atlantic Highly Migratory Species,NMFS/Rutgers IDW Interpolation -756,Rostroraja eglanteria,Clearnose skate,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Northeast US,NEFMC,Northeast Skate Complex,NMFS/Rutgers IDW Interpolation -757,Sardinella aurita,Spanish sardine,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Northeast US,,,Not for IDW -758,Scomber scombrus,Atlantic mackerel,Scombriformes (Mackerels),US East Coast,Northeast US,MAFMC,"Mackerel, Squid and Butterfish",NMFS/Rutgers IDW Interpolation -759,Scomberesox saurus,Atlantic saury,Scombriformes (Mackerels),US East Coast,Northeast US,,,Not for IDW -760,Scomberomorus maculatus,Spanish mackerel,Scombriformes (Mackerels),US East Coast,Northeast US,,,Not for IDW -761,Scophthalmus aquosus,Windowpane flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -762,Scyliorhinus retifer,Chain catshark,Elasmobranchii: Selachii (sharks),US East Coast,Northeast US,,,Not for IDW -763,Sebastes fasciatus,Acadian redfish,Perciformes/Scorpaenoidei (Scorpionfishes),US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -764,Selene setapinnis,Atlantic moonfish,Carangiformes (Jacks),US East Coast,Northeast US,,,Not for IDW -765,Sphoeroides maculatus,Northern puffer,Tetraodontiformes (puffers and filefishes),US East Coast,Northeast US,,,Not for IDW -766,Squalus acanthias,Spiny dogfish,Elasmobranchii: Selachii (sharks),US East Coast,Northeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -767,Squalus acanthias,Spiny dogfish,Elasmobranchii: Selachii (sharks),US East Coast,Northeast US,MAFMC,Spiny Dogfish,NMFS/Rutgers IDW Interpolation -768,Squalus acanthias,Spiny dogfish,Elasmobranchii: Selachii (sharks),US East Coast,Northeast US,NEFMC,Spiny Dogfish,NMFS/Rutgers IDW Interpolation -769,Stenotomus chrysops,Scup,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Northeast US,ASMFC,"Summer Flounder, Scup and Black Sea Bass",NMFS/Rutgers IDW Interpolation -770,Stenotomus chrysops,Scup,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Northeast US,MAFMC,"Summer Flounder, Scup and Black Sea Bass",NMFS/Rutgers IDW Interpolation -771,Synodus foetens,Inshore lizardfish,"Aulopiformes (Grinners, lizardfish)",US East Coast,Northeast US,,,Not for IDW -772,Tautogolabrus adspersus,Cunner,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Northeast US,,,Not for IDW -773,Trachurus lathami,Rough scad,Carangiformes (Jacks),US East Coast,Northeast US,,,Not for IDW -774,Trichiurus lepturus,Atlantic cutlassfish,Scombriformes (Mackerels),US East Coast,Northeast US,,,Not for IDW -775,Urophycis chuss,Red hake,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -776,Urophycis regia,Spotted hake,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Northeast US,,,NMFS/Rutgers IDW Interpolation -777,Urophycis tenuis,White hake,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -778,Zenopsis conchifer,Silvery john dory,Zeiformes(Dories),US East Coast,Northeast US,,,Not for IDW -779,Zoarces americanus,Ocean pout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),US East Coast,Northeast US,NEFMC,Northeast Multispecies,NMFS/Rutgers IDW Interpolation -780,Crangon septemspinosa,Sevenspine bay shrimp,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,,,Not for IDW -781,Etropus microstomus,Smallmouth flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Northeast US,,,Not for IDW -782,Lebbeus polaris,Polar lebbeid,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Northeast US,,,Not for IDW -783,Menidia menidia,Atlantic silverside,Atheriniformes (Silversides),US East Coast,Northeast US,,,Not for IDW -784,Acanthostracion quadricornis,Scrawled cowfish,Tetraodontiformes (puffers and filefishes),US East Coast,Southeast US,,,Not for IDW -785,Achelous gibbesii,Iridescent swimming crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -786,Achelous spinimanus,Blotched swimming crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -787,Aetobatus narinari,Spotted eagle ray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Southeast US,,,Not for IDW -788,Alosa aestivalis,Blueback herring,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Southeast US,ASMFC,Interstate Fishery Management Plan ,Not for IDW -789,Aluterus schoepfii,Orange filefish,Tetraodontiformes (puffers and filefishes),US East Coast,Southeast US,,,Not for IDW -790,Anchoa spp.,Anchovies,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -791,Ancylopsetta quadrocellata,Ocellated flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -792,Archosargus probatocephalus,Sheepshead,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,Not for IDW -793,Arenaeus cribrarius,Speckled swimming crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -794,Ariopsis felis,Hardhead catfish,Siluriformes (catfishes),US East Coast,Southeast US,,,Not for IDW -795,Bagre marinus,Gafftopsail catfish,Siluriformes (catfishes),US East Coast,Southeast US,,,Not for IDW -796,Bairdiella chrysoura,Silver perch,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -797,Bathytoshia centroura,Roughtail stingray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Southeast US,,,Not for IDW -798,Brevoortia smithi,Yellowfin menhaden,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Southeast US,,,Not for IDW -799,Brevoortia tyrannus,Atlantic menhaden,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Southeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -800,Calamus leucosteus,Whitebone porgy,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,Not for IDW -801,Calappa flammea,Flame box crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,Not for IDW -802,Callinectes ornatus,Shelling crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -803,Callinectes sapidus,Blue crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -804,Callinectes similis,Lesser blue crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -805,Caranx crysos,Blue runner,Carangiformes (Jacks),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -806,Caranx hippos,Crevalle jack,Carangiformes (Jacks),US East Coast,Southeast US,,,Not for IDW -807,Carcharhinus acronotus,Blacknose shark,Elasmobranchii: Selachii (sharks),US East Coast,Southeast US,Atlantic HMS,Consolidated Atlantic Highly Migratory Species,Not for IDW -808,Carcharhinus limbatus,Blacktip shark,Elasmobranchii: Selachii (sharks),US East Coast,Southeast US,Atlantic HMS,Consolidated Atlantic Highly Migratory Species,Not for IDW -809,Centropristis philadelphica,Rock sea bass,Perciformes/Serranoidei (Groupers),US East Coast,Southeast US,SAFMC,Snapper-Grouper Fishery of the South Atlantic Region,NMFS/Rutgers IDW Interpolation -810,Centropristis striata,Black sea bass,Perciformes/Serranoidei (Groupers),US East Coast,Southeast US,SAFMC,Snapper-Grouper Fishery of the South Atlantic Region,NMFS/Rutgers IDW Interpolation -811,Chaetodipterus faber,Atlantic spadefish,Acanthuriformes (Surgeonfishes),US East Coast,Southeast US,SAFMC,Snapper-Grouper Fishery of the South Atlantic Region,NMFS/Rutgers IDW Interpolation -812,Charybdis (Charybdis) hellerii,Spiny hands,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,Not for IDW -813,Chilomycterus schoepfii,Striped burrfish,Tetraodontiformes (puffers and filefishes),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -814,Chloroscombrus chrysurus,Atlantic bumper,Carangiformes (Jacks),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -815,Citharichthys macrops,Spotted whiff,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -816,Citharichthys spilopterus,Bay whiff,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -817,Cynoscion nebulosus,Spotted weakfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,Not for IDW -818,Cynoscion nothus,Silver seatrout,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -819,Cynoscion regalis,Weakfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -820,Cynoscion regalis,Weakfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,SAFMC,Snapper-Grouper Fishery of the South Atlantic Region,NMFS/Rutgers IDW Interpolation -821,Decapterus punctatus,Round scad,Carangiformes (Jacks),US East Coast,Southeast US,,,Not for IDW -822,Diplectrum formosum,Sand perch,Perciformes/Serranoidei (Groupers),US East Coast,Southeast US,,,Not for IDW -823,Doryteuthis sp,Inshore Squid sp.,"Cephalopoda (squid, octopus)",US East Coast,Southeast US,SAFMC,,NMFS/Rutgers IDW Interpolation -824,Echeneis naucrates,Sharksucker,Carangiformes (Jacks),US East Coast,Southeast US,,,Not for IDW -825,Etropus crossotus,Fringed flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -826,Etropus cyclosquamus,Shelf flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -827,Eucinostomus spp.,Mojarras,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -828,Gibbesia neglecta,Lesser mantis shrimp,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -829,Gymnachirus melas,Naked sole,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,,,Not for IDW -830,Gymnura altavela,Spiny butterfly ray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Southeast US,,,Not for IDW -831,Gymnura micrura,Smooth butterfly ray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -832,Harengula jaguana,Scaled sardine,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -833,Hepatus epheliticus,Calico box crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -834,Hippocampus erectus,Lined seahorse,Syngnathiformes (Seahorses),US East Coast,Southeast US,,,Not for IDW -835,Hypanus americanus,Southern stingray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -836,Hypanus sabinus,Atlantic stingray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -837,Hypanus say,Bluntnose stingray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -838,Lagocephalus laevigatus,Smooth puffer,Tetraodontiformes (puffers and filefishes),US East Coast,Southeast US,,,Not for IDW -839,Lagodon rhomboides,Pinfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -840,Larimus fasciatus,Banded drum,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -841,Leiostomus xanthurus,Spot,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -842,Limulus polyphemus,Horseshoe crab,Xiphosura (horseshoe crabs),US East Coast,Southeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -843,Lolliguncula brevis,Atlantic brief squid,"Cephalopoda (squid, octopus)",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -844,Lutjanus synagris,Lane snapper,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,Not for IDW -845,Menippe mercenaria,Florida stone crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,Not for IDW -846,Menticirrhus americanus,Southern kingfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -847,Menticirrhus littoralis,Gulf kingfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -848,Menticirrhus saxatilis,Northern kingfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,Not for IDW -849,Micropogonias undulatus,Atlantic croaker,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -850,Mobula hypostoma,Devil ray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Southeast US,,,Not for IDW -851,Mugil curema,White mullet,Mugiliformes (Mullets),US East Coast,Southeast US,,,Not for IDW -852,Myliobatis freminvillei,Bullnose eagle ray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -853,Narcine brasiliensis,Brazilian electric ray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Southeast US,,,Not for IDW -854,Octopus vulgaris,Common octopus,"Cephalopoda (squid, octopus)",US East Coast,Southeast US,,,Not for IDW -855,Ogcocephalus cubifrons,NA,Lophiiformes (Anglerfishes),US East Coast,Southeast US,,,Not for IDW -856,Ogcocephalus rostellum,Palefin batfish,Lophiiformes (Anglerfishes),US East Coast,Southeast US,,,Not for IDW -857,Opisthonema oglinum,Atlantic thread herring,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -858,Orthopristis chrysoptera,Pigfish,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -859,Ovalipes ocellatus,Ocellate lady crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -860,Ovalipes stephensoni,Coarsehand lady crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -861,Pagurus longicarpus,Longwrist hermit crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,Not for IDW -862,Pagurus pollicaris,Gray hermit crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -863,Paralichthys albigutta,Gulf flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,,,Not for IDW -864,Paralichthys dentatus,Summer flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,ASMFC,"Summer Flounder, Scup and Black Sea Bass",NMFS/Rutgers IDW Interpolation -865,Paralichthys dentatus,Summer flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,MAFMC,"Summer Flounder, Scup and Black Sea Bass",NMFS/Rutgers IDW Interpolation -866,Paralichthys lethostigma,Southern flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -867,Penaeus aztecus,Brown shrimp,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,SAFMC,Shrimp Fishery of the South Atlantic Region,NMFS/Rutgers IDW Interpolation -868,Penaeus duorarum,Pink shrimp,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,SAFMC,Shrimp Fishery of the South Atlantic Region,NMFS/Rutgers IDW Interpolation -869,Penaeus setiferus,Northern white shrimp,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,SAFMC,Shrimp Fishery of the South Atlantic Region,NMFS/Rutgers IDW Interpolation -870,Peprilus paru,Harvestfish,Scombriformes (Mackerels),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -871,Peprilus triacanthus,American butterfish,Scombriformes (Mackerels),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -872,Persephona mediterranea,Mottled purse crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -873,Pilumnus sayi,Spineback hairy crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,Not for IDW -874,Pogonias cromis,Black drum,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,ASMFC,Interstate Fishery Management Plan ,Not for IDW -875,Pomatomus saltatrix,Bluefish,Scombriformes (Mackerels),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -876,Porcellana sigsbeiana,Striped porcelain crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,Not for IDW -877,Portunus sayi,Sargassum swimming crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,Not for IDW -878,Prionotus carolinus,Northern searobin,Perciformes/Scorpaenoidei (Scorpionfishes),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -879,Prionotus evolans,Striped searobin,Perciformes/Scorpaenoidei (Scorpionfishes),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -880,Prionotus rubio,Blackwing searobin,Perciformes/Scorpaenoidei (Scorpionfishes),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -881,Prionotus scitulus,Leopard searobin,Perciformes/Scorpaenoidei (Scorpionfishes),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -882,Prionotus tribulus,Bighead searobin,Perciformes/Scorpaenoidei (Scorpionfishes),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -883,Pseudobatos lentiginosus,Atlantic guitarfish,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Southeast US,,,Not for IDW -884,Rachycentron canadum,Cobia,Carangiformes (Jacks),US East Coast,Southeast US,,,Not for IDW -885,Rhinoptera bonasus,Cownose ray,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -886,Rhizoprionodon terraenovae,Atlantic sharpnose shark,Elasmobranchii: Selachii (sharks),US East Coast,Southeast US,Atlantic HMS,Consolidated Atlantic Highly Migratory Species,NMFS/Rutgers IDW Interpolation -887,Rimapenaeus constrictus,Roughneck shrimp,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,Not for IDW -888,Rostroraja eglanteria,Clearnose skate,"Elasmobranchii: Batoidea (skates, rays)",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -889,Sardinella aurita,Spanish sardine,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Southeast US,,,Not for IDW -890,Scomberomorus cavalla,King mackerel,Scombriformes (Mackerels),US East Coast,Southeast US,GMFMC,Coastal Migratory Pelagic Resources of the Gulf of Mexico and South Atlantic,NMFS/Rutgers IDW Interpolation -891,Scomberomorus cavalla,King mackerel,Scombriformes (Mackerels),US East Coast,Southeast US,SAFMC,Coastal Migratory Pelagic Resources of the Gulf of Mexico and South Atlantic,NMFS/Rutgers IDW Interpolation -892,Scomberomorus maculatus,Spanish mackerel,Scombriformes (Mackerels),US East Coast,Southeast US,ASMFC,Interstate Fishery Management Plan ,NMFS/Rutgers IDW Interpolation -893,Scomberomorus maculatus,Spanish mackerel,Scombriformes (Mackerels),US East Coast,Southeast US,GMFMC,Coastal Migratory Pelagic Resources of the Gulf of Mexico and South Atlantic,NMFS/Rutgers IDW Interpolation -894,Scomberomorus maculatus,Spanish mackerel,Scombriformes (Mackerels),US East Coast,Southeast US,SAFMC,Coastal Migratory Pelagic Resources of the Gulf of Mexico and South Atlantic,NMFS/Rutgers IDW Interpolation -895,Scophthalmus aquosus,Windowpane flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -896,Selene setapinnis,Atlantic moonfish,Carangiformes (Jacks),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -897,Selene vomer,Lookdown,Carangiformes (Jacks),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -898,Sphoeroides maculatus,Northern puffer,Tetraodontiformes (puffers and filefishes),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -899,Sphyraena guachancho,Guachanche barracuda,"Carangaria/misc (barracuda, threadfins)",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -900,Sphyrna lewini,Scalloped hammerhead,Elasmobranchii: Selachii (sharks),US East Coast,Southeast US,Atlantic HMS,Consolidated Atlantic Highly Migratory Species,Not for IDW -901,Sphyrna tiburo,Bonnethead,Elasmobranchii: Selachii (sharks),US East Coast,Southeast US,Atlantic HMS,Consolidated Atlantic Highly Migratory Species,NMFS/Rutgers IDW Interpolation -902,Squilla empusa,Mantis shrimp,Stomatopoda (mantis shrimp),US East Coast,Southeast US,SAFMC,Shrimp Fishery of the South Atlantic Region,NMFS/Rutgers IDW Interpolation -903,Stellifer lanceolatus,Star drum,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -904,Stephanolepis hispida,Planehead filefish,Tetraodontiformes (puffers and filefishes),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -905,Stomolophus meleagris,Cannonball jellyfish,"Cnidaria (jellyfish, corals, anenomes) ",US East Coast,Southeast US,,,Not for IDW -906,Syacium papillosum,Dusky flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,,,Not for IDW -907,Symphurus plagiusa,Blackcheek tonguefish,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -908,Synodus foetens,Inshore lizardfish,"Aulopiformes (Grinners, lizardfish)",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -909,Trachinotus carolinus,Florida pompano,Carangiformes (Jacks),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -910,Trichiurus lepturus,Atlantic cutlassfish,Scombriformes (Mackerels),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -911,Trinectes maculatus,Hogchoker,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -912,Urophycis earllii,Carolina hake,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Southeast US,,,Not for IDW -913,Xiphopenaeus kroyeri,Atlantic seabob,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -914,Alopias vulpinus,Thresher,Elasmobranchii: Selachii (sharks),US East Coast,Southeast US,,,Not for IDW -915,Cancer irroratus,Atlantic rock crab,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,Not for IDW -916,Carcharias taurus,Sand tiger shark,Elasmobranchii: Selachii (sharks),US East Coast,Southeast US,,,Not for IDW -917,Etrumeus sadina,Round herring,"Clupeiformes (Herrings, anchovy, shad)",US East Coast,Southeast US,,,Not for IDW -918,Mustelus canis,Smooth dogfish,Elasmobranchii: Selachii (sharks),US East Coast,Southeast US,Atlantic HMS,Consolidated Atlantic Highly Migratory Species,NMFS/Rutgers IDW Interpolation -919,Oligoplites saurus,Leatherjacket,Carangiformes (Jacks),US East Coast,Southeast US,,,Not for IDW -920,Ophidion marginatum,Striped cusk-eel,Ophidiiformes (Cusk eels) ,US East Coast,Southeast US,,,Not for IDW -921,Sicyonia brevirostris,Brown rock shrimp,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,SAFMC,Shrimp Fishery of the South Atlantic Region,Not for IDW -922,Squalus acanthias,Spiny dogfish,Elasmobranchii: Selachii (sharks),US East Coast,Southeast US,,,Not for IDW -923,Squatina dumeril,Sand devil,Elasmobranchii: Selachii (sharks),US East Coast,Southeast US,,,Not for IDW -924,Syngnathus louisianae,Chain pipefish,Syngnathiformes (Seahorses),US East Coast,Southeast US,,,Not for IDW -925,Trachurus lathami,Rough scad,Carangiformes (Jacks),US East Coast,Southeast US,,,Not for IDW -926,Upeneus parvus,Dwarf goatfish,Mulliformes (Goatfishes),US East Coast,Southeast US,,,Not for IDW -927,Urophycis floridana,Southern hake,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Southeast US,,,Not for IDW -928,Urophycis regia,Spotted hake,"Gadiformes (Cods, genadiers, pollock) ",US East Coast,Southeast US,,,NMFS/Rutgers IDW Interpolation -929,Alectis ciliaris,African pompano,Carangiformes (Jacks),US East Coast,Southeast US,,,Not for IDW -930,Carcharhinus brevipinna,Spinner shark,Elasmobranchii: Selachii (sharks),US East Coast,Southeast US,,,Not for IDW -931,Gobiosoma bosc,Naked goby,Gobiiformes (Gobies),US East Coast,Southeast US,,,Not for IDW -932,Haemulon aurolineatum,Tomtate grunt,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US East Coast,Southeast US,,,Not for IDW -933,Hypleurochilus geminatus,Crested blenny,Blenniiformes (Blennies),US East Coast,Southeast US,,,Not for IDW -934,Opsanus tau,Oyster toadfish,Batrachoidiformes (Toadfishes),US East Coast,Southeast US,,,Not for IDW -935,Paralichthys squamilentus,Broad flounder,Pleuronectiformes (Flatfishes) ,US East Coast,Southeast US,,,Not for IDW -936,Petrochirus diogenes,Giant hermit,Decapoda (Crabs/Lobster/Shrimp),US East Coast,Southeast US,,,Not for IDW -937,Porichthys plectrodon,Atlantic midshipman,Batrachoidiformes (Toadfishes),US East Coast,Southeast US,,,Not for IDW -938,Actinauge verrillii,Reticulate anemone,"Cnidaria (jellyfish, corals, anenomes) ",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -939,Actinostola faeculenta,Hobnail vase anemone,"Cnidaria (jellyfish, corals, anenomes) ",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -940,Albatrossia pectoralis,Giant grenadier,"Gadiformes (Cods, genadiers, pollock) ",US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -941,Alepocephalus tenebrosus,California slickhead,Alepocephaliformes (Slickheads and tubeshoulders.),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -942,Alosa sapidissima,American shad,"Clupeiformes (Herrings, anchovy, shad)",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -943,Ampheraster marianus,Mariana's island star,Asteroidea (starfishes) ,US West Coast,West Coast,,,Not for IDW -944,Anoplopoma fimbria,Sablefish,Perciformes/Cottoidei (sculpins),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -945,Anthopleura xanthogrammica,Giant green anemone,"Cnidaria (jellyfish, corals, anenomes) ",US West Coast,West Coast,,,Not for IDW -946,Anthoptilum grandiflorum,Feather boa sea pen,"Cnidaria (jellyfish, corals, anenomes) ",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -947,Antimora microlepis,Finescale mora,"Gadiformes (Cods, genadiers, pollock) ",US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -948,Aphrocallistes vastus,Cloud sponge,Porifera (sponges),US West Coast,West Coast,,,Not for IDW -949,Apostichopus californicus,Giant california sea cucumber,Holothuroidea (sea cucumbers),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -950,Apostichopus leukothele,White-knobbed sea cucumber,Holothuroidea (sea cucumbers),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -951,Apristurus brunneus,Brown catshark,Elasmobranchii: Selachii (sharks),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -952,Astropecten californicus,California sand star,Asteroidea (starfishes) ,US West Coast,West Coast,,,Not for IDW -953,Atheresthes stomias,Arrowtooth flounder,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -954,Bathyagonus nigripinnis,Blackfin poacher,Perciformes/Cottoidei (sculpins),US West Coast,West Coast,,,Not for IDW -955,Bathybembix bairdii,NA,Gastropoda (sea snails and slugs),US West Coast,West Coast,,,Not for IDW -956,Bathyraja spp.,Skate complex,"Elasmobranchii: Batoidea (skates, rays)",US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -957,Beringraja binoculata,Big skate,"Elasmobranchii: Batoidea (skates, rays)",US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -958,Beringraja inornata,California skate,"Elasmobranchii: Batoidea (skates, rays)",US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -959,Beringraja rhina,Longnose skate,"Elasmobranchii: Batoidea (skates, rays)",US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -960,Beringraja stellulata,Starry skate,"Elasmobranchii: Batoidea (skates, rays)",US West Coast,West Coast,PFMC,Pacific Coast Groundfish,Not for IDW -961,Bothrocara brunneum,Twoline eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -962,Brisaster latifrons,Northern heart urchin,"Echinoidea (sea urchins, sand dollars) ",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -963,Brissopsis pacifica,Pacific heart urchin,"Echinoidea (sea urchins, sand dollars) ",US West Coast,West Coast,,,Not for IDW -964,Cancer productus,Red rock crab,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,Not for IDW -965,Careproctus melanurus,Blacktail snailfish,Perciformes/Cottoidei (sculpins),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -966,Chauliodus macouni,Pacific viperfish,Stomiiformes (Lightfishes and dragonfishes),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -967,Chionoecetes tanneri,Grooved tanner crab,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -968,Chorilia longipes,Longhorn decorator crab,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -969,Citharichthys sordidus,Pacific sanddab,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -970,Clupea pallasii,Pacific herring,"Clupeiformes (Herrings, anchovy, shad)",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -971,Coryphaenoides acrolepis,Pacific grenadier,"Gadiformes (Cods, genadiers, pollock) ",US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -972,Crossaster borealis,Grooved sun star,Asteroidea (starfishes) ,US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -973,Dipsacaster eximius,Extraordinary sand star,Asteroidea (starfishes) ,US West Coast,West Coast,,,Not for IDW -974,Doryteuthis opalescens,California market squid,"Cephalopoda (squid, octopus)",US West Coast,West Coast,PFMC,Coastal Pelagic Species,NMFS/Rutgers IDW Interpolation -975,Dromalia alexandri,Sea dandelion,"Cnidaria (jellyfish, corals, anenomes) ",US West Coast,West Coast,,,Not for IDW -976,Echidnocerus foraminatus,Brown box crab,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -977,Eopsetta jordani,Petrale sole,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -978,Eptatretus deani,Black hagfish,Myxiniformes (Hagfishes),US West Coast,West Coast,,,Not for IDW -979,Eptatretus stoutii,Pacific hagfish,Myxiniformes (Hagfishes),US West Coast,West Coast,,,Not for IDW -980,Eualus macrophthalmus,Big eyed shrimp,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,Not for IDW -981,Gadus macrocephalus,Pacific cod,"Gadiformes (Cods, genadiers, pollock) ",US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -982,Genyonemus lineatus,White croaker,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -983,Glyptocephalus zachirus,Rex sole,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -984,Gonatus onyx,Clawed armhook squid,"Cephalopoda (squid, octopus)",US West Coast,West Coast,,,Not for IDW -985,Gorgonocephalus eucnemis,Basket star,Ophiuroidea (brittle stars),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -986,Grimothea planipes,Pelagic red crab,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,Not for IDW -987,Heterozonias alternatus,Canonball sun star,Asteroidea (starfishes) ,US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -988,Hippasteria californica,Californian spiny star,Asteroidea (starfishes) ,US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -989,Hippasteria phrygiana,Arctic cushion star,Asteroidea (starfishes) ,US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -990,Hippoglossina stomata,Bigmouth flounder,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,,,Not for IDW -991,Hippoglossoides elassodon,Flathead sole,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -992,Hippoglossus stenolepis,Pacific halibut,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,PFMC,Species Managed Under International Agreement - IPHC,NMFS/Rutgers IDW Interpolation -993,Histioteuthis heteropsis,NA,"Cephalopoda (squid, octopus)",US West Coast,West Coast,,,Not for IDW -994,Hydrolagus colliei,Spotted ratfish,Chimaeriformes (Chimaeras),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -995,Icelinus filamentosus,Threadfin sculpin,Perciformes/Cottoidei (sculpins),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -996,Lepidopsetta sp.,Rock soles,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -997,Liponema brevicorne,Tentacle shedding anemone,"Cnidaria (jellyfish, corals, anenomes) ",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -998,Lithodes couesi,Scarlet king crab,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -999,Luidia foliolata,Gray sand star,Asteroidea (starfishes) ,US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1000,Lycenchelys crotalinus,Snakehead eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1001,Lycodes cortezianus,Bigfin eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1002,Lycodes diapterus,Black eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1003,Lycodes pacificus,Blackbelly eelpout,Perciformes/Zoarcoidei (Eelpouts and pricklebacks),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1004,Lyopsetta exilis,Slender sole,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1005,Mediaster aequalis,Vermillion star,Asteroidea (starfishes) ,US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1006,Merluccius productus,Pacific hake,"Gadiformes (Cods, genadiers, pollock) ",US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1007,Metacarcinus magister,Dungeness crab,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1008,Metridium farcimen,Giant plumose anemone,"Cnidaria (jellyfish, corals, anenomes) ",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1009,Microgadus proximus,Pacific tomcod,"Gadiformes (Cods, genadiers, pollock) ",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1010,Microstomus bathybius,Deep-sea sole,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1011,Microstomus pacificus,Dover sole,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1012,Molpadia intermedia,Sweet potato sea cucumber,Holothuroidea (sea cucumbers),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1013,Myxoderma platyacanthum,NA,Asteroidea (starfishes) ,US West Coast,West Coast,,,Not for IDW -1014,Myxoderma sacculatum,Giant slimy star,Asteroidea (starfishes) ,US West Coast,West Coast,,,Not for IDW -1015,Nearchaster (Nearchaster) aciculosus,Needle spined fragile star,Asteroidea (starfishes) ,US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1016,Neptunea amianta,White neptune,Gastropoda (sea snails and slugs),US West Coast,West Coast,,,Not for IDW -1017,Nezumia liolepis,Smooth grenadier,"Gadiformes (Cods, genadiers, pollock) ",US West Coast,West Coast,,,Not for IDW -1018,Nezumia stelgidolepis,California grenadier,"Gadiformes (Cods, genadiers, pollock) ",US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1019,Octopoteuthis deletron,Octopus squid,"Cephalopoda (squid, octopus)",US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1020,Octopus californicus,North pacific bigeye octopus,"Cephalopoda (squid, octopus)",US West Coast,West Coast,,,Not for IDW -1021,Ophiodon elongatus,Lingcod,Perciformes/Cottoidei (sculpins),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1022,Ophiura sarsii,Notched brittle star,Ophiuroidea (brittle stars),US West Coast,West Coast,,,Not for IDW -1023,Opisthoteuthis californiana,Flapjack octopus,"Cephalopoda (squid, octopus)",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1024,Pandalus amplus,Deepwater bigeye,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,Not for IDW -1025,Pandalus jordani,Ocean shrimp,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1026,Pandalus platyceros,Spot shrimp,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1027,Pannychia moseleyi,Deep sea papillate cucumber,Holothuroidea (sea cucumbers),US West Coast,West Coast,,,Not for IDW -1028,Paralomis multispina,Many spine spider crab,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,Not for IDW -1029,Parmaturus xaniurus,Filetail catshark,Elasmobranchii: Selachii (sharks),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1030,Parophrys vetulus,English sole,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1031,Pasiphaea pacifica,Pacific glass shrimp,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1032,Pasiphaea tarda,Crimson pasiphaeid,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1033,Peprilus simillimus,Pacific pompano,Scombriformes (Mackerels),US West Coast,West Coast,,,Not for IDW -1034,Periphylla periphylla,Merchant cap,"Cnidaria (jellyfish, corals, anenomes) ",US West Coast,West Coast,,,Not for IDW -1035,Pisaster brevispinus,Giant pink sea star,Asteroidea (starfishes) ,US West Coast,West Coast,,,Not for IDW -1036,Platymera gaudichaudii,Armed box crab,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1037,Pleurobranchaea californica,NA,Gastropoda (sea snails and slugs),US West Coast,West Coast,,,Not for IDW -1038,Pleuronichthys decurrens,Curlfin sole,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1039,Pleuronichthys verticalis,Hornyhead turbot,Pleuronectiformes (Flatfishes) ,US West Coast,West Coast,,,Not for IDW -1040,Porichthys notatus,Plainfin midshipman,Batrachoidiformes (Toadfishes),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1041,Pseudostichopus mollis,Sandy sea cucumber,Holothuroidea (sea cucumbers),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1042,Pteraster jordani,Jordan's cushion star,Asteroidea (starfishes) ,US West Coast,West Coast,,,Not for IDW -1043,Pycnopodia helianthoides,Sunflower sea star,Asteroidea (starfishes) ,US West Coast,West Coast,,,Not for IDW -1044,Pyrosoma atlanticum,NA,"Tunicata (sea squirts, tunicates, salps) ",US West Coast,West Coast,,,Not for IDW -1045,Rathbunaster californicus,California sun star,Asteroidea (starfishes) ,US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1046,Rossia pacifica,Eastern pacific bobtail,"Cephalopoda (squid, octopus)",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1047,Sagenaster evermanni,Evermann's star,Asteroidea (starfishes) ,US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1048,Sebastes alutus,Pacific ocean perch,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1049,Sebastes aurora,Aurora rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1050,Sebastes babcocki,Redbanded rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1051,Sebastes chlorostictus,Greenspotted rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1052,Sebastes crameri,Darkblotched rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1053,Sebastes diploproa,Splitnose rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1054,Sebastes elongatus,Greenstriped rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1055,Sebastes entomelas,Widow rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1056,Sebastes flavidus,Yellowtail rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1057,Sebastes goodei,Chilipepper rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1058,Sebastes helvomaculatus,Rosethorn rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1059,Sebastes jordani,Shortbelly rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1060,Sebastes melanostictus and S. aleutianus,Blackspotted and rougheye rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1061,Sebastes melanostomus,Blackgill rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,Not for IDW -1062,Sebastes paucispinis,Bocaccio,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1063,Sebastes pinniger,Canary rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1064,Sebastes saxicola,Stripetail rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1065,Sebastes semicinctus,Halfbanded rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1066,Sebastes zacentrus,Sharpchin rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1067,Sebastolobus alascanus,Shortspine thornyhead,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1068,Sebastolobus altivelis,Longspine thornyhead,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1069,Squalus suckleyi,Pacific spiny dogfish,Elasmobranchii: Selachii (sharks),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1070,Strongylocentrotus fragilis,Fragile sea urchin,"Echinoidea (sea urchins, sand dollars) ",US West Coast,West Coast,,,Not for IDW -1071,Stylasterias forreri,Velcro star,Asteroidea (starfishes) ,US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1072,Tactostoma macropus,Longfin dragonfish,Stomiiformes (Lightfishes and dragonfishes),US West Coast,West Coast,,,Not for IDW -1073,Talismania bifurcata,Threadfin slickhead,Alepocephaliformes (Slickheads and tubeshoulders.),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1074,Tetronarce californica,Pacific electric ray,"Elasmobranchii: Batoidea (skates, rays)",US West Coast,West Coast,,,Not for IDW -1075,Thaleichthys pacificus,Eulachon,"Osmeriformes (caplin, freshwater smelt)",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1076,Thetys vagina,Virgin salpa,"Tunicata (sea squirts, tunicates, salps) ",US West Coast,West Coast,,,Not for IDW -1077,Thrissacanthias penicillatus,NA,Asteroidea (starfishes) ,US West Coast,West Coast,,,Not for IDW -1078,Tritonia tetraquetra,Large orange peel nudibranch,Gastropoda (sea snails and slugs),US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1079,Vampyroteuthis infernalis,Vampire squid,"Cephalopoda (squid, octopus)",US West Coast,West Coast,,,Not for IDW -1080,Zalembius rosaceus,Pink seaperch,"Ovalentaria (damselfish, sufperches)",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1081,Zaniolepis frenata,Shortspine combfish,Perciformes/Cottoidei (sculpins),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,Not for IDW -1082,Zaniolepis latipinnis,Longspine combfish,Perciformes/Cottoidei (sculpins),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1083,Argentina sialis,Pacific argentine,Argentiniformes (marine smelts),US West Coast,West Coast,,,Not for IDW -1084,Chilara taylori,Spotted cusk-eel,Ophidiiformes (Cusk eels) ,US West Coast,West Coast,,,Not for IDW -1085,Gadus chalcogrammus,Walleye pollock,"Gadiformes (Cods, genadiers, pollock) ",US West Coast,West Coast,,,NMFS/Rutgers IDW Interpolation -1086,Oncorhynchus tshawytscha,Chinook salmon,Salmoniformes (Salmons),US West Coast,West Coast,PFMC,Pacific Coast Salmon,NMFS/Rutgers IDW Interpolation -1087,Pandalus dispar,Sidestripe shrimp,Decapoda (Crabs/Lobster/Shrimp),US West Coast,West Coast,,,Not for IDW -1088,Pseudarchaster parelii,Northern scarlet star,Asteroidea (starfishes) ,US West Coast,West Coast,,,Not for IDW -1089,Sardinops sagax,South american pilchard,"Clupeiformes (Herrings, anchovy, shad)",US West Coast,West Coast,,,Not for IDW -1090,Scomber japonicus,Chub mackerel,Scombriformes (Mackerels),US West Coast,West Coast,PFMC,Coastal Pelagic Species,Not for IDW -1091,Sebastes brevispinis,Silvergray rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,Not for IDW -1092,Sebastes proriger,Redstripe rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,NMFS/Rutgers IDW Interpolation -1093,Sebastes ruberrimus,Yelloweye rockfish,Perciformes/Scorpaenoidei (Scorpionfishes),US West Coast,West Coast,PFMC,Pacific Coast Groundfish,Not for IDW -1094,Trachurus symmetricus,Jack mackerel,Carangiformes (Jacks),US West Coast,West Coast,,,Not for IDW -1095,Xeneretmus latifrons,Blacktip poacher,Perciformes/Cottoidei (sculpins),US West Coast,West Coast,,,Not for IDW -1096,Aphareus rutilans,Lehi,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Hawai'i,Hawai'i,WPFMC,Hawaii Archipelago Ecosystem, -1097,Etelis carbunculus,Ehu,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Hawai'i,Hawai'i,WPFMC,Hawaii Archipelago Ecosystem, -1098,Etelis coruscans,Onaga,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Hawai'i,Hawai'i,WPFMC,Hawaii Archipelago Ecosystem, -1099,Hyporthodus quernus,Hapu'upu'u ,Perciformes/Serranoidei (Groupers),Hawai'i,Hawai'i,WPFMC,Hawaii Archipelago Ecosystem, -1100,Pristipomoides filamentosus,Opakapaka,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Hawai'i,Hawai'i,WPFMC,Hawaii Archipelago Ecosystem, -1101,Pristipomoides sieboldii,Kalekale,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Hawai'i,Hawai'i,WPFMC,Hawaii Archipelago Ecosystem, -1102,Pristipomoides zonatus,Gindai,"Eupercaria (drums, croakers, porgies, tilefishes, parrotfish, snappers) ",Hawai'i,Hawai'i,WPFMC,Hawaii Archipelago Ecosystem, diff --git a/data_processing_rcode/README.md b/data_processing_rcode/README.md deleted file mode 100644 index 7bc798d..0000000 --- a/data_processing_rcode/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Compiling and process/cleaning the Survey Data for DisMAP! -> This code is always in development. Find code used for various reports in the code [releases](https://github.com/nmfs-fish-tools/DisMAP/releases). - -This folder sets up the directory structure needed to run the data processing steps. - -## All R scripts used in this data processing are found in the "code" folder. This includes: -1. "download_x.R" scripts - follow the instructions in each script to download or otherwise obtain the survey data -2. [`Compile_Dismap_Current.R`](https://github.com/nmfs-fish-tools/DisMAP/blob/main/data_processing_rcode/code/Compile_Dismap_Current.R)- this script will compile and clean the regional survey data into standardized formats, and reivew/check for taxonomic naming issues. -3. [`clean_taxa.R`](https://github.com/nmfs-fish-tools/DisMAP/blob/main/data_processing_rcode/code/clean_taxa.R) - contains the code for the function used to obtain clean taxa names. Use of this code will only be needed occasionally when taxonomic naming errors are flagged in the Compile code -5. [`create_data_for_map_generation.R`](https://github.com/nmfs-fish-tools/DisMAP/blob/main/data_processing_rcode/code/create_data_for_map_generation.R) - run this after Compile script to get the data in the needed file format for use in the Python script and generate the interpolated biomass rasters and calculate the indicators. -4. [`DisMAP_data_download_API.R`](https://github.com/nmfs-fish-tools/DisMAP/blob/main/data_processing_rcode/code/DisMAP_Data_Download_API.R) - this code runs through example scripts of how to download the data presented on the DisMAP site using API to connect to our [Inport records](https://www.fisheries.noaa.gov/inport/item/66799) - -## The raw data downloaded using the download_x.R scripts will be saved to the "data" folder, and outputs generated will be saved to the appropriate subfolders of the "outputs" folder. - - - -NOAA Fisheries - -[U.S. Department of Commerce](https://www.commerce.gov/) \| [National -Oceanographic and Atmospheric Administration](https://www.noaa.gov) \| -[NOAA Fisheries](https://www.fisheries.noaa.gov/) - diff --git a/data_processing_rcode/Survey_metadata_DisMAP_surveyExplorer.csv b/data_processing_rcode/Survey_metadata_DisMAP_surveyExplorer.csv deleted file mode 100644 index c84b30e..0000000 --- a/data_processing_rcode/Survey_metadata_DisMAP_surveyExplorer.csv +++ /dev/null @@ -1,23 +0,0 @@ -Survey Name,Region,Season,Gear Type,Years,Freqeuncy,Data Filtering notes,Total species count,Data Source,Data Citation -Aleutian Islands Bottom Trawl Survey,Aleutian Islands,Summer,Bottom Trawl,1991-2022,Biennial; even years,none,122,https://www.fisheries.noaa.gov/foss/f?p=215:28:11659615688681::::: ,"NOAA Fisheries Alaska Fisheries Science Center, 2024. Fisheries One Stop Shop Public Data: RACE Division Bottom Trawl Survey Data Query. U.S. Dep. Commer. Public Domian. https://www.fisheries.noaa.gov/foss/f?p=215:28:11659615688681::::: . Accessed 14 February 2025." -Eastern Bering Sea Crab/Groundfish Bottom Trawl Survey,Eastern Bering Sea,Summer,Bottom Trawl,1982-2023,Annual,remove years 1982-1986,139,https://www.fisheries.noaa.gov/foss/f?p=215:28:11659615688681::::: ,"NOAA Fisheries Alaska Fisheries Science Center, 2024. Fisheries One Stop Shop Public Data: RACE Division Bottom Trawl Survey Data Query. U.S. Dep. Commer. Public Domian. https://www.fisheries.noaa.gov/foss/f?p=215:28:11659615688681::::: . Accessed 14 February 2025." -Gulf of Alaska Bottom Trawl Survey,Gulf of Alaska,Summer,Bottom Trawl,1993-2023,Biennial; odd years,remove year 2001; keep strata sampled >= 11 years,114,https://www.fisheries.noaa.gov/foss/f?p=215:28:11659615688681::::: ,"NOAA Fisheries Alaska Fisheries Science Center, 2024. Fisheries One Stop Shop Public Data: RACE Division Bottom Trawl Survey Data Query. U.S. Dep. Commer. Public Domian. https://www.fisheries.noaa.gov/foss/f?p=215:28:11659615688681::::: . Accessed 14 February 2025." -Northern Bering Sea Crab/Groundfish Survey - Eastern Bering Sea Shelf Survey Extension,Northern Bering Sea,Summer,Bottom Trawl,"2010, 2017-2023",Biennial/Annual,none,95,https://www.fisheries.noaa.gov/foss/f?p=215:28:11659615688681::::: ,"NOAA Fisheries Alaska Fisheries Science Center, 2024. Fisheries One Stop Shop Public Data: RACE Division Bottom Trawl Survey Data Query. U.S. Dep. Commer. Public Domian. https://www.fisheries.noaa.gov/foss/f?p=215:28:11659615688681::::: . Accessed 14 February 2025." -West Coast Bottom Trawl Triennial,West Coast,Summer,Bottom Trawl,1977-2004,Triennial,keep only strata sampled all 10 years of survey ,84,https://www.webapps.nwfsc.noaa.gov/data/map,"West Coast Groundfish Bottom Trawl Survey, NOAA Fisheries, NWFSC/FRAM, 2725 Montlake Blvd. East, Seattle, WA 98112. https://www.webapps.nwfsc.noaa.gov/data/map" -West Coast Bottom Trawl Annual,West Coast ,Summer,Bottom Trawl,2003-2023,Annual,Keep only strata sampled in >= 20 years ,145,https://www.webapps.nwfsc.noaa.gov/data/map,"West Coast Groundfish Bottom Trawl Survey, NOAA Fisheries, NWFSC/FRAM, 2725 Montlake Blvd. East, Seattle, WA 98112. https://www.webapps.nwfsc.noaa.gov/data/map" -Gulf of Mexico Summer Shrimp/Groundfish Survey,Gulf of Mexico,Summer,Bottom Trawl,1982-2022,Annual,"keep years >= 2008, drop 2022; keep strata sampled 13 of years 2008-2021",195,https://www.gsmfc.org/seamap, -SEAMAP Fall Coastal Trawl Survey,Southeast US,Fall,Bottom Trawl,1989-2022,Annual,Keep only strata sampled >31 years ,125,http://www.seamap.org/datapage.html,"SEAMAP-SA Data Management Work Group. 2025, February, 14. SEAMAP-SA online database. Retrieved from: https://seamap.org/data-portal/ - - - " -SEAMAP Spring Coastal Trawl Survey,Southeast US,Spring,Bottom Trawl,1989-2022,Annual,keep only strata sampled >= 29 years of survey,124,http://www.seamap.org/datapage.html,"SEAMAP-SA Data Management Work Group. 2025, February, 14. SEAMAP-SA online database. Retrieved from: https://seamap.org/data-portal/ - - - " -SEAMAP Summer Coastal Trawl Survey,Southeast US,Summer,Bottom Trawl,1989-2022,Annual,Remove year 2021 (poorly sampled),121,http://www.seamap.org/datapage.html,"SEAMAP-SA Data Management Work Group. 2025, February, 14. SEAMAP-SA online database. Retrieved from: https://seamap.org/data-portal/ - - - " -NEFSC Fall Bottom Trawl,Northeast US,Fall,Bottom Trawl,1963-2023,Annual,"keep years > 1973, dropped 2017; keep strata sampled all but 2 years",102,https://www.fisheries.noaa.gov/inport/item/22560,"Northeast Fisheries Science Center, 2025: Fall Bottom Trawl Survey from 1963 to 2023. NOAA National Centers for Environmental Information, https://www.fisheries.noaa.gov/inport/item/22560." -NEFSC Spring Bottom Trawl,Northeast US,Spring,Bottom Trawl,1968-2023,Annual,"keep years > 1973, drop 2023, 2020, 2014, 1975; keep strata sampled all but 2 years",77,https://www.fisheries.noaa.gov/inport/item/22561,"Northeast Fisheries Science Center, 2025: Spring Bottom Trawl Survey from 1968 to 2023. NOAA National Centers for Environmental Information, https://www.fisheries.noaa.gov/inport/item/22561." -Bottomfish Fishery-Independent Survey in Hawaii (BFISH),Hawai'i Islands,Fall,Cooperative Research hook-and-line fishing operations (CRF) and the Modular Optical Underwater Survey System (MOUSS),2016-2023,Annual,none,7,https://www.fisheries.noaa.gov/inport/item/20969 ,"Pacific Islands Fisheries Science Center, 2025: Bottomfish Fishery-Independent Survey in Hawaii (BFISH) - Cooperative Research Fishing Surveys from 2016 to 2023. NOAA National Centers for Environmental Information, https://www.fisheries.noaa.gov/inport/item/20969." diff --git a/data_processing_rcode/code/Compile_Dismap_Current.R b/data_processing_rcode/code/Compile_Dismap_Current.R deleted file mode 100644 index e3f7a88..0000000 --- a/data_processing_rcode/code/Compile_Dismap_Current.R +++ /dev/null @@ -1,3690 +0,0 @@ -## ---- DISMAP 2/20/2025 -## updated srcipt to include "expanded survey data" for the new Survey Data Module - -## updated thru 2023 survey data for all regions except SEUS and Gmex(which is thru 2022) - -#--------------------------------------------------------------------------------------# -#### LOAD LIBRARIES AND FUNCTIONS #### -#--------------------------------------------------------------------------------------# -## Testing changes ## -# install.packages("devtools") -library(devtools) -# install.packages("readr") -# install.packages("here") -# install.packages("purrr") -# install.packages("stringr") -# install.packages("forcats") -# install.packages("tidyr") -# install.packages("ggplot2") -# install.packages("dplyr") -# install.packages("tibble") -# install.packages("lubridate") -# install.packages("PBSmapping") -# install.packages("data.table") -# install.packages("gridExtra") -# install.packages("questionr") -# install.packages("geosphere") -# install.packages("taxize") -# install.packages("worrms") -# install.packages("rfishbase") - - -# Load required packages -library(taxize) -library(worrms) -library(rfishbase) -library(lubridate) -library(PBSmapping) -library(gridExtra) -library(questionr) -library(geosphere) -library(here) -library(dplyr) -library(readr) # note need to install from repo to get older version 1.3.1 for it to work properly -library(purrr) -library(forcats) -library(tidyr) -library(tibble) -library(ggplot2) -library(stringr) -library(data.table) - - -## The data_processing_rcode directory contains three folders (code, data, outputs) -# 1. code - this folder contains all the Rscripts (including this Compile_Dismap_Current.R script) used to download and -# process the data -# 2. data directory - this is the folder containing all raw data files you downloaded using the Rscripts in the code folder -# 3. output directory - folder where the cleaned data will be saved to. This folder includes subfolders for -# data_clean, plots, the data generated for the python scripts by creat_data_for_map_generation.R, and by clean_taxa.R script - -# The zip file you downloaded created this directory structure for you. - -# a note on species name adjustment #### -# At some point during certain surveys it was realized that what was believed to be one species was actually a different species or more than one species. Species have been lumped together as a genus in those instances. -# Additionally, species names were verified against WORMs database and standardized across regions (and within surveys) - -# Answer the following questions using all caps TRUE or FALSE to direct the actions of the script ===================================== - -# 1. Some strata and years have very little data, should they be removed and saved as fltr data? #DEFAULT: TRUE. -HQ_DATA_ONLY <- TRUE - -# 2. View plots of removed strata for HQ_DATA. #OPTIONAL, DEFAULT:FALSE -# It takes a while to generate these plots. -HQ_PLOTS <- FALSE - -# 3. Remove ai,ebs,gmex,goa,neus,seus,wcann,wctri, scot. Keep `dat`. #DEFAULT: FALSE -REMOVE_REGION_DATASETS <- FALSE - -# # 4. Create graphs based on the data similar to those shown on the website and outputs them to pdf. #DEFAULT:FALSE -# PLOT_CHARTS <- FALSE - -# 5. If you would like to write out the clean data, would you prefer it in Rdata or CSV form? Note the CSV's are much larger than the Rdata files. #DEFAULT:TRUE, FALSE generates CSV's instead of Rdata. -PREFER_RDATA <- TRUE - -# 6. Output the clean full master data frame. #DEFAULT:FALSE -WRITE_MASTER_DAT <- TRUE - -# 7. Output the clean trimmed data frame. #DEFAULT:FALSE -WRITE_TRIMMED_DAT <- TRUE - -# 7. Generate dat.exploded table. #OPTIONAL, DEFAULT:TRUE -DAT_EXPLODED <- TRUE - -# 9. Output the dat.exploded table #DEFAULT:FALSE -WRITE_DAT_EXPLODED <- TRUE - - -# Workspace setup --------------------------------------------------------- -print("Workspace setup") - -# This script works best when the repository is downloaded from github, -# especially when that repository is loaded as a project into RStudio. - -# The working directory is assumed to be the DisMAP directory of this repository. -# library(tidyverse)# use ggplot2, tibble, readr, dplyr, stringr, purrr - - -# Functions =========================================================== -print("Functions") - -# function to calculate convex hull area in km2 -#developed from http://www.nceas.ucsb.edu/files/scicomp/GISSeminar/UseCases/CalculateConvexHull/CalculateConvexHullR.html -calcarea <- function(lon,lat){ - hullpts = chull(x=lon, y=lat) # find indices of vertices - hullpts = c(hullpts,hullpts[1]) # close the loop - lonlat <- data.frame(cbind(lon, lat)) - ps = appendPolys(NULL,mat=as.matrix(lonlat[hullpts,]),1,1,FALSE) # create a Polyset object - attr(ps,"projection") = "LL" # set projection to lat/lon - psUTM = convUL(ps, km=TRUE) # convert to UTM in km - polygonArea = calcArea(psUTM,rollup=1) - return(polygonArea$area) -} - -sumna <- function(x){ - #acts like sum(na.rm=T) but returns NA if all are NA - if(!all(is.na(x))) return(sum(x, na.rm=T)) - if(all(is.na(x))) return(NA) -} - -meanna = function(x){ - if(!all(is.na(x))) return(mean(x, na.rm=T)) - if(all(is.na(x))) return(NA) -} - -# weighted mean for use with summarize(). values in col 1, weights in col 2 -wgtmean = function(x, na.rm=FALSE) {questionr::wtd.mean(x=x[,1], weights=x[,2], na.rm=na.rm)} - -wgtse = function(x, na.rm=TRUE){ - if(sum(!is.na(x[,1]) & !is.na(x[,2]))>1){ - if(na.rm){ - return(sqrt(wtd.var(x=x[,1], weights=x[,2], na.rm=TRUE, normwt=TRUE))/sqrt(sum(!is.na(x[,1] & !is.na(x[,2]))))) - } else { - return(sqrt(wtd.var(x=x[,1], weights=x[,2], na.rm=FALSE, normwt=TRUE))/sqrt(length(x))) # may choke on wtd.var without removing NAs - } - } else { - return(NA) # NA if vector doesn't have at least 2 values - } -} - -se <- function(x) sd(x)/sqrt(length(x)) # assumes no NAs - -lunique = function(x) length(unique(x)) # number of unique values in a vector - -present_every_year <- function(dat, ...){ - presyr <- dat %>% - filter(wtcpue > 0) %>% - group_by(...) %>% - summarise(pres = n()) - return(presyr) -} - -num_hauls_year <- function(dat, ...){ - haulsyr <- dat %>% - select(c(region, haulid, year)) %>% - distinct() %>% - group_by(...) %>% - summarise(hauls = n()) - return(haulsyr) -} - -# num_year_present <- function(presyr, ...){ -# presyrsum <- presyr %>% -# filter(pres > 0) %>% -# group_by(...) %>% -# summarise(presyr = n()) -# return(presyrsum) -# } - -num_year_present <- function(haulsyr, ...){ - presyrsum <- haulsyr %>% - filter(pres > 0) %>% - group_by(...) %>% - summarise(presyr = n()) - return(presyrsum) -} - -max_year_surv <- function(presyrsum, ...){ - maxyrs <- presyrsum %>% - group_by(...) %>% - summarise(maxyrs = max(presyr)) - return(maxyrs) - -} - -explode0 <- function(x, by=c("region")){ - # x <- copy(x) - stopifnot(is.data.table(x)) - - # print(x[1]) - - # x <- as.data.table(x) - # x <- as.data.table(trimmed_dat)[region=="Scotian Shelf Summer"] - # setkey(x, sampleid, stratum, year, lat, lon, stratumarea, depth) - # group the data by these columns - setorder(x, haulid, stratum, year, lat, lon, stratumarea, depth) - - # pull out all of the unique spp - u.spp <- x[,as.character(unique(spp))] - # pull out all of the unique common names - u.cmmn <- x[,common[!duplicated(as.character(spp))]] - - # pull out these location related columns and sort by haulid and year - x.loc <- x[,list(haulid, year, stratum, stratumarea, lat, lon, depth)] - setkey(x.loc, haulid, year) - - # attatch all spp to all locations - x.skele <- x.loc[,list(spp=u.spp, common=u.cmmn), by=eval(colnames(x.loc))] - setkey(x.skele, haulid, year, spp) - x.skele <- unique(x.skele) - setcolorder(x.skele, c("haulid","year","spp", "common", "stratum", "stratumarea","lat","lon","depth")) - - # pull in multiple observations of the same species - x.spp.dat <- x[,list(haulid, year, spp, wtcpue)] - setkey(x.spp.dat, haulid, year, spp) - x.spp.dat <- unique(x.spp.dat) - - out <- x.spp.dat[x.skele, allow.cartesian = TRUE] - - out$wtcpue[is.na(out$wtcpue)] <- 0 - - out -} - -#convert factors to numeric - -as.numeric.factor <- function(x) {as.numeric(levels(x))[x]} - -#Reformat string - first letter uppercase -firstup <- function(x) { - x <- tolower(x) - substr(x, 1, 1) <- toupper(substr(x, 1, 1)) - x -} - -#add one to odd numbers -oddtoeven <- function(x) { - ifelse(x %% 2 == 1,x+1,x) -} - -#add one to even numbers -eventoodd <- function(x) { - ifelse(x %% 2 == x+1,1,x) -} - -#--------------------------------------------------------------------------------------# -#### PULL IN AND EDIT RAW DATA FILES #### -#--------------------------------------------------------------------------------------# - -# Compile AFSC Bottom Trawl Data ===================================================== -print("Compile Alaska") - -# Load data -------------------------------------------------------------------- -catch <- readr::read_csv(file = here::here("data_processing_rcode/data/AK_gap_products_foss_catch.csv"))[,-1] # remove "row number" column -haul <- readr::read_csv(file = here::here("data_processing_rcode/data/AK_gap_products_foss_haul.csv"))[,-1] # remove "row number" column -species <- readr::read_csv(file = here::here("data_processing_rcode/data/AK_gap_products_foss_species.csv"))[,-1] # remove "row number" column - -# Wrangle data ----------------------------------------------------------------- -ak_full <- - # join haul and catch data to unique species by survey table - dplyr::left_join(haul, catch, by="HAULJOIN") %>% - # join species data to unique species by survey table - dplyr::left_join(species, by="SPECIES_CODE") %>% - # modify zero-filled rows - dplyr::mutate( - CPUE_KGKM2 = ifelse(is.na(CPUE_KGKM2), 0, CPUE_KGKM2), # just in case - CPUE_KGHA = CPUE_KGKM2/100, # Hectares - CPUE_NOKM2 = ifelse(is.na(CPUE_NOKM2), 0, CPUE_NOKM2), # just in case - CPUE_NOHA = CPUE_NOKM2/100, # Hectares - COUNT = ifelse(is.na(COUNT), 0, COUNT), - WEIGHT_KG = ifelse(is.na(WEIGHT_KG), 0, WEIGHT_KG), # just in case - region = dplyr::case_when( - SURVEY_DEFINITION_ID == 78 ~ "Bering Sea Slope Survey", - SURVEY_DEFINITION_ID == 47 ~ "Gulf of Alaska", - SURVEY_DEFINITION_ID == 52 ~ "Aleutian Islands", - SURVEY_DEFINITION_ID == 98 ~ "Eastern Bering Sea", - SURVEY_DEFINITION_ID == 143 ~ "Northern Bering Sea" - )) - - -ak_full<- ak_full %>% - dplyr::rename(year = YEAR, - haulid = HAULJOIN, - lat = LATITUDE_DD_START, - lon = LONGITUDE_DD_START, - stratum = STRATUM, - depth = DEPTH_M, - spp = SCIENTIFIC_NAME, - common = COMMON_NAME, - wtcpue = CPUE_KGHA) %>% - dplyr::mutate( - stratumarea = NA, # removed above because the new data tables dont provide this - # Calculate a corrected longitude for Aleutians (all in western hemisphere coordinates) - lon = ifelse(lon > 0, lon - 360, lon), - # adjust spp names - # add species names for two rockfish complexes - spp = ifelse(grepl("rougheye and blackspotted rockfish unid.", common), "Sebastes melanostictus and S. aleutianus", spp), - spp = ifelse(grepl("dusky and dark rockfishes unid.", common), "Sebastes variabilis and S. ciliatus", spp), - # catch A. stomias and A. evermanii (grouped together due to identification issues early on in dataset) - # spp = ifelse(grepl("Atheresthes", spp), "Atheresthes stomias and A. evermanni", spp), #doesn't apply to all regions - # catch L. polystryxa (valid in 2018), and L. bilineata (valid in 2018) - spp = ifelse(grepl("Lepidopsetta", spp), "Lepidopsetta sp.", spp), - # # group together because of identification issues: catch M. jaok (valid in 2018), M. niger (valid in 2018), M. polyacanthocephalus (valid in 2018), M. quadricornis (valid in 2018), M. verrucosus (changed to scorpius), M. scorpioides (valid in 2018), M. scorpius (valid in 2018) (M. scorpius is in the data set but not on the list so it is excluded from the change) - # spp = ifelse(grepl("Myoxocephalus", spp ) & !grepl("scorpius", spp), "Myoxocephalus sp.", spp), - # catch B. maculata (valid in 2018), abyssicola (valid in 2018), aleutica (valid in 2018), interrupta (valid in 2018), lindbergi (valid in 2018), mariposa (valid in 2018), minispinosa (valid in 2018), smirnovi (valid in 2018), cf parmifera (Orretal), spinosissima (valid in 2018), taranetzi (valid in 2018), trachura (valid in 2018), violacea (valid in 2018) - spp = ifelse(grepl("Bathyraja", spp), 'Bathyraja sp.', spp), - # catch S. melanostictus and S. aleutianus (blackspotted & rougheye), combined into one complex - spp = ifelse(grepl("Sebastes melanostictus", spp)|grepl("Sebastes aleutianus", spp), "Sebastes melanostictus and S. aleutianus", spp), - # catch S. variabilis and S. ciliatus (dusky + dark rockfish), combined into one complex - spp = ifelse(grepl("Sebastes variabilis", spp)|grepl("Sebastes ciliatus", spp), "Sebastes variabilis and S. ciliatus", spp) - #spp = ifelse(grepl("Hippoglossoides", spp), "Hippoglossoides elassodon and H. robustus", spp) #doesn't apply to all regions - ) %>% - # remove rows that are eggs, shells, etc (they will have NA for scientific name) - dplyr::filter(spp != "" & - # remove any additional rows where spp contains the word "egg" - !grepl("egg", spp), - !grepl("Polychaete tubes", spp)) %>% - readr::type_convert(col_types = cols( - lat = col_double(), - lon = col_double(), - year = col_integer(), - wtcpue = col_double(), - spp = col_character(), - depth = col_integer(), - haulid = col_character() - )) %>% - dplyr::group_by(region, haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% - dplyr::summarise(wtcpue = sum(wtcpue, na.rm = TRUE)) %>% - dplyr::select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% - dplyr::ungroup() - -# clean up -rm(haul, catch) - -# now that main data set has been compiled and cleaned/standardized, can split out the different surveys -### Aleutian Islands survey ----- -ai <- ak_full %>% - dplyr::filter(region == "Aleutian Islands") %>% - dplyr::mutate(# catch A. stomias and A. evermanii (grouped together due to identification issues early on in dataset) - spp = ifelse(grepl("Atheresthes", spp), "Atheresthes stomias and A. evermanni", spp)) %>% - dplyr::group_by(region, haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% - dplyr::summarise(wtcpue = sum(wtcpue, na.rm = TRUE)) %>% - dplyr::select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% - dplyr::ungroup() - -if (HQ_DATA_ONLY == TRUE){ - - # look at the graph and make sure decisions to keep or eliminate data make sense - - # plot the strata by year - - p1 <- ai %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p2 <- ai %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - test <- ai %>% - select(stratum, year) %>% - distinct() %>% - group_by(stratum) %>% - summarise(count = n()) %>% - filter(count >= 13) - - # how many rows will be lost if only stratum trawled ever year are kept? - test2 <- ai %>% - filter(stratum %in% test$stratum) - nrow(ai) - nrow(test2) - # percent that will be lost - print((nrow(ai) - nrow(test2))/nrow(ai)) - # 0% of rows are removed (Each strata is sampled each year!) - ai_fltr <- ai %>% - filter(stratum %in% test$stratum) - - # plot the results after editing - p3 <- ai_fltr %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p4 <- ai_fltr %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - if (HQ_PLOTS == TRUE){ - temp <- grid.arrange(p1, p2, p3, p4, nrow = 2) - ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "ai_hq_dat_removed.png")) - rm(temp) - } - rm(test, test2, p1, p2, p3, p4) -} - -### Eastern Bering Sea survey ----- -ebs <- ak_full %>% - dplyr::filter(region == "Eastern Bering Sea")%>% - dplyr::mutate(# catch A. stomias and A. evermanii (grouped together due to idenfication issues early on in dataset) - spp = ifelse(grepl("Atheresthes", spp), "Atheresthes stomias and A. evermanni", spp), - spp = ifelse(grepl("Hippoglossoides", spp), "Hippoglossoides elassodon and H. robustus", spp))%>% - dplyr::group_by(region, haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% - dplyr::summarise(wtcpue = sum(wtcpue, na.rm = TRUE)) %>% - dplyr::select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% - dplyr::ungroup() - -# ebs<-left_join(ebs, ebs_strata, by=c("stratum"="StratumCode"))%>% -# select(-stratumarea, -SubareaDescription) %>% -# rename(stratumarea=Areakm2) %>% -# dplyr::select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) - -if (HQ_DATA_ONLY == TRUE){ - # look at the graph and make sure decisions to keep or eliminate data make sense - - p1 <- ebs %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p2 <- ebs %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - test <- ebs %>% - select(stratum, year) %>% - distinct() %>% - group_by(year) %>% - summarise(count = n()) %>% - filter(count >= 12) - - # how many rows will be lost if only years where all stratum sampled are kept? and start timeseries in 1987 - test2 <- ebs %>% - filter(year %in% test$year) %>% - filter(year != 1985) - nrow(ebs) - nrow(test2) - # percent that will be lost - print((nrow(ebs) - nrow(test2))/nrow(ebs)) - # 8% of rows are removed - ebs_fltr <- ebs %>% - filter(year %in% test$year)%>% - filter(year != 1985) - - p3 <- ebs_fltr %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p4 <- ebs_fltr %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - if (HQ_PLOTS == TRUE){ - temp <- grid.arrange(p1, p2, p3, p4, nrow = 2) - ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "ebs_hq_dat_removed.png")) - rm(temp) - } - rm(test, test2, p1, p2, p3, p4) -} - -### Gulf of Alaska survey ----- -goa <- ak_full %>% - dplyr::filter(region == "Gulf of Alaska") - -if (HQ_DATA_ONLY == TRUE){ - # look at the graph and make sure decisions to keep or eliminate data make sense - - p1 <- goa %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p2 <- goa %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - # for GOA in 2001 missed 27 strata and will be removed, stratum 50 is - # missing from 3 years but will be kept, 410, 420, 430, 440, 450 are missing - #from 3 years but will be kept, 510 and higher are missing from 7 or more years - # of data and will be removed - test <- goa %>% - filter(year != 2001) %>% - select(stratum, year) %>% - distinct() %>% - group_by(stratum) %>% - summarise(count = n())%>% - filter(count >= 11) ## I think this may need to change to 12 years? - - # how many rows will be lost if only stratum trawled ever year and the ones mentioned - # above are kept? - test2 <- goa %>% - filter(stratum %in% test$stratum) - nrow(goa) - nrow(test2) - # percent that will be lost - print ((nrow(goa) - nrow(test2))/nrow(goa)) - - goa_fltr <- goa %>% - filter(stratum %in% test$stratum) %>% - filter(year != 2001) - - p3 <- goa_fltr %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p4 <- goa_fltr %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - if (HQ_PLOTS == TRUE){ - temp <- grid.arrange(p1, p2, p3, p4, nrow = 2) - ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "goa_hq_dat_removed.png")) - - rm(temp) - } - rm(test, test2, p1, p2, p3, p4) -} - -### Northern Bering Sea survey ----- -nbs <- ak_full %>% - dplyr::filter(region == "Northern Bering Sea") %>% - dplyr::mutate(# catch A. stomias and A. evermanii (grouped together due to idenfication issues early on in dataset) - spp = ifelse(grepl("Atheresthes", spp), "Atheresthes stomias and A. evermanni", spp), - spp = ifelse(grepl("Hippoglossoides", spp), "Hippoglossoides elassodon and H. robustus", spp)) %>% - dplyr::group_by(region, haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% - dplyr::summarise(wtcpue = sum(wtcpue, na.rm = TRUE)) %>% - dplyr::select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% - dplyr::ungroup() - -if (HQ_DATA_ONLY == TRUE){ - # look at the graph and make sure decisions to keep or eliminate data make sense - - p1 <- nbs %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p2 <- nbs %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - test <- nbs %>% - select(stratum, year) %>% - distinct() %>% - group_by(stratum) %>% - summarise(count = n())%>% - filter(count >= 5) - - # how many rows will be lost if only stratum trawled ever year aare kept? - test2 <- nbs %>% - filter(stratum %in% test$stratum) - nrow(nbs) - nrow(test2) - # percent that will be lost - print ((nrow(nbs) - nrow(test2))/nrow(nbs)) - - nbs_fltr <- nbs %>% - filter(stratum %in% test$stratum) - - p3 <- nbs_fltr %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p4 <- nbs_fltr %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - if (HQ_PLOTS == TRUE){ - temp <- grid.arrange(p1, p2, p3, p4, nrow = 2) - ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "nbs_hq_dat_removed.png")) - - rm(temp) - } - rm(test, test2, p1, p2, p3, p4) -} - -# Compile WCTRI =========================================================== -print("Compile WCTRI") - -wctri_catch <- read_csv(here::here("data_processing_rcode/data", "wctri_catch.csv"), col_types = cols( - CRUISEJOIN = col_integer(), - HAULJOIN = col_integer(), - CATCHJOIN = col_integer(), - REGION = col_character(), - VESSEL = col_integer(), - CRUISE = col_integer(), - HAUL = col_integer(), - SPECIES_CODE = col_integer(), - WEIGHT = col_double(), - NUMBER_FISH = col_integer(), - SUBSAMPLE_CODE = col_character(), - VOUCHER = col_character(), - AUDITJOIN = col_integer() -)) %>% - select(CRUISEJOIN, HAULJOIN, VESSEL, CRUISE, HAUL, SPECIES_CODE, WEIGHT) - -wctri_haul <- read_csv(here::here("data_processing_rcode/data", "wctri_haul.csv"), col_types = - cols( - CRUISEJOIN = col_integer(), - HAULJOIN = col_integer(), - REGION = col_character(), - VESSEL = col_integer(), - CRUISE = col_integer(), - HAUL = col_integer(), - HAUL_TYPE = col_integer(), - PERFORMANCE = col_double(), - START_TIME = col_character(), - DURATION = col_double(), - DISTANCE_FISHED = col_double(), - NET_WIDTH = col_double(), - NET_MEASURED = col_character(), - NET_HEIGHT = col_double(), - STRATUM = col_integer(), - START_LATITUDE = col_double(), - END_LATITUDE = col_double(), - START_LONGITUDE = col_double(), - END_LONGITUDE = col_double(), - STATIONID = col_character(), - GEAR_DEPTH = col_integer(), - BOTTOM_DEPTH = col_integer(), - BOTTOM_TYPE = col_integer(), - SURFACE_TEMPERATURE = col_double(), - GEAR_TEMPERATURE = col_double(), - WIRE_LENGTH = col_integer(), - GEAR = col_integer(), - ACCESSORIES = col_integer(), - SUBSAMPLE = col_integer(), - AUDITJOIN = col_integer() - )) %>% - select(CRUISEJOIN, HAULJOIN, VESSEL, CRUISE, HAUL, HAUL_TYPE, PERFORMANCE, START_TIME, DURATION, DISTANCE_FISHED, NET_WIDTH, STRATUM, START_LATITUDE, END_LATITUDE, START_LONGITUDE, END_LONGITUDE, STATIONID, BOTTOM_DEPTH) - -wctri_species <- read_csv(here::here("data_processing_rcode/data", "wctri_species.csv"), col_types = cols( - SPECIES_CODE = col_integer(), - SPECIES_NAME = col_character(), - COMMON_NAME = col_character(), - REVISION = col_character(), - BS = col_character(), - GOA = col_character(), - WC = col_character(), - AUDITJOIN = col_integer() -)) %>% - select(SPECIES_CODE, SPECIES_NAME, COMMON_NAME) - -# Add haul info to catch data -wctri <- left_join(wctri_catch, wctri_haul, by = c("CRUISEJOIN", "HAULJOIN", "VESSEL", "CRUISE", "HAUL")) -# add species names -wctri <- left_join(wctri, wctri_species, by = "SPECIES_CODE") - - -wctri <- wctri %>% - # trim to standard hauls and good performance - filter(HAUL_TYPE == 3 & PERFORMANCE == 0) %>% - # Create a unique haulid - mutate( - haulid = paste(formatC(VESSEL, width=3, flag=0), formatC(CRUISE, width=3, flag=0), formatC(HAUL, width=3, flag=0), sep='-'), - # Extract year where needed - year = substr(CRUISE, 1, 4), - # Add "strata" (define by lat, lon and depth bands) where needed # degree bins # 100 m bins # no need to use lon grids on west coast (so narrow) - stratum = paste(floor(START_LATITUDE)+0.5, floor(BOTTOM_DEPTH/100)*100 + 50, sep= "-"), - # adjust for tow area # weight per hectare (10,000 m2) - wtcpue = (WEIGHT*10000)/(DISTANCE_FISHED*1000*NET_WIDTH) - ) - -# Calculate stratum area where needed (use convex hull approach) -wctri_strats <- wctri %>% - group_by(stratum) %>% - summarise(stratumarea = calcarea(START_LONGITUDE, START_LATITUDE)) - -wctri <- left_join(wctri, wctri_strats, by = "stratum") -wctri <- wctri %>% - mutate( - # add species names for two rockfish complexes - SPECIES_NAME = ifelse(grepl("rougheye and blackspotted rockfish unid.", COMMON_NAME), "Sebastes melanostictus and S. aleutianus", SPECIES_NAME), - SPECIES_NAME = ifelse(grepl("dusky and dark rockfishes unid.", COMMON_NAME), "Sebastes variabilis and S. ciliatus", SPECIES_NAME)) - - -wctri <- wctri %>% - rename( - svvessel = VESSEL, - lat = START_LATITUDE, - lon = START_LONGITUDE, - depth = BOTTOM_DEPTH, - spp = SPECIES_NAME - ) %>% - filter( - spp != "" & - !grepl("egg", spp), - !grepl("Egg", spp), - !grepl("Empty", spp) - ) %>% - # adjust spp names - mutate(spp = ifelse(grepl("Lepidopsetta", spp), "Lepidopsetta sp.", spp), - spp = ifelse(grepl("Bathyraja", spp), 'Bathyraja sp.', spp), - spp = ifelse(grepl("Squalus", spp), 'Squalus suckleyi', spp)) %>% - group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% - summarise(wtcpue = sumna(wtcpue)) %>% - # add region column - mutate(region = "West Coast Triennial") %>% - select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% - ungroup() - -if (HQ_DATA_ONLY == TRUE){ - # look at the graph and make sure decisions to keep or eliminate data make sense - - - p1 <- wctri %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p2 <- wctri %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - test <- wctri %>% - select(stratum, year) %>% - distinct() %>% - group_by(stratum) %>% - summarise(count = n()) %>% - filter(count >= 10) - - # how many rows will be lost if only stratum trawled ever year are kept? - test2 <- wctri %>% - filter(stratum %in% test$stratum) - nrow(wctri) - nrow(test2) - # percent that will be lost - print((nrow(wctri) - nrow(test2))/nrow(wctri)) - # 23% of rows are removed - wctri_fltr <- wctri %>% - filter(stratum %in% test$stratum) - - p3 <- wctri_fltr %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p4 <- wctri_fltr %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - if (HQ_PLOTS == TRUE){ - temp <- grid.arrange(p1, p2, p3, p4, nrow = 2) - ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "wctri_hq_dat_removed.png")) - rm(temp) - } - rm(test, test2, p1, p2, p3, p4) -} - -rm(wctri_catch, wctri_haul, wctri_species, wctri_strats) - -# Compile WCANN =========================================================== -print("Compile WCANN") -wcann_catch <- read_csv(here::here("data_processing_rcode/data", "wcann_catch.csv"), col_types = cols( - catch_id = col_integer(), - common_name = col_character(), - cpue_kg_per_ha_der = col_double(), - cpue_numbers_per_ha_der = col_double(), - date_yyyymmdd = col_integer(), - depth_m = col_double(), - latitude_dd = col_double(), - longitude_dd = col_double(), - pacfin_spid = col_character(), - partition = col_character(), - performance = col_character(), - program = col_character(), - project = col_character(), - sampling_end_hhmmss = col_character(), - sampling_start_hhmmss = col_character(), - scientific_name = col_character(), - station_code = col_double(), - subsample_count = col_integer(), - subsample_wt_kg = col_double(), - total_catch_numbers = col_integer(), - total_catch_wt_kg = col_double(), - tow_end_timestamp = col_datetime(format = ""), - tow_start_timestamp = col_datetime(format = ""), - trawl_id = col_double(), - vessel = col_character(), - vessel_id = col_integer(), - year = col_integer(), - year_stn_invalid = col_integer() -)) %>% - select("trawl_id","year","longitude_dd","latitude_dd","depth_m","scientific_name","total_catch_wt_kg","cpue_kg_per_ha_der", "partition", "performance") - -wcann_haul <- read_csv(here::here("data_processing_rcode/data", "wcann_haul.csv"), col_types = cols( - area_swept_ha_der = col_double(), - date_yyyymmdd = col_integer(), - depth_hi_prec_m = col_double(), - invertebrate_weight_kg = col_double(), - latitude_hi_prec_dd = col_double(), - longitude_hi_prec_dd = col_double(), - mean_seafloor_dep_position_type = col_character(), - midtow_position_type = col_character(), - nonspecific_organics_weight_kg = col_double(), - performance = col_character(), - program = col_character(), - project = col_character(), - sample_duration_hr_der = col_double(), - sampling_end_hhmmss = col_character(), - sampling_start_hhmmss = col_character(), - station_code = col_double(), - tow_end_timestamp = col_datetime(format = ""), - tow_start_timestamp = col_datetime(format = ""), - trawl_id = col_double(), - vertebrate_weight_kg = col_double(), - vessel = col_character(), - vessel_id = col_integer(), - year = col_integer(), - year_stn_invalid = col_integer() -)) %>% - select("trawl_id","year","longitude_hi_prec_dd","latitude_hi_prec_dd","depth_hi_prec_m","area_swept_ha_der", "performance") -# It is ok to get warning message that missing column names filled in: 'X1' [1]. - -wcann <- left_join(wcann_haul, wcann_catch, by = c("trawl_id", "year", "performance")) %>% - filter(performance !='Unsatisfactory') - -wcann <- wcann %>% - mutate( - # create haulid - haulid = trawl_id, - # Add "strata" (define by lat, lon and depth bands) where needed # no need to use lon grids on west coast (so narrow) - #stratum = paste(floor(latitude_dd)+0.5, floor(depth_m/100)*100 + 50, sep= "-"), - # adjust for tow area # kg per hectare (10,000 m2) - wtcpue = total_catch_wt_kg/area_swept_ha_der - ) - -wcann$stratum<-ifelse(wcann$latitude_dd <=35.5 & wcann$depth_hi_prec_m<=183, "35.5-183", - ifelse(wcann$latitude_dd <= 35.5 & wcann$depth_hi_prec_m <= 549, "35.5-549", - ifelse(wcann$latitude_dd <= 35.5 & wcann$depth_hi_prec_m <= 1280, "35.5-1280", - ifelse(wcann$latitude_dd <= 35.5 & wcann$depth_hi_prec_m > 1280, "35.5-2000", - ifelse(wcann$latitude_dd <=40.5 & wcann$depth_hi_prec_m<=183, "40.5-183", - ifelse(wcann$latitude_dd <= 40.5 & wcann$depth_hi_prec_m<= 549, "40.5-549", - ifelse(wcann$latitude_dd <= 40.5 & wcann$depth_hi_prec_m <= 1280, "40.5-1280", - ifelse(wcann$latitude_dd <= 40.5 & wcann$depth_hi_prec_m > 1280, "40.5-2000", - ifelse(wcann$latitude_dd <=43.5 & wcann$depth_hi_prec_m<=183, "43.5-183", - ifelse(wcann$latitude_dd <= 43.5 & wcann$depth_hi_prec_m <= 549, "43.5-549", - ifelse(wcann$latitude_dd <= 43.5 & wcann$depth_hi_prec_m <= 1280, "43.5-1280", - ifelse(wcann$latitude_dd <= 43.5 & wcann$depth_hi_prec_m > 1280, "43.5-2000", - # ifelse(wcann$latitude_dd <=47.5 & wcann$depth_m<=183, "47.5-183", - # ifelse(wcann$latitude_dd <= 47.5 & wcann$depth_m <= 549, "47.5-549", - # ifelse(wcann$latitude_dd <= 47.5 & wcann$depth_m <= 1280, "47.5-1280", - # ifelse(wcann$latitude_dd <= 47.5 & wcann$depth_m > 1280, "47.5-2000", - ifelse(wcann$latitude_dd <=50.5 & wcann$depth_hi_prec_m<=183, "50.5-183", - ifelse(wcann$latitude_dd <= 50.5 & wcann$depth_hi_prec_m <= 549, "50.5-549", - ifelse(wcann$latitude_dd <= 50.5 & wcann$depth_hi_prec_m <= 1280, "50.5-1280", - ifelse(wcann$latitude_dd <= 50.5 & wcann$depth_hi_prec_m > 1280, "50.5-2000",NA)))))))))))))))) -wcann_strats <- wcann %>% - filter(!is.na(wtcpue)) %>% - group_by(stratum) %>% - summarise(stratumarea = calcarea(longitude_dd, latitude_dd), na.rm = T) - - -wcann <- left_join(wcann, wcann_strats, by = "stratum") - -wcann <- wcann %>% - rename(lat = latitude_dd, - lon = longitude_dd, - depth = depth_hi_prec_m, - spp = scientific_name) %>% - # remove non-fish - filter(spp != "" & - !grepl("Egg", partition), - !grepl("crushed", spp), - !grepl("empty", spp), - !grepl("tube worm unident", spp), - !grepl("unsorted shab", spp), - !grepl("Gelatinous material unident", spp), - !grepl("fish unident", spp), - !grepl("shrimp unident", spp), - !grepl("unident.", spp)) %>% - # adjust spp names - mutate( - spp = ifelse(grepl("Lepidopsetta", spp), "Lepidopsetta sp.", spp), - spp = ifelse(grepl("Bathyraja", spp), 'Bathyraja sp.', spp), - spp = ifelse(grepl("Poromitra", spp), 'Poromitra curilensis', spp) - ) %>% - group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% - summarise(wtcpue = sumna(wtcpue)) %>% - # add region column - mutate(region = "West Coast Annual") %>% - select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% - ungroup() - - -if (HQ_DATA_ONLY == TRUE){ - # if want to keep the same footprint as wctri - # how many rows of data will be lost? - # nrow(wcann) - nrow(filter(wcann, stratum %in% wctri_fltr$stratum)) - # # percent that will be lost - 61% ! - # print((nrow(wcann) - nrow(filter(wcann, stratum %in% wctri_fltr$stratum)))/nrow(wcann)) - # - # wcann_fltr <- wcann %>% - # filter(stratum %in% wctri_fltr$stratum) - - ## Use the full WCANN footprint -- don't match to the WCtri footprint - p1 <- wcann %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p2 <- wcann %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - test <- wcann %>% - #filter(year != 2019) %>% - select(stratum, year) %>% - distinct() %>% - group_by(stratum) %>% - summarise(count = n()) %>% - filter(count>=20) - - # how many rows will be lost if only stratum trawled ever year are kept? - test2 <- wcann %>% - filter(stratum %in% test$stratum) - nrow(wcann) - nrow(test2) - # percent that will be lost - print((nrow(wcann) - nrow(test2))/nrow(wcann)) - - wcann_fltr <- wcann %>% - #filter(year != 2019)%>% - filter(stratum %in% test$stratum) - - p3 <- wcann_fltr %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p4 <- wcann_fltr %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - if (HQ_PLOTS == TRUE){ - temp <- grid.arrange(p1, p2, p3, p4, nrow = 2) - ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "wcann_hq_dat_removed.png")) - rm(temp) - } - rm(p1, p2) -} - -# cleanup -rm(wcann_catch, wcann_haul, wcann_strats) - -# Compile GMEX =========================================================== -print("Compile GMEX") -##Read in data -gmex_station <- read_csv(here::here("data_processing_rcode/data", "gmex_STAREC.csv"), col_types = cols(.default = col_character())) %>% - select('STATIONID', 'CRUISEID', 'CRUISE_NO', 'P_STA_NO', 'TIME_ZN', 'TIME_MIL', 'S_LATD', 'S_LATM', 'S_LOND', 'S_LONM', 'E_LATD', 'E_LATM', 'E_LOND', 'E_LONM', 'STAT_ZONE', 'DEPTH_SSTA', 'MO_DAY_YR', 'VESSEL_SPD', 'COMSTAT') - -gmex_station <- type_convert(gmex_station, col_types = cols( - STATIONID = col_integer(), - CRUISEID = col_integer(), - CRUISE_NO = col_integer(), - P_STA_NO = col_character(), - TIME_ZN = col_integer(), - TIME_MIL = col_character(), - S_LATD = col_integer(), - S_LATM = col_double(), - S_LOND = col_integer(), - S_LONM = col_double(), - E_LATD = col_integer(), - E_LATM = col_double(), - E_LOND = col_integer(), - E_LONM = col_double(), - DEPTH_SSTA = col_double(), - STAT_ZONE = col_double(), - MO_DAY_YR = col_date(format = "%d/%m/%Y"), - VESSEL_SPD = col_double(), - COMSTAT = col_character() -)) - -names(gmex_station)<-tolower(names(gmex_station)) - -gmex_tow <-readr::read_delim(here::here("data_processing_rcode/data","gmex_INVREC.csv"), - delim = ',', escape_backslash = T, escape_double = F) -gmex_tow<-type_convert(gmex_tow, col_types = cols( - INVRECID = col_integer(), - STATIONID = col_integer(), - CRUISEID = col_integer(), - VESSEL = col_integer(), - CRUISE_NO = col_integer(), - P_STA_NO = col_character(), - GEAR_SIZE = col_integer(), - GEAR_TYPE = col_character(), - MESH_SIZE = col_double(), - OP = col_character(), - MIN_FISH = col_integer(), - WBCOLOR = col_character(), - BOT_TYPE = col_character(), - BOT_REG = col_character(), - TOT_LIVE = col_double(), - FIN_CATCH = col_double(), - CRUS_CATCH = col_double(), - OTHR_CATCH = col_double(), - T_SAMPLEWT = col_double(), - T_SELECTWT = col_double(), - FIN_SMP_WT = col_double(), - FIN_SEL_WT = col_double(), - CRU_SMP_WT = col_double(), - CRU_SEL_WT = col_double(), - OTH_SMP_WT = col_double(), - OTH_SEL_WT = col_double(), - COMBIO = col_character(), - X28 = col_character() -)) -gmex_tow <- gmex_tow %>% - select('CRUISEID', 'STATIONID', 'VESSEL', 'CRUISE_NO', 'P_STA_NO', 'INVRECID', 'GEAR_SIZE', 'GEAR_TYPE', 'MESH_SIZE', 'MIN_FISH', 'OP') %>% - filter(GEAR_TYPE=='ST') - -gmex_bio <-readr::read_delim(here::here("data_processing_rcode/data","gmex_BGSREC.csv"), - delim = ',', escape_backslash = T, escape_double = F) - -gmex_bio <- type_convert(gmex_bio, cols( - CRUISEID = col_integer(), - STATIONID = col_integer(), - VESSEL = col_integer(), - CRUISE_NO = col_integer(), - P_STA_NO = col_character(), - GENUS_BGS = col_character(), - SPEC_BGS = col_character(), - BGSCODE = col_character(), - BIO_BGS = col_integer(), - SELECT_BGS = col_double() -)) - -gmex_cruise <-read_csv(here::here("data_processing_rcode/data", "gmex_CRUISES.csv"), col_types = cols(.default = col_character())) %>% - select(CRUISEID, VESSEL, TITLE) - - -gmex_cruise <- type_convert(gmex_cruise, col_types = cols(CRUISEID = col_integer(), VESSEL = col_integer(), TITLE = col_character())) -names(gmex_cruise)<-tolower(names(gmex_cruise)) - -gmex_spp <-read_csv(here::here("data_processing_rcode/data","gmex_BCT_NFR_01182023.csv")) -problems(gmex_spp) -names(gmex_spp)<-tolower(names(gmex_spp)) -gmex_spp<-dplyr::select(gmex_spp,biocode,ciu_biocode,taxon) - -##Resolve issues -#Issue 1: Proper way to Merge the Tow (invrec) and bio (bgsrec) tables -# The proper way to link the invrec table to the bgsrec is supposed to use the invrecid -# variable as the primary key. However, the bgsrec table has null invrecid for data collected -# under previous data collection systems. The invrec and bgsrec tables can be linked using -# the vessel, cruise_no and p_sta_no variables as a primary key. Unfortunately, there are -# a series stations where the Oregon II (Vessel 4 Cruise_No = 0284) towed standard -# shrimp trawls (ST) side by side (port/starboard) with experimental trawls (ES). Therefore, -# linking the invrec and bgsrec tabls based on the vessel, cruise_no and p_sta_no variables -# will lead to all catch records for both the shrimp and experimental trawls being linked -# to both trawls. The bgsrec also contains records for catches not associated with invrec table -# records. These are from reef fish cruises. The following codes creates a modified bgsrec table -# that updates the null invrecid for older data and performs some checks. - -names(gmex_tow) <- tolower(names(gmex_tow)) -names(gmex_bio) <- tolower(names(gmex_bio)) -#create bgsrec_invrecid_fix -#get only stationid and invrecid from invrec table -get_stationid_invrecid <- gmex_tow %>% dplyr::select(stationid, invrecid) %>% rename(inv_invrecid = invrecid) - -#extract bgsrec table records with missing invrecid and update based on stationid from get_stationid_invrecid -bgsrec_null_invrecid <- gmex_bio %>% - dplyr::filter(is.na(invrecid)) %>% - dplyr::left_join(get_stationid_invrecid, by = 'stationid') %>% - dplyr::mutate(invrecid = inv_invrecid) %>% dplyr::select(-inv_invrecid) - -#Extracts any remaining bgsrec table records with null invrecid. These should all be -#associated with reef fish cruises at this point. -bgsrec_null_check1 <- bgsrec_null_invrecid %>% - dplyr::filter(is.na(invrecid)) - -#extract bgsrec table records with valid invrecid -bgsrec_with_invrecid <- gmex_bio %>% - dplyr::filter(!is.na(invrecid)) - -#Stack bgsrec_null_invrec now updated with valid invrecid and bgsrec_with_invrecid -gmex_bio_mod <- bgsrec_null_invrecid %>% - dplyr::bind_rows(bgsrec_with_invrecid) %>% - #Remove null invrecid which should only include those in bgsrec_null_check1 - dplyr::filter(!is.na(invrecid)) %>% - dplyr::arrange(bgsid) - -#Check to make sure only records with invrecs are present - should have 0 rows -bgsrec_null_check2 <- gmex_bio_mod %>% filter(is.na(invrecid)) - -#drop unwanted data objects -rm(bgsrec_null_invrecid,bgsrec_null_check1,bgsrec_null_check2,bgsrec_with_invrecid,get_stationid_invrecid, gmex_bio) -# garbace collect to free up memory -gc() - -#Issues 2: Taxonomic coding -# (3-1) The newbiocodesbig table does not fully contain all code/taxonomic names found in the bgsrec table: -# (3-2) the bgsrec table has a few instances of invalid bio_bgs (biocode) values; and -# (3-3) multiple code/taxonomic combinations may refer to the same organisms under different names. For example, -# 189040204/MONACANTHUS HISPIDUS, 189040305/STEPHANOLEPIS HISPIDA, 189040306/STEPHANOLEPIS HISPIDUS -# and 189040307/STEPHANOLEPIS HISPIDA (current) have all been used to identify Planehead Filefish due to -# changes in taxonomy. The bsgrec file reflects the code/taxonomic use at time of data ingest. -# The provided master biocode table (MBT) will allow translation of the vast majority cases where multiple -# code/taxonomic refer to the same organism. The process relies on the use of the biocode, -# ciu_biocode and taxon variables in the MBT. The MBT biocode variable in numeric form is equivalent to the -# code (character) variable in the newbiocodesbig and bio_bgs (character) variable in the bgsrec tables. -# Similarly the taxon variable in the MBT table is equivalent to taxonomic in the newbiocodesbig table. -# The MBT also has a rb_biocode (replaced by biocode) variable which is the numeric biocode that -# replaces a inactive (inactive = 1 variable) biocode, and allows me to track changes over time. -# Since multiple changes may have occurred, the ciu_biocode (currently in use biocode) value ties multiple records -# that are now inactive to the current active biocode. Inactive biocodes have the variable inactive set to zero. -# Using the example above, the ciu_biocode that ties together records of Planehead Filefish is 189040307. -# The following script updates bgsrec table code to ciu_biocode via the MBT table. The rb_biocode variable is not -# needed for this purpose. - -# starting with our gmex_bio_mod from above -gmex_bio_utax1 <- gmex_bio_mod %>% - #convert bgsrec table bio_bgs varialbe to numeric integer - dplyr::mutate(bio_bgs = as.integer(bio_bgs)) %>% - #rename bio_bgs to biocode to allow for easier manipulation with master biocode table (mbt) - dplyr::rename(biocode = bio_bgs) %>% - ### take care of Issue 3-2 ### - # fix invalid zero code and make it the code (999999998) for unidentified specimen - dplyr::mutate(biocode = ifelse(biocode == 0,999999998,biocode)) %>% - # fix invalid unidentified fish code 100000001 to proper code - dplyr::mutate(biocode = ifelse(biocode == 100000001,100000000,biocode)) %>% - # fix invalid unidentified crustacean code 200000001 to proper code - dplyr::mutate(biocode = ifelse(biocode == 200000001,200000000,biocode)) %>% - # fix invalid unidentified crustacean code 300000001 and 300000001 to proper code - dplyr::mutate(biocode = ifelse(biocode == 300000001,300000000,biocode)) %>% - dplyr::mutate(biocode = ifelse(biocode == 300000002,300000000,biocode)) %>% - ### take care of Issue 3-3 ### - #update older inactive biocodes to those currently in use (ciu_biocode) - dplyr::left_join(dplyr::select(gmex_spp,biocode,taxon,ciu_biocode), by = "biocode") %>% - #rename taxon to bgs taxon to keep the original name associated with a biocode - dplyr::rename(bgs_taxon = taxon) %>% - #do a left join to bring in taxon associated with ciu_taxon - dplyr::left_join(dplyr::select(gmex_spp,biocode,taxon), by = c("ciu_biocode" = "biocode")) - -### Issue 3: Problematic Taxa with taxonomic issues or problematic separation in the field### -# Collapse taxa with known identification issues and collapse all sponge to single category -# Note this process needs to be implemented after the ciu_biocode update as the statements -# rely on the ciu_biocode. The statements undergo a review with each updated version of the -# MBT -gmex_bio_utax2 <- gmex_bio_utax1 %>% - #Take care of squid and species complexes... - #Update the squid genus Loligo and all species under genus Doryteuthis to the genus Doryteuthis - mutate(ciu_biocode = ifelse(ciu_biocode %in% c(347020200,347021001,347021002,347021003),347021000,ciu_biocode)) %>% - mutate(taxon = ifelse(ciu_biocode %in% c(347021000),'DORYTEUTHIS SP',taxon)) %>% - # #Update batfish species to Halieutichthys - mutate(ciu_biocode = ifelse(ciu_biocode >= 195050401 & ciu_biocode <= 195050405,195050400,ciu_biocode)) %>% - mutate(taxon = ifelse(ciu_biocode %in% c(195050400),'HALIEUTICHTHYS SP',taxon)) %>% - #Update all jellfishy in the genus Aurelia to the genus Aurelia - mutate(ciu_biocode = ifelse(ciu_biocode >= 618010101 & ciu_biocode <= 618010105,618010100,ciu_biocode)) %>% - mutate(taxon = ifelse(ciu_biocode %in% c(618010100),'AURELIA',taxon)) %>% - #Update all lionfishes species to the genus Pterois - mutate(ciu_biocode = ifelse(ciu_biocode %in% c(168011901,168011902),168011900,ciu_biocode)) %>% - mutate(taxon = ifelse(ciu_biocode %in% c(168011900),'PTEROIS',taxon)) %>% - #smoothhounds (Mustelus) Managed as species complex, our ids are OK now but in the past assumptions made %>% - mutate(ciu_biocode = ifelse(ciu_biocode %in% c(108031101,108031102,108031103,108031104),108031100,ciu_biocode)) %>% - mutate(taxon = ifelse(ciu_biocode %in% c(108031100),'MUSTELUS SP',taxon)) %>% - #lump all sponge identifications to Porifera - mutate(ciu_biocode = ifelse(ciu_biocode >= 613000000 & ciu_biocode < 616000000,613000000,ciu_biocode)) %>% - mutate(taxon = ifelse(ciu_biocode %in% c(613000000),'PORIFERA',taxon)) %>% - #handle out of order Porifera Demospngiae and Agelas and Agelas and Agelasidae in coral numbers - mutate(ciu_biocode = ifelse(ciu_biocode %in% c(999997000,999997020,617170000,617170100),613000000,ciu_biocode)) %>% - mutate(taxon = ifelse(ciu_biocode %in% c(613000000),'PORIFERA',taxon)) %>% - #Collapse all shrimp species in Rimnapenaeus as they are not consistently seperated in the field - mutate(ciu_biocode = ifelse(ciu_biocode %in% c(228012001,228012002),228012000,ciu_biocode)) %>% - mutate(taxon = ifelse(ciu_biocode %in% c(228012000),'RIMAPENAEUS',taxon)) %>% - #Astropecten species have changed, distribution overlap with major east west differences - mutate(biocode = ifelse(biocode >= 691010101 & biocode <= 691010112,691010100,biocode)) %>% - mutate(taxon = ifelse(biocode %in% c(691010100),'ASTROPECTEN',taxon)) - -## MERGE the corrected catch/tow/species information from above with cruise information, but only for shrimp trawl tows (ST) -gmex <- left_join(gmex_bio_utax2, gmex_tow, by = c("cruiseid", "stationid","vessel", "cruise_no", "p_sta_no", "invrecid")) %>% - # add station location and related data - left_join(gmex_station, by = c("cruiseid", "stationid", "cruise_no", "p_sta_no")) %>% - # add cruise title - left_join(gmex_cruise, by = c("cruiseid", "vessel")) %>% - #filter out YOY (denoted by BSGCODE=T) since they are useful for counts by not weights - filter(bgscode != "T"| is.na(bgscode)) - -gmex <- gmex %>% - # Trim to high quality SEAMAP summer trawls, based off the subset used by Jeff Rester's GS_TRAWL_05232011.sas - filter(grepl("Summer", title) & - gear_size == 40 & - mesh_size == 1.63 & - # OP has no letter value - !grepl("[A-Z]", op)) %>% - mutate( - # Create a unique haulid - haulid = paste(formatC(vessel, width=3, flag=0), formatC(cruise_no, width=3, flag=0), formatC(p_sta_no, width=5, flag=0, format='d'), sep='-'), - # Extract year where needed - year = year(mo_day_yr), - # Calculate decimal lat and lon, depth in m, where needed - s_latd = ifelse(s_latd == 0, NA, s_latd), - s_lond = ifelse(s_lond == 0, NA, s_lond), - e_latd = ifelse(e_latd == 0, NA, e_latd), - e_lond = ifelse(e_lond == 0, NA, e_lond), - lat = rowMeans(cbind(s_latd + s_latm/60, e_latd + e_latm/60), na.rm=T), - lon = -rowMeans(cbind(s_lond + s_lonm/60, e_lond + e_lonm/60), na.rm=T), - # Add "strata" (define by STAT_ZONE and depth bands) - # degree bins, # degree bins, # 100 m bins - #stratum = paste(STAT_ZONE, floor(depth/100)*100 + 50, sep= "-") - ) - -#add stratum code defined by STAT_ZONE and depth bands (note depth in recorded as m, and depth bands based on 0-20 fathoms -# and 21-60 fathoms)) -gmex$depth_zone<-ifelse(gmex$depth_ssta<=36.576, "20", - ifelse(gmex$depth_ssta>36.576, "60", NA)) -gmex<-gmex %>% - mutate(stratum = paste(stat_zone, depth_zone, sep= "-")) - -# # fix speed -# Trim out or fix speed and duration records -# trim out tows of 0, >60, or unknown minutes -gmex <- gmex %>% - filter(min_fish <= 60 & min_fish > 0 & !is.na(min_fish )) %>% - # fix typo according to Jeff Rester: 30 = 3 - mutate(vessel_spd = ifelse(vessel_spd == 30, 3, vessel_spd)) %>% - # trim out vessel speeds 0, unknown, or >5 (need vessel speed to calculate area trawled) - filter(vessel_spd <= 5 & vessel_spd > 0 & !is.na(vessel_spd)) - -gmex_strats <- gmex %>% - group_by(stratum) %>% - summarise(stratumarea = calcarea(lon, lat)) -gmex <- left_join(gmex, gmex_strats, by = "stratum") - -# while comsat is still present -# Remove a tow when paired tows exist (same lat/lon/year but different haulid, only Gulf of Mexico) -# identify duplicate tows at same year/lat/lon -dups <- gmex %>% - group_by(year, lat, lon) %>% - filter(n() > 1) %>% - group_by(haulid) %>% - filter(n() == 1) - -# remove the identified tows from the dataset -gmex <- gmex %>% - filter(!haulid %in% dups$haulid & !grepl("PORT", comstat)) - -gmex <- gmex %>% - rename(spp = taxon, - depth = depth_ssta) %>% - # adjust for area towed - mutate( - # kg per 10000m2. calc area trawled in m2: knots * 1.8 km/hr/knot * 1000 m/km * minutes * 1 hr/60 min * width of gear in feet * 0.3 m/ft # biomass per standard tow - wtcpue = 10000*select_bgs/(vessel_spd * 1.85200 * 1000 * min_fish / 60 * gear_size * 0.3048) - ) %>% - # remove non-fish - filter( - spp != '' | !is.na(spp), - # remove unidentified spp - !spp %in% c('UNID CRUSTA', 'UNID OTHER', 'UNID.FISH', 'CRUSTACEA(INFRAORDER) BRACHYURA', 'MOLLUSCA AND UNID.OTHER #01', 'ALGAE', 'MISCELLANEOUS INVERTEBR', 'OTHER INVERTEBRATES') - ) %>% - group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% - summarise(wtcpue = sumna(wtcpue)) %>% - # add region column - mutate(region = "Gulf of Mexico") %>% - select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% - ungroup() - - -if (HQ_DATA_ONLY == TRUE){ - # look at the graph and make sure decisions to keep or eliminate data make sense - - p1 <- gmex %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p2 <- gmex %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - - test <- gmex %>% - filter(year >= 2010, year!=2023) %>% #switched to 2010 and after since 2008-2009 were experimental years - select(stratum, year) %>% - distinct() %>% - group_by(stratum) %>% - summarise(count = n()) %>% - filter(count >=10) # removes strata that are poorly sampled through time - - # how many rows will be lost if years where all strata sampled (>2008) are kept? - test2 <- gmex %>% - filter(stratum %in% test$stratum) - nrow(gmex) - nrow(test2) - # percent that will be lost - print((nrow(gmex) - nrow(test2))/nrow(gmex)) - # lose % of rows - - gmex_fltr <- gmex %>% - filter(stratum %in% test$stratum) %>% - filter(year>=2010, year != 2023) - - #### #filter out the points that are outside of the standard survey extent - # library(sf) - # library(sp) - # shape<-read_sf(dsn="~/transfer/DisMAP project/IDW_survey_shapefiles/GMEX_IDW", layer="GMEX_IDW_Region") - # plot(shape) - # points<-gmex_fltr %>% - # sf::st_as_sf(coords=c("lon", "lat")) - # st_crs(points)<-4326 - # shape<-sf::st_transform(shape, CRS("+proj=longlat")) - # st_crs(shape)<-4326 - # - # library(tmap) - # tmap::qtm(points) - # ponts_in_boundary<-st_intersection(points, shape) - # tmap::qtm(ponts_in_boundary) - # gmex_coords <- unlist(st_geometry(ponts_in_boundary)) %>% - # matrix(ncol=2,byrow=TRUE) %>% - # as_tibble() %>% - # setNames(c("lon","lat")) - # gmex_bind<-bind_cols(ponts_in_boundary, gmex_coords) - # gmex_fltr<-as.data.frame(gmex_bind) %>% - # select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) - # - # plot_new<-gmex_fltr %>% - # select(lat, lon) - # # plot_old<-gmex_fltr %>% - # # select(lat, lon) - # ggplot()+ - # geom_sf(data=shape, color="red")+ - # geom_point(data=plot, aes(x = lon, y = lat), color="blue") - # # geom_point(data=plot_new, aes(x = lon, y = lat), color="green") - - p3 <- gmex_fltr %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p4 <- gmex_fltr %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - if (HQ_PLOTS == TRUE){ - temp <- grid.arrange(p1, p2, p3, p4, nrow = 2) - ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "gmex_hq_dat_removed.png")) - rm(temp) - } - rm(test, test2, p1, p2, p3, p4) -} -rm(gmex_bio, gmex_cruise, gmex_spp, gmex_station, gmex_tow, problems,gmex_bio_mod, gmex_bio_utax2, gmex_bio_utax1, dups) - -# Compile Northeast US =========================================================== -print("Compile NEUS") -## 2023 update, NEFSC gave data set already with the conversions done -#read strata file -neus_strata <- read_csv(here::here("data_processing_rcode/data", "neus_strata.csv"), col_types = cols(.default = col_character())) %>% - select(stratum, stratum_area) %>% - mutate(stratum = as.double(stratum)) %>% - distinct() - -#read in catch file, which includes both spring and fall survey. Need to parse them out -neus_catch <- read.csv("data_processing_rcode/data/NEFSC_BTS_ALLCATCHES_May2024.csv", header=T, sep=",")%>% - filter(!is.na(SCINAME)) %>% - mutate(SVSPP = as.character(SVSPP)) -neus_fall_catch<-neus_catch %>% - filter(SEASON=="FALL") -neus_spring_catch<-neus_catch %>% - filter(SEASON=="SPRING") - -#NEUS fall -neus_fall <- neus_fall_catch %>% - rename(year = EST_YEAR, - lat = DECDEG_BEGLAT, - lon = DECDEG_BEGLON, - depth = AVGDEPTH, - stratum = STRATUM, - haulid = ID, - spp = SCINAME, - wtcpue = CALIB_WT) %>% - mutate( - haulid= paste(CRUISE6,"0",stratum,"00",TOW, "0000"),sep="") %>% - mutate(stratum = as.double(stratum), - lat = as.double(lat), - lon = as.double(lon), - depth = as.double(depth), - haulid= as.character(haulid), - wtcpue = as.double(wtcpue), - year = as.double(year)) - -# sum different sexes of same spp together -neus_fall <- neus_fall %>% - group_by(year, lat, lon, depth, haulid, STATION, stratum, spp) %>% - summarise(wtcpue = sum(wtcpue)) -neus_fall <- ungroup(neus_fall) - -#join with strata -neus_fall <- left_join(neus_fall, neus_strata, by = "stratum") -neus_fall <- filter(neus_fall, !is.na(stratum_area)) -neus_fall <- neus_fall %>% - rename(stratumarea = stratum_area) %>% - mutate(stratumarea = as.double(stratumarea)* 3.429904) #convert square nautical miles to square kilometers -neus_fall$region <- "Northeast US Fall" - -neus_fall<- neus_fall %>% - select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% - # remove unidentified spp and non-species - filter( - !spp %in% c("TRASH SPECIES IN CATCH")) %>% - filter( - spp != "" | !is.na(spp), - haulid !="197512 0 3290 00 1 0000", - !grepl("EGG", spp), - !grepl("UNIDENTIFIED", spp), - !grepl("UNKNOWN", spp), - !grepl("NO FISH BUT GOOD TOW", spp), ## FLAG. should this tow be kept in somehow? - !grepl("DELPHINIDAE", spp)) %>% - # remove any extra white space from around spp names - mutate(spp = str_trim(spp)) - - -# are there any strata in the data that are not in the strata file? -stopifnot(nrow(filter(neus_fall, is.na(stratumarea))) == 0) - -rm(neus_fall_catch) - -if (HQ_DATA_ONLY == TRUE){ - # look at the graph and make sure decisions to keep or eliminate data make sense - - p1 <- neus_fall %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p2 <- neus_fall %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - test <- neus_fall %>% - filter(year != 2017, year >= 1974) %>% - select(stratum, year) %>% - distinct() %>% - group_by(stratum) %>% - summarise(count = n())%>% - filter(count >= 46) - - # how many rows will be lost if only stratum trawled fairly consistently (>46 years - so all but 2 of the years) are kept? - test2 <- neus_fall %>% - filter(year != 2017, year > 1973) %>% - filter(stratum %in% test$stratum) - nrow(neus_fall) - nrow(test2) - # percent that will be lost - print((nrow(neus_fall) - nrow(test2))/nrow(neus_fall)) - # When bad strata are removed after bad years we only lose 34% - - neus_fall_fltr <- neus_fall %>% - filter(year != 2017, year > 1973) %>% - filter(stratum %in% test$stratum) - - p3 <- neus_fall_fltr %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p4 <- neus_fall_fltr %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - if (HQ_PLOTS == TRUE){ - temp <- grid.arrange(p1, p2, p3, p4, nrow = 2) - ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "neusF_hq_dat_removed.png")) - rm(temp) - } - rm(test, test2, p1, p2, p3, p4) -} - -#NEUS Spring -neus_spring <- neus_spring_catch %>% - rename(year = EST_YEAR, - lat = DECDEG_BEGLAT, - lon = DECDEG_BEGLON, - depth = AVGDEPTH, - stratum = STRATUM, - haulid = ID, - spp = SCINAME, - wtcpue = EXPCATCHWT) %>% - mutate(haulid= paste(CRUISE6,"0",stratum,"00",TOW, "0000"),sep="") %>% - mutate(stratum = as.double(stratum), - lat = as.double(lat), - lon = as.double(lon), - depth = as.double(depth), - wtcpue = as.double(wtcpue)) - -# sum different sexes of same spp together -neus_spring <- neus_spring %>% - group_by(year, lat, lon, depth, haulid, CRUISE6, STATION, stratum, spp) %>% - summarise(wtcpue = sum(wtcpue)) -neus_spring <- ungroup(neus_spring) - -#join with strata -neus_spring <- left_join(neus_spring, neus_strata, by = "stratum") -neus_spring <- filter(neus_spring, !is.na(stratum_area)) - -# are there any strata in the data that are not in the strata file? -stopifnot(nrow(filter(neus_spring, is.na(stratum_area))) == 0) -neus_spring <- neus_spring %>% - rename(stratumarea = stratum_area) %>% - mutate(stratumarea = as.double(stratumarea)* 3.429904)#convert square nautical miles to square kilometers - -neus_spring$region <- "Northeast US Spring" - -neus_spring <- neus_spring %>% - select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% - # remove unidentified spp and non-species - # remove non-fish - filter( - !spp %in% c("TRASH SPECIES IN CATCH")) %>% - filter( - spp != "" | !is.na(spp), - !grepl("EGG", spp), - !grepl("UNIDENTIFIED", spp), - !grepl("UNKNOWN", spp), - !grepl("NO FISH BUT GOOD TOW", spp)) %>% - # remove any extra white space from around spp names - mutate(spp = str_trim(spp)) - -if (HQ_DATA_ONLY == TRUE){ - # look at the graph and make sure decisions to keep or eliminate data make sense - - p1 <-neus_spring %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p2 <- neus_spring %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - test <- neus_spring %>% - filter(year != 2020,year != 2014, year != 1975, year > 1973) %>% - select(stratum, year) %>% - distinct() %>% - group_by(stratum) %>% - summarise(count = n())%>% - filter(count >= 44) #note: every year would be 46, but that would lost some key strata in the south - - # how many rows will be lost if only stratum trawled ALMOST ever year are kept? - test2 <- neus_spring %>% - filter(year!= 2023, year != 2020,year != 2014, year != 1975, year > 1973) %>% - filter(stratum %in% test$stratum) - nrow(neus_spring) - nrow(test2) - # percent that will be lost - (nrow(neus_spring) - nrow(test2))/nrow(neus_spring) - # When bad strata are removed after bad years we only lose 35% - - neus_spring_fltr <- neus_spring %>% - filter(year!= 2023, year != 2020,year != 2014, year != 1975, year > 1973) %>% - filter(stratum %in% test$stratum) - - p3 <- neus_spring_fltr %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p4 <- neus_spring_fltr %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - if (HQ_PLOTS == TRUE){ - temp <- grid.arrange(p1, p2, p3, p4, nrow = 2) - ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "neusS_hq_dat_removed.png")) - rm(temp) - } - rm(test, p1, p2, p3, p4) -} - -rm(neus_strata) - -# Compile SEUS =========================================================== -print("Compile SEUS") -# turns everything into a character so import as character anyway -seus_catch <- read_csv(here::here("data_processing_rcode/data", "seus_catch.csv"), col_types = cols(.default = col_character())) %>% - # remove symbols - mutate_all(list(~str_replace(., "=", ""))) %>% - mutate_all(list(~str_replace(., '"', ''))) %>% - mutate_all(list(~str_replace(., '\"', ''))) - -# The 9 parsing failures are due to the metadata at the end of the file that does not fit into the data columns - -# problems should have 0 obs -problems <- problems(seus_catch) %>% - filter(!is.na(col)) -stopifnot(nrow(problems) == 0) - -# convert the columns to their correct formats -seus_catch <- type_convert(seus_catch, col_types = cols( - PROJECTNAME = col_character(), - PROJECTAGENCY = col_character(), - DATE = col_character(), - EVENTNAME = col_character(), - COLLECTIONNUMBER = col_character(), - VESSELNAME = col_character(), - GEARNAME = col_character(), - GEARCODE = col_character(), - SPECIESCODE = col_character(), - MRRI_CODE = col_character(), - SPECIESSCIENTIFICNAME = col_character(), - SPECIESCOMMONNAME = col_character(), - NUMBERTOTAL = col_integer(), - SPECIESTOTALWEIGHT = col_double(), - SPECIESSUBWEIGHT = col_double(), - SPECIESWGTPROCESSED = col_character(), - WEIGHTMETHODDESC = col_character(), - ORGWTUNITS = col_character(), - EFFORT = col_character(), - CATCHSUBSAMPLED = col_logical(), - CATCHWEIGHT = col_double(), - CATCHSUBWEIGHT = col_double(), - TIMESTART = col_character(), - DURATION = col_integer(), - TOWTYPETEXT = col_character(), - LOCATION = col_character(), - REGION = col_character(), - DEPTHZONE = col_character(), - ACCSPGRIDCODE = col_character(), - STATIONCODE = col_character(), - EVENTTYPEDESCRIPTION = col_character(), - TEMPSURFACE = col_double(), - TEMPBOTTOM = col_double(), - SALINITYSURFACE = col_double(), - SALINITYBOTTOM = col_double(), - SDO = col_character(), - BDO = col_character(), - TEMPAIR = col_double(), - LATITUDESTART = col_double(), - LATITUDEEND = col_double(), - LONGITUDESTART = col_double(), - LONGITUDEEND = col_double(), - SPECSTATUSDESCRIPTION = col_character(), - LASTUPDATED = col_character() -)) - -seus_haul <- read_csv(here::here("data_processing_rcode/data", "seus_haul.csv"), col_types = cols(.default = col_character())) %>% - distinct(EVENTNAME, DEPTHSTART) %>% - # remove symbols - mutate_all(list(~str_replace(., "=", ""))) %>% - mutate_all(list(~str_replace(., '"', ''))) %>% - mutate_all(list(~str_replace(., '"', ''))) - -# problems should have 0 obs -problems <- problems(seus_haul) %>% - filter(!is.na(col)) -stopifnot(nrow(problems) == 0) - -seus_haul <- type_convert(seus_haul, col_types = cols( - EVENTNAME = col_character(), - DEPTHSTART = col_integer() -)) - -seus <- left_join(seus_catch, seus_haul, by = "EVENTNAME") - -# contains strata areas -seus_strata <- read_csv(here::here("data_processing_rcode/data", "seus_strata.csv"), col_types = cols( - STRATA = col_integer(), - STRATAHECTARE = col_double() -)) - -#Create STRATA column -seus <- seus %>% - mutate(STRATA = as.numeric(str_sub(STATIONCODE, 1, 2))) %>% - # Drop OUTER depth zone because it was only sampled for 10 years - filter(DEPTHZONE != "OUTER") - -#add STRATAHECTARE to main file -seus <- left_join(seus, seus_strata, by = "STRATA") - -#Create a 'SEASON' column using 'MONTH' as a criteria -seus <- seus %>% - mutate(DATE = as.Date(DATE, "%m-%d-%Y"), - MONTH = month(DATE)) %>% - # create season column -- FLAG, in 2023 the survey was conducted in two "seasons" see here for details: https://seamap.org/seamap-sa-coastal-trawl/ - mutate(SEASON = NA, - SEASON = ifelse(MONTH >= 1 & MONTH <= 3, "winter", SEASON), - SEASON = ifelse(MONTH >= 4 & MONTH <= 6, "spring", SEASON), - SEASON = ifelse(MONTH >= 7 & MONTH <= 8, "summer", SEASON), - #September EVENTS were grouped with summer, should be fall because all - #hauls made in late-September during fall-survey - SEASON = ifelse(MONTH >= 9 & MONTH <= 12, "fall", SEASON)) - -# find rows where weight wasn't provided for a species -misswt <- seus %>% - filter(is.na(SPECIESTOTALWEIGHT)) %>% - select(SPECIESCODE, SPECIESSCIENTIFICNAME) %>% - distinct() - -# calculate the mean weight for those species -meanwt <- seus %>% - filter(SPECIESCODE %in% misswt$SPECIESCODE) %>% - group_by(SPECIESCODE) %>% - summarise(mean_wt = mean(SPECIESTOTALWEIGHT, na.rm = T)) - -# rows that need to be changed -change <- seus %>% - filter(is.na(SPECIESTOTALWEIGHT)) - -# remove those rows from SEUS -seus <- anti_join(seus, change) - -# change the rows -change <- change %>% - select(-SPECIESTOTALWEIGHT) - -# update the column values -change <- left_join(change, meanwt, by = "SPECIESCODE") %>% - rename(SPECIESTOTALWEIGHT = mean_wt) - -# rejoin to the data -seus <- rbind(seus, change) - - -#Data entry error fixes for lat/lon coordinates -seus <- seus %>% - mutate( - # longitudes of less than -360 (like -700), do not exist. This is a missing decimal. - LONGITUDESTART = ifelse(LONGITUDESTART < -360, LONGITUDESTART/10, LONGITUDESTART), - LONGITUDEEND = ifelse(LONGITUDEEND < -360, LONGITUDEEND/10, LONGITUDEEND), - # latitudes of more than 100 are outside the range of this survey. This is a missing decimal. - LATITUDESTART = ifelse(LATITUDESTART > 100, LATITUDESTART/10, LATITUDESTART), - LATITUDEEND = ifelse(LATITUDEEND > 100, LATITUDEEND/10, LATITUDEEND) - ) - -# calculate trawl distance in order to calculate effort -# create a matrix of starting positions -start <- as.matrix(seus[,c("LONGITUDESTART", "LATITUDESTART")], nrow = nrow(seus), ncol = 2) -# create a matrix of ending positions -end <- as.matrix(seus[,c("LONGITUDEEND", "LATITUDEEND")], nrow = nrow(seus), ncol = 2) -# add distance to seus table -seus <- seus %>% - mutate(distance_m = geosphere::distHaversine(p1 = start, p2 = end), - distance_km = distance_m / 1000.0, - distance_mi = distance_m / 1609.344) %>% - # calculate effort = mean area swept - # EFFORT = 0 where the boat didn't move, distance_m = 0 - mutate(EFFORT = (13.5 * distance_m)/10000, - # Create a unique haulid - haulid = EVENTNAME, - # Extract year where needed - year = substr(EVENTNAME, 1,4) - ) %>% - rename( - stratum = STRATA, - lat = LATITUDESTART, - lon = LONGITUDESTART, - depth = DEPTHSTART, - spp = SPECIESSCIENTIFICNAME, - stratumarea = STRATAHECTARE) - -seus$year <- as.integer(seus$year) - -#In seus there are two 'COLLECTIONNUMBERS' per 'EVENTNAME', with no exceptions, -#for each side of the boat; -#EFFORT is always the same for each COLLECTIONNUMBER -# We sum the two tows in seus (port and starboard tows), and this steps deletes any haul id x spp duplicates -seus <- seus %>% - group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp, SEASON, EFFORT) %>% - # remove non-fish and records with no species or common name - filter( - !spp %in% c('MISCELLANEOUS INVERTEBRATES','XANTHIDAE','MICROPANOPE NUTTINGI','ALGAE','DYSPANOPEUS SAYI', 'PSEUDOMEDAEUS AGASSIZII') - ) %>% - filter(!is.na(spp)) %>% - # adjust spp names - mutate( - spp = ifelse(grepl("ANCHOA", spp), "ANCHOA", spp), - spp = ifelse(grepl("LIBINIA", spp), "LIBINIA", spp) - ) %>% - #now this accounts for both sides of the boat, and merging within specified gensuses - summarise(biomass = sumna(SPECIESTOTALWEIGHT)) %>% - mutate(wtcpue=biomass/(EFFORT*2)) %>% - # add temporary region column that will be converted to seasonal - mutate(region = "Southeast US") %>% - select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue, SEASON) %>% - ungroup() - -#remove infinite wtcpue values (where effort was 0, causes wtcpue to be inf) -seus <- seus[!is.infinite(seus$wtcpue),] - -# now that lines have been removed from the main data set, can split out seasons -# SEUS spring ==== -#Separate the the spring season and convert to dataframe -seusSPRING <- seus %>% - filter(SEASON == "spring") %>% - select(-SEASON) %>% - mutate(region = "Southeast US Spring") - -if (HQ_DATA_ONLY == TRUE){ - # look at the graph and make sure decisions to keep or eliminate data make sense - - - p1 <- seusSPRING %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p2 <- seusSPRING %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - test <- seusSPRING %>% - select(stratum, year) %>% - distinct() %>% - group_by(stratum) %>% - summarise(count = n()) %>% - filter(count >= 29) # strata sampled all but a few year!! - - # how many rows will be lost if only stratum trawled ever year are kept? - test2 <- seusSPRING %>% - filter(stratum %in% test$stratum) - nrow(seusSPRING) - nrow(test2) - # percent that will be lost - print((nrow(seusSPRING) - nrow(test2))/nrow(seusSPRING)) - # 6% are removed - - seusSPRING_fltr <- seusSPRING %>% - filter(stratum %in% test$stratum) - - p3 <- seusSPRING_fltr %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p4 <- seusSPRING_fltr %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - if (HQ_PLOTS == TRUE){ - temp <- grid.arrange(p1, p2, p3, p4, nrow = 2) - ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "seusSPR_hq_dat_removed.png")) - rm(temp) - } - rm(test, p1, p2, p3, p4) -} - -# SEUS summer ==== -#Separate the summer season and convert to dataframe -seusSUMMER <- seus %>% - filter(SEASON == "summer") %>% - select(-SEASON) %>% - mutate(region = "Southeast US Summer") - -if (HQ_DATA_ONLY == TRUE){ - # look at the graph and make sure decisions to keep or eliminate data make sense - - p1 <- seusSUMMER %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p2 <- seusSUMMER %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - #2021 was poorly sampled, so should be removed from data - seusSUMMER_fltr <- seusSUMMER %>% - filter(year!=2021) - - p3 <- seusSUMMER_fltr %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p4 <- seusSUMMER_fltr %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - if (HQ_PLOTS == TRUE){ - temp <- grid.arrange(p1, p2, p3, p4, nrow = 2) - ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "seusSUM_hq_dat_removed.png")) - rm(temp) - } - rm(p1, p2, p3, p4) -} - - -# SEUS fall ==== -seusFALL <- seus %>% - filter(SEASON == "fall") %>% - select(-SEASON) %>% - mutate(region = "Southeast US Fall") - -# how many rows will be lost if only stratum trawled ever year are kept? -if (HQ_DATA_ONLY == TRUE){ - - p1 <- seusFALL %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p2 <- seusFALL %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - test <- seusFALL %>% - #filter(year != 2018, year != 2019) %>% - select(stratum, year) %>% - distinct() %>% - group_by(stratum) %>% - summarise(count = n()) %>% - filter(count >= 31) - - test2 <- seusFALL %>% - #filter(year != 2018, year != 2019) %>% - filter(stratum %in% test$stratum) - nrow(seusFALL) - nrow(test2) - # percent that will be lost - print((nrow(seusFALL) - nrow(test2))/nrow(seusFALL)) - # 5.1% are removed - - seusFALL_fltr <- seusFALL %>% - #filter(year != 2018, year != 2019) %>% - filter(stratum %in% test$stratum) - - # plot the results after editing - p3 <- seusFALL_fltr %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - - p4 <- seusFALL_fltr %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - - if (HQ_PLOTS == TRUE){ - temp <- grid.arrange(p1, p2, p3, p4, nrow = 2) - ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "seusFALL_hq_dat_removed.png")) - rm(temp) - } -} -#clean up -rm(test, test2, p1, p2, p3, p4) - -rm(seus_catch, seus_haul, seus_strata, end, start, meanwt, misswt, biomass, problems, change, seus) - -# # COMPILE CANADIAN REGIONS ================================================== -# # Compile Maritimes ========================================================= -# spp_files <- as.list(dir(pattern = "_SPP", path = "data", full.names = T)) -# mar_spp <- spp_files %>% -# purrr::map_dfr(~ readr::read_csv(.x, col_types = cols( -# SPEC = col_character() -# ))) -# -# mar_spp <- mar_spp %>% -# rename(spp = SPEC, -# SPEC = CODE) %>% -# distinct() -# -# mission_files <- as.list(dir(pattern = "_MISSION", path = "data", full.names = T)) -# mar_missions <- mission_files %>% -# purrr::map_dfr(~ readr::read_csv(.x, col_types = cols( -# .default = col_double(), -# MISSION = col_character(), -# VESEL = col_character(), -# SEASON = col_character() -# ))) -# -# info_files <- as.list(dir(pattern = "_INF", path = "data", full.names = T)) -# mar_info <- info_files %>% -# purrr::map_dfr(~ readr::read_csv(.x, col_types = cols( -# .default = col_double(), -# MISSION = col_character(), -# SDATE = col_character(), -# GEARDESC = col_character(), -# STRAT = col_character() -# ))) -# -# catch_files <- as.list(dir(pattern = "_CATCH", path = "data", full.names = T)) -# mar_catch <- catch_files %>% -# purrr::map_dfr(~ readr::read_csv(.x, col_types = cols( -# .default = col_double(), -# MISSION = col_character() -# ))) -# -# mar <- left_join(mar_catch, mar_missions, by = "MISSION") -# -# mar <- mar %>% -# # Create a unique haulid -# mutate( -# haulid = paste(formatC(MISSION, width=3, flag=0), formatC(SETNO, width=3, flag=0))) -# -# mar_info <- mar_info %>% -# # Create a unique haulid -# mutate( -# haulid = paste(formatC(MISSION, width=3, flag=0), formatC(SETNO, width=3, flag=0))) -# -# drops <- c("MISSION","SETNO") -# mar_info <- mar_info[ , !(names(mar_info) %in% drops)] -# -# mar <- left_join(mar, mar_info, by = "haulid") -# mar <- left_join(mar, mar_spp, by = "SPEC") -# mar$region <- "Maritimes" -# -# names(mar) <- tolower(names(mar)) -# -# -# mar <- mar %>% -# # convert mission to haul_id -# rename(wtcpue = totwgt, -# lat = slat, -# lon = slong, -# stratum = strat) -# -# # calculate stratum area for each stratum -# mar <- mar %>% -# group_by(stratum) %>% -# filter(stratum != 'NA') %>% -# mutate(stratumarea = calcarea(lon, lat)) %>% -# ungroup() -# -# -# # Does the spp column contain any eggs or non-organism notes? #many eggs and unidentified names that need to be removed -# # test <- mar %>% -# # select(spp) %>% -# # filter(!is.na(spp)) %>% -# # distinct() %>% -# # mutate(spp = as.factor(spp)) %>% -# # filter(grepl("UNIDENTIFIED", spp) & grepl("", spp)) -# # #filter(grepl("EGG", spp) & grepl("", spp)) -# # stopifnot(nrow(test)==0) -# -# # combine the wtcpue for each species by haul -# mar <- mar %>% -# # remove unidentified spp and non-species -# filter(spp != "" | !is.na(spp), -# !grepl("EGG", spp), -# !grepl("UNIDENTIFIED", spp), -# !grepl("PURSE", spp), -# !grepl("UNID. FISH", spp), -# !grepl("UNID FISH AND INVERTEBRATES", spp), -# !grepl("UNID REMAINS,DIGESTED", spp), -# !grepl("UNID FISH AND REMAINS", spp), -# !grepl("CALAPPA MEGALOPS",spp), -# !grepl("MARINE INVERTEBRATA", spp), -# !grepl("EMPTY", spp), -# !grepl("SHELLS", spp), -# !grepl("RESERVED", spp), -# !grepl("SAND TUBE", spp), -# !grepl("SHARK", spp), -# !grepl("SHRIMP-LIKE", spp), -# !grepl("UNKNOWN FISH",spp), -# !grepl("^MUD$", spp), -# !grepl("WATER", spp), -# !grepl("DEBRIS", spp), -# !grepl("FISH REMAINS", spp), -# !grepl("POLYCHAETE REMAINS", spp), -# !grepl("CRUSTACEA LARVAE", spp), -# !grepl("FOREIGN ARTICLES,GARBAGE", spp), -# !grepl("NO LONGER USED - PHAKELLIA SPP.", spp), -# !grepl("PARASITES,ROUND WORMS", spp), -# !grepl("POLYCHAETA C.,LARGE", spp), -# !grepl("POLYCHAETA C.,SMALL", spp), -# !grepl("SEA CORALS", spp), -# !grepl("STONES AND ROCKS", spp), -# !grepl("CRAB", spp)) %>% -# group_by(haulid, stratum, stratumarea, year, season, lat, lon, depth, spp, region) %>% -# summarise(wtcpue = sumna(wtcpue)) %>% -# ungroup() %>% -# # remove extra columns -# select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue, season) -# -# rm(mar_catch, mar_info, mar_missions, mar_spp, mission_files, info_files, spp_files, catch_files) -# -# #mar$spp <- firstup(mar$spp) -# -# # Maritimes Fall ==== -# marFall <- mar %>% -# ungroup() %>% -# filter(season == "FALL") %>% -# select(-season) %>% -# mutate(region = "Maritimes Fall") -# -# # # plot the strata by year -# p1 <- marFall %>% -# select(stratum, year) %>% -# ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + -# geom_jitter() -# p2 <- marFall %>% -# select(lat, lon) %>% -# ggplot(aes(x = lon, y = lat)) + -# geom_jitter() -# # -# -# # Maritimes Spring ==== -# marSpring <- mar %>% -# ungroup() %>% -# filter(season == "SPRING") %>% -# select(-season) %>% -# mutate(region = "Maritimes Spring") -# -# # # plot the strata by year -# p1 <- marSpring %>% -# select(stratum, year) %>% -# ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + -# geom_jitter() -# p2 <- marSpring %>% -# select(lat, lon) %>% -# ggplot(aes(x = lon, y = lat)) + -# geom_jitter() -# # -# # grid.arrange(p1, p2, nrow = 2) -# -# # Maritimes Summer ==== -# marSummer <- mar %>% -# ungroup() %>% -# filter(season == "SUMMER") %>% -# select(-season) %>% -# mutate(region = "Maritimes Summer") -# -# # # plot the strata by year -# p1 <- marSummer %>% -# select(stratum, year) %>% -# ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + -# geom_jitter() -# p2 <- marSummer %>% -# select(lat, lon) %>% -# ggplot(aes(x = lon, y = lat)) + -# geom_jitter() -# # -# # grid.arrange(p1, p2, nrow = 2) -# -# test <- mar %>% -# filter(region != "4VSW") -# # -# # # plot the strata by year without 4VSW -# p1 <- test %>% -# select(stratum, year) %>% -# ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + -# geom_jitter() -# p2 <- mar %>% -# select(lat, lon) %>% -# ggplot(aes(x = lon, y = lat)) + -# geom_jitter() -# # -# # grid.arrange(p1, p2, nrow = 2) -# -# # ONLY consistent methodology and coverage occurred in Summer, so will only use the SUMMER data for furthur analysis -# -# if (HQ_DATA_ONLY == TRUE){ -# # look at the graph and make sure decisions to keep or eliminate data make sense -# -# # plot the strata by year -# p1 <- marSummer %>% -# select(stratum, year) %>% -# ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + -# geom_jitter() -# p2 <- marSummer %>% -# select(lat, lon) %>% -# ggplot(aes(x = lon, y = lat)) + -# geom_jitter() -# -# # find strata sampled every year -# annual_strata <- marSummer %>% -# filter(year != 2018) %>% -# select(stratum, year) %>% -# distinct() %>% -# group_by(stratum) %>% -# summarise(count = n()) %>% -# filter(count >= 25) -# -# # find strata sampled every year -# annual_strata_old <- marSummer %>% -# select(stratum, year) %>% -# distinct() %>% -# group_by(stratum) %>% -# summarise(count = n()) -# -# sum(length(unique(annual_strata_old$count)) - length(unique(annual_strata$count))) -# # how many rows will be lost if only stratum trawled ever year are kept? -# test <- marSummer %>% -# filter(year!= 2018) %>% -# filter(stratum %in% annual_strata$stratum) -# nrow(marSummer) - nrow(test) -# # percent that will be lost -# print((nrow(marSummer) - nrow(test))/nrow(marSummer)) -# # 7.6% are removed -# -# mar_fltr <- marSummer %>% -# filter(year != 2018) %>% -# filter(stratum %in% annual_strata$stratum) -# -# p3 <- mar_fltr %>% -# select(stratum, year) %>% -# ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + -# geom_jitter() -# -# p4 <- mar_fltr %>% -# select(lat, lon) %>% -# ggplot(aes(x = lon, y = lat)) + -# geom_jitter() -# -# if (HQ_PLOTS == TRUE){ -# temp <- grid.arrange(p1, p2, p3, p4, nrow = 2) -# ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "mar_hq_dat_removed.png")) -# } -# } -# -# -# # Compile Canadian Pacific --------------------------------------------------- -# print("Compile CPAC") -# -# #Queen Charlotte Sound -# -# files <- as.list(dir(pattern = "QCS", path = "data", full.names = T)) -# -# -# QCS_catch <- read_csv(here::here("data_processing_rcode/data", "QCS_catch.csv"), col_types = cols( -# Survey.Year = col_integer(), -# Trip.identifier = col_integer(), -# Set.number = col_integer(), -# ITIS.TSN = col_integer(), -# Species.code = col_character(), -# Scientific.name = col_character(), -# English.common.name = col_character(), -# French.common.name = col_character(), -# LSID = col_character(), -# Catch.weight..kg. = col_double(), -# Catch.count..pieces. = col_integer() -# )) %>% -# select(Trip.identifier, Set.number,Survey.Year, ITIS.TSN, Species.code, Scientific.name, English.common.name, Catch.weight..kg.) -# -# QCS_effort <- read_csv(here::here("data_processing_rcode/data", "QCS_effort.csv"), col_types = -# cols( -# Survey.Year = col_integer(), -# Trip.identifier = col_integer(), -# Vessel.name = col_character(), -# Trip.start.date = col_character(), -# Trip.end.date = col_character(), -# GMA = col_character(), -# PFMA = col_character(), -# Set.number = col_integer(), -# Set.date = col_character(), -# Start.latitude = col_double(), -# Start.longitude = col_double(), -# End.latitude = col_double(), -# End.longitude = col_double(), -# Bottom.depth..m. = col_double(), -# Tow.duration..min. = col_integer(), -# Distance.towed..m. = col_double(), -# Vessel.speed..m.min. = col_double(), -# Trawl.door.spread..m. = col_double(), -# Trawl.mouth.opening.height..m. = col_double() -# )) %>% -# select(Trip.identifier, Set.number,Survey.Year,Trip.start.date,Trip.end.date, GMA, PFMA,Set.date, Start.latitude,Start.longitude, End.latitude, End.longitude, Bottom.depth..m., Tow.duration..min.,Distance.towed..m., Trawl.door.spread..m., Trawl.mouth.opening.height..m. ) -# -# QCS <- left_join(QCS_catch, QCS_effort, by = c("Trip.identifier", "Set.number","Survey.Year")) -# -# -# -# QCS <- QCS %>% -# # Create a unique haulid -# mutate( -# haulid = paste(formatC(Trip.identifier, width=3, flag=0), formatC(Set.number, width=3, flag=0), sep= "-"), -# # Add "strata" (define by lat, lon and depth bands) where needed # degree bins # 100 m bins # no need to use lon grids on west coast (so narrow) -# stratum = paste(floor(Start.latitude), floor(Start.longitude),floor(Bottom.depth..m./100)*100, sep= "-"), -# # catch weight (kg.) per tow -# wtcpue = (Catch.weight..kg.)#/(Distance.towed..m.*Trawl.door.spread..m.) -# ) -# -# -# # Calculate stratum area where needed (use convex hull approach) -# QCS_strats <- QCS %>% -# group_by(stratum) %>% -# summarise(stratumarea = calcarea(Start.longitude, Start.latitude)) -# -# QCS <- left_join(QCS, QCS_strats, by = "stratum") -# -# QCS <- QCS %>% -# rename( -# lat = Start.latitude, -# lon = Start.longitude, -# depth = Bottom.depth..m., -# spp = Scientific.name, -# year = Survey.Year -# ) %>% -# # remove unidentified spp and non-species -# filter(spp != "" | !is.na(spp), -# !grepl("EGG", spp), -# !grepl("UNIDENTIFIED", spp), -# !grepl("PURSE", spp), -# !grepl("UNID. FISH", spp), -# !grepl("UNID FISH AND INVERTEBRATES", spp), -# !grepl("UNID REMAINS,DIGESTED", spp), -# !grepl("UNID FISH AND REMAINS", spp), -# !grepl("CALAPPA MEGALOPS",spp), -# !grepl("MARINE INVERTEBRATA", spp), -# !grepl("EMPTY", spp), -# !grepl("SHELLS", spp), -# !grepl("RESERVED", spp), -# !grepl("SAND TUBE", spp), -# !grepl("SHARK", spp), -# !grepl("SHRIMP-LIKE", spp), -# !grepl("UNKNOWN FISH",spp), -# !grepl("^MUD$", spp), -# !grepl("WATER", spp), -# !grepl("DEBRIS", spp), -# !grepl("FISH REMAINS", spp), -# !grepl("POLYCHAETE REMAINS", spp)) %>% -# # adjust spp names -# mutate(spp = ifelse(grepl("LEPIDOPSETTA", spp), "LEPIDOPSETTA SP.", spp), -# spp = ifelse(grepl("BATHYRAJA", spp), 'BATHYRAJA SP.', spp), -# spp = ifelse(grepl("SQUALUS", spp), 'SQUALUS SUCKLEYI', spp)) %>% -# group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% -# summarise(wtcpue = sumna(wtcpue)) %>% -# # add region column -# mutate(region = "Queen Charlotte Sound") %>% -# select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% -# ungroup() -# -# -# # combine the wtcpue for each species by haul -# QCS <- QCS %>% -# group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% -# summarise(wtcpue = sumna(wtcpue)) %>% -# ungroup() %>% -# # remove extra columns -# select(haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) -# -# #test = setcolorder(scot, c('region', 'haulid', 'year', 'lat', 'lon', 'stratum', 'stratumarea', 'depth', 'spp', 'wtcpue')) -# test <- QCS %>% -# filter(stratumarea > 0) -# -# -# #West Coast Vancouver Island -# -# WCV_catch <- read_csv(here::here("data_processing_rcode/data", "WCV_catch.csv"), col_types = cols( -# Survey.Year = col_integer(), -# Trip.identifier = col_integer(), -# Set.number = col_integer(), -# ITIS.TSN = col_integer(), -# Species.code = col_character(), -# Scientific.name = col_character(), -# English.common.name = col_character(), -# French.common.name = col_character(), -# LSID = col_character(), -# Catch.weight..kg. = col_double(), -# Catch.count..pieces. = col_integer() -# )) %>% -# select(Trip.identifier, Set.number,Survey.Year, ITIS.TSN, Species.code, Scientific.name, English.common.name, Catch.weight..kg.) -# -# WCV_effort <- read_csv(here::here("data_processing_rcode/data", "WCV_effort.csv"), col_types = -# cols( -# Survey.Year = col_integer(), -# Trip.identifier = col_integer(), -# Vessel.name = col_character(), -# Trip.start.date = col_character(), -# Trip.end.date = col_character(), -# GMA = col_character(), -# PFMA = col_character(), -# Set.number = col_integer(), -# Set.date = col_character(), -# Start.latitude = col_double(), -# Start.longitude = col_double(), -# End.latitude = col_double(), -# End.longitude = col_double(), -# Bottom.depth..m. = col_double(), -# Tow.duration..min. = col_integer(), -# Distance.towed..m. = col_double(), -# Vessel.speed..m.min. = col_double(), -# Trawl.door.spread..m. = col_double(), -# Trawl.mouth.opening.height..m. = col_double() -# )) %>% -# select(Trip.identifier, Set.number,Survey.Year,Trip.start.date,Trip.end.date, GMA, PFMA,Set.date, Start.latitude,Start.longitude, End.latitude, End.longitude, Bottom.depth..m., Tow.duration..min.,Distance.towed..m., Trawl.door.spread..m., Trawl.mouth.opening.height..m. ) -# -# -# WCV <- left_join(WCV_catch, WCV_effort, by = c("Trip.identifier", "Set.number","Survey.Year")) -# -# -# -# WCV <- WCV %>% -# # Create a unique haulid -# mutate( -# haulid = paste(formatC(Trip.identifier, width=3, flag=0), formatC(Set.number, width=3, flag=0), sep= "-"), -# # Add "strata" (define by lat, lon and depth bands) where needed # degree bins # 100 m bins # no need to use lon grids on west coast (so narrow) -# stratum = paste(floor(Start.latitude), floor(Start.longitude),floor(Bottom.depth..m./100)*100, sep= "-"), -# # catch weight (kg.) per tow -# wtcpue = (Catch.weight..kg.)#/(Distance.towed..m.*Trawl.door.spread..m.) -# ) -# -# # Calculate stratum area where needed (use convex hull approach) -# WCV_strats <- WCV %>% -# group_by(stratum) %>% -# summarise(stratumarea = calcarea(Start.longitude, Start.latitude)) -# -# WCV <- left_join(WCV, WCV_strats, by = "stratum") -# -# WCV <- WCV %>% -# rename( -# lat = Start.latitude, -# lon = Start.longitude, -# depth = Bottom.depth..m., -# spp = Scientific.name, -# year = Survey.Year -# ) %>% -# # remove unidentified spp and non-species -# filter(spp != "" | !is.na(spp), -# !grepl("EGG", spp), -# !grepl("UNIDENTIFIED", spp), -# !grepl("PURSE", spp), -# !grepl("UNID. FISH", spp), -# !grepl("UNID FISH AND INVERTEBRATES", spp), -# !grepl("UNID REMAINS,DIGESTED", spp), -# !grepl("UNID FISH AND REMAINS", spp), -# !grepl("CALAPPA MEGALOPS",spp), -# !grepl("MARINE INVERTEBRATA (NS)", spp), -# !grepl("EMPTY", spp), -# !grepl("SHELLS", spp), -# !grepl("RESERVED", spp), -# !grepl("SAND TUBE", spp), -# !grepl("SHARK (NS)", spp), -# !grepl("SHRIMP-LIKE", spp), -# !grepl("UNKNOWN FISH",spp), -# !grepl("^MUD$", spp), -# !grepl("WATER", spp), -# !grepl("DEBRIS", spp), -# !grepl("FISH REMAINS", spp), -# !grepl("POLYCHAETE REMAINS", spp)) %>% -# # adjust spp names -# mutate(spp = ifelse(grepl("LEPIDOPSETTA", spp), "LEPIDOPSETTA SP.", spp), -# spp = ifelse(grepl("BATHYRAJA", spp), 'BATHYRAJA SP.', spp), -# spp = ifelse(grepl("SQUALUS", spp), 'SQUALUS SUCKLEYI', spp)) %>% -# group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% -# summarise(wtcpue = sumna(wtcpue)) %>% -# # add region column -# mutate(region = "West Coast Vancouver Island") %>% -# select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% -# ungroup() -# -# -# # combine the wtcpue for each species by haul -# WCV <- WCV %>% -# group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% -# summarise(wtcpue = sumna(wtcpue)) %>% -# ungroup() %>% -# # remove extra columns -# select(haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) -# -# #test = setcolorder(scot, c('region', 'haulid', 'year', 'lat', 'lon', 'stratum', 'stratumarea', 'depth', 'spp', 'wtcpue')) -# test <- WCV %>% -# filter(stratumarea > 0) -# -# -# #West Coast Haida Guai -# -# WCHG_catch <- read_csv(here::here("data_processing_rcode/data", "WCHG_catch.csv"), col_types = cols( -# Survey.Year = col_integer(), -# Trip.identifier = col_integer(), -# Set.number = col_integer(), -# ITIS.TSN = col_integer(), -# Species.code = col_character(), -# Scientific.name = col_character(), -# English.common.name = col_character(), -# French.common.name = col_character(), -# LSID = col_character(), -# Catch.weight..kg. = col_double(), -# Catch.count..pieces. = col_integer() -# )) %>% -# select(Trip.identifier, Set.number,Survey.Year, ITIS.TSN, Species.code, Scientific.name, English.common.name, Catch.weight..kg.) -# -# WCHG_effort <- read_csv(here::here("data_processing_rcode/data", "WCHG_effort.csv"), col_types = -# cols( -# Survey.Year = col_integer(), -# Trip.identifier = col_integer(), -# Vessel.name = col_character(), -# Trip.start.date = col_character(), -# Trip.end.date = col_character(), -# GMA = col_character(), -# PFMA = col_character(), -# Set.number = col_integer(), -# Set.date = col_character(), -# Start.latitude = col_double(), -# Start.longitude = col_double(), -# End.latitude = col_double(), -# End.longitude = col_double(), -# Bottom.depth..m. = col_double(), -# Tow.duration..min. = col_integer(), -# Distance.towed..m. = col_double(), -# Vessel.speed..m.min. = col_double(), -# Trawl.door.spread..m. = col_double(), -# Trawl.mouth.opening.height..m. = col_double() -# )) %>% -# select(Trip.identifier, Set.number,Survey.Year,Trip.start.date,Trip.end.date, GMA, PFMA,Set.date, Start.latitude,Start.longitude, End.latitude, End.longitude, Bottom.depth..m., Tow.duration..min.,Distance.towed..m., Trawl.door.spread..m., Trawl.mouth.opening.height..m. ) -# -# -# WCHG <- left_join(WCHG_catch, WCHG_effort, by = c("Trip.identifier", "Set.number","Survey.Year")) -# -# -# -# WCHG <- WCHG %>% -# # Create a unique haulid -# mutate( -# haulid = paste(formatC(Trip.identifier, width=3, flag=0), formatC(Set.number, width=3, flag=0), sep= "-"), -# # Add "strata" (define by lat, lon and depth bands) where needed # degree bins # 100 m bins # no need to use lon grids on west coast (so narrow) -# stratum = paste(floor(Start.latitude), floor(Start.longitude),floor(Bottom.depth..m./100)*100, sep= "-"), -# # catch weight (kg.) per tow -# wtcpue = (Catch.weight..kg.)#/(Distance.towed..m.*Trawl.door.spread..m.) -# ) -# -# # Calculate stratum area where needed (use convex hull approach) -# WCHG_strats <- WCHG %>% -# group_by(stratum) %>% -# summarise(stratumarea = calcarea(Start.longitude, Start.latitude)) -# -# WCHG <- left_join(WCHG, WCHG_strats, by = "stratum") -# -# WCHG <- WCHG %>% -# rename( -# lat = Start.latitude, -# lon = Start.longitude, -# depth = Bottom.depth..m., -# spp = Scientific.name, -# year = Survey.Year -# ) %>% -# # remove unidentified spp and non-species -# filter(spp != "" | !is.na(spp), -# !grepl("EGG", spp), -# !grepl("UNIDENTIFIED", spp), -# !grepl("PURSE", spp), -# !grepl("UNID. FISH", spp), -# !grepl("UNID FISH AND INVERTEBRATES", spp), -# !grepl("UNID REMAINS,DIGESTED", spp), -# !grepl("UNID FISH AND REMAINS", spp), -# !grepl("CALAPPA MEGALOPS",spp), -# !grepl("MARINE INVERTEBRATA (NS)", spp), -# !grepl("EMPTY", spp), -# !grepl("SHELLS", spp), -# !grepl("RESERVED", spp), -# !grepl("SAND TUBE", spp), -# !grepl("SHARK (NS)", spp), -# !grepl("SHRIMP-LIKE", spp), -# !grepl("UNKNOWN FISH",spp), -# !grepl("^MUD$", spp), -# !grepl("WATER", spp), -# !grepl("DEBRIS", spp), -# !grepl("FISH REMAINS", spp), -# !grepl("POLYCHAETE REMAINS", spp)) %>% -# # adjust spp names -# mutate(spp = ifelse(grepl("LEPIDOPSETTA", spp), "LEPIDOPSETTA SP.", spp), -# spp = ifelse(grepl("BATHYRAJA", spp), 'BATHYRAJA SP.', spp), -# spp = ifelse(grepl("SQUALUS", spp), 'SQUALUS SUCKLEYI', spp)) %>% -# group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% -# summarise(wtcpue = sumna(wtcpue)) %>% -# # add region column -# mutate(region = "West Coast Vancouver Island") %>% -# select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% -# ungroup() -# -# # combine the wtcpue for each species by haul -# WCHG <- WCHG %>% -# group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% -# summarise(wtcpue = sumna(wtcpue)) %>% -# ungroup() %>% -# # remove extra columns -# select(haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) -# -# -# #Hecate Strait -# -# HS_catch <- read_csv(here::here("data_processing_rcode/data", "HS_catch.csv"), col_types = cols( -# Survey.Year = col_integer(), -# Trip.identifier = col_integer(), -# Set.number = col_integer(), -# ITIS.TSN = col_integer(), -# Species.code = col_character(), -# Scientific.name = col_character(), -# English.common.name = col_character(), -# French.common.name = col_character(), -# LSID = col_character(), -# Catch.weight..kg. = col_double(), -# Catch.count..pieces. = col_integer() -# )) %>% -# select(Trip.identifier, Set.number,Survey.Year, ITIS.TSN, Species.code, Scientific.name, English.common.name, Catch.weight..kg.) -# -# HS_effort <- read_csv(here::here("data_processing_rcode/data", "HS_effort.csv"), col_types = -# cols( -# Survey.Year = col_integer(), -# Trip.identifier = col_integer(), -# Vessel.name = col_character(), -# Trip.start.date = col_character(), -# Trip.end.date = col_character(), -# GMA = col_character(), -# PFMA = col_character(), -# Set.number = col_integer(), -# Set.date = col_character(), -# Start.latitude = col_double(), -# Start.longitude = col_double(), -# End.latitude = col_double(), -# End.longitude = col_double(), -# Bottom.depth..m. = col_double(), -# Tow.duration..min. = col_integer(), -# Distance.towed..m. = col_double(), -# Vessel.speed..m.min. = col_double(), -# Trawl.door.spread..m. = col_double(), -# Trawl.mouth.opening.height..m. = col_double() -# )) %>% -# select(Trip.identifier, Set.number,Survey.Year,Trip.start.date,Trip.end.date, GMA, PFMA,Set.date, Start.latitude,Start.longitude, End.latitude, End.longitude, Bottom.depth..m., Tow.duration..min.,Distance.towed..m., Trawl.door.spread..m., Trawl.mouth.opening.height..m. ) -# -# -# HS <- left_join(HS_catch, HS_effort, by = c("Trip.identifier", "Set.number","Survey.Year")) -# -# HS <- HS %>% -# # Create a unique haulid -# mutate( -# haulid = paste(formatC(Trip.identifier, width=3, flag=0), formatC(Set.number, width=3, flag=0), sep= "-"), -# # Add "strata" (define by lat, lon and depth bands) where needed # degree bins # 100 m bins # no need to use lon grids on west coast (so narrow) -# stratum = paste(floor(Start.latitude), floor(Start.longitude),floor(Bottom.depth..m./100)*100, sep= "-"), -# # catch weight (kg.) per tow -# wtcpue = (Catch.weight..kg.)#/(Distance.towed..m.*Trawl.door.spread..m.) -# ) -# -# # Calculate stratum area where needed (use convex hull approach) -# HS_strats <- HS %>% -# group_by(stratum) %>% -# summarise(stratumarea = calcarea(Start.longitude,Start.latitude)) -# -# HS <- left_join(HS, HS_strats, by = "stratum") -# -# HS <- HS %>% -# rename( -# lat = Start.latitude, -# lon = Start.longitude, -# depth = Bottom.depth..m., -# spp = Scientific.name, -# year = Survey.Year -# ) %>% -# # remove unidentified spp and non-species -# filter(spp != "" | !is.na(spp), -# !grepl("EGG", spp), -# !grepl("UNIDENTIFIED", spp), -# !grepl("PURSE", spp), -# !grepl("UNID. FISH", spp), -# !grepl("UNID FISH AND INVERTEBRATES", spp), -# !grepl("UNID REMAINS,DIGESTED", spp), -# !grepl("UNID FISH AND REMAINS", spp), -# !grepl("CALAPPA MEGALOPS",spp), -# !grepl("MARINE INVERTEBRATA (NS)", spp), -# !grepl("EMPTY", spp), -# !grepl("SHELLS", spp), -# !grepl("RESERVED", spp), -# !grepl("SAND TUBE", spp), -# !grepl("SHARK (NS)", spp), -# !grepl("SHRIMP-LIKE", spp), -# !grepl("UNKNOWN FISH",spp), -# !grepl("^MUD$", spp), -# !grepl("WATER", spp), -# !grepl("DEBRIS", spp), -# !grepl("FISH REMAINS", spp), -# !grepl("POLYCHAETE REMAINS", spp)) %>% -# # adjust spp names -# mutate(spp = ifelse(grepl("LEPIDOPSETTA", spp), "LEPIDOPSETTA SP.", spp), -# spp = ifelse(grepl("BATHYRAJA", spp), 'BATHYRAJA SP.', spp), -# spp = ifelse(grepl("SQUALUS", spp), 'SQUALUS SUCKLEYI', spp)) %>% -# group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% -# summarise(wtcpue = sumna(wtcpue)) %>% -# # add region column -# mutate(region = "Hecate Strait") %>% -# select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% -# ungroup() -# -# -# # combine the wtcpue for each species by haul -# HS <- HS %>% -# group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% -# summarise(wtcpue = sumna(wtcpue)) %>% -# ungroup() %>% -# # remove extra columns -# select(haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) -# -# -# #Strait of Georgia -# -# SOG_catch <- read_csv(here::here("data_processing_rcode/data", "SOG_catch.csv"), col_types = cols( -# Survey.Year = col_integer(), -# Trip.identifier = col_integer(), -# Set.number = col_integer(), -# ITIS.TSN = col_integer(), -# Species.code = col_character(), -# Scientific.name = col_character(), -# English.common.name = col_character(), -# French.common.name = col_character(), -# LSID = col_character(), -# Catch.weight..kg. = col_double(), -# Catch.count..pieces. = col_integer() -# )) %>% -# select(Trip.identifier, Set.number,Survey.Year, ITIS.TSN, Species.code, Scientific.name, English.common.name, Catch.weight..kg.) -# -# SOG_effort <- read_csv(here::here("data_processing_rcode/data", "SOG_effort.csv"), col_types = -# cols( -# Survey.Year = col_integer(), -# Trip.identifier = col_integer(), -# Vessel.name = col_character(), -# Trip.start.date = col_character(), -# Trip.end.date = col_character(), -# GMA = col_character(), -# PFMA = col_character(), -# Set.number = col_integer(), -# Set.date = col_character(), -# Start.latitude = col_double(), -# Start.longitude = col_double(), -# End.latitude = col_double(), -# End.longitude = col_double(), -# Bottom.depth..m. = col_double(), -# Tow.duration..min. = col_integer(), -# Distance.towed..m. = col_double(), -# Vessel.speed..m.min. = col_double(), -# Trawl.door.spread..m. = col_double(), -# Trawl.mouth.opening.height..m. = col_double() -# )) %>% -# select(Trip.identifier, Set.number,Survey.Year,Trip.start.date,Trip.end.date, GMA, PFMA,Set.date, Start.latitude,Start.longitude, End.latitude, End.longitude, Bottom.depth..m., Tow.duration..min.,Distance.towed..m., Trawl.door.spread..m., Trawl.mouth.opening.height..m. ) -# -# -# SOG <- left_join(SOG_catch, SOG_effort, by = c("Trip.identifier", "Set.number","Survey.Year")) -# -# -# -# SOG <- SOG %>% -# # Create a unique haulid -# mutate( -# haulid = paste(formatC(Trip.identifier, width=3, flag=0), formatC(Set.number, width=3, flag=0), sep= "-"), -# # Add "strata" (define by lat, lon and depth bands) where needed # degree bins # 100 m bins # no need to use lon grids on west coast (so narrow) -# stratum = paste(floor(Start.latitude), floor(Start.longitude),floor(Bottom.depth..m./100)*100, sep= "-"), -# # catch weight (kg.) per tow -# wtcpue = (Catch.weight..kg.)#/(Distance.towed..m.*Trawl.door.spread..m.) -# ) -# -# # Calculate stratum area where needed (use convex hull approach) -# SOG_strats <- SOG %>% -# group_by(stratum) %>% -# summarise(stratumarea = calcarea(Start.longitude, Start.latitude)) -# -# SOG <- left_join(SOG, SOG_strats, by = "stratum") -# -# SOG <- SOG %>% -# rename( -# lat = Start.latitude, -# lon = Start.longitude, -# depth = Bottom.depth..m., -# spp = Scientific.name, -# year = Survey.Year -# ) %>% -# # remove unidentified spp and non-species -# filter(spp != "" | !is.na(spp), -# !grepl("EGG", spp), -# !grepl("UNIDENTIFIED", spp), -# !grepl("PURSE", spp), -# !grepl("UNID. FISH", spp), -# !grepl("UNID FISH AND INVERTEBRATES", spp), -# !grepl("UNID REMAINS,DIGESTED", spp), -# !grepl("UNID FISH AND REMAINS", spp), -# !grepl("CALAPPA MEGALOPS",spp), -# !grepl("MARINE INVERTEBRATA (NS)", spp), -# !grepl("EMPTY", spp), -# !grepl("SHELLS", spp), -# !grepl("RESERVED", spp), -# !grepl("SAND TUBE", spp), -# !grepl("SHARK (NS)", spp), -# !grepl("SHRIMP-LIKE", spp), -# !grepl("UNKNOWN FISH",spp), -# !grepl("^MUD$", spp), -# !grepl("WATER", spp), -# !grepl("DEBRIS", spp), -# !grepl("FISH REMAINS", spp), -# !grepl("POLYCHAETE REMAINS", spp)) %>% -# # adjust spp names -# mutate(spp = ifelse(grepl("LEPIDOPSETTA", spp), "LEPIDOPSETTA SP.", spp), -# spp = ifelse(grepl("BATHYRAJA", spp), 'BATHYRAJA SP.', spp), -# spp = ifelse(grepl("SQUALUS", spp), 'SQUALUS SUCKLEYI', spp)) %>% -# group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% -# summarise(wtcpue = sumna(wtcpue)) %>% -# # add region column -# mutate(region = "Strait of Georgia") %>% -# select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% -# ungroup() -# -# -# # combine the wtcpue for each species by haul -# SOG <- SOG %>% -# group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% -# summarise(wtcpue = sumna(wtcpue)) %>% -# ungroup() %>% -# # remove extra columns -# select(haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) -# -# -# #combine canadian pacific -# CPAC <- rbind(QCS, WCV, WCHG, HS, SOG) -# -# #test = setcolorder(scot, c('region', 'haulid', 'year', 'lat', 'lon', 'stratum', 'stratumarea', 'depth', 'spp', 'wtcpue')) -# test <- CPAC %>% -# filter(stratumarea > 0) -# -# #CPAC$year <- as.integer(CPAC$year) -# -# -# # how many rows will be lost if only stratum trawled ever year are kept? -# test2 <- CPAC %>% -# filter(stratum %in% test$stratum) -# nrow(CPAC) - nrow(test2) -# # percent that will be lost -# print((nrow(CPAC) - nrow(test2))/nrow(CPAC)) -# # 0.9% of rows are removed -# test2 <- CPAC %>% -# filter(stratum %in% test$stratum) -# -# -# CPAC$region <- 'Canadian Pacific' -# -# CPAC <- CPAC %>% -# select(region, everything()) -# -# CPAC$spp <- firstup(CPAC$spp) -# -# -# if (HQ_DATA_ONLY == TRUE){ -# # look at the graph and make sure decisions to keep or eliminate data make sense -# -# # plot the strata by year -# p1 <- CPAC %>% -# select(stratum, year) %>% -# ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + -# geom_jitter() -# p2 <- CPAC %>% -# select(lat, lon) %>% -# ggplot(aes(x = lon, y = lat)) + -# geom_jitter() -# -# CPAC_fltr <- CPAC -# -# # regroup year bins -# # update this when adding a new year! -# # The following line will place data into two year bins -# # bin names (e.g., 2015) refer to the stated year and the one following (e.g., 2015 = 2015-2016) -# # This maintains year as a numeric variable and facilitates all other analyses -# CPAC_fltr$year <- oddtoeven(CPAC_fltr$year)-1 -# -# # Old code to create character bin names -# # CPAC_fltr$year[CPAC_fltr$year=='2020'] <- '2019' -# # CPAC_fltr$year[CPAC_fltr$year=='2018'] <- '2017-2018' -# # CPAC_fltr$year[CPAC_fltr$year=='2016'] <- '2015-2016' -# # CPAC_fltr$year[CPAC_fltr$year=='2014'] <- '2013-2014' -# # CPAC_fltryear[CPAC_fltr$year=='2012'] <- '2011-2012' -# # CPAC_fltr$year[CPAC_fltr$year=='2010'] <- '2009-2010' -# # CPAC_fltr$year[CPAC_fltr$year=='2008'] <- '2007-2008' -# # CPAC_fltr$year[CPAC_fltr$year=='2006'] <- '2005-2006' -# # CPAC_fltr$year[CPAC_fltr$year=='2004'] <- '2003-2004' -# -# # find strata sampled every year -# annual_strata <- CPAC_fltr %>% -# select(stratum, year) %>% -# distinct() %>% -# group_by(stratum) %>% -# summarise(count = n()) %>% -# filter(count >= 3) -# -# # find strata sampled every year -# annual_strata_old <- CPAC %>% -# #filter(year != 1986, year != 1978) %>% -# select(stratum, year) %>% -# distinct() %>% -# group_by(stratum) %>% -# summarise(count = n()) -# -# -# # how many rows will be lost if only stratum trawled ever year are kept? -# test <- CPAC_fltr %>% -# #filter(year != 1986, year != 1978, year!= 2018) %>% -# filter(stratum %in% annual_strata$stratum) -# nrow(CPAC) - nrow(test) -# # percent that will be lost -# print((nrow(CPAC) - nrow(test))/nrow(CPAC)) -# # 3.03% are removed -# -# #how much additional data will be lost if we remove years 2003-2004? -# test <- CPAC_fltr%>% -# filter(year != 2003,year != 2019 ) %>% -# filter(stratum %in% annual_strata$stratum) -# nrow(CPAC) - nrow(test) -# # percent that will be lost -# print((nrow(CPAC) - nrow(test))/nrow(CPAC)) -# # 18.3% are removed -# -# CPAC_fltr <- CPAC_fltr %>% -# filter(year != 2003,year != 2019 ) %>% -# filter(stratum %in% test$stratum) -# -# p3 <- CPAC_fltr %>% -# select(stratum, year) %>% -# ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + -# geom_jitter() -# -# p4 <- CPAC_fltr %>% -# select(lat, lon) %>% -# ggplot(aes(x = lon, y = lat)) + -# geom_jitter() -# -# if (HQ_PLOTS == TRUE){ -# temp <- grid.arrange(p1, p2,p3,p4, nrow = 2) -# ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "cpac_hq_dat_removed.png")) -# } -# } -# -# -# rm(SOG, SOG_catch, SOG_effort, SOG_strats, QCS, QCS_catch, QCS_effort, QCS_strats, -# HS, HS_catch, HS_effort, HS_strats, WCHG, WCHG_catch, WCHG_effort, WCHG_strats, -# WCV, WCV_catch, WCV_effort, WCV_strats) -# -# # Compile Canadian Gulf of Saint Lawrence South --------------------------------------------------- -# print("Compile GSL South") -# -# #GSL South -# -# GSLsouth <- read_csv(here::here("data_processing_rcode/data", "GSLsouth.csv")) -# -# GSLsouth$haulid <- paste(GSLsouth$year,GSLsouth$month,GSLsouth$day,GSLsouth$start.hour,GSLsouth$start.minute, sep="-") -# -# GSLsouth <- GSLsouth %>% -# # Create a unique haulid -# mutate( -# # Add "strata" (define by lat, lon and depth bands) where needed # degree bins # 100 m bins # no need to use lon grids on west coast (so narrow) -# stratum = paste(floor(latitude), floor(longitude), sep= "-"), -# # distance, 1.75 nau mi. (via Daniel Ricard) = 3241 m., trawl door width, 12.497 m. Hurlbut and Clay (1990) -# # catch weight (kg.) per tow -# wtcpue = (weight.caught)#/(3241*12.497) -# ) -# -# # Calculate stratum area where needed (use convex hull approach) -# GSLsouth_strats <- GSLsouth %>% -# group_by(stratum) %>% -# summarise(stratumarea = calcarea(longitude, latitude)) -# -# GSLsouth <- left_join(GSLsouth, GSLsouth_strats, by = "stratum") -# -# #No depth data available - fill with NA -# GSLsouth$depth <- NA -# #GSLsouth$latin.name <- firstup(GSLsouth$latin.name) -# GSLsouth <- GSLsouth %>% -# mutate(spp = latin.name, -# lat = latitude, -# lon = longitude) %>% -# # remove unidentified spp and non-species -# filter(spp != "" | !is.na(spp), -# !grepl("EGG", spp), -# !grepl("UNIDENTIFIED", spp), -# !grepl("PURSE", spp), -# !grepl("UNID. FISH", spp), -# !grepl("UNID FISH AND INVERTEBRATES", spp), -# !grepl("UNID REMAINS,DIGESTED", spp), -# !grepl("UNID FISH AND REMAINS", spp), -# !grepl("CALAPPA MEGALOPS",spp), -# !grepl("MARINE INVERTEBRATA", spp), -# !grepl("EMPTY", spp), -# !grepl("SHELLS", spp), -# !grepl("RESERVED", spp), -# !grepl("SAND TUBE", spp), -# !grepl("SHARK (NS)", spp), -# !grepl("SHRIMP-LIKE", spp), -# !grepl("UNKNOWN FISH",spp), -# !grepl("^MUD$", spp), -# !grepl("WATER", spp), -# !grepl("DEBRIS", spp), -# !grepl("FISH REMAINS", spp), -# !grepl("POLYCHAETE REMAINS", spp), -# !grepl("CRUSTACEA LARVAE", spp), -# !grepl("FOREIGN ARTICLES,GARBAGE", spp), -# !grepl("NO LONGER USED - PHAKELLIA SPP.", spp), -# !grepl("PARASITES,ROUND WORMS", spp), -# !grepl("POLYCHAETA C.,LARGE", spp), -# !grepl("POLYCHAETA C.,SMALL", spp), -# !grepl("SEA CORALS", spp), -# !grepl("STONES AND ROCKS", spp), -# !grepl("CRAB", spp), -# !grepl("FISH LARVAE, UNID", spp)) %>% -# group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% -# summarise(wtcpue = sumna(wtcpue)) %>% -# # add region column -# mutate(region = "Gulf of St. Lawrence South") %>% -# select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% -# ungroup() -# -# -# if (HQ_DATA_ONLY == TRUE){ -# # look at the graph and make sure decisions to keep or eliminate data make sense -# -# # plot the strata by year -# p1 <- GSLsouth %>% -# select(stratum, year) %>% -# ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + -# geom_jitter() -# p2 <- GSLsouth %>% -# select(lat, lon) %>% -# ggplot(aes(x = lon, y = lat)) + -# geom_jitter() -# -# -# # how many rows will be lost if only stratum trawled ever year are kept? -# test <- GSLsouth %>% -# select(stratum, year) %>% -# distinct() %>% -# group_by(stratum) %>% -# summarise(count = n()) %>% -# filter(count >= 29) -# -# # how many rows will be lost if only stratum trawled ever year are kept? -# test2 <- GSLsouth %>% -# filter(stratum %in% test$stratum) -# nrow(GSLsouth) - nrow(test2) -# # percent that will be lost -# print((nrow(GSLsouth) - nrow(test2))/nrow(GSLsouth)) -# # 1.2% of rows are removed -# -# # how many rows will be lost if only stratum trawled ever year are kept? -# # and remove first year with very low coverage -# test <- GSLsouth %>% -# filter(year != 1970) %>% -# select(stratum, year) %>% -# distinct() %>% -# group_by(stratum) %>% -# summarise(count = n()) %>% -# filter(count > 37) -# -# # how many rows will be lost if only stratum trawled ever year are kept? -# test2 <- GSLsouth %>% -# filter(stratum %in% test$stratum) -# nrow(GSLsouth) - nrow(test2) -# # percent that will be lost -# print((nrow(GSLsouth) - nrow(test2))/nrow(GSLsouth)) -# # 5.6% of rows removed -# -# -# test3 <- GSLsouth %>% -# filter(year >= 1985) -# #filter(year != 1984,year != 1983,year != 1982,year != 1981,year != 1980,year != 1979) -# -# # how many rows will be lost if only years with all strata are kept? -# test4 <- GSLsouth %>% -# filter(year %in% test3$year) -# nrow(GSLsouth) - nrow(test4) -# # percent that will be lost -# print((nrow(GSLsouth) - nrow(test4))/nrow(GSLsouth)) -# # 5.3% of rows are removed -# -# #how many rows will be lost if both years with low coverage and strata with low coverage are dropped? -# test5 <- GSLsouth %>% -# filter(year >= 1985) %>% -# select(stratum, year) %>% -# distinct() %>% -# group_by(stratum) %>% -# summarise(count = n()) %>% -# filter(count >= 28) -# -# test6 <- GSLsouth %>% -# filter(stratum %in% test5$stratum) %>% -# filter(year >= 1985) -# -# nrow(GSLsouth) - nrow(test6) -# # percent that will be lost -# print((nrow(GSLsouth) - nrow(test6))/nrow(GSLsouth)) -# # 7.4% of rows are removed -# -# -# -# # GSLsouth <- GSLsouth %>% -# # #filter(year != 1986, year != 1978, year != 2018) %>% -# # filter(stratum %in% test$stratum) %>% -# # filter(year >= 1985) -# -# #Filter spatially and first year with very low coverage -# GSLsouth_fltr <- GSLsouth %>% -# filter(year != 1970) %>% -# filter(stratum %in% test$stratum) -# -# p3 <- GSLsouth_fltr %>% -# select(stratum, year) %>% -# ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + -# geom_jitter() -# -# p4 <- GSLsouth_fltr %>% -# select(lat, lon) %>% -# ggplot(aes(x = lon, y = lat)) + -# geom_jitter() -# -# if (HQ_PLOTS == TRUE){ -# temp <- grid.arrange(p1, p2,p3,p4, nrow = 2) -# ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "GSLsouth_hq_dat_removed.png")) -# } -# } -# -# -# rm(GSLsouth_strats) -# -# # Compile Canadian Gulf of Saint Lawrence North --------------------------------------------------- -# print("Compile GSL North") -# -# #GSL North Sentinel -# -# GSLnor_sent <- read.csv(here::here("data_processing_rcode/data", "GSLnorth_sentinel.csv")) -# -# #GSL North Gadus -# -# GSLnor_gad <- read.csv(here::here("data_processing_rcode/data", "GSLnorth_gadus.csv")) -# -# #GSL North Hammond -# -# GSLnor_ham <- read.csv(here::here("data_processing_rcode/data", "GSLnorth_hammond.csv")) -# -# #GSL North Needler -# -# GSLnor_need <- read.csv(here::here("data_processing_rcode/data", "GSLnorth_needler.csv")) -# -# #GSL North Teleost -# -# GSLnor_tel <- read.csv(here::here("data_processing_rcode/data", "GSLnorth_teleost.csv")) -# -# #Bind all datasets -# -# GSLnor <- plyr::rbind.fill(GSLnor_sent, GSLnor_gad, GSLnor_ham, GSLnor_need, GSLnor_tel) -# GSLnor$lat <-as.numeric(as.character(GSLnor$Latit_Deb)) -# GSLnor$lon <-as.numeric(as.character(GSLnor$Longit_Deb)) -# GSLnor$depth <-as.numeric(as.character(GSLnor$Prof_Max)) -# GSLnor$Dist_Towed <-as.numeric(GSLnor$Dist_Chalute_Position) -# GSLnor$Pds_Capture <- as.double(GSLnor$Pds_Capture) -# GSLnor$Date <-as.Date(GSLnor$Date_Deb_Trait) -# GSLnor$year <- as.integer(year(GSLnor$Date)) -# GSLnor$spp <- trimws(as.character(GSLnor$Nom_Scient_Esp), which = "right") -# -# -# #GSLnor$haulid <- paste(GSLnor$No_Releve,GSLnor$Trait,GSLnor$Date_Deb_Trait,GSLnor$Hre_Deb, sep="-") -# -# GSLnor <- GSLnor[!is.na(GSLnor$lat),] -# GSLnor <- GSLnor[!is.na(GSLnor$depth),] -# -# GSLnor <- GSLnor %>% -# # Create a unique haulid -# mutate( -# haulid = paste(GSLnor$No_Releve,GSLnor$Trait,GSLnor$Date_Deb_Trait,GSLnor$Hre_Deb, sep="-"), -# # Add "strata" (define by lat, lon and depth bands) where needed # degree bins # 100 m bins # no need to use lon grids on west coast (so narrow) -# #stratum = paste(floor(lat), floor(lon),floor(depth)*100, sep= "-"), -# stratum = paste(floor(lat), floor(lon),plyr::round_any(GSLnor$depth, 100), sep= "-"), -# #weight of catch (kg.) per tow -# wtcpue = (Pds_Capture)#/(Dist_Towed *12.497) -# ) -# -# -# # Calculate stratum area where needed (use convex hull approach) -# GSLnor_strats <- GSLnor %>% -# group_by(stratum) %>% -# summarise(stratumarea = calcarea(lon,lat)) %>% -# ungroup() -# -# -# GSLnor <- left_join(GSLnor, GSLnor_strats, by = "stratum") -# -# GSLnor <- GSLnor %>% -# # remove unidentified spp and non-species -# filter(spp != "" | !is.na(spp), -# !grepl("EGG", spp), -# !grepl("UNIDENTIFIED", spp), -# !grepl("PURSE", spp), -# !grepl("UNID. FISH", spp), -# !grepl("UNID FISH AND INVERTEBRATES", spp), -# !grepl("UNID REMAINS,DIGESTED", spp), -# !grepl("UNID FISH AND REMAINS", spp), -# !grepl("CALAPPA MEGALOPS",spp), -# !grepl("MARINE INVERTEBRATA (NS)", spp), -# !grepl("EMPTY", spp), -# !grepl("SHELLS", spp), -# !grepl("RESERVED", spp), -# !grepl("SAND TUBE", spp), -# !grepl("SHARK (NS)", spp), -# !grepl("SHRIMP-LIKE", spp), -# !grepl("UNKNOWN FISH",spp), -# !grepl("^MUD$", spp), -# !grepl("WATER", spp), -# !grepl("INORGANIC DEBRIS", spp), -# !grepl("FISH REMAINS", spp), -# !grepl("POLYCHAETA REMAINS", spp)) %>% -# group_by(haulid, stratum, stratumarea, year, lat, lon, depth, spp) %>% -# summarise(wtcpue = sumna(wtcpue)) %>% -# # add region column -# mutate(region = "Gulf of St. Lawrence North") %>% -# select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, wtcpue) %>% -# ungroup() -# -# if (HQ_DATA_ONLY == TRUE){ -# # look at the graph and make sure decisions to keep or eliminate data make sense -# -# # plot the strata by year -# p1 <- GSLnor %>% -# select(stratum, year) %>% -# ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + -# geom_jitter() -# p2 <- GSLnor %>% -# select(lon, lat) %>% -# ggplot(aes(x = lon, y = lat)) + -# geom_jitter() -# -# test <- GSLnor %>% -# filter(year != 1979, year != 1980,year != 1981) %>% -# select(stratum, year) %>% -# distinct() %>% -# group_by(stratum) %>% -# summarise(count = n()) %>% -# filter(count >= 29) -# -# # how many rows will be lost if only stratum trawled ever year are kept? -# test2 <- GSLnor %>% -# filter(stratum %in% test$stratum) -# nrow(GSLnor) - nrow(test2) -# # percent that will be lost -# print ((nrow(GSLnor) - nrow(test2))/nrow(GSLnor)) -# # 10.5% of rows are removed -# -# # find strata sampled every year -# annual_strata <- GSLnor %>% -# filter(year != 1979, year != 1980,year != 1981) %>% -# select(stratum, year) %>% -# distinct() %>% -# group_by(stratum) %>% -# summarise(count = n()) %>% -# filter(count >= 29) -# -# # find strata sampled every year -# annual_strata_old <- GSLnor %>% -# select(stratum, year) %>% -# distinct() %>% -# group_by(stratum) %>% -# summarise(count = n()) -# -# sum(length(unique(annual_strata_old$count)) - length(unique(annual_strata$count))) -# # how many rows will be lost if only stratum trawled ever year are kept? -# # test <- GSLnor %>% -# # filter(year != 1979, year != 1980,year != 1981) %>% -# # select(stratum, year) %>% -# # distinct() %>% -# # group_by(stratum) %>% -# # summarise(count = n()) #%>% -# # #filter(count <=34) -# # -# # nrow(GSLnor) - nrow(test) -# # # percent that will be lost -# # print((nrow(GSLnor) - nrow(test))/nrow(GSLnor)) -# # # 5.6% are removed -# # # -# -# GSLnor_fltr <- GSLnor %>% -# filter(year != 1979, year != 1980,year != 1981) %>% -# filter(stratum %in% annual_strata$stratum) -# -# p3 <- GSLnor_fltr %>% -# select(stratum, year) %>% -# ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + -# geom_jitter() -# -# p4 <- GSLnor_fltr %>% -# select(lon, lat) %>% -# ggplot(aes(x = lon, y = lat)) + -# geom_jitter() -# -# if (HQ_PLOTS == TRUE){ -# temp <- grid.arrange(p1, p2,p3,p4, nrow = 2) -# ggsave(plot = temp, filename = here::here("data_processing_rcode/output/plots", "GSLnorth_hq_dat_removed.png")) -# } -# } -# -# rm(GSLnor_gad, GSLnor_ham, GSLnor_need, GSLnor_sent, GSLnor_tel, GSLnor_strats) - - - - -# Compile TAX =============================================================== -print("Compile TAX") - -tax <- read_csv(here::here("data_processing_rcode/spp_taxonomy_mater_key.csv"), col_types = cols( - survey_name = col_character(), - accepted_name = col_character(), - common = col_character(), - kingdom = col_character(), - phylum = col_character(), - class = col_character(), - order = col_character(), - family = col_character(), - genus = col_character(), - rank = col_character(), - worms_id = col_character(), - SpecCode = col_character())) - - -tax<- tax %>% - # remove any extra white space from around spp and common names - mutate(survey_name= str_squish(survey_name), - valid_name= str_squish(accepted_name), - common = str_squish(common)) %>% - select(c(survey_name, valid_name, common, rank, class, filtercat)) %>% - distinct() - -tax$survey_name<-firstup(tax$survey_name) - -if(isTRUE(WRITE_MASTER_DAT)){ - save(ai, ebs, gmex, goa, neus_fall, neus_spring, seusFALL, seusSPRING, seusSUMMER, tax, wcann, wctri, file = here("data_processing_rcode/output/data_clean", "individual-regions.rds")) -} -if(isTRUE(WRITE_MASTER_DAT)){ - save(ai_fltr, ebs_fltr, gmex_fltr, goa_fltr, neus_fall_fltr, neus_spring_fltr, seusFALL_fltr, seusSPRING_fltr, seusSUMMER_fltr, tax, wcann_fltr, wctri_fltr, file = here("data_processing_rcode/output/data_clean", "individual-regions-fltr.rds")) -} - - -# Master Data Set =========================================================== -print("Join into Master Data Set") -#Full unfiltered data set -dat <- rbind(ai, ebs, gmex, goa, nbs, neus_fall, neus_spring, seusFALL, seusSPRING, seusSUMMER, wcann, wctri) %>% - # Remove NA values in wtcpue - filter(!is.na(wtcpue)) %>% - # remove any extra white space from around spp and common names - mutate(spp= str_squish(spp)) - -#convert all taxa names to first word capitalzied and rest lowercase... -dat$spp<-firstup(dat$spp) - -#========================== start SPECIES CHECK ============= -#Species Taxon checkpoint before proceeding!! -# Check if any new species are in survey data sets before proceeding....take the 'dat' file that combines the individual regions but before joined with 'spp_taxonomy' file -dat_spp <- dat %>% - select(spp,region) %>% - distinct() %>% - mutate(spp_id = 1:nrow(.)) - -# Anti-join this spp list to the taxon column from the tax file to see which spp are not represented there -not_in_tax <- anti_join(dat_spp, tax, by = c("spp" = "survey_name")) -not_in_tax<- not_in_tax %>% group_by(spp) %>% - summarise_all(funs(toString(unique(na.omit(.))))) - -#========================== end species name check =========== - -# add a case sensitive spp and common name -dat <- left_join(dat, tax, by = c("spp" = "survey_name")) %>% - select(region, haulid, year, lat, lon, stratum, stratumarea, depth, spp, valid_name, common, rank, wtcpue) %>% - distinct() - -#check for errors in name matching -if(sum(dat$valid_name == 'NA') > 0 | sum(is.na(dat$valid_name)) > 0){ - warning('>>create_master_table(): Did not match on some taxon [Variable: `tax`] names.') -} - -# #if get warning, check for which spp have NA for name and common if check above fails -spp_na<-dat %>% - filter(is.na(dat$valid_name) & is.na(dat$common)) %>% - select(c("region", "spp", "valid_name", "common")) %>% - distinct() - -# spp_na_list<-unique(c(as.character(spp_na$spp))) -# spp_na<-as.data.frame(spp_na) -# sppNA_unique<-unique(spp_na[c("spp")]) -# write.csv(sppNA_unique, "sppNA_unique.csv") - -# #get list of higher order taxon names by region/survey and use to generate the list of higher order names to exclude later on -# dat_HO_list<-dat %>% -# filter(grepl("HigherOrder", rank)) %>% -# select(c("region", "valid_name", "rank")) %>% -# distinct() - -if(isTRUE(REMOVE_REGION_DATASETS)) { - rm(ai, ebs, gmex, goa, neus_fall, neus_spring, seusFALL, seusSPRING, seusSUMMER, wcann, wctri, tax) -} - -if(isTRUE(WRITE_MASTER_DAT)){ - if(isTRUE(PREFER_RDATA)){ - saveRDS(dat, file = here("data_processing_rcode/output/data_clean", "all-regions-full.rds")) - }else{ - write_csv(dat, file =here("data_processing_rcode/output/data_clean", "all-regions-full.csv")) - } -} - - -# Master "Filtered" dataset -dat_fltr <- rbind(ai_fltr, ebs_fltr, nbs_fltr, gmex_fltr, goa_fltr, neus_fall_fltr, neus_spring_fltr, seusFALL_fltr, seusSPRING_fltr, seusSUMMER_fltr, wcann_fltr, wctri_fltr) %>% - # Remove NA values in wtcpue - filter(!is.na(wtcpue)) %>% - # remove any extra white space from around spp and common names - mutate(spp= str_squish(spp)) -#convert all taxa names to first word capitalzied and rest lowercase... -dat_fltr$spp<-firstup(dat_fltr$spp) -# add a case sensitive spp and common name and filter out Higher Level taxon names, the turtle, bird, and dolphin species, and plants/seaweed species. -dat_fltr <- left_join(dat_fltr, tax, by = c("spp" = "survey_name")) %>% - filter(!grepl("Remove", filtercat), - !grepl("Caretta caretta", valid_name), - !grepl("Sagmatias obliquidens", valid_name), - !grepl("Puffinus gravis", valid_name), - !grepl("Phaeophyceae", class), - !grepl("Florideophyceae", class), - !grepl("Ulvophyceae", class)) %>% - select(region, haulid, year, lat, lon, stratum, stratumarea, depth, valid_name, common, wtcpue) %>% - distinct() %>% - rename(spp = valid_name) - -#check for errors in name matching -if(sum(dat_fltr$spp == 'NA') > 0 | sum(is.na(dat_fltr$spp)) > 0){ - warning('>>create_master_table(): Did not match on some taxon [Variable: `tax`] names.') -} -#if get warning, check for which spp have NA for name and common if check above fails -spp_na<-dat_fltr %>% - filter(is.na(dat_fltr$spp) & is.na(dat_fltr$common)) -rm(spp_na) - -if(isTRUE(REMOVE_REGION_DATASETS)) { - rm(ai_fltr, ebs_fltr, gmex_fltr, goa_fltr, neus_fall_fltr, neus_spring_fltr, seusFALL_fltr, seusSPRING_fltr, seusSUMMER_fltr, wcann_fltr, wctri_fltr, tax) -} - -if(isTRUE(WRITE_MASTER_DAT)){ - if(isTRUE(PREFER_RDATA)){ - saveRDS(dat_fltr, file = here("data_processing_rcode/output/data_clean", "all-regions-full-fltr_6_7_24.rds")) - }else{ - write_csv(dat_fltr,file=here("data_processing_rcode/output/data_clean", "all-regions-full-fltr_3_17_23.csv")) - } -} - - -# Expanded Survey Dataset================================================= -print ("Expanded dataset") -presyr <- present_every_year(dat_fltr, region, spp, common, year) - -haulsyr<-num_hauls_year(dat_fltr, region, year) - -preshaul<-left_join(presyr, haulsyr, by=c("region", "year")) %>% - mutate(proportion=((pres/hauls)*100)) %>% - filter(proportion>=5) - -# years in which spp was present in >= 5% of tows -presyrsum <- num_year_present(preshaul, region, spp, common) - -# max num years of survey in each region -maxyrs <- max_year_surv(presyrsum, region) - -# merge in max years -presyrsum <- left_join(presyrsum, maxyrs, by = "region") -# write.csv(presyrsum, "presyrsum_11_22_22.csv") -# retain all spp present at >5% of tows in at least 2 of the available years in a survey -spplist <- presyrsum %>% - filter(presyr >= 2) %>% - select(region, spp, common) - -spp_addin<-read.csv("data_processing_rcode/Add_managed_spp.csv",header=T, sep=",") -spplist<-rbind(spplist, spp_addin) %>% - distinct() - -# Trim dat to these species (for a given region, spp pair in spplist_final, in dat, keep only rows that match that region, spp pairing) -trimmed_dat_fltr_expanded <- dat_fltr %>% - filter(paste(region, spp) %in% paste(spplist$region, spplist$spp)) - -# Trim species (for IDW analysis)=========================================================== -print("Trim species") - -## FILTERED DATA -# Find a standard set of species (present at least 3/4 of the years of the filtered data in a region) -# this result differs from the original code because it does not include any species that have a pres value of 0. It does, however, include species for which the common name is NA. -presyr <- present_every_year(dat_fltr, region, spp, common, year) - -haulsyr<-num_hauls_year(dat_fltr, region, year) - -preshaul<-left_join(presyr, haulsyr, by=c("region", "year")) %>% - mutate(proportion=((pres/hauls)*100)) %>% - filter(proportion>=5) - -# years in which spp was present in >= 5% of tows -presyrsum <- num_year_present(preshaul, region, spp, common) - -# max num years of survey in each region -maxyrs <- max_year_surv(presyrsum, region) - -# merge in max years -presyrsum <- left_join(presyrsum, maxyrs, by = "region") -# write.csv(presyrsum, "presyrsum_11_22_22.csv") -# retain all spp present at least 3/4 of the available years in a survey -spplist_IDW <- presyrsum %>% - filter(presyr >= (maxyrs * 3/4)) %>% - select(region, spp, common) - -spp_addin<-read.csv("data_processing_rcode/Add_managed_spp.csv",header=T, sep=",") -spplist2<-rbind(spplist_IDW, spp_addin) %>% - distinct() %>% - mutate(DistributionProjectName="NMFS/Rutgers IDW Interpolation") -## use this spp list after explode 0 to add a column indicating that these species should be kept for IDW - -#add an EBS+NBS combined region ========================= -#select years from compiled EBS that match the NBS survey years -years<-c(2010, 2017, 2019, 2021, 2022, 2023) -enbs_trimmed<- trimmed_dat_fltr_expanded %>% filter(region %in% c("Eastern Bering Sea", "Northern Bering Sea"), - year %in% years) %>% - mutate(region="Bering Sea Combined") - -p1 <- enbs_trimmed %>% - select(stratum, year) %>% - ggplot(aes(x = as.factor(stratum), y = as.factor(year))) + - geom_jitter() - -p2 <- enbs_trimmed %>% - select(lat, lon) %>% - ggplot(aes(x = lon, y = lat)) + - geom_jitter() - -trimmed_dat_fltr_expanded <-rbind(trimmed_dat_fltr_expanded, enbs_trimmed) - -if(isTRUE(WRITE_TRIMMED_DAT)){ - if(isTRUE(PREFER_RDATA)){ - saveRDS(trimmed_dat_fltr_expanded, file = here("data_processing_rcode/output/data_clean", "all-regions-trimmed-fltr.rds")) - }else{ - write_csv(trimmed_dat_fltr_expanded, "data_processing_rcode/data_clean/all-regions-trimmed-fltr.csv") - } -} - -# Dat_exploded - Add 0's ====================================================== -print("Dat exploded") -# these Sys.time() flags are here::here to see how long this section of code takes to run. -Sys.time() -# This takes about 10 minutes -if (DAT_EXPLODED == TRUE){ - dat.exploded <- as.data.table(trimmed_dat_fltr_expanded)[,explode0(.SD), by="region"] - dat_expl_spl <- split(dat.exploded, dat.exploded$region, drop = FALSE) - - if(isTRUE(WRITE_DAT_EXPLODED)){ - if(isTRUE(PREFER_RDATA)){ - lapply(dat_expl_spl, function(x) saveRDS(x, here::here("data_processing_rcode/output/data_clean", paste0('dat_exploded', x$region[1], '.rds')))) - }else{ - lapply(dat_expl_spl, function(x) write_csv(x, gzfile(here::here("data_processing_rcode/output/data_clean", paste0('dat_exploded', x$region[1], '.csv.gz'))))) - } - } - -} -Sys.time() - -#clean up -rm(dat_expl_spl) - -## Add the DistributionProjectName column to dat.exploded -#use the spplist2 to indicate which species should be kept for IDW as opposed to which are for both IDW and expanded survey module -dat.exploded<-left_join(dat.exploded, spplist2, by=c("spp","common","region")) - -spp_IDW<-dat.exploded %>% - filter(DistributionProjectName=="NMFS/Rutgers IDW Interpolation") %>% - select(spp, common) %>% - distinct() - -spp_survey<-dat.exploded %>% - select(spp, common, region) %>% - distinct() - -#stop and.... -## Go to Update_Filter_Table.R -## GO TO create_data_for_map_generation.R now - - -###################### CAN STOP HERE ########################################## -## CORE Species -- caught every year of survey ======= - -print("Core species") - -## FILTERED DATA -# Find a standard set of species (present in all years of the filtered data in a region) -# this result differs from the original code because it does not include any species that have a pres value of 0. It does, however, include speices for which the common name is NA. -presyr <- present_every_year(dat_fltr, region, spp, common, year) - -haulsyr<-num_hauls_year(dat_fltr, region, year) - -preshaul<-left_join(presyr, haulsyr, by=c("region", "year")) %>% - mutate(proportion=((pres/hauls)*100))%>% - filter(proportion>=5) - -# years in which spp was present in >= 5% of tows -presyrsum <- num_year_present(preshaul, region, spp, common) - -# max num years of survey in each region -maxyrs <- max_year_surv(presyrsum, region) - -# merge in max years -presyrsum <- left_join(presyrsum, maxyrs, by = "region") -# write.csv(presyrsum, "presyrsum_11_22_22.csv") -# retain all spp present all years of the available years in a survey -spplist_core <- presyrsum %>% - filter(presyr >= maxyrs) %>% - select(region, spp, common) - -# Summary information about # of species in this analysis================ -#number of unique species across all regions -dfuniq<-unique(spplist[c("spp", "common", "region")]) %>% - mutate( - region = ifelse(grepl("West Coast", region), "West Coast", region), - region = ifelse(grepl("Northeast", region), "Northeast", region), - region = ifelse(grepl("Southeast", region), "Southeast", region)) %>% - distinct() - -dfuniq_Core<-unique(spplist_core[c("spp", "common")]) -length(dfuniq_Core) - -#number of unique species caught in each regional survey (expanded data set) -spp_reg_counts<-spplist %>% - group_by(region)%>% - summarise(distinct_spp=n_distinct(spp)) - -#number of unique species within each regional survey (caught 3/4 or years) -spp_reg_counts_quarters<-spplist2 %>% - group_by(region)%>% - summarise(spp_3_4years=n_distinct(spp)) - -#number of unique species CAUGHT ALL YEARS within each region -spp_reg_counts_Core<-spplist_core%>% - group_by(region)%>% - summarise(spp_all_yrs=n_distinct(spp)) - -num_spp_summary<-left_join(spp_reg_counts, spp_reg_counts_quarters, by=c("region")) -num_spp_summary<-left_join(num_spp_summary, spp_reg_counts_Core, by=c("region")) -write.csv(num_spp_summary, file=here("data_processing_rcode/output/data_clean", "summary_unique_spp_table_7_24_24.csv")) -write.csv(spplist_core, file=here("data_processing_rcode/output/data_clean","core_spp_list_7_24_24.csv")) - -## compare with the Master Filter Table for the filter functionality on the portal -filter_table<-read.csv("Species_Filter.csv", header=T, sep=",") -spp_to_remove<-anti_join(filter_table, dfuniq, by=c("spp", "FilterSubRegion"="region")) - -# write.csv(spp_to_remove, "spp_removed_filter_6_10_24.csv") -# #remove these species from the filter table -# filter_table_revised<-anti_join(filter_table, spp_to_remove) -# -miss_filter<-anti_join(dfuniq, filter_table, by=c("spp", "region"="FilterSubRegion")) %>% - rename(FilterSubRegion=region) -# -# Filter_table_updated<-bind_rows(filter_table_revised, miss_filter) -# #write.csv(Filter_table_updated, file=here("data_processing_rcode/output/data_clean", "Final_Filter_Table.csv")) - -## Compare old and new filter table to see which species were removed and which were added! -old_table<-read.csv("filter_table_final_5_31_23.csv", header=T, sep=",") -new_table<- read.csv("output/data_clean/Final_Filter_Table.csv", header=T, sep=",") - -spp_added<-anti_join(new_table, old_table, by= c("spp", "FilterSubRegion")) -write.csv(spp_added, "spp_added_to_filter_6_10_24.csv") -spp_removed<-anti_join(old_table, new_table, by= c("spp", "FilterSubRegion")) -write.csv(spp_removed, "spp_removed_from_filter_6_10_24.csv") - - -##GET LIST OF SPECIES AND TAXON REMOVED -# Master "Filtered" dataset -dat_fltr <- rbind(ai_fltr, ebs_fltr, nbs_fltr, gmex_fltr, goa_fltr, neus_fall_fltr, neus_spring_fltr, seusFALL_fltr, seusSPRING_fltr, seusSUMMER_fltr, wcann_fltr, wctri_fltr) %>% - # Remove NA values in wtcpue - filter(!is.na(wtcpue)) %>% - # remove any extra white space from around spp and common names - mutate(spp= str_squish(spp)) -#convert all taxa names to first word capitalzied and rest lowercase... -dat_fltr$spp<-firstup(dat_fltr$spp) -# add a case sensitive spp and common name and filter out Higher Level taxon names, the turtle, bird, and dolphin species, and plants/seaweed species. -dat_fltr <- left_join(dat_fltr, tax, by = c("spp" = "survey_name")) -data_fltr_HOremoved<- dat_fltr %>% - filter(!grepl("HigherOrder", rank), - !grepl("remove", rank), - !grepl("Caretta caretta", valid_name), - !grepl("Sagmatias obliquidens", valid_name), - !grepl("Puffinus gravis", valid_name), - !grepl("Phaeophyceae", class), - !grepl("Florideophyceae", class), - !grepl("Ulvophyceae", class)) %>% - distinct() -removed<-anti_join(dat_fltr, data_fltr_HOremoved, by=c("valid_name", "region")) %>% - select(valid_name, common)%>% - distinct() -write.csv(removed, "removed_HO_taxa.csv") - -filterd_spp<-anti_join(data_fltr_HOremoved, dfuniq, by=c("valid_name"="spp")) %>% - select(valid_name, common) %>% - distinct() -write.csv(filterd_spp, "filter_removed_spp.csv") diff --git a/data_processing_rcode/code/DisMAP_Data_Download_API.R b/data_processing_rcode/code/DisMAP_Data_Download_API.R deleted file mode 100644 index 9ace2e8..0000000 --- a/data_processing_rcode/code/DisMAP_Data_Download_API.R +++ /dev/null @@ -1,206 +0,0 @@ -## The code below shows how to download the various data products available for DisMAP through -#the ESRI and fisheries map server API. -#This data includes: -# - indicators table which includes information on the COG lat, depth, lon of each species -# - interpolated biomass raster layers -# - survey points - -## IMPORTANT INSTRUCTIONS#### -## The data URLs referenced in this code can be found in the DisMAP inPort records under the Distribution information: -## Check the inport page for DisMAP for the most up-to-date URLS for each data product: https://www.fisheries.noaa.gov/inport/item/66799 - #look under "Child Items", the numbers at the end of the title indicate the date of the layer in Year-Month-Day format. Click on the data set of interest - # and use that URL in the steps below (examples for an earlier dataset are provided below) -# for the indicators table: https://services2.arcgis.com/C8EMgrsFcRFL6LrL/arcgis/rest/services/Indicators_CURRENT/FeatureServer -# for the survey data: https://www.fisheries.noaa.gov/inport/item/69743 -# for the interpolated biomass layers: https://www.fisheries.noaa.gov/inport/item/70034 - -## Please see our technical report for more details on how the analysis and data found in the DisMAP portal -# https://apps-st.fisheries.noaa.gov/dismap/DisMAP.html - -#load required packages -library(jsonlite) -library(dplyr) -library(raster) -# install.packages("rgdal") -# library(rgdal) -#library(sp) -library(ggplot2) -library(rasterVis) -library(httr) -#install.packages("gganimate") -library(gganimate) -library(maps) -#install.packages("ggthemes") -library(ggthemes) -#install.packages("gifski") -library(gifski) -#install.packages("gapminder") -library(gapminder) -library(dplyr) -require(viridis) -#install.packages("mapdata") -library(mapdata) -# install.packages("cmocean") -library(cmocean) -# install.packages("tidyverse") -# library(tidyverse) -# install.packages("exactextractr") -library(exactextractr) -library(sf) - - -#### 1. Querying the INDICATORS TABLE #### -#Query the Distribution indicators table (switch out common name with desired species common name, and Region -# with desired region for the selected species (or remove the Region portion if want all regions for -# a given species)) -###Available Regions include: "Aleutian Islands", "Eastern Bering Sea", "Gulf of Alaska", "West Coast Triennial", -# "West Coast Annual", "Gulf of Mexico", "Northeast US Spring", "Northeast US Fall", -# "Southeast US Fall", "Southeats US Spring", "Southeast US Summer", "Northern Bering Sea", "Eastern and Northern Bering Sea" - -## Example for American Lobster in Northeast US Spring -url <- parse_url("https://services2.arcgis.com/C8EMgrsFcRFL6LrL/arcgis/rest/services/") -url$path <- paste(url$path, "Indicators_CURRENT/FeatureServer/1/query", sep = "/") -url$query <- list(where = "CommonName = 'American lobster' AND Datasetcode='NEUS_SPR'", - outFields = "*", - f = "geojson") -request <- build_url(url) - -ALob_metrics <- st_read(request) -ALob_COG<-as.data.frame(ALob_metrics) -ALob_COG<-ALob_COG %>% - rename(lon=CenterOfGravityLongitude, - lat=CenterOfGravityLatitude) -write.csv(ALob_COG, "ALob_COG_change.csv") - -COG_change<-ggplot() + - geom_point(data=ALob_COG, aes(x=lon, y=lat, col=Year)) + - theme_classic() + labs(y="", x="") + - theme( panel.border = element_rect(colour = "black", fill=NA, size=1)) + #makes a box - annotation_map(map_data("world"), colour = "black", fill="grey50")+ - coord_quickmap(xlim=c(-80,-65),ylim=c(33,45)) + #Sets aspect ratio - scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0)) - - -#### 2. Downloading INTERPOLATED BIOMASS RASTERS #### - ## Example for Summer Flounder in NEUS Spring - #Get the sliceIDs that correspond to Summer Flounder in NEUS Spring. There will be a unique slice ID for each species-year pair within each region - ##Note that the URLs may change with data updates (mainly just the #s at the end that indicate the date, e.g., the 20220516 would change to reflect new date) - # make sure to double check the URLs for the data layer you want by going to the InPort page, clicking on Fish and Invertebrate Interpolated Biomass Distribution - #surfaces for the data release date you want, and then scrolling down to the Distribution section and checking the URL for the region of interest. Swap out that - #URL for everything before the /slices in the below, and /exportImage in the next step ... - SumFl_slices <- "https://maps.fisheries.noaa.gov/image/rest/services/DisMAP/NEUS_SPR_IDW_CURRENT/ImageServer/slices?multidimensionalDefinition=%5B%7B%22variableName%22%3A+%22Paralichthys+dentatus%22%7D%5D&f=pjson" - header_type <- "applcation/json" - response<-GET(SumFl_slices) - text_json <- content(response, type = 'text', encoding = "UTF-8") - jfile <- fromJSON( text_json) - df <- as.data.frame(jfile) - - #now to use the exportImage function of ESRI API to export the raster images for Summer Flounder based on the slice #s in df - #and save the rasters in folder on your local computer - ##loop through the sliceIDs (can see the slice in the file "df") - ## replace the #s with the first and last slice ID that can be found in the 'df' generaged in previous step - for (i in c(1472:1517)){ - print(paste0("Downloading raster image for slice ", i)) - - url<-httr::parse_url("https://maps.fisheries.noaa.gov/image/rest/services/DisMAP/NEUS_SPR_IDW_CURRENT/ImageServer/exportImage") - - query_arg <- list(imageSR = "4326", - format = "tiff", - pixelType = "F32", - noData = "3.4e38", - noDataInterpretation = "esriNoDataMatchAny", - interpolation = "+RSP_BilinearInterpolation", - sliceID = 1511, - f = "json") - - bbox_arg <- list(bbox = paste( #note that the bounding box will be different for each region! - min(428349.9584999997), - min(3888846.4584999997), - max(1278349.9584999997), - max(4952846.4585), - sep = "," - )) - - res <- httr::GET(url, query = c(bbox_arg, query_arg)) - - tmpfile <-tempfile() - content <-httr::content(res, type = "application/json") - - httr::RETRY("GET", content$href, - httr::progress(), - httr::write_disk(tmpfile), - times = 10, pause_cap = 10) - r <-raster(tmpfile) - plot(r) - rcube<-r^(1/3) - plot(rcube) - #save raster - fname<-paste0("SummerFlounder","_", i) - writeRaster(r, paste0("SummerFlounder_NE_spring", "/", fname), overwrite=TRUE) - } - - ## load in the saved rasters into R... - dir<-"" #NOTE: here will need to add in your dir, which is the local directory that points to where raster data is stored - - files_SumFl_NEspring<-list.files(paste0(dir, '/SummerFlounder_NE_Spring'), full.names=TRUE, pattern=".grd") - years<-seq(1974, 2019) - yearsEx<-years[years!=1975] - yearsEx<-yearsEx[yearsEx!=2014] - output <- as.data.frame(matrix(NA, nrow=160000*44,ncol=4)) #160000 non-NA grid cells in raster (use: rNA <- !is.na(SmFl)), 44 is the # of years - colnames(output) <- c("lon","lat","year","wtcpue") - - #----Loop through the slices---- - #s is the year, so loop through the 44 years - for (s in 1:44){ - SmFl <- raster(files_SumFl_NEspring[s]) - plot(SmFl) - ###Extract data for each 'slice' (which corresponds to each year) - print("Extracting Data") - ei <- 160000*s #end location in output grid to index to - se <- ei - (160000-1) #start location in output grid to index to - output$lat[se:ei] <- rasterToPoints(SmFl)[,2] - output$lon[se:ei] <- rasterToPoints(SmFl)[,1] - output$year[se:ei] <- rep(yearsEx[s],160000) - output$wtcpue[se:ei] <- rasterToPoints(SmFl)[,3] - } - - #NOTE: need to mutate data frame so that values of 3.4e+38 which is what is given to "no data" is switched to NA, - #and add a new column where wtcpue values are cube-rooted. The cube-root provides for better visualizations - SmFl_Spring_data<-output %>% - mutate( - wtcpue = ifelse(wtcpue>3000, NA, wtcpue), - #wtcpue = ifelse(wtcpue == 0, NA, wtcpue), - cuberoot_wtcpue = (wtcpue)^(1/3)) - #can also chose to make 0's NA as well. This is what we did for DisMAP, so only areas of positive predicted biomass are shown - # as colors in the distribution map. We felt this makes it easier to see some of the trends. - - write.csv(SmFl_Spring_data, "SummerFlounder_NEUS_spring_data.csv") - - ### Example of how to make animated GIFs of the distribution - SmFl_NEUS_spring <- ggplot(data = SmFl_Spring_data, aes(x=lon,y=lat))+ - geom_tile(aes(fill=cuberoot_wtcpue))+ - theme_classic() + labs(y="", x="") + - theme(legend.position="right",legend.title = element_blank())+ - theme( panel.border = element_rect(colour = "black", fill=NA, size=1)) + #makes a box - scale_fill_gradientn(colours = cmocean("matter")(256),limits = c(0, max(SmFl_Spring_data$cuberoot_wtcpue))) + - annotation_map(map_data("world"), colour = "black", fill="grey50")+ - coord_quickmap(xlim=c(-78,-65),ylim=c(34,48)) + #Sets aspect ratio - scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0))+ - transition_time(year)+ - ease_aes("linear") + - labs(title="Summer Flounder NEUS Spring {frame_time}") #takes some time - - SmFl_annimated <- gganimate::animate(SmFl_NEUS_spring,nframes = 44, fps=2, renderer = gifski_renderer())#renders in - anim_save('SmFl_NEUS_spring.gif', SmFl_annimated) - - -#### 3. Survey points #### - url <- parse_url("https://services2.arcgis.com/C8EMgrsFcRFL6LrL/ArcGIS/rest/services") - url$path <- paste(url$path, "Eastern_Bering_Sea_Survey_Locations_20220516/FeatureServer/1/query", sep = "/") - url$query <- list(where = "OARegion='Eastern Bering Sea'", - outFields = "*", - f = "geojson") - request <- build_url(url) - - selected_regions <- st_read(request) - selected_regions<-as.data.frame(selected_regions) diff --git a/data_processing_rcode/code/Fix_Taxon_QAQC_data.R b/data_processing_rcode/code/Fix_Taxon_QAQC_data.R deleted file mode 100644 index b1b3852..0000000 --- a/data_processing_rcode/code/Fix_Taxon_QAQC_data.R +++ /dev/null @@ -1,67 +0,0 @@ -# clean Taxon QAQC Sheet =============================================================== -print("Clean & Compile TAX") -source("clean_taxa.R") - -# Get WoRM's id for sourcing -wrm <- gnr_datasources() %>% - filter(title == "World Register of Marine Species") %>% - pull(id) - -#Full unfiltered data set -dat <- rbind(ai, ebs, gmex, goa, nbs, neus_fall, neus_spring, seusFALL, seusSPRING, seusSUMMER, wcann, wctri) %>% - # Remove NA values in wtcpue - filter(!is.na(wtcpue)) %>% - # remove any extra white space from around spp names - mutate(spp= str_squish(spp)) - -### Automatic cleaning -dat<- dat %>% - mutate( - taxa2 = str_squish(spp), - taxa2 = str_remove_all(taxa2," spp\\.| sp\\.| spp|"), - taxa2 = str_to_sentence(str_to_lower(taxa2))) - -## check taxon names against WORMS -#first need to split the dataset into smaller data frames to work with ... -ParentAccount <- dat_spp %>% select(-spp_id) -# split you data in a list of 10 dataframes, each has 465 rows -ParentAccount.ls <- split(ParentAccount, rep(1:10, each = 465)) -# save the files -lapply(names(ParentAccount.ls), - function(x) {write.csv(ParentAccount.ls[[x]], - file = paste("speciesList_split_", x, ".csv", sep = ""))}) - -# Set Survey code -All_srvy_code <- "All-svry" - -clean_auto <- clean_taxa(unique(dat$spp), - input_survey = All_srvy_code, - save = T, output="add", fishbase=T) - -Flags<-anti_join(clean_auto, full_tax, by=c("taxa")) -#28 entries that dont match. But that is ok. If more than 28 unmatches in future then check-spp list - -##merge new and old tax check to see what matches and doesnt match ... -taxa_2<- taxa_2 %>% - mutate( - survey_name = str_squish(survey_name), - survey_name = str_remove_all(survey_name," spp\\.| sp\\.| spp|"), - survey_name = str_to_sentence(str_to_lower(survey_name))) - -merge_tax<-left_join(taxa_2, clean_auto, by=c("survey_name"="query", "valid_name"="taxa")) -merge_tax_v2<-left_join(clean_auto, taxa_2, by=c("query"="survey_name", "taxa"="valid_name")) - -write.csv(merge_tax, "tax_clean_9_29_23.csv") -write.csv(merge_tax_v2, "clean_auto_check.csv") - -missing<-read.csv("missing_taxa_check.csv", sep=",", header=T) %>% - select(survey_name, valid_name, common) - -missing_merge<-left_join(missing, clean_auto, by=c("valid_name"="taxa")) -write.csv(missing_merge, "add_missing_cleaned.csv") - -missing_merge_v2<-left_join(missing, clean_auto, by=c("survey_name"="query")) - -remaining<-read.csv("remaining_missing_spp.csv", sep=",", header=T) -remaining_merge<-left_join(remaining, clean_auto, by=c("survey_name"="query")) -write.csv(remaining_merge, "remaining_worms_matches.csv") diff --git a/data_processing_rcode/code/Update_Filter_Table.R b/data_processing_rcode/code/Update_Filter_Table.R deleted file mode 100644 index 918b326..0000000 --- a/data_processing_rcode/code/Update_Filter_Table.R +++ /dev/null @@ -1,27 +0,0 @@ -##Use this script to update the Filter Table when data is updated, and check if any new species need to be described in the table -Filter_list<-read.csv("Filter_list_Expanded_Survey.csv", header=T, sep=",") - -#change region name for matching with filter table -spp_survey2<-spp_survey -spp_survey2$FilterSubRegion<-ifelse(spp_survey2$region=="Aleutian Islands","Aleutian Islands", - ifelse(spp_survey2$region=="Eastern Bering Sea", "Eastern Bering Sea", - ifelse(spp_survey2$region=="Gulf of Alaska", "Gulf of Alaska", - ifelse(spp_survey2$region=="Bering Sea Combined", "Bering Sea Combined", - ifelse(spp_survey2$region=="Northern Bering Sea", "Northern Bering Sea", - ifelse(spp_survey2$region=="Gulf of Mexico", "Gulf of Mexico", - ifelse(spp_survey2$region=="West Coast Triennial", "West Coast", - ifelse(spp_survey2$region=="West Coast Annual", "West Coast", - ifelse(spp_survey2$region=="Northeast US Spring", "Northeast", - ifelse(spp_survey2$region=="Northeast US Fall", "Northeast", - ifelse(spp_survey2$region=="Southeast US Spring", "Southeast", - ifelse(spp_survey2$region=="Southeast US Summer", "Southeast", - ifelse(spp_survey2$region=="Southeast US Fall", "Southeast", NA))))))))))))) -spp_survey2<- spp_survey2 %>% - select(spp, common, FilterSubRegion) %>% - distinct()%>% - filter(FilterSubRegion!="Bering Sea Combined") - -Filter_updated<-left_join(spp_survey2, Filter_list, by=c("spp", "common", "FilterSubRegion")) -write.csv(Filter_updated, "Filter_list_Expanded_Survey.csv") - - diff --git a/data_processing_rcode/code/clean_taxa.R b/data_processing_rcode/code/clean_taxa.R deleted file mode 100644 index e737fb9..0000000 --- a/data_processing_rcode/code/clean_taxa.R +++ /dev/null @@ -1,315 +0,0 @@ -### NOTE: this script is not working as intended. For some species it doesnt recognzie the species name -#change in WORMS and matches it to the Genus level instead (e.g., Henricia aleutica should match to -#Henricia longispina aleutica but instead matches to the Henricia Genus) - -# ------------------------------------------ # -# Function: clean taxa -# Author: Juliano Palacios Abrantes | j.palacios@oceans.ubc -# Last Updated: June 2021 -# Last Updated: August 2023 -# Update task: worms package is outdated, updating functions to use -# worrms package instead. -# ------------------------------------------ # - ## THIS FUNCTION IS USED IN THE Fix_Taxon_QAQC_data.R script -# ------------# -# Explanation -# ------------# -# This function is used to clean taxa names. It follows a series -# of steps where it i) corrects misspellings, ii) identifies synonyms and -# non-accepted names, iii) gets corrected names and worm's aphia id, iv) gets -# fishbase ID and v) filters out non-fish classes. - -# ------------# -# Inputs -# ------------# -# taxon_list; Expects a list of scientific names or worm's aphia ID (e.g., Gadus morhua or 125342) -# input_survey = "NA", expects a character identifying the survey code (e.g., "CHL") -# save = F, If set to T will save the final output and the non-cleaned taxa -# output = NA, if "over" it will override any previous data identified by input_survey - -# ------------# -# Outputs -# ------------# -# This function returns two main data frames: - -# A data frame with the supplied taxa/aphia id, the valid scientific name and aphia ID, -# fishbase id, kingdom, phylum, class, order,family, genus, and the rank of the supplied -# taxa - -# It also saves a data frame with the taxa that was not identified by the function. Note -# that this result only appears if save = T. - -# ------------# -# Requires -# ------------# -# The following packages are needed for the function to run: "tidyverse","taxize","worrms","here", "worms" -# Note that the function will automatically install any package you need. You do not need -# to call any of the libraries neither. - -# ------------# -# Example -# ------------# - -# # # Test for misspelled species -# taxa <- c("Henricia aleutica","plop","THUNUS ALALONGA", "Octopus vulgaris") -# # Call function -# clean_taxa(taxon_list = taxa, input_survey = "Test", save = T, output = "over") - -# OUTPUT -# Time difference of -3.160841 secs -# query worms_id SpecCode taxa kingdom phylum class order family genus rank survey -# 1 gaduss morhua 126436 69 Gadus morhua Animalia Chordata Actinopterygii Gadiformes Gadidae Gadus Species test - -# ------------# -# Function -# ------------# - -clean_taxa <- function(taxon_list, input_survey = "NA", save = F, output = NA, fishbase=TRUE){ - - # Make sure you have all packages installed - packages_needed <- c("tidyverse","taxize","worrms","here","readr","janitor", - # "worms", - "rfishbase") - install_me <- packages_needed[!(packages_needed %in% installed.packages()[,"Package"])] - - if(length(install_me) > 0){ - print(paste("Installing package(s) <",install_me,"> before running the function")) - install.packages(install_me) - } - - # Start routine - s_time <- Sys.time() - - # Get WoRM's id for sourcing - wrm <- taxize::gnr_datasources() %>% - dplyr::filter(title == "World Register of Marine Species") %>% - dplyr::pull(id) - - ##---------------## - # Worms Names and IDs - ##---------------## - - # Convert to number a numeric character list and get species - if(stringr::str_detect(taxon_list[1],"[1-9]") == TRUE){ - - # Set list to numeric - suppressWarnings( # No need for NAs warning. already taken into consideration - taxon_id <- as.numeric(taxon_list) - ) - # Remove NAs in data (in case you have a mix of spp and codes) - # Will return an error that you should check - taxon_id <- taxon_id[!is.na(taxon_id)] - - # Get discarded aphias - missing_aphiaid <- tibble::tibble( - query = taxon_list) %>% - filter(!query %in% taxon_id) - - - # For some reason `wm_record)()` only works for 50 species, it is unfortunate - # cus it is way faster than `wormsbyid()` which is from worms package - if(length(taxon_id) <= 50){ - alphaid <- worrms::wm_record(taxon_id) %>% - # Select only marine species (NOTE: These are not exclusively marine species) - dplyr::select( - status, - taxa = valid_name, - AphiaID = valid_AphiaID,kingdom:genus,isMarine,rank) %>% - # Include originally supplied taxa - dplyr::mutate( - query = as.character(taxon_id) - ) - }else{ - - # Needs a bit of work because wm_record() only acceopts 50 values - - # Initialize a list to store the results - aphia_results <- list() - - # Loop through the values in batches - for (i in seq(1, length(taxon_id), by = 50)) { - batch <- taxon_id[i:min(i + 50 - 1, length(taxon_id))] - batch_results <- wm_record(batch) - aphia_results <- c(aphia_results, list(batch_results)) - } - - alphaid <- do.call(rbind, aphia_results) %>% - dplyr::select( - status, - taxa = valid_name, - AphiaID = valid_AphiaID,kingdom:genus,isMarine,rank) %>% - # Include originally supplied taxa - dplyr::mutate( - query = as.character(taxon_id) - ) - - } - - - # Get missing data for saving latter - missing_alphaid <- tibble::tibble( - query = as.character(taxon_id)) %>% - dplyr::filter(!query %in% alphaid$query) - - # No misspelling on id - missing_misspelling <- tibble() - missing_misspelling_wrms <- tibble() - - }else{ # close when taxon list is AphaiID - # If scientific names are provided, check synonyms and get correct name and ID - # NOTE: it takes longer because it goes trough a - # series of checkpoints a taxon validation - - - # If scientific names are provided, check misspelling - fix_taxon <- taxize::gnr_resolve(taxon_list, - data_source_ids = wrm, - best_match_only = TRUE, - canonical = TRUE, - ask = FALSE) %>% - # dplyr::filter(score > 0.98) %>% - dplyr::select( - query = user_supplied_name, - taxa = matched_name2) - - # # Missing in fix_taxon - missing_misspelling <- tibble::tibble( - query = taxon_list) %>% - dplyr::filter(!query %in% fix_taxon$query) - - # Make a batch loop to deal with curl_fetch_memory HTTP and internal errors of webpage - - # Initialize an empty list to store the results - all_results <- list() - - # Process in batches - for (i in seq(1, length(fix_taxon$taxa), by = 50)) { - batch <- fix_taxon$taxa[i:min(i + 50 - 1, length(fix_taxon$taxa))] - results <- worrms::wm_records_names(batch) - all_results <- append(all_results, results) - } - - - alphaid <- dplyr::bind_rows(all_results) %>% - dplyr::select(scientificname,status,AphiaID = valid_AphiaID,taxa = valid_name,kingdom:genus, isMarine,rank) %>% - left_join(fix_taxon, - by = "taxa", - relationship = "many-to-many") %>% - dplyr::mutate(query = ifelse(is.na(query),scientificname,query)) %>% - select(-scientificname) - - # Missing in fix_taxon - missing_misspelling_wrms <- alphaid %>% - # For when the name has multiple wrong outputs - arrange(status) %>% - dplyr::filter(status == "unaccepted") %>% - dplyr::distinct(query,.keep_all = T) %>% - dplyr::select(query) - - # Missing in AphiaIDs - missing_alphaid <- alphaid %>% - dplyr::filter(is.na(AphiaID) | AphiaID == -999) %>% - dplyr::select(query) - - } # close else of species names - - - ##---------------## - # Filter out unwanted records - ##---------------## - - worms_db <- alphaid %>% - # Select only marine species (NOTE: These are not exclusively marine species) - dplyr::filter( - isMarine > 0) %>% - arrange(status) %>% - dplyr::select(-isMarine, - -status) %>% - dplyr::distinct(query,.keep_all = T) - - missing_salt_fish <- alphaid %>% - # Select only marine species (NOTE: These are not exclusively marine species) - dplyr::filter(is.na(isMarine) | isMarine != 1) %>% - dplyr::select(-isMarine) # we don't really need this - - - ##---------------## - # Get fishbase id - ##---------------## - - if(fishbase==TRUE){ - suppressMessages( - fishbase_id <- rfishbase::species(worms_db$taxa, server = "fishbase") %>% - dplyr::select(SpecCode, - taxa = Species) - ) - } else { - fishbase_id <- data.frame(taxa = worms_db$taxa) %>% - dplyr::mutate(SpecCode = NA) - } - - # Filter out unwanted fish - - - # worms_db_selection <- worms_db %>% - # # remove non-fish species (a.k.a. invertebrates, mammals...) - # dplyr::filter(class %in% c("Elasmobranchii","Actinopterygii","Holocephali","Myxini", - # "Petromyzonti", "Actinopteri", "Teleostei", "Holostei", - # "Chondrostei") - # ) - - - # suppressMessages( - # missing_worms_db_selection <- anti_join(worms_db,worms_db_selection) %>% - # select(query, taxa) - # ) - - - - ##---------------## - # Final Database - ##---------------## - - # Final clean output data frame - fishbase_id <- unique(fishbase_id) - output_df <- dplyr::left_join(worms_db, fishbase_id, by = "taxa") %>% - # rest of selection - dplyr::distinct() %>% - dplyr::select( - query, - worms_id = AphiaID, - SpecCode, - everything() - ) %>% - dplyr::mutate(survey = input_survey) - - # Get Missing information - missing_data <- dplyr::bind_rows(missing_alphaid,missing_misspelling) - - - # Feedback message - if(nrow(worms_db) != nrow(missing_data)){ - n_dropped <- nrow(missing_data) - # print(paste("Dropped",n_dropped,"non-fish/non-marine taxa")) - } - - - ##---------------## - # Save data - ##---------------## - - if(save == TRUE){ - write.csv(output_df, "output/taxa_qaqc/clean_taxon.csv") - write.csv(missing_data, "output/taxa_qaqc/missing_taxon.csv") - } - - - # Misc, - if(exists("n_dropped")==FALSE){n_dropped <- 0} - if(exists("missing_misspelling")==FALSE){n_misspell <- 0}else{n_misspell <- nrow(missing_misspelling_wrms)+nrow(missing_misspelling)} - print(paste0("Returned ", nrow(output_df), " taxa and dropped ",n_dropped,". Misspelled taxa: ",n_misspell,"; No alphia id found: ",nrow(missing_alphaid),"; Non-marine taxa: ", nrow(missing_salt_fish)," All taxa assessed =", nrow(output_df) + n_dropped == length(taxon_list))) - e_time <- Sys.time() - print(s_time-e_time) - return(output_df) - -} diff --git a/data_processing_rcode/code/create_data_for_map_generation.R b/data_processing_rcode/code/create_data_for_map_generation.R deleted file mode 100644 index eaad535..0000000 --- a/data_processing_rcode/code/create_data_for_map_generation.R +++ /dev/null @@ -1,87 +0,0 @@ - -OUTPUT_CSV_DIRECTORY = "~/transfer/DisMAP project/DisMAP/data_processing_rcode/output/python" - -# dat.exploded should have already be created - -print ("[Local]: CSV Tables are being prepped.") -ai_csv = dat.exploded[dat.exploded$region %in% c('Aleutian Islands'),] -ebs_csv = dat.exploded[dat.exploded$region %in% c('Eastern Bering Sea'),] -goa_csv = dat.exploded[dat.exploded$region %in% c('Gulf of Alaska'),] -nbs_csv = dat.exploded[dat.exploded$region %in% c('Northern Bering Sea'),] -enbs_csv = dat.exploded[dat.exploded$region %in% c('Bering Sea Combined'),] - -neusS_csv = dat.exploded[dat.exploded$region %in% c('Northeast US Spring'),] -neusf_csv = dat.exploded[dat.exploded$region %in% c('Northeast US Fall'),] - -wctri_csv = dat.exploded[dat.exploded$region %in% c('West Coast Triennial'),] -wcann_csv = dat.exploded[dat.exploded$region %in% c('West Coast Annual'),] - -gmex_csv = dat.exploded[dat.exploded$region %in% c('Gulf of Mexico'),] - -seus_spr_csv = dat.exploded[dat.exploded$region %in% c('Southeast US Spring'),] -seus_sum_csv = dat.exploded[dat.exploded$region %in% c('Southeast US Summer'),] -seus_fal_csv = dat.exploded[dat.exploded$region %in% c('Southeast US Fall'),] - -print ("[Local]: CSV Tables prepped.") -write.csv(ai_csv, file.path(OUTPUT_CSV_DIRECTORY, "AI_survey.csv")) -print ("[Local]: ai_csv.csv output successfully") -write.csv(ebs_csv, file.path(OUTPUT_CSV_DIRECTORY, "EBS_survey.csv")) -print ("[Local]: ebs_csv.csv output successfully") -write.csv(goa_csv, file.path(OUTPUT_CSV_DIRECTORY, "GOA_survey.csv")) -print ("[Local]: goa_csv.csv output successfully") -write.csv(nbs_csv, file.path(OUTPUT_CSV_DIRECTORY, "NBS_survey.csv")) -print ("[Local]: nbs_csv.csv output successfully") -write.csv(enbs_csv, file.path(OUTPUT_CSV_DIRECTORY, "ENBS_survey.csv")) -print ("[Local]: enbs_csv.csv output successfully") - -write.csv(neusS_csv, file.path(OUTPUT_CSV_DIRECTORY, "NEUS_SPR_survey.csv")) -print ("[Local]: neus_csv.csv output successfully") -write.csv(neusf_csv, file.path(OUTPUT_CSV_DIRECTORY, "NEUS_FAL_survey.csv")) -print ("[Local]: neusf_csv.csv output successfully") - -write.csv(wctri_csv, file.path(OUTPUT_CSV_DIRECTORY, "WC_TRI_survey.csv")) -print ("[Local]: wctri_csv.csv output successfully") -write.csv(wcann_csv, file.path(OUTPUT_CSV_DIRECTORY, "WC_ANN_survey.csv")) -print ("[Local]: wcann_csv.csv output successfully") - -write.csv(gmex_csv, file.path(OUTPUT_CSV_DIRECTORY, "GMEX_survey.csv")) -print ("[Local]: gmex_csv.csv output successfully") - -write.csv(seus_spr_csv, file.path(OUTPUT_CSV_DIRECTORY, "SEUS_SPR_survey.csv")) -print ("[Local]: seus_spr_csv.csv output successfully") -write.csv(seus_sum_csv, file.path(OUTPUT_CSV_DIRECTORY, "SEUS_SUM_survey.csv")) -print ("[Local]: seus_sum_csv.csv output successfully") -write.csv(seus_fal_csv, file.path(OUTPUT_CSV_DIRECTORY, "SEUS_FAL_survey.csv")) -print ("[Local]: seus_fal_csv.csv output successfully") - -## Old script for generated the data for IDW... the new script has file name change b/c its the expanded survey data -# write.csv(ai_csv, file.path(OUTPUT_CSV_DIRECTORY, "AI_IDW.csv")) -# print ("[Local]: ai_csv.csv output successfully") -# write.csv(ebs_csv, file.path(OUTPUT_CSV_DIRECTORY, "EBS_IDW.csv")) -# print ("[Local]: ebs_csv.csv output successfully") -# write.csv(goa_csv, file.path(OUTPUT_CSV_DIRECTORY, "GOA_IDW.csv")) -# print ("[Local]: goa_csv.csv output successfully") -# write.csv(nbs_csv, file.path(OUTPUT_CSV_DIRECTORY, "NBS_IDW.csv")) -# print ("[Local]: nbs_csv.csv output successfully") -# write.csv(enbs_csv, file.path(OUTPUT_CSV_DIRECTORY, "ENBS_IDW.csv")) -# print ("[Local]: enbs_csv.csv output successfully") -# -# write.csv(neusS_csv, file.path(OUTPUT_CSV_DIRECTORY, "NEUS_SPR_IDW.csv")) -# print ("[Local]: neus_csv.csv output successfully") -# write.csv(neusf_csv, file.path(OUTPUT_CSV_DIRECTORY, "NEUS_FAL_IDW.csv")) -# print ("[Local]: neusf_csv.csv output successfully") -# -# write.csv(wctri_csv, file.path(OUTPUT_CSV_DIRECTORY, "WC_TRI_IDW.csv")) -# print ("[Local]: wctri_csv.csv output successfully") -# write.csv(wcann_csv, file.path(OUTPUT_CSV_DIRECTORY, "WC_ANN_IDW.csv")) -# print ("[Local]: wcann_csv.csv output successfully") -# -# write.csv(gmex_csv, file.path(OUTPUT_CSV_DIRECTORY, "GMEX_IDW.csv")) -# print ("[Local]: gmex_csv.csv output successfully") -# -# write.csv(seus_spr_csv, file.path(OUTPUT_CSV_DIRECTORY, "SEUS_SPR_IDW.csv")) -# print ("[Local]: seus_spr_csv.csv output successfully") -# write.csv(seus_sum_csv, file.path(OUTPUT_CSV_DIRECTORY, "SEUS_SUM_IDW.csv")) -# print ("[Local]: seus_sum_csv.csv output successfully") -# write.csv(seus_fal_csv, file.path(OUTPUT_CSV_DIRECTORY, "SEUS_FAL_IDW.csv")) -# print ("[Local]: seus_fal_csv.csv output successfully") \ No newline at end of file diff --git a/data_processing_rcode/code/download_ak.R b/data_processing_rcode/code/download_ak.R deleted file mode 100644 index e35866b..0000000 --- a/data_processing_rcode/code/download_ak.R +++ /dev/null @@ -1,193 +0,0 @@ -# This function can be used to download the most recent survey data files for the AK regions and -# put them in the data folder. -# The ai_strata.csv, ebs_strata.csv, and goa_strata.csv do not change year to year, and should be retained -# between updates (do not delete these files) - -# Resources -------------------------------------------------------------------- - -# https://www.fisheries.noaa.gov/alaska/science-data/groundfish-assessment-program-bottom-trawl-surveys -# adatapted from https://afsc-gap-products.github.io/gap_products/content/foss-api-r.html#haul-data -# Last updated by April 21, 2025 by Emily Markowitz, AFSC - -# Install libraries ------------------------------------------------------------ - -library(dplyr) -library(httr) -library(jsonlite) -options(scipen = 999) - -# Download data from FOSS API -------------------------------------------------- - -## Download Haul Data ---------------------------------------------------------- - -dat <- data.frame() -for (i in seq(0, 500000, 10000)){ - # print(i) - ## query the API link - res <- httr::GET(url = paste0('https://apps-st.fisheries.noaa.gov/ods/foss/afsc_groundfish_survey_haul/', - "?offset=",i,"&limit=10000")) - ## convert from JSON format - data <- jsonlite::fromJSON(base::rawToChar(res$content)) - - ## if there are no data, stop the loop - if (is.null(nrow(data$items))) { - break - } - - ## bind sub-pull to dat data.frame - dat <- dplyr::bind_rows(dat, - data$items %>% - dplyr::select(-links)) # necessary for API accounting, but not part of the dataset) -} -haul <- dat %>% - dplyr::mutate(date_time = as.POSIXct(date_time, - format = "%Y-%m-%dT%H:%M:%S", - tz = Sys.timezone())) - -# mostly for testing, but also nice to have it organized -haul <- haul[order(haul$hauljoin), ] - -write.csv(x = haul, - here::here("data_processing_rcode/data/AK_gap_products_foss_haul.csv")) - -## Download Species Data ------------------------------------------------------- - -res <- httr::GET(url = paste0('https://apps-st.fisheries.noaa.gov/ods/foss/afsc_groundfish_survey_species/', - "?offset=0&limit=10000")) # , '&q={"species_code":{"$lt":32000}}')) - -## convert from JSON format -data <- jsonlite::fromJSON(base::rawToChar(res$content)) -catch_spp <- data$items %>% - dplyr::select(-links) # necessary for API accounting, but not part of the dataset - -catch_spp <- catch_spp %>% - dplyr::filter(species_code < 32000) # dplyr::filter(species_code < 32000 | species_code %in% c(69323, 69322, 68580)) - -write.csv(x = catch_spp, - here::here("data_processing_rcode/data/AK_gap_products_foss_species.csv")) - -## Download Catch Data --------------------------------------------------------- -# pull only the data in the catch_spp list (which currently includes species codes below 32000) - -dat <- data.frame() -for (ii in 1:nrow(catch_spp)) { -for (i in seq(0, 1000000, 10000)){ - ## find how many iterations it takes to cycle through the data - print(i) - ## query the API link - res <- httr::GET(url = paste0("https://apps-st.fisheries.noaa.gov/ods/foss/afsc_groundfish_survey_catch/", - "?offset=",i,"&limit=10000", '&q={"species_code":',catch_spp$species_code[ii],'}')) # '&q={"species_code":{"$lt":32000}}' - ## convert from JSON format - data <- jsonlite::fromJSON(base::rawToChar(res$content)) - - ## if there are no data, stop the loop - if (is.null(nrow(data$items))) { - break - } - - ## bind sub-pull to dat data.frame - dat <- dplyr::bind_rows(dat, - data$items %>% - dplyr::select(-links)) # necessary for API accounting, but not part of the dataset) -} -} -catch <- unique(dat) - -# mostly for testing, but also nice to have it organized -catch <- catch[order(catch$species_code), ] -catch <- catch[order(catch$hauljoin), ] - -write.csv(x = catch, - here::here("data_processing_rcode/data/AK_gap_products_foss_catch.csv")) - -############ Testing # April 21, 2025 -dim(catch) -# 438608 7 -summary(catch) -# hauljoin species_code cpue_kgkm2 cpue_nokm2 count weight_kg taxon_confidence -# Min. : -23911 Min. : 1 Min. : 0 Min. : 14 Min. : 1.0 Min. : 0.001 Length:438608 -# 1st Qu.: -14310 1st Qu.:10130 1st Qu.: 25 1st Qu.: 64 1st Qu.: 2.0 1st Qu.: 0.872 Class :character -# Median : -4750 Median :20510 Median : 171 Median : 243 Median : 9.0 Median : 5.900 Mode :character -# Mean : 284057 Mean :16337 Mean : 2236 Mean : 4437 Mean : 154.4 Mean : 71.638 -# 3rd Qu.: 802455 3rd Qu.:21740 3rd Qu.: 897 3rd Qu.: 1307 3rd Qu.: 46.0 3rd Qu.: 31.320 -# Max. :1225635 Max. :30600 Max. :3226235 Max. :4481702 Max. :47118.0 Max. :18187.700 -# NA's :943 NA's :943 - -# ### Download Catch Data - Alt -------------------------------------------------- -# # pull all data and crop to the species codes less than 32000 -# -# dat <- data.frame() -# for (i in seq(0, 1000000, 10000)){ -# ## find how many iterations it takes to cycle through the data -# print(i) -# ## query the API link -# res <- httr::GET(url = paste0("https://apps-st.fisheries.noaa.gov/ods/foss/afsc_groundfish_survey_catch/", -# "?offset=",i,"&limit=10000")) # '&q={"species_code":{"$lt":32000}}' -# ## convert from JSON format -# data <- jsonlite::fromJSON(base::rawToChar(res$content)) -# -# ## if there are no data, stop the loop -# if (is.null(nrow(data$items))) { -# break -# } -# -# ## bind sub-pull to dat data.frame -# dat <- dplyr::bind_rows(dat, -# data$items %>% -# dplyr::select(-links)) # necessary for API accounting, but not part of the dataset) -# } -# -# -# -# catch <- dat %>% -# dplyr::filter(species_code < 32000) %>% -# unique() -# -# ############ Testing # April 21, 2025 -# # all data -# dim(dat) -# # 891144 7 -# summary(dat) -# # hauljoin species_code cpue_kgkm2 cpue_nokm2 count weight_kg taxon_confidence -# # Min. : -23911 Min. : 1 Min. : 0 Min. : 13 Min. : 1.0 Min. : 0.001 Length:891144 -# # 1st Qu.: -14439 1st Qu.:20510 1st Qu.: 6 1st Qu.: 58 1st Qu.: 2.0 1st Qu.: 0.199 Class :character -# # Median : -5267 Median :40500 Median : 49 Median : 214 Median : 8.0 Median : 1.814 Mode :character -# # Mean : 280338 Mean :45195 Mean : 1250 Mean : 4605 Mean : 180.5 Mean : 41.720 -# # 3rd Qu.: 802426 3rd Qu.:71800 3rd Qu.: 372 3rd Qu.: 1137 3rd Qu.: 43.0 3rd Qu.: 13.780 -# # Max. :1225635 Max. :99999 Max. :3226235 Max. :21780780 Max. :867119.0 Max. :18187.700 -# # NA's :87811 NA's :87811 -# -# ############ Testing # April 21, 2025 -# # data cropped to species codes of interest -# dim(catch) -# # 438608 7 -# summary(catch) -# # hauljoin species_code cpue_kgkm2 cpue_nokm2 count weight_kg taxon_confidence -# # Min. : -23911 Min. : 1 Min. : 0 Min. : 14 Min. : 1.0 Min. : 0.001 Length:438608 -# # 1st Qu.: -14310 1st Qu.:10130 1st Qu.: 25 1st Qu.: 64 1st Qu.: 2.0 1st Qu.: 0.872 Class :character -# # Median : -4750 Median :20510 Median : 171 Median : 243 Median : 9.0 Median : 5.900 Mode :character -# # Mean : 284057 Mean :16337 Mean : 2236 Mean : 4437 Mean : 154.4 Mean : 71.638 -# # 3rd Qu.: 802455 3rd Qu.:21740 3rd Qu.: 897 3rd Qu.: 1307 3rd Qu.: 46.0 3rd Qu.: 31.320 -# # Max. :1225635 Max. :30600 Max. :3226235 Max. :4481702 Max. :47118.0 Max. :18187.700 -# # NA's :943 NA's :943 -# -# # mostly for testing, but also nice to have it organized -# catch <- catch[order(catch$species_code), ] -# catch <- catch[order(catch$hauljoin), ] -# -# write.csv(x = catch, -# here::here("data_processing_rcode/data/AK_gap_products_foss_catch.csv")) - -# # Zero-Filled Data ----------------------------------------------------------- -# -# dat <- dplyr::full_join( -# haul, -# catch) %>% -# dplyr::full_join( -# catch_spp) %>% -# # modify zero-filled rows -# dplyr::mutate( -# cpue_kgkm2 = ifelse(is.na(cpue_kgkm2), 0, cpue_kgkm2), -# cpue_nokm2 = ifelse(is.na(cpue_nokm2), 0, cpue_nokm2), -# count = ifelse(is.na(count), 0, count), -# weight_kg = ifelse(is.na(weight_kg), 0, weight_kg)) diff --git a/data_processing_rcode/code/download_gmex.R b/data_processing_rcode/code/download_gmex.R deleted file mode 100644 index 5baf013..0000000 --- a/data_processing_rcode/code/download_gmex.R +++ /dev/null @@ -1,12 +0,0 @@ -# Visit the [Gulf of Mexico]("https://seamap.gsmfc.org/") website -# Click "Download" the SEAMAP Trawl/Plankton, Bottom Longline -# Fill in the form ("Scientific Research", "Educational Institution", "Trawl/Plankton Data (CSV)" -# Unzip the CSV in your downloads folder -# then copy them into the data_raw folder with the script below - -file.copy(from = "C:/Users/Melissa.Karp//Downloads/public_seamap_csvs/public_seamap_csvs/BGSREC.csv", to = "C:/Users/Melissa.Karp/Documents/transfer/DisMAP project/DisMAP/data_processing_rcode/data/gmex_BGSREC.csv", overwrite = T) -file.copy(from = "C:/Users/Melissa.Karp//Downloads/public_seamap_csvs/public_seamap_csvs/CRUISES.csv", to = "C:/Users/Melissa.Karp/Documents/transfer/DisMAP project/DisMAP/data_processing_rcode/data/gmex_CRUISES.csv", overwrite = T) -file.copy(from = "C:/Users/Melissa.Karp//Downloads/public_seamap_csvs/public_seamap_csvs/STAREC.csv", to = "C:/Users/Melissa.Karp/Documents/transfer/DisMAP project/DisMAP/data_processing_rcode/data/gmex_STAREC.csv", overwrite = T) -file.copy(from = "C:/Users/Melissa.Karp//Downloads/public_seamap_csvs/public_seamap_csvs/INVREC.csv", to = "C:/Users/Melissa.Karp/Documents/transfer/DisMAP project/DisMAP/data_processing_rcode/data/gmex_INVREC.csv", overwrite = T) -#file.copy(from = "C:/Users/Melissa.Karp//Downloads/public_seamap_csvs/public_seamap_csvs/NEWBIOCODESBIG.csv", to = "C:/Users/Melissa.Karp/Documents/transfer/DisMAP project/DisMAP/data_processing_rcode/data_raw/gmex_NEWBIOCODESBIG_2024.csv", overwrite = T) -#Note: for the updated BioCodes table need to reach out to David Hanisko at the SEFSC \ No newline at end of file diff --git a/data_processing_rcode/code/download_neus.R b/data_processing_rcode/code/download_neus.R deleted file mode 100644 index d94b723..0000000 --- a/data_processing_rcode/code/download_neus.R +++ /dev/null @@ -1,66 +0,0 @@ -#' --- -#' title: "Download NEUS" -#' --- -## As of 2023 the NEFSC is changing how they host their data, so for now need to reach out directly to: -## Philip Politis and Catherine Foley to get the data (Jan of each year) - - - -### NO LONGER WHERE DATA IS STORED -#' Download the spring and fall bottom trawl survey files from below links using the WinSCP app and save the zipped file to data_raw folder -#' [Fall] -#' (https://inport.nmfs.noaa.gov/inport/item/22560) -- go to the Distribution 1 and 2 links to get the files (note: only seems to work in internet explorer or Edge) -#' [Distribution 1](ftp://ftp.nefsc.noaa.gov/pub/dropoff/PARR/PEMAD/ESB/22560/) -#' [Distribution 2](ftp://ftp.nefsc.noaa.gov/pub/dropoff/PARR/PEMAD/ESB/SVDBS/)# this doesn't change year to year so don't need to download -#' -#' [Spring] -#' (https://inport.nmfs.noaa.gov/inport/item/22561). -#' [Distribution 1](ftp://ftp.nefsc.noaa.gov/pub/dropoff/PARR/PEMAD/ESB/22561) -#' [Distribution 2](ftp://ftp.nefsc.noaa.gov/pub/dropoff/PARR/PEMAD/ESB/SVDBS) ## this is same as Fall so only need to download one of them - - -## ----neus---------------------------------------------------------------- -unzip(here("data_raw/SVDBS_SupportTables.zip"), exdir = here("data_raw")) -svdbs <- dir(pattern = "SVDBS", path = "data_raw", full.names = T) -svdbs <- svdbs[-c(grep("STRATA|SPECIES|Support", svdbs))] - -file.rename(here::here("data_raw", "SVDBS_SVMSTRATA.csv"), here::here("data_raw", "neus_strata.csv")) -file.rename(here::here("data_raw", "SVDBS_SVSPECIES_LIST.csv"), here::here("data_raw", "neus_spp.csv")) - - -unzip(here("data_raw/22560_NEFSCFallFisheriesIndependentBottomTrawlData.zip"), exdir = here("data_raw")) -unzip(here("data_raw/22561_NEFSCSpringFisheriesIndependentBottomTrawlData.zip"), exdir = here("data_raw")) - -#Fall -file.rename(here::here("data_raw","22560_UNION_FSCS_SVSTA.csv"), here::here( "data_raw","neus_fall_svsta.csv")) -file.rename(here::here( "data_raw","22560_UNION_FSCS_SVCAT.csv"), here::here( "data_raw","neus_fall_svcat.csv")) -#Spring -file.rename(here::here( "data_raw","22561_UNION_FSCS_SVSTA.csv"), here::here( "data_raw","neus_spring_svsta.csv")) -file.rename(here::here( "data_raw","22561_UNION_FSCS_SVCAT.csv"), here::here( "data_raw","neus_spring_svcat.csv")) - -#Remove unnecessary/duplicate files -other <- dir(pattern = "FSCS_", path = "data_raw", full.names = T) -file.remove(other) -file.remove(svdbs) - -## old code that doesnt work -# library(here) -# install.packages("RCurl") -# library(RCurl) -# install.packages("curl") -# library(curl) -# ##download the files -# #Fall -# url_fall_1<- "ftp://ftp.nefsc.noaa.gov/pub/dropoff/PARR/PEMAD/ESB/22561" -# url_fall_2<- "ftp://ftp.nefsc.noaa.gov/pub/dropoff/PARR/PEMAD/ESB/SVDBS/" -# -# fall_filenames_1 <-getURL(url_fall_1, ftp.use.epsv=FALSE, dirlistonly=TRUE) -# fall_filenames_1 <- strsplit(fall_filenames_1, "\r\n") -# fall_filenames_1 <- unlist(fall_filenames_1) -# -# for (filename in fall_filenames_1) { -# download.file(paste(url_fall_1, filename, sep=""), paste(getwd(), "/", filename, sep="")) -# } -# -# options(download.file.method="libcurl", url.method="libcurl") -# source("ftp://ftp.nefsc.noaa.gov/pub/dropoff/PARR/PEMAD/ESB/22561") \ No newline at end of file diff --git a/data_processing_rcode/code/download_seus.R b/data_processing_rcode/code/download_seus.R deleted file mode 100644 index d25c034..0000000 --- a/data_processing_rcode/code/download_seus.R +++ /dev/null @@ -1,17 +0,0 @@ -## For [SEUS] -# 1. Using Chrome or Firefox (not Safari) visit the website: ("https://www2.dnr.sc.gov/seamap/Account/LogOn?ReturnUrl=%2fseamap%2fReports") -# 2. Login by creating your own account. -# 3. Click on Coastal Trawl Survey Extraction. -# 4. Select "Event Information" from the drop down menu. -# 5. For all of the remaining boxes, click on the <- arrow on the upper right side of each box to move all options over to the left. Sometimes these pop back over to the right so wait a while to make sure everything sticks. -# 6. Click create report. -# 7. Update the line below to point to the downloaded file to wherever your file downloaded and whatever it was named, pay attention that the EVENT file stays on the event line and the ABUNDANCE file stays on the abundance line. -# 8. repeat steps 4-7 for the dropdown menu item "Abundance and Biomass". - -#ABUNDANCE = catch -#EVENT = haul - -file.copy(from = "C:/Users/Melissa.Karp//Downloads/makarp.Coastal Survey.ABUNDANCEBIOMASS.2024-05-02T11.18.49.csv", to = "C:/Users/Melissa.Karp/Documents/transfer/DisMAP project/DisMAP/data_processing_rcode/data/seus_catch.csv", overwrite = T) -file.copy(from = "C:/Users/Melissa.Karp//Downloads/makarp.Coastal Survey.EVENT.2024-05-02T11.00.31.csv", to = "C:/Users/Melissa.Karp/Documents/transfer/DisMAP project/DisMAP/data_processing_rcode/data/seus_haul.csv", overwrite = T) - -##Note, for some reason the above code is not working, so may need to manually move the files over the appropriate folder diff --git a/data_processing_rcode/code/download_wcann.R b/data_processing_rcode/code/download_wcann.R deleted file mode 100644 index c44ab6d..0000000 --- a/data_processing_rcode/code/download_wcann.R +++ /dev/null @@ -1,31 +0,0 @@ -# WCANN download ---- -# info about West Coast api: https://www.nwfsc.noaa.gov/data/api/v1/source -library(readr) -library(jsonlite) -library(here) -library(httr) - -wcann_save_loc <- "data" -save_date <- Sys.Date() -catch_file_name <- paste("wcann", "catch.csv", sep="_") -haul_file_name <- paste("wcann", "haul.csv", sep="_") - -# url_catch <- "https://www.webapps.nwfsc.noaa.gov/data/api/v1/source/trawl.catch_fact/selection.json?filters=project=Groundfish%20Slope%20and%20Shelf%20Combination%20Survey,date_dim$year>=2003" #updated URL in March 2021 -# data_catch <- jsonlite::fromJSON(url_catch) - -url_catch <- "https://www.webapps.nwfsc.noaa.gov/data/api/v1/source/trawl.catch_fact/selection.json?filters=project=Groundfish%20Slope%20and%20Shelf%20Combination%20Survey,date_dim$year>=2003" -header_type <- "applcation/json" -response<-GET(url_catch) -text_json <- content(response, type = 'text', encoding = "UTF-8") -jfile <- fromJSON( text_json) -data_catch <- as.data.frame(jfile) - -url_haul <- "https://www.webapps.nwfsc.noaa.gov/data/api/v1/source/trawl.operation_haul_fact/selection.json?filters=project=Groundfish%20Slope%20and%20Shelf%20Combination%20Survey,date_dim$year>=2003" #updated URL in March 2021 -data_haul <- jsonlite::fromJSON(url_haul) - - -write.csv(data_catch, here::here(wcann_save_loc, catch_file_name)) -write.csv(data_haul, here::here(wcann_save_loc, haul_file_name)) -### NOTE: the above urls download files with different columns then if go directly to the FRAM site and click on the CSV next to the table type. This way has more column names, including Temperature - - diff --git a/data_processing_rcode/code/empty.txt b/data_processing_rcode/code/empty.txt deleted file mode 100644 index e69de29..0000000 diff --git a/data_processing_rcode/data/empty.txt b/data_processing_rcode/data/empty.txt deleted file mode 100644 index e69de29..0000000 diff --git a/data_processing_rcode/output/data_clean/empty b/data_processing_rcode/output/data_clean/empty deleted file mode 100644 index 8b13789..0000000 --- a/data_processing_rcode/output/data_clean/empty +++ /dev/null @@ -1 +0,0 @@ - diff --git a/data_processing_rcode/output/empty.txt b/data_processing_rcode/output/empty.txt deleted file mode 100644 index e69de29..0000000 diff --git a/data_processing_rcode/output/plots/empty b/data_processing_rcode/output/plots/empty deleted file mode 100644 index 8b13789..0000000 --- a/data_processing_rcode/output/plots/empty +++ /dev/null @@ -1 +0,0 @@ - diff --git a/data_processing_rcode/output/python/empty b/data_processing_rcode/output/python/empty deleted file mode 100644 index 8b13789..0000000 --- a/data_processing_rcode/output/python/empty +++ /dev/null @@ -1 +0,0 @@ - diff --git a/data_processing_rcode/spp_taxonomy_mater_key.csv b/data_processing_rcode/spp_taxonomy_mater_key.csv deleted file mode 100644 index 4a9ab2b..0000000 --- a/data_processing_rcode/spp_taxonomy_mater_key.csv +++ /dev/null @@ -1,5247 +0,0 @@ -survey_name,accepted_name,common,kingdom,phylum,class,order,family,genus,rank,worms_id,SpecCode,filtercat,,,,,,, -Abietinaria,Abietinaria,NA,Animalia,Cnidaria,Hydrozoa,Leptothecata,Sertulariidae,Abietinaria,Genus,117225,NA,Remove,,,,,,, -Abietinaria sp.,Abietinaria,NA,Animalia,Cnidaria,Hydrozoa,Leptothecata,Sertulariidae,Abietinaria,Genus,117226,NA,Remove,,,,,,, -Abietinaria sp. A (Clark 2006),Abietinaria sp. A (Clark 2006),white tangled hydroid,Animalia,Cnidaria,Hydrozoa,Leptothecata,Sertulariidae,Abietinaria,Species,NA,NA,Species,,,,,,, -Abisa,Abisa,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Ablennes hians,Ablennes hians,Flat needlefish,Animalia,Chordata,Teleostei,Beloniformes,Belonidae,Ablennes,Species,159246,972,Species,,,,,,, -Abralia redfieldi,Abralia redfieldi,Redfield's enope squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Enoploteuthidae,Abralia,Species,341837,NA,Species,,,,,,, -Abralia veranyi,Abralia veranyi,Eye flash squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Enoploteuthidae,Abralia,Species,139688,NA,Species,,,,,,, -Abraliopsis felis,Abraliopsis felis,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Enoploteuthidae,Abraliopsis,Species,341849,NA,Species,,,,,,, -Abudefduf saxatilis,Abudefduf saxatilis,Sergeant major,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Abudefduf,Species,159288,1119,Species,,,,,,, -Esperiopsis flagrum,Abyssocladia flagrum,Cheesestick sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Esperiopsidae,Esperiopsis,Species,864174,NA,Species,,,,,,, -Abyssocladia flagrum,Abyssocladia flagrum,Cheesestick sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Esperiopsidae,Esperiopsis,Species,864175,NA,Species,,,,,,, -Acanthascus,Acanthascus,NA,Animalia,Porifera,Hexactinellida,Lyssacinosida,Rossellidae,Acanthascus,Genus,171966,NA,Remove,,,,,,, -Acanthascus sp.,Acanthascus,NA,Animalia,Porifera,Hexactinellida,Lyssacinosida,Rossellidae,Acanthascus,Genus,171967,NA,Remove,,,,,,, -Rhabdocalyptus,Acanthascus (Rhabdocalyptus),NA,Animalia,Porifera,Hexactinellida,Lyssacinosida,Rossellidae,Rhabdocalyptus,Genus,171972,NA,Remove,,,,,,, -Staurocalyptus,Acanthascus (Staurocalyptus),NA,Animalia,Porifera,Hexactinellida,Lyssacinosida,Rossellidae,Staurocalyptus,Genus,171991,NA,Remove,,,,,,, -Acanthascus sp. A,Acanthascus sp. A,angel-hair vase sponge,Animalia,Porifera,Hexactinellida,Lyssacinosida,Rossellidae,Acanthascus,Species,NA,NA,Species,,,,,,, -Acanthascus sp. B,Acanthascus sp. B,thin-lipped vase sponge,Animalia,Porifera,Hexactinellida,Lyssacinosida,Rossellidae,Acanthascus,Species,NA,NA,Species,,,,,,, -Acanthephyra,Acanthephyra,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Acanthephyridae,Acanthephyra,Genus,107018,NA,Remove,,,,,,, -Acanthephyra curtirostris,Acanthephyra curtirostris,Peaked shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Acanthephyridae,Acanthephyra,Species,107579,NA,Species,,,,,,, -Iliacantha intermedia,Acanthilia intermedia,Granulose purse crab,Animalia,Arthropoda,Malacostraca,Decapoda,Leucosiidae,Iliacantha,Species,421926,NA,Species,,,,,,, -Acanthilia intermedia,Acanthilia intermedia,Granulose purse crab,Animalia,Arthropoda,Malacostraca,Decapoda,Leucosiidae,Iliacantha,Species,421926,NA,Species,,,,,,, -Acanthocarpus,Acanthocarpus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Acanthocarpus,Genus,106872,NA,Remove,,,,,,, -Acanthocarpus alexandri,Acanthocarpus alexandri,Gladiator box crab,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Acanthocarpus,Species,158044,NA,Species,,,,,,, -Acantholiparis opercularis,Acantholiparis opercularis,Spiny snailfish,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Acanthocarpus,Species,279480,NA,Species,,,,,,, -Acantholithodes,Acantholithodes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Hapalogastridae,Acantholithodes,Genus,590102,NA,Remove,,,,,,, -Acantholithodes sp.,Acantholithodes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Hapalogastridae,Acantholithodes,Genus,590103,NA,Remove,,,,,,, -Acantholithodes hispidus,Acantholithodes hispidus,Spiny lithode crab,Animalia,Arthropoda,Malacostraca,Decapoda,Hapalogastridae,Acantholithodes,Species,590103,NA,Species,,,,,,, -Acantholumpenus mackayi,Acantholumpenus mackayi,Pighead prickleback,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Acantholumpenus,Species,249703,3771,Species,,,,,,, -Acanthoptilum gracile,Acanthoptilum gracile,White sea pen,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Virgulariidae,Acanthoptilum,Species,289324,NA,Species,,,,,,, -Acanthostracion,Acanthostracion,NA,Animalia,Chordata,Teleostei,Tetraodontiformes,Ostraciidae,Acanthostracion,Genus,126237,NA,Remove,,,,,,, -Lactophrys polygonia,Acanthostracion polygonium,Honeycomb cowfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Ostraciidae,Lactophrys,Species,1577312,4287,Species,,,,,,, -Acanthostracion polygonius,Acanthostracion polygonium,Honeycomb cowfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Ostraciidae,Lactophrys,Species,1577312,4287,Species,,,,,,, -Acanthostracion quadricornis,Acanthostracion quadricornis,Scrawled cowfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Ostraciidae,Acanthostracion,Species,158920,92,Species,,,,,,, -Lactophrys quadricornis,Acanthostracion quadricornis,Scrawled cowfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Ostraciidae,Acanthostracion,Species,158920,92,Species,,,,,,, -Acanthurus bahianus,Acanthurus bahianus,Barber surgeonfish,Animalia,Chordata,Teleostei,Acanthuriformes,Acanthuridae,Acanthurus,Species,159578,68792,Species,,,,,,, -Acanthurus chirurgus,Acanthurus chirurgus,Doctorfish,Animalia,Chordata,Teleostei,Acanthuriformes,Acanthuridae,Acanthurus,Species,159580,943,Species,,,,,,, -Acanthurus coeruleus,Acanthurus coeruleus,Blue tang surgeonfish,Animalia,Chordata,Teleostei,Acanthuriformes,Acanthuridae,Acanthurus,Species,159581,944,Species,,,,,,, -Arca imbricata,Acar clathrata,Mossy ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Arca,Species,236692,NA,Species,,,,,,, -Acesta sphoni,Acesta sphoni,NA,Animalia,Mollusca,Bivalvia,Limida,Limidae,Acesta,Species,505422,NA,Species,,,,,,, -Acharax johnsoni,Acharax johnsoni,NA,Animalia,Mollusca,Bivalvia,Solemyida,Solemyidae,Acharax,Species,293239,NA,Species,,,,,,, -Achelous,Achelous,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Achelous,Genus,206816,NA,Remove,,,,,,, -Portunus depressifrons,Achelous depressifrons,Flatface swimming crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Achelous,Species,557881,NA,Species,,,,,,, -Achelous depressifrons,Achelous depressifrons,Flatface swimming crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Achelous,Species,557881,NA,Species,,,,,,, -Portunus floridanus,Achelous floridanus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Achelous,Species,557882,NA,Species,,,,,,, -Achelous floridanus,Achelous floridanus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Achelous,Species,557882,NA,Species,,,,,,, -Portunus gibbesii,Achelous gibbesii,Iridescent swimming crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Portunus,Species,557883,NA,Species,,,,,,, -Achelous gibbesii,Achelous gibbesii,Iridescent swimming crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Portunus,Species,557883,NA,Species,,,,,,, -Achelous ordwayi,Achelous ordwayi,Silvery-clawed swimming crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Achelous,Species,451838,NA,Species,,,,,,, -Portunus spinicarpus,Achelous spinicarpus,Longspine swimming crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Achelous,Species,557889,NA,Species,,,,,,, -Achelous spinicarpus,Achelous spinicarpus,Longspine swimming crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Achelous,Species,557889,NA,Species,,,,,,, -Portunus spinimanus,Achelous spinimanus,Blotched swimming crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Portunus,Species,456069,NA,Species,,,,,,, -Achelous spinimanus,Achelous spinimanus,Blotched swimming crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Portunus,Species,456069,NA,Species,,,,,,, -Portunus ventralis,Achelous ventralis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Portunus,Species,1587865,NA,Species,,,,,,, -Achirus lineatus,Achirus lineatus,Lined sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Achiridae,Achirus,Species,279493,4256,Species,,,,,,, -Acila castrensis,Acila castrensis,Divaricate nutclam,NA,NA,NA,NA,NA,NA,Species,506568,NA,Species,,,,,,, -Acipenser medirostris,Acipenser medirostris,Green sturgeon,Animalia,Chordata,Chondrostei,Acipenseriformes,Acipenseridae,Acipenser,Species,271695,2592,Species,,,,,,, -Acipenser oxyrhynchus,Acipenser oxyrinchus,Atlantic sturgeon,Animalia,Chordata,Chondrostei,Acipenseriformes,Acipenseridae,Acipenser,Species,151802,2593,Species,,,,,,, -Acipenser oxyrinchus,Acipenser oxyrinchus,Atlantic sturgeon,Animalia,Chordata,Chondrostei,Acipenseriformes,Acipenseridae,Acipenser,Species,151802,2593,Species,,,,,,, -Acmaea,Acmaea,NA,Animalia,Mollusca,Gastropoda,NA,Acmaeidae,Acmaea,Genus,137616,NA,Remove,,,,,,, -Acoela,Acoela,Acoel turbellarian,NA,NA,NA,NA,NA,NA,Order,2847,NA,Remove,,,,,,, -Acoelida,Acoelida,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Actaea,Actaea,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Xanthidae,Actaea,Genus,204271,NA,Remove,,,,,,, -Acteocina,Acteocina,NA,Animalia,Mollusca,Gastropoda,Cephalaspidea,Tornatinidae,Acteocina,Genus,137866,NA,Remove,,,,,,, -Acteocina sp.,Acteocina,NA,Animalia,Mollusca,Gastropoda,Cephalaspidea,Tornatinidae,Acteocina,Genus,137867,NA,Remove,,,,,,, -Actinauge verrilli,Actinauge verrillii,Reticulate anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Hormathiidae,Actinauge,Species,592915,NA,Species,,,,,,, -Actinauge verrillii,Actinauge verrillii,Reticulate anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Hormathiidae,Actinauge,Species,592916,NA,Species,,,,,,, -Actinernus,Actinernus,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinernidae,Actinernus,Genus,100691,NA,Remove,,,,,,, -Actinernus sp.,Actinernus,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinernidae,Actinernus,Genus,100692,NA,Remove,,,,,,, -Actinia,Actinia,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actiniidae,Actinia,Genus,100694,NA,Remove,,,,,,, -Actiniaria,Actiniaria,Sea anemones,Animalia,Cnidaria,Anthozoa,Actiniaria,NA,NA,Order,1360,NA,Remove,,,,,,, -Actiniidae,Actiniidae,Actinid sea anemones unid.,Animalia,Cnidaria,Anthozoa,Actiniaria,Actiniidae,NA,Family,100653,NA,Remove,,,,,,, -Actinoscyphia,Actinoscyphia,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinoscyphiidae,Actinoscyphia,Genus,100707,NA,Remove,,,,,,, -Actinoscyphia sp.,Actinoscyphia,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinoscyphiidae,Actinoscyphia,Genus,100708,NA,Remove,,,,,,, -Actinostola,Actinostola,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,Actinostola,Genus,100709,NA,Remove,,,,,,, -Actinostola sp.,Actinostola,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,Actinostola,Genus,100710,NA,Remove,,,,,,, -Actinostola faeculenta,Actinostola faeculenta,Hobnail vase anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,Actinostola,Species,854440,NA,Species,,,,,,, -Paractinostola faeculenta,Actinostola faeculenta,Hobnail vase anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,Actinostola,Species,854440,NA,Species,,,,,,, -Actinostola groenlandica,Actinostola groenlandica,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,Actinostola,Species,283451,NA,Species,,,,,,, -Actinostola sp. A (Clark 2006),Actinostola sp. A (Clark 2006),NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,Actinostola,Species,NA,NA,Species,,,,,,, -Actinostola sp. B (Clark 2006),Actinostola sp. B (Clark 2006),NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,Actinostola,Species,NA,NA,Species,,,,,,, -Actinostolidae,Actinostolidae,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,NA,Family,100655,NA,Remove,,,,,,, -Adelogorgia phyllosclera,Adelogorgia phyllosclera,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Gorgoniidae,Adelogorgia,Species,289357,NA,Species,,,,,,, -Adelosebastes latens,Adelosebastes latens,Aleutian scorpionfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Adelosebastes,Species,279508,23885,Species,,,,,,, -Admete laevior,Admete laevior,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Cancellariidae,Admete,Genus,137723,NA,Remove,,,,,,, -Admete solida,Admete solida,Noble Admete,Animalia,Mollusca,Gastropoda,Neogastropoda,Cancellariidae,Admete,Species,576338,NA,Species,,,,,,, -Aega,Aega,NA,Animalia,Arthropoda,Malacostraca,Isopoda,Aegidae,Aega,Genus,118394,NA,Remove,,,,,,, -Aegapheles antillensis,Aegapheles antillensis,NA,Animalia,Arthropoda,Malacostraca,Isopoda,Aegidae,Aegapheles,Species,256389,NA,Species,,,,,,, -Aequipecten,Aequipecten,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Aequipecten,Genus,138313,NA,Remove,,,,,,, -Aequipecten glyptus,Aequipecten glyptus,Red ribbed scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Aequipecten,Species,156732,NA,Species,,,,,,, -Aequorea,Aequorea,NA,Animalia,Cnidaria,Hydrozoa,Leptothecata,Aequoreidae,Aequorea,Genus,116998,NA,Remove,,,,,,, -Aequorea sp.,Aequorea,NA,Animalia,Cnidaria,Hydrozoa,Leptothecata,Aequoreidae,Aequorea,Genus,116999,NA,Remove,,,,,,, -Aequorea aequorea,Aequorea forskalea,Many ribbed jellyfish,Animalia,Cnidaria,Hydrozoa,Leptothecata,Aequoreidae,Aequorea,Species,117270,NA,Species,,,,,,, -Aequorea forskalea,Aequorea forskalea,Many ribbed jellyfish,Animalia,Cnidaria,Hydrozoa,Leptothecata,Aequoreidae,Aequorea,Species,117270,NA,Species,,,,,,, -Aequorea macrodactyla,Aequorea macrodactyla,NA,Animalia,Cnidaria,Hydrozoa,Leptothecata,Aequoreidae,Aequorea,Species,117271,NA,Species,,,,,,, -Aequoreidae,Aequoreidae,NA,Animalia,Cnidaria,Hydrozoa,Leptothecata,Aequoreidae,NA,Family,13553,NA,Remove,,,,,,, -Aetobatis narinari,Aetobatus narinari,Spotted eagle ray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Myliobatidae,Aetobatus,Species,217426,1250,Species,,,,,,, -Aetobatus narinari,Aetobatus narinari,Spotted eagle ray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Myliobatidae,Aetobatus,Species,217426,1250,Species,,,,,,, -Aforia,Aforia,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Cochlespiridae,Aforia,Genus,196995,NA,Remove,,,,,,, -Aforia sp.,Aforia,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Cochlespiridae,Aforia,Genus,196996,NA,Remove,,,,,,, -Aforia circinata,Aforia circinata,Keeled aforia,Animalia,Mollusca,Gastropoda,Neogastropoda,Cochlespiridae,Aforia,Species,432904,NA,Species,,,,,,, -Aforia goodei,Aforia goodei,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Cochlespiridae,Aforia,Species,432906,NA,Species,,,,,,, -Aglaophenia,Aglaophenia,Feather hydroids,Animalia,Cnidaria,Hydrozoa,Leptothecata,Aglaopheniidae,Aglaophenia,Genus,116999,NA,Remove,,,,,,, -Aglaophenia sp.,Aglaophenia,Feather hydroids,Animalia,Cnidaria,Hydrozoa,Leptothecata,Aglaopheniidae,Aglaophenia,Genus,117000,NA,Remove,,,,,,, -Agolambrus agonus,Agolambrus agonus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Agolambrus,Species,442238,NA,Species,,,,,,, -Agonidae,Agonidae,Alligatorfishes,Animalia,Chordata,Teleostei,Perciformes,Agonidae,NA,Family,125588,NA,Remove,,,,,,, -Agonopsis sterletus,Agonopsis sterletus,Southern spearnose poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Agonopsis,Species,279521,4151,Species,,,,,,, -Agonopsis vulsa,Agonopsis vulsa,Northern spearnose poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Agonopsis,Species,279522,4152,Species,,,,,,, -Pitar morrhuanus,Agriopoma morrhuanum,False quahog,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Pitar,Species,594424,NA,Species,,,,,,, -Agriopoma morrhuanum,Agriopoma morrhuanum,False quahog,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Pitar,Species,594424,NA,Species,,,,,,, -Agriopoma texasiana,Agriopoma texasianum,NA,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Agriopoma,Species,582802,NA,Species,,,,,,, -Agriopoma texasianum,Agriopoma texasianum,NA,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Agriopoma,Species,582802,NA,Species,,,,,,, -Akoya platinum,Akoya platinum,Silvery topsnail,Animalia,Mollusca,Gastropoda,Trochida,Calliostomatidae,Akoya,Species,1324693,NA,Species,,,,,,, -Calliostoma platinum,Akoya platinum,Silvery topsnail,Animalia,Mollusca,Gastropoda,Trochida,Calliostomatidae,Akoya,Species,1324693,NA,Species,,,,,,, -Calliostoma titanium,Akoya platinum,Silvery topsnail,Animalia,Mollusca,Gastropoda,Trochida,Calliostomatidae,Akoya,Species,1324693,NA,Species,,,,,,, -Alaskagorgia,Alaskagorgia,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Malacalcyonacea incertae sedis,Alaskagorgia,Genus,267210,NA,Remove,,,,,,, -Alaskagorgia sp.,Alaskagorgia,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Malacalcyonacea incertae sedis,Alaskagorgia,Genus,267211,NA,Remove,,,,,,, -Alaskagorgia aleutiana,Alaskagorgia aleutiana,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Malacalcyonacea incertae sedis,Alaskagorgia,Species,289377,NA,Species,,,,,,, -Albatrossia pectoralis,Albatrossia pectoralis,Giant grenadier,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Albatrossia,Species,236135,8435,Species,,,,,,, -Albula vulpes,Albula vulpes,Bonefish,Animalia,Chordata,Teleostei,Albuliformes,Albulidae,Albula,Species,212256,228,Species,,,,,,, -Albunea gibbesii,Albunea gibbesii,Surf mole crab,Animalia,Arthropoda,Malacostraca,Decapoda,Albuneidae,Albunea,Species,421880,NA,Species,,,,,,, -Albunea paretii,Albunea paretii,Beach mole crab,Animalia,Arthropoda,Malacostraca,Decapoda,Albuneidae,Albunea,Species,107192,NA,Species,,,,,,, -Alcyonacea,Alcyonacea,Soft corals,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Alcyonidiidae,Alcyonidiidae,NA,Animalia,Bryozoa,Gymnolaemata,Ctenostomatida,Alcyonidiidae,NA,Family,110783,NA,Remove,,,,,,, -Alcyonidium,Alcyonidium,NA,Animalia,Bryozoa,Gymnolaemata,Ctenostomatida,Alcyonidiidae,Alcyonidium,Genus,110993,NA,Remove,,,,,,, -Alcyonidium sp.,Alcyonidium,NA,Animalia,Bryozoa,Gymnolaemata,Ctenostomatida,Alcyonidiidae,Alcyonidium,Genus,110993,NA,Remove,,,,,,, -Alcyonidium disciforme,Alcyonidium disciforme,Disc bryozoan,Animalia,Bryozoa,Gymnolaemata,Ctenostomatida,Alcyonidiidae,Alcyonidium,Species,111598,NA,Species,,,,,,, -Alcyonidium enteromorpha,Alcyonidium enteromorpha,Noodle bryozoan,Animalia,Bryozoa,Gymnolaemata,Ctenostomatida,Alcyonidiidae,Alcyonidium,Species,470633,NA,Species,,,,,,, -Alcyonidium pedunculatum,Alcyonidium pedunculatum,Smooth leather bryozoan,Animalia,Bryozoa,Gymnolaemata,Ctenostomatida,Alcyonidiidae,Alcyonidium,Species,470641,NA,Species,,,,,,, -Alcyonidium sp. A,Alcyonidium sp. A,medusa bryozoan,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Alcyonium,Alcyonium,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Alcyoniidae,Alcyonium,Genus,125284,NA,Remove,,,,,,, -Alcyonium sp.,Alcyonium,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Alcyoniidae,Alcyonium,Genus,125284,NA,Remove,,,,,,, -Alcyonium sp. A (Clark 2006),Alcyonium sp. A (Clark 2006),pink orange mushroom coral,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Alcyonium sp. B (Clark 2006),Alcyonium sp. B (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Alectis ciliaris,Alectis ciliaris,African pompano,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Alectis,Species,159629,988,Species,,,,,,, -Alepisauridae,Alepisauridae,NA,Animalia,Chordata,Teleostei,Aulopiformes,Alepisauridae,NA,Family,125439,NA,Remove,,,,,,, -Alepisaurus ferox,Alepisaurus ferox,Long snouted lancetfish,Animalia,Chordata,Teleostei,Aulopiformes,Alepisauridae,Alepisaurus,Species,126333,99,Species,,,,,,, -Alepocephalidae,Alepocephalidae,Slickheads,Animalia,Chordata,Teleostei,Alepocephaliformes,Alepocephalidae,NA,Family,125507,NA,Remove,,,,,,, -Alepocephaliidae,Alepocephalidae,Slickheads,Animalia,Chordata,Teleostei,Alepocephaliformes,Alepocephalidae,NA,Family,125507,NA,Remove,,,,,,, -Alepocephalus,Alepocephalus,NA,Animalia,Chordata,Teleostei,Alepocephaliformes,Alepocephalidae,Alepocephalus,Genus,125868,NA,Remove,,,,,,, -Alepocephalus tenebrosus,Alepocephalus tenebrosus,California slickhead,Animalia,Chordata,Teleostei,Alepocephaliformes,Alepocephalidae,Alepocephalus,Species,272849,11590,Species,,,,,,, -Aleutiaster,Aleutiaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Asterinidae,Aleutiaster,Genus,291628,NA,Remove,,,,,,, -Aleutiaster sp.,Aleutiaster,Ahearns star,Animalia,Echinodermata,Asteroidea,Valvatida,Asterinidae,Aleutiaster,Genus,291628,NA,Remove,,,,,,, -Aleutibuccinum clarki,Aleutibuccinum clarki,Roger buccinid,NA,NA,NA,NA,NA,NA,Species,1699280,NA,Species,,,,,,, -Aleutihenricia beringiana,Aleutihenricia beringiana,Bering henricia,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Aleutihenricia,Species,597761,NA,Species,,,,,,, -Aleutihenricia federi,Aleutihenricia federi,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Aleutihenricia,Species,509316,NA,Species,,,,,,, -Beringius aleuticus,Aleutijapelion aleuticus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Beringius,Species,1699080,NA,Species,,,,,,, -Aleutijapelion aleuticus,Aleutijapelion aleuticus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Beringius,Species,1699080,NA,Species,,,,,,, -Strombus gallus,Aliger gallus,Roostertail conch,Animalia,Mollusca,Gastropoda,Littorinimorpha,Strombidae,Strombus,Species,419692,NA,Species,,,,,,, -Aliger gallus,Aliger gallus,Roostertail conch,Animalia,Mollusca,Gastropoda,Littorinimorpha,Strombidae,Strombus,Species,419692,NA,Species,,,,,,, -Strombus gigas,Aliger gigas,Pink conch,Animalia,Mollusca,Gastropoda,Littorinimorpha,Strombidae,Strombus,Species,1429769,NA,Species,,,,,,, -Aliger gigas,Aliger gigas,Pink conch,Animalia,Mollusca,Gastropoda,Littorinimorpha,Strombidae,Strombus,Species,1429769,NA,Species,,,,,,, -Allocareproctus,Allocareproctus,NA,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Allocareproctus,Genus,268260,NA,Remove,,,,,,, -Allocareproctus sp.,Allocareproctus,NA,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Allocareproctus,Genus,268260,NA,Remove,,,,,,, -Allocareproctus jordani,Allocareproctus jordani,Cherry snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Allocareproctus,Species,279555,24122,Species,,,,,,, -Allocareproctus kallaion,Allocareproctus kallaion,Combed snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Allocareproctus,Species,279556,62924,Species,,,,,,, -Allocareproctus tanix,Allocareproctus tanix,Peach snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Allocareproctus,Species,279557,62923,Species,,,,,,, -Allocareproctus unangas,Allocareproctus unangas,Goldeneye snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Allocareproctus,Species,279558,62925,Species,,,,,,, -Allocareproctus ungak,Allocareproctus ungak,Whiskered snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Allocareproctus,Species,279559,62926,Species,,,,,,, -Allocyttus folletti,Allocyttus folletti,Oxeye oreo,Animalia,Chordata,Teleostei,Zeiformes,Oreosomatidae,Allocyttus,Species,254555,11685,Species,,,,,,, -Allosmerus elongatus,Allosmerus elongatus,Whitebait smelt,Animalia,Chordata,Teleostei,Osmeriformes,Osmeridae,Allosmerus,Species,279564,2694,Species,,,,,,, -Allothyone mexicana,Allothyone mexicana,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Phyllophoridae,Allothyone,Species,422529,NA,Species,,,,,,, -Alopias superciliosus,Alopias superciliosus,Bigeye thresher,Animalia,Chordata,Elasmobranchii,Lamniformes,Alopiidae,Alopias,Species,105835,2534,Species,,,,,,, -Alopias vulpinus,Alopias vulpinus,Thresher,Animalia,Chordata,Elasmobranchii,Lamniformes,Alopiidae,Alopias,Species,105836,2535,Species,,,,,,, -Alosa,Alosa,NA,Animalia,Chordata,Teleostei,Clupeiformes,Alosidae,Alosa,Genus,125715,NA,Remove,,,,,,, -Alosa aestivalis,Alosa aestivalis,Blueback herring,Animalia,Chordata,Teleostei,Clupeiformes,Alosidae,Alosa,Species,158667,1574,Species,,,,,,, -Alosa chrysochloris,Alosa chrysochloris,Skipjack shad,Animalia,Chordata,Teleostei,Clupeiformes,Alosidae,Alosa,Species,272250,1578,Species,,,,,,, -Alosa mediocris,Alosa mediocris,Hickory shad,Animalia,Chordata,Teleostei,Clupeiformes,Alosidae,Alosa,Species,158668,1582,Species,,,,,,, -Alosa pseudoharengus,Alosa pseudoharengus,Alewife,Animalia,Chordata,Teleostei,Clupeiformes,Alosidae,Alosa,Species,158669,1583,Species,,,,,,, -Alosa sapidissima,Alosa sapidissima,American shad,Animalia,Chordata,Teleostei,Clupeiformes,Alosidae,Alosa,Species,158670,1584,Species,,,,,,, -Alpheidae,Alpheidae,Snapping shrimps,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,NA,Family,106776,NA,Remove,,,,,,, -Alpheus,Alpheus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Alpheus,Genus,106978,NA,Remove,,,,,,, -Alpheus armatus,Alpheus armatus,Brown snapping shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Alpheus,Species,421729,NA,Species,,,,,,, -Alpheus floridanus,Alpheus floridanus,Sand snapping shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Alpheus,Species,240707,NA,Species,,,,,,, -Alpheus formosus,Alpheus formosus,Striped snapping shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Alpheus,Species,421736,NA,Species,,,,,,, -Alpheus heterochaelis,Alpheus heterochaelis,Bigclaw snapping shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Alpheus,Species,158348,NA,Species,,,,,,, -Alpheus heterochelis,Alpheus heterochaelis,Bigclaw snapping shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Alpheus,Species,158348,NA,Species,,,,,,, -Alpheus intrinsecus,Alpheus intrinsecus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Alpheus,Species,240852,NA,Species,,,,,,, -Alpheus normanni,Alpheus normanni,Green snapping shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Alpheus,Species,158349,NA,Species,,,,,,, -Aluterus,Aluterus,NA,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Aluterus,Genus,126235,NA,Remove,,,,,,, -Aluterus heudeloti,Aluterus heudelotii,Dotterel filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Aluterus,Species,159489,4273,Species,,,,,,, -Aluterus heudelotii,Aluterus heudelotii,Dotterel filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Aluterus,Species,159489,4273,Species,,,,,,, -Aluterus heudelotti,Aluterus heudelotii,Dotterel filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Aluterus,Species,159489,4273,Species,,,,,,, -Aluterus monoceros,Aluterus monoceros,Unicorn leatherjacket filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Aluterus,Species,127407,4274,Species,,,,,,, -Aluterus schoepfi,Aluterus schoepfii,Orange filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Aluterus,Species,159490,1081,Species,,,,,,, -Aluterus schoepfii,Aluterus schoepfii,Orange filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Aluterus,Species,159490,1081,Species,,,,,,, -Aluterus scriptus,Aluterus scriptus,Scribbled leatherjacket filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Aluterus,Species,159491,4275,Species,,,,,,, -Alyconiidae,Alyconiidae,Octocorals,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Amaea mitchelli,Amaea mitchelli,Mitchell's wentletrap,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Epitoniidae,Amaea,Species,419794,NA,Species,,,,,,, -Zoobotryon,Amathia,NA,Animalia,Bryozoa,Gymnolaemata,Ctenostomatida,Vesiculariidae,Zoobotryon,Genus,111022,NA,Remove,,,,,,, -Zoobotryon verticillatum,Amathia verticillata,Bushy bryozoan,Animalia,Bryozoa,Gymnolaemata,Ctenostomatida,Vesiculariidae,Zoobotryon,Species,851581,NA,Species,,,,,,, -Amathia verticillata,Amathia verticillata,Bushy bryozoan,Animalia,Bryozoa,Gymnolaemata,Ctenostomatida,Vesiculariidae,Zoobotryon,Species,851581,NA,Species,,,,,,, -Amauropsis purpurea,Amauropsis islandica,Iceland moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Amauropsis,Species,140521,NA,Species,,,,,,, -Amauropsis islandica,Amauropsis islandica,Iceland moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Amauropsis,Species,140521,NA,Species,,,,,,, -Amblyraja badia,Amblyraja hyperborea,Broad skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Amblyraja,Species,105863,9256,Species,,,,,,, -Raja badia,Amblyraja hyperborea,Broad skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Species,105863,9256,Species,,,,,,, -Amblyraja radiata,Amblyraja radiata,Thorny skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Amblyraja,Species,105865,2565,Species,,,,,,, -Ameiurus catus,Ameiurus catus,NA,NA,NA,NA,NA,NA,NA,notMarine,NA,NA,Remove,,,,,,, -Americardia media,Americardia media,Atlantic strawberry-cockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Americardia,Species,420847,NA,Species,,,,,,, -Tellina modesta,Ameritella modesta,Plain tellin,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Tellina,Species,878514,NA,Species,,,,,,, -Ameritella modesta,Ameritella modesta,Plain tellin,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Tellina,Species,878514,NA,Species,,,,,,, -Amiantis,Amiantis,NA,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Amiantis,Genus,205708,NA,Remove,,,,,,, -Amicula vestita,Amicula vestita,NA,Animalia,Mollusca,Polyplacophora,Chitonida,Mopaliidae,Amicula,Species,159928,NA,Species,,,,,,, -Ammodytes,Ammodytes,sand lance unid.,Animalia,Chordata,Teleostei,Perciformes,Ammodytidae,Ammodytes,Genus,125909,NA,Remove,,,,,,, -Ammodytes sp.,Ammodytes,sand lance unid.,Animalia,Chordata,Teleostei,Perciformes,Ammodytidae,Ammodytes,Genus,125909,NA,Remove,,,,,,, -Ammodytes americanus,Ammodytes americanus,American sand lance,Animalia,Chordata,Teleostei,Perciformes,Ammodytidae,Ammodytes,Species,159587,3820,Species,,,,,,, -Ammodytes dubius,Ammodytes dubius,Northern sand lance,Animalia,Chordata,Teleostei,Perciformes,Ammodytidae,Ammodytes,Species,151520,3821,Species,,,,,,, -Ammodytes hexapterus,Ammodytes hexapterus,Arctic sand lance,Animalia,Chordata,Teleostei,Perciformes,Ammodytidae,Ammodytes,Species,254510,3822,Species,,,,,,, -Ammodytes personatus,Ammodytes personatus,Pacific sand lance,Animalia,Chordata,Teleostei,Perciformes,Ammodytidae,Ammodytes,Species,272967,487,Species,,,,,,, -Ammodytidae,Ammodytidae,NA,Animalia,Chordata,Teleostei,Perciformes,Ammodytidae,NA,Family,125516,NA,Remove,,,,,,, -Ampheraster,Ampheraster,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Pedicellasteridae,Ampheraster,Genus,178776,NA,Remove,,,,,,, -Ampheraster sp.,Ampheraster,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Pedicellasteridae,Ampheraster,Genus,178776,NA,Remove,,,,,,, -Ampheraster marianus,Ampheraster marianus,Mariana's island star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Pedicellasteridae,Ampheraster,Species,254842,NA,Species,,,,,,, -Amphilectus lobatus,Amphilectus ovulum,Beige horny sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Esperiopsidae,Amphilectus,Species,1424119,NA,Species,,,,,,, -Amphilectus ovulum,Amphilectus ovulum,Beige horny sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Esperiopsidae,Amphilectus,Species,1424119,NA,Species,,,,,,, -Amphinomidae,Amphinomidae,NA,Animalia,Annelida,Polychaeta,Amphinomida,Amphinomidae,NA,Family,960,NA,Remove,,,,,,, -Octopus burryi,Amphioctopus burryi,Brownstriped octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Octopodidae,Octopus,Species,420653,NA,Species,,,,,,, -Amphioctopus burryi,Amphioctopus burryi,Brownstriped octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Octopodidae,Octopus,Species,420653,NA,Species,,,,,,, -Amphiodia,Amphiodia,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Amphiuridae,Amphiodia,Genus,172595,NA,Remove,,,,,,, -Amphiodia sp.,Amphiodia,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Amphiuridae,Amphiodia,Genus,172595,NA,Remove,,,,,,, -Diamphiodia occidentalis,Amphiodia occidentalis,Long armed brittle star,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Amphiodia occidentalis,Amphiodia occidentalis,Long armed brittle star,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Amphiophiura,Amphiophiura,NA,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiopyrgidae,Amphiophiura,Genus,123554,NA,Remove,,,,,,, -Amphiophiura sp. A (Clark 2006),Amphiophiura sp. A (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Amphiophiura superba,Amphiophiura superba,NA,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiopyrgidae,Amphiophiura,Species,242740,NA,Species,,,,,,, -Amphipoda,Amphipoda,Amphipods,Animalia,Arthropoda,Malacostraca,Amphipoda,NA,NA,Order,1135,NA,Remove,,,,,,, -Abietinaria greenei,Amphisbetia greenei,Fibre optic hydroid,Animalia,Cnidaria,Hydrozoa,Leptothecata,Sertulariidae,Abietinaria,Species,1358362,NA,Species,,,,,,, -Amphisbetia greenei,Amphisbetia greenei,Fibre optic hydroid,Animalia,Cnidaria,Hydrozoa,Leptothecata,Sertulariidae,Abietinaria,Species,1358362,NA,Species,,,,,,, -Amphistichus argenteus,Amphistichus argenteus,Barred surfperch,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Embiotocidae,Amphistichus,Species,279594,3622,Species,,,,,,, -Amphistichus rhodoterus,Amphistichus rhodoterus,Redtail surfperch,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Embiotocidae,Amphistichus,Species,279596,3624,Species,,,,,,, -Amphiura diomedeae,Amphiura (Amphiura) diomedeae,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Amphiuridae,Amphiura,Species,243029,NA,Species,,,,,,, -Amphiuridae,Amphiuridae,Burrowing brittle star unid.,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Amphiuridae,NA,Family,123206,NA,Remove,,,,,,, -Amusium,Amusium,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Amusium,Genus,205333,NA,Remove,,,,,,, -Amusium papyraceum,Amusium papyraceum,Paper scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Amusium,Species,766475,NA,Species,,,,,,, -Anadara,Anadara,NA,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Anadara,Genus,137669,NA,Remove,,,,,,, -Anadara brasiliana,Anadara brasiliana,Incongruous ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Anadara,Species,504322,NA,Species,,,,,,, -Anadara chemnitzi,Anadara chemnitzii,Triangular ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Anadara,Species,504337,NA,Species,,,,,,, -Anadara chemnitzii,Anadara chemnitzii,Triangular ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Anadara,Species,504337,NA,Species,,,,,,, -Anadara notabilis,Anadara notabilis,Eared ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Anadara,Species,420712,NA,Species,,,,,,, -Anadara baughmani,Anadara secernenda,Skewed ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Anadara,Species,504326,NA,Species,,,,,,, -Anadara secernenda,Anadara secernenda,Skewed ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Anadara,Species,504326,NA,Species,,,,,,, -Anadara floridana,Anadara secticostata,Cut ribbed ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Anadara,Species,504356,NA,Species,,,,,,, -Anadara secticostata,Anadara secticostata,Cut ribbed ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Anadara,Species,504356,NA,Species,,,,,,, -Anadara transversa,Anadara transversa,Transverse ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Anadara,Species,156734,NA,Species,,,,,,, -Anarchias similis,Anarchias similis,Pygmy moray,Animalia,Chordata,Teleostei,Anguilliformes,Muraenidae,Anarchias,Species,158581,NA,Species,,,,,,, -Anarhichadidae,Anarhichadidae,NA,Animalia,Chordata,Teleostei,Perciformes,Anarhichadidae,NA,Genus,125517,NA,Remove,,,,,,, -Anarhichas lupus,Anarhichas lupus,Atlantic wolffish,Animalia,Chordata,Teleostei,Perciformes,Anarhichadidae,Anarhichas,Species,126758,2501,Species,,,,,,, -Anarhichas orientalis,Anarhichas orientalis,Bering wolffish,Animalia,Chordata,Teleostei,Perciformes,Anarhichadidae,Anarhichas,Species,254511,3812,Species,,,,,,, -Anarrhichthys ocellatus,Anarrhichthys ocellatus,Wolf-eel,Animalia,Chordata,Teleostei,Perciformes,Anarhichadidae,Anarrhichthys,Species,279605,3813,Species,,,,,,, -Anasimus,Anasimus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Anasimus,Genus,415055,NA,Remove,,,,,,, -Anasimus latus,Anasimus latus,Stilt spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Anasimus,Species,421959,NA,Species,,,,,,, -Anatinella,Anatinella,NA,Animalia,Mollusca,Bivalvia,Venerida,Anatinellidae,Anatinella,Genus,489099,NA,Remove,,,,,,, -Anchistioides antiguensis,Anchistioides antiguensis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Palaemonidae,Anchistioides,Species,421678,NA,Species,,,,,,, -Anchoa cubana,Anchoa cubana,Cuban anchovy,Animalia,Chordata,Teleostei,Clupeiformes,Engraulidae,Anchoa,Species,275513,1687,Species,,,,,,, -Anchoa hepsetus,Anchoa hepsetus,Striped anchovy,Animalia,Chordata,Teleostei,Clupeiformes,Engraulidae,Anchoa,Species,158698,1133,Species,,,,,,, -Anchoa lamprotaenia,Anchoa lamprotaenia,Big eye anchovy,Animalia,Chordata,Teleostei,Clupeiformes,Engraulidae,Anchoa,Species,275522,1688,Species,,,,,,, -Anchoa lyolepis,Anchoa lyolepis,Shortfinger anchovy,Animalia,Chordata,Teleostei,Clupeiformes,Engraulidae,Anchoa,Species,275524,1132,Species,,,,,,, -Anchoa nasuta,Anchoa lyolepis,Shortfinger anchovy,Animalia,Chordata,Teleostei,Clupeiformes,Engraulidae,Anchoa,Species,275524,1132,Species,,,,,,, -Anchoa mitchilli,Anchoa mitchilli,Bay anchovy,Animalia,Chordata,Teleostei,Clupeiformes,Engraulidae,Anchoa,Species,158699,545,Species,,,,,,, -Anchoa,Anchoa spp.,Anchovies,Animalia,Chordata,Teleostei,Clupeiformes,Engraulidae,Anchoa,Species,158697,NA,Species,,,,,,, -Anchoviella,Anchoviella,NA,Animalia,Chordata,Teleostei,Clupeiformes,Engraulidae,Anchoviella,Genus,158700,NA,Remove,,,,,,, -Anchoviella perfasciata,Anchoviella perfasciata,Poey's anchovy,Animalia,Chordata,Teleostei,Clupeiformes,Engraulidae,Anchoviella,Species,158701,1678,Species,,,,,,, -Ancistrolepis,Ancistrolepis,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Ancistrolepis,Genus,248331,NA,Remove,,,,,,, -Ancistrolepis sp.,Ancistrolepis,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Ancistrolepis,Genus,248331,NA,Remove,,,,,,, -Ancistrolepis eucosmius,Ancistrolepis eucosmius,two-ribbed whelk,NA,NA,NA,NA,NA,NA,Species,491391,NA,Species,,,,,,, -Ancistrolepis bicinctus,Ancistrolepis eucosmius eucosmius,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Ancistrolepis,SubSpecies,491412,NA,Species,,,,,,, -Ancylopsetta,Ancylopsetta,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Ancylopsetta,Genus,159272,NA,Remove,,,,,,, -Ancylopsetta dilecta,Ancylopsetta dilecta,Three-eye flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Ancylopsetta,Species,276008,4205,Species,,,,,,, -Ancylopsetta quadrocellata,Ancylopsetta quadrocellata,Ocellated flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Ancylopsetta,Species,308768,4206,Species,,,,,,, -Ancylopsetta ommata,Ancylopsetta quadrocellata,Ocellated flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Ancylopsetta,Species,308768,4206,Species,,,,,,, -Andvakiidae,Andvakiidae,NA,Animalia,Cnidaria,Hexacorallia,Actiniaria,Andvakiidae,NA,Genus,100659,NA,Remove,,,,,,, -Anguilla rostrata,Anguilla rostrata,American eel,Animalia,Chordata,Teleostei,Anguilliformes,Anguillidae,Anguilla,Species,158562,296,Species,,,,,,, -Anguilliformes,Anguilliformes,NA,Animalia,Chordata,Teleostei,Anguilliformes,NA,NA,Order,10295,NA,Remove,,,,,,, -Anisarchus medius,Anisarchus medius,Stout eelblenny,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Anisarchus,Species,127070,3789,Species,,,,,,, -Lumpenus medius,Anisarchus medius,Stout eelblenny,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Anisarchus,Species,127070,3789,Species,,,,,,, -Anisotremus surinamensis,Anisotremus surinamensis,Black margate,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Haemulidae,Anisotremus,Species,279623,1123,Species,,,,,,, -Anisotremus virginicus,Anisotremus virginicus,Porkfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Haemulidae,Anisotremus,Species,279625,1124,Species,,,,,,, -Annelida,Annelida,Segmented worms,Animalia,Annelida,NA,NA,NA,NA,Phylum,882,NA,Remove,,,,,,, -Colus martensi,Anomalisipho martensi,Marten's whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,821662,NA,Species,,,,,,, -Anomalisipho martensi,Anomalisipho martensi,Marten's whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,821662,NA,Species,,,,,,, -Colus datuzenbergii,Anomalisipho verkruezeni,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Anomalisipho,Species,490701,NA,Species,,,,,,, -Anomalisipho verkruezeni,Anomalisipho verkruezeni,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Anomalisipho,Species,490701,NA,Species,,,,,,, -Anomalocera,Anomalocera,NA,Animalia,Arthropoda,Copepoda,Calanoida,Pontellidae,Anomalocera,Genus,104206,NA,Remove,,,,,,, -Anomia simplex,Anomia simplex,Common jingle,Animalia,Mollusca,Bivalvia,Pectinida,Anomiidae,Anomia,Species,156737,NA,Species,,,,,,, -Anomiidae,Anomiidae,Jingle shells,Animalia,Mollusca,Bivalvia,Pectinida,Anomiidae,NA,Family,214,NA,Remove,,,,,,, -Anomura,Anomura,NA,Animalia,Arthropoda,Malacostraca,Decapoda,NA,NA,InfraOrder,106671,NA,Remove,,,,,,, -Anoplagonus inermis,Anoplagonus inermis,Smooth alligatorfish,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Anoplagonus,Species,279630,4155,Species,,,,,,, -Anoplodactylus,Anoplodactylus,NA,Animalia,Arthropoda,Pycnogonida,Pantopoda,Phoxichilidiidae,Anoplodactylus,Genus,134592,NA,Remove,,,,,,, -Anoplodactylus lentus,Anoplodactylus lentus,Black sea spider,Animalia,Arthropoda,Pycnogonida,Pantopoda,Phoxichilidiidae,Anoplodactylus,Species,158478,NA,Species,,,,,,, -Anoplogaster cornuta,Anoplogaster cornuta,Common fangtooth,Animalia,Chordata,Teleostei,Trachichthyiformes,Anoplogastridae,Anoplogaster,Species,126393,2308,Species,,,,,,, -Anoplogastridae,Anoplogastridae,NA,Animalia,Chordata,Teleostei,Trachichthyiformes,Anoplogastridae,NA,Family,267002,NA,Remove,,,,,,, -Anoplopoma fimbria,Anoplopoma fimbria,Sablefish,Animalia,Chordata,Teleostei,Perciformes,Anoplopomatidae,Anoplopoma,Species,159463,512,Species,,,,,,, -Anotopterus nikparini,Anotopterus nikparini,North pacific daggertooth,Animalia,Chordata,Teleostei,Aulopiformes,Anotopteridae,Anotopterus,Species,272040,60529,Species,,,,,,, -Antedonidae,Antedonidae,NA,Animalia,Echinodermata,Crinoidea,Comatulida,Antedonidae,NA,Family,123148,NA,Remove,,,,,,, -Anteliaster,Anteliaster,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Pedicellasteridae,Anteliaster,Genus,172537,NA,Remove,,,,,,, -Anteliaster sp.,Anteliaster,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Pedicellasteridae,Anteliaster,Genus,172537,NA,Remove,,,,,,, -Anteliaster nannodes,Anteliaster microgenys nannodes,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Pedicellasteridae,Anteliaster,Species,255110,NA,Species,,,,,,, -Anteliaster microgenys nannodes,Anteliaster microgenys nannodes,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Pedicellasteridae,Anteliaster,Species,255110,NA,Species,,,,,,, -Antennarius,Antennarius,NA,Animalia,Chordata,Teleostei,Lophiiformes,Antennariidae,Antennarius,Genus,125790,NA,Remove,,,,,,, -Antennarius multiocellatus,Antennarius multiocellatus,Longlure frogfish,Animalia,Chordata,Teleostei,Lophiiformes,Antennariidae,Antennarius,Species,272539,3084,Species,,,,,,, -Antennarius pauciradiatus,Antennarius pauciradiatus,Dwarf frogfish,Animalia,Chordata,Teleostei,Lophiiformes,Antennariidae,Antennarius,Species,272541,NA,Species,,,,,,, -Phrynelox nuttingi,Antennarius scaber,Striated frogfish,Animalia,Chordata,Teleostei,Lophiiformes,Antennariidae,Antennarius,Species,158790,5474,Species,,,,,,, -Antennarius striatus,Antennarius striatus,Striated frogfish,Animalia,Chordata,Teleostei,Lophiiformes,Antennariidae,Antennarius,Species,158790,5474,Species,,,,,,, -Anthenoides peircei,Anthenoides peircei,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Anthenoides,Species,178061,NA,Species,,,,,,, -Anthias,Anthias,Anthias,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Anthias,Genus,126067,NA,Remove,,,,,,, -Anthias nicholsi,Anthias nicholsi,Yellowfin bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Anthias,Species,159344,3313,Species,,,,,,, -Anthias tenuis and woodsi,Anthias tenuis and woodsi,Anthias tenuis and woodsi,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Anthoathecatae,Anthoathecata,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecatae,NA,NA,Order,13551,NA,Remove,,,,,,, -Anthomastus,Anthomastus,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Coralliidae,Anthomastus,Genus,125285,NA,Remove,,,,,,, -Anthomastus sp.,Anthomastus,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Coralliidae,Anthomastus,Genus,125285,NA,Remove,,,,,,, -Anthomastus sp. A,Anthomastus sp. A,red mushroom coral,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Anthomastus sp. B,Anthomastus sp. B,gray mushroom coral,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Anthopleura xanthogrammica,Anthopleura xanthogrammica,Giant green anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Actiniidae,Anthopleura,Species,283377,NA,Species,,,,,,, -Anthoptilum,Anthoptilum,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Anthoptilidae,Anthoptilum,Genus,128489,NA,Remove,,,,,,, -Anthoptilum grandiflorum,Anthoptilum grandiflorum,Feather boa sea pen,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Anthoptilidae,Anthoptilum,Species,128504,NA,Species,,,,,,, -Anthoptilum murrayi,Anthoptilum murrayi,Murray sea pen,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Anthoptilidae,Anthoptilum,Species,128505,NA,Species,,,,,,, -Anthothela grandiflora,Anthothela grandiflora,Great flowerbud coral,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Alcyoniidae,Anthothela,Species,125414,NA,Species,,,,,,, -Anthozoa,Anthozoa,Sea anemones and corals,Animalia,Cnidaria,Anthozoa,NA,NA,NA,Class,1292,NA,Remove,,,,,,, -Antigonia capros,Antigonia capros,Deepbody boarfish,Animalia,Chordata,Teleostei,Acanthuriformes,Caproidae,Antigonia,Species,127418,3258,Species,,,,,,, -Antigonia combatia,Antigonia combatia,Shortspine boarfish,Animalia,Chordata,Teleostei,Acanthuriformes,Caproidae,Antigonia,Species,159429,3259,Species,,,,,,, -Munida flinti,Antillimunida flinti,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Munididae,Munida,Species,1605697,NA,Species,,,,,,, -Munida hispida,Antillimunida hispida,Brittle squat lobster,Animalia,Arthropoda,Malacostraca,Decapoda,Munididae,Munida,Species,1605699,NA,Species,,,,,,, -Antillophos,Antillophos,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Nassariidae,Antillophos,Genus,390690,NA,Remove,,,,,,, -Antillophos candei,Antillophos candeanus,Beaded phos,Animalia,Mollusca,Gastropoda,Neogastropoda,Nassariidae,Antillophos,Species,419959,NA,Species,,,,,,, -Antillophos candeanus,Antillophos candeanus,Beaded phos,Animalia,Mollusca,Gastropoda,Neogastropoda,Nassariidae,Antillophos,Species,419959,NA,Species,,,,,,, -Antimora microlepis,Antimora microlepis,Finescale mora,Animalia,Chordata,Teleostei,Gadiformes,Moridae,Antimora,Species,272460,2006,Species,,,,,,, -Antimora rostrata,Antimora rostrata,Blue antimora,Animalia,Chordata,Teleostei,Gadiformes,Moridae,Antimora,Species,126486,2005,Species,,,,,,, -Antipatharia,Antipatharia,Thorny corals,Animalia,Cnidaria,Anthozoa,Antipatharia,NA,NA,Order,22549,NA,Remove,,,,,,, -Antipatheria,Antipatheria,Thorny corals,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Antipathes,Antipathes,NA,Animalia,Cnidaria,Anthozoa,Antipatharia,Antipathidae,Antipathes,Genus,103302,NA,Remove,,,,,,, -Antipathes sp.,Antipathes,NA,Animalia,Cnidaria,Anthozoa,Antipatharia,Antipathidae,Antipathes,Genus,103302,NA,Remove,,,,,,, -Antipathidae,Antipathidae,NA,Animalia,Cnidaria,Anthozoa,Antipatharia,Antipathidae,NA,Family,103301,NA,Remove,,,,,,, -Antiplanes,Antiplanes,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Pseudomelatomidae,Antiplanes,Genus,432398,NA,Remove,,,,,,, -Antiplanes sp.,Antiplanes,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Pseudomelatomidae,Antiplanes,Genus,432398,NA,Remove,,,,,,, -Antiplanes perversa,Antiplanes catalinae,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Pseudomelatomidae,Antiplanes,Species,433018,NA,Species,,,,,,, -Antiplanes thalaea,Antiplanes thalaea,NA,NA,NA,NA,NA,NA,NA,Species,433031,NA,Species,,,,,,, -Anuropus bathypelagica,Anuropus bathypelagicus,Giant isopod,Animalia,Arthropoda,Malacostraca,Isopoda,Anuropidae,Anuropus,Species,257917,NA,Species,,,,,,, -Anuropus bathypelagicus,Anuropus bathypelagicus,Giant isopod,Animalia,Arthropoda,Malacostraca,Isopoda,Anuropidae,Anuropus,Species,257917,NA,Species,,,,,,, -Apeltes quadracus,Apeltes quadracus,Fourspine stickleback,Animalia,Chordata,Teleostei,Perciformes,Gasterosteidae,Apeltes,Species,159436,3269,Species,,,,,,, -Aphanopus arigato,Aphanopus arigato,Pacific black scabbardfish,Animalia,Chordata,Teleostei,Scombriformes,Trichiuridae,Aphanopus,Species,274008,59043,Species,,,,,,, -Aphanopus carbo,Aphanopus carbo,Black scabbardfish,Animalia,Chordata,Teleostei,Scombriformes,Trichiuridae,Aphanopus,Species,127085,646,Species,,,,,,, -Aphanopus intermedius,Aphanopus intermedius,Intermediate scabbardfish,Animalia,Chordata,Teleostei,Scombriformes,Trichiuridae,Aphanopus,Species,159833,8540,Species,,,,,,, -Aphrocallistes vastus,Aphrocallistes vastus,Cloud sponge,Animalia,Porifera,Hexactinellida,Sceptrulophora,Aphrocallistidae,Aphrocallistes,Species,171632,NA,Species,,,,,,, -Aphrodita,Aphrodita,Sea mice,Animalia,Annelida,Polychaeta,Phyllodocida,Aphroditidae,Aphrodita,Genus,129194,NA,Remove,,,,,,, -Aphrodita sp.,Aphrodita,Sea mice,Animalia,Annelida,Polychaeta,Phyllodocida,Aphroditidae,Aphrodita,Genus,129194,NA,Remove,,,,,,, -Aphrodita japonica,Aphrodita japonica,NA,NA,NA,NA,NA,NA,NA,Species,326499,NA,Species,,,,,,, -Aphrodita negligens,Aphrodita negligens,Dishevelled sea-mouse,Animalia,Annelida,Polychaeta,Phyllodocida,Aphroditidae,Aphrodita,Species,332999,NA,Species,,,,,,, -Aphroditidae,Aphroditidae,Sea mice,Animalia,Annelida,Polychaeta,Phyllodocida,Aphroditidae,NA,Family,938,NA,Remove,,,,,,, -Aphrogenia alba,Aphrogenia alba,NA,Animalia,Annelida,Polychaeta,Phyllodocida,Aphroditidae,Aphrogenia,Species,129843,NA,Species,,,,,,, -Aplacophora,Aplacophora,NA,Animalia,Mollusca,NA,NA,NA,NA,SuperClass,411,NA,Remove,,,,,,, -Aplatophis chauliodus,Aplatophis chauliodus,Fangtooth snake-eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Aplatophis,Species,279644,7550,Species,,,,,,, -Amaroucium,Aplidium,Sea pork,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polyclinidae,Aplidium,Genus,103471,NA,Remove,,,,,,, -Aplidium,Aplidium,Sea pork,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polyclinidae,Aplidium,Genus,103471,NA,Remove,,,,,,, -Aplidium sp.,Aplidium,Sea pork,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polyclinidae,Aplidium,Genus,103471,NA,Remove,,,,,,, -Aplidium bermudae,Aplidium bermudae,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polyclinidae,Aplidium,Species,103638,NA,Species,,,,,,, -Aplidium californicum,Aplidium californicum,California sea pork,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polyclinidae,Aplidium,Species,249827,NA,Species,,,,,,, -Aplidium ruzickai,Aplidium ruzickai,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polyclinidae,Aplidium,Species,487766,NA,Species,,,,,,, -Amaroucium soldatovi,Aplidium soldatovi,Sand-grain imbedded ascidian,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polyclinidae,Amaroucium,Species,251595,NA,Species,,,,,,, -Aplidium soldatovi,Aplidium soldatovi,Sand-grain imbedded ascidian,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polyclinidae,Amaroucium,Species,251595,NA,Species,,,,,,, -Aplidium sp. A,Aplidium sp. A,orange Aplidium,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Aplidium sp. A (Clark 2006),Aplidium sp. A (Clark 2006),sea glob,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Amaroucium stellatum,Aplidium stellatum,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polyclinidae,Amaroucium,Species,251739,NA,Species,,,,,,, -Aplidium stellatum,Aplidium stellatum,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polyclinidae,Amaroucium,Species,251739,NA,Species,,,,,,, -Aplysia,Aplysia,Sea hares,Animalia,Mollusca,Gastropoda,Aplysiida,Aplysiidae,Aplysia,Genus,137654,NA,Remove,,,,,,, -Aplysia brasiliana,Aplysia brasiliana,Mottled seahare,Animalia,Mollusca,Gastropoda,Aplysiida,Aplysiidae,Aplysia,Species,160029,NA,Species,,,,,,, -Aplysia dactylomela,Aplysia dactylomela,Large-spotted sea hare,Animalia,Mollusca,Gastropoda,Aplysiida,Aplysiidae,Aplysia,Species,138753,NA,Species,,,,,,, -Aplysia willcoxi,Aplysia fasciata,Banded sea hare,Animalia,Mollusca,Gastropoda,Aplysiida,Aplysiidae,Aplysia,Species,138755,NA,Species,,,,,,, -Aplysia juliana,Aplysia juliana,NA,Animalia,Mollusca,Gastropoda,Aplysiida,Aplysiidae,Aplysia,Species,138756,NA,Species,,,,,,, -Aplysia badistes,Aplysia juliana,NA,Animalia,Mollusca,Gastropoda,Aplysiida,Aplysiidae,Aplysia,Species,138756,NA,Species,,,,,,, -Aplysia morio,Aplysia morio,Atlantic black seahare,Animalia,Mollusca,Gastropoda,Aplysiida,Aplysiidae,Aplysia,Species,160031,NA,Species,,,,,,, -Anaspidea,Aplysiida,NA,Animalia,Mollusca,Gastropoda,Anaspidea,NA,NA,Order,1058953,NA,Remove,,,,,,, -Aplysiidae,Aplysiidae,NA,Animalia,Mollusca,Gastropoda,Aplysiida,Aplysiidae,NA,Family,172,NA,Remove,,,,,,, -Apogon,Apogon,NA,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Apogon,Genus,125913,NA,Remove,,,,,,, -Apogon aurolineatus,Apogon aurolineatus,Bridle cardinalfish,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Apogon,Species,272981,3521,Species,,,,,,, -Apogon maculatus,Apogon maculatus,Flamefish,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Apogon,Species,159589,3526,Species,,,,,,, -Apogon phenax,Apogon phenax,Mimic cardinalfish,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Apogon,Species,273069,3527,Species,,,,,,, -Apogon pseudomaculatus,Apogon pseudomaculatus,Twospot cardinalfish,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Apogon,Species,159590,3530,Species,,,,,,, -Apogon quadrisquamatus,Apogon quadrisquamatus,Sawcheek cardinalfish,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Apogon,Species,273078,3531,Species,,,,,,, -Apogonidae,Apogonidae,Cardinalfishes,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,NA,Family,125518,NA,Remove,,,,,,, -Apostichopus californicus,Apostichopus californicus,Giant california sea cucumber,Animalia,Echinodermata,Holothuroidea,Synallactida,Stichopodidae,Apostichopus,Species,529363,NA,Species,,,,,,, -Parastichopus californicus,Apostichopus californicus,Giant california sea cucumber,Animalia,Echinodermata,Holothuroidea,Synallactida,Stichopodidae,Apostichopus,Species,529363,NA,Species,,,,,,, -Apostichopus japonicus,Apostichopus japonicus,Japanese sea cucumber,Animalia,Echinodermata,Holothuroidea,Synallactida,Stichopodidae,Apostichopus,Species,241776,NA,Species,,,,,,, -Apostichopus leukothele,Apostichopus leukothele,White-knobbed sea cucumber,Animalia,Echinodermata,Holothuroidea,Synallactida,Stichopodidae,Apostichopus,Species,529431,NA,Species,,,,,,, -Parastichopus leukothele,Apostichopus leukothele,White-knobbed sea cucumber,Animalia,Echinodermata,Holothuroidea,Synallactida,Stichopodidae,Apostichopus,Species,529431,NA,Species,,,,,,, -Parastichopus parvimensis,Apostichopus parvimensis,Warty sea cucumber,Animalia,Echinodermata,Holothuroidea,Synallactida,Stichopodidae,Parastichopus,Species,123458,NA,Species,,,,,,, -Apristurus,Apristurus,NA,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Pentanchidae,Apristurus,Genus,105727,NA,Remove,,,,,,, -Apristurus brunneus,Apristurus brunneus,Brown catshark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Pentanchidae,Apristurus,Species,158512,763,Species,,,,,,, -Apristurus kampae,Apristurus kampae,Longnose catshark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Pentanchidae,Apristurus,Species,271342,769,Species,,,,,,, -Apterichtus,Apterichtus,NA,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Apterichtus,Genus,125644,NA,Remove,,,,,,, -Aptocyclus ventricosus,Aptocyclus ventricosus,Smooth lumpsucker,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Aptocyclus,Species,254299,4177,Species,,,,,,, -Arbacia punctulata,Arbacia punctulata,Purple-spined sea urchin,Animalia,Echinodermata,Echinoidea,Arbacioida,Arbaciidae,Arbacia,Species,158058,NA,Species,,,,,,, -Arca,Arca,NA,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Arca,Genus,137670,NA,Remove,,,,,,, -Arca zebra,Arca zebra,Turkey wing,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Arca,Species,420713,NA,Species,,,,,,, -Archistes biseriatus,Archistes biseriatus,Scaled sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Archistes,Species,279679,4040,Species,,,,,,, -Archistes plumarius,Archistes plumarius,Plumed sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Archistes,Species,279680,61284,Species,,,,,,, -Architectonica nobilis,Architectonica nobilis,Common sundial,Animalia,Mollusca,Gastropoda,NA,Architectonicidae,Architectonica,Species,181092,NA,Species,,,,,,, -Architectonicidae,Architectonicidae,NA,Animalia,Mollusca,Gastropoda,NA,Architectonicidae,NA,Family,22989,NA,Remove,,,,,,, -Archosargus probatocephalus,Archosargus probatocephalus,Sheepshead,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Archosargus,Species,159238,441,Species,,,,,,, -Archosargus rhomboidalis,Archosargus rhomboidalis,Western atlantic seabream,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Archosargus,Species,159239,1219,Species,,,,,,, -Arcinella cornuta,Arcinella cornuta,Florida spiny jewelbox,Animalia,Mollusca,Bivalvia,Venerida,Chamidae,Arcinella,Species,420813,NA,Species,,,,,,, -Arctica islandica,Arctica islandica,Ocean quahog,Animalia,Mollusca,Bivalvia,Venerida,Arcticidae,Arctica,Species,138802,NA,Species,,,,,,, -Arctomelon,Arctomelon,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutidae,Arctomelon,Genus,382314,NA,Remove,,,,,,, -Arctomelon sp.,Arctomelon,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutidae,Arctomelon,Genus,382314,NA,Remove,,,,,,, -Arctomelon borealis,Arctomelon boreale,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutidae,Arctomelon,Species,1309364,NA,Species,,,,,,, -Arctomelon boreale,Arctomelon boreale,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutidae,Arctomelon,Species,1309364,NA,Species,,,,,,, -Arctomelon sp. cf. stearnsii (Clark and McLean),Arctomelon sp. cf. stearnsii (Clark and McLean),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Arctomelon stearnsii,Arctomelon stearnsii,Alaska volute,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutidae,Arctomelon,Species,384681,NA,Species,,,,,,, -Arctomelon tamikoae,Arctomelon tamikoae,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutidae,Arctomelon,Species,384684,NA,Species,,,,,,, -Arctonoe vittata,Arctonoe vittata,Red banded commensal scaleworm,Animalia,Annelida,Polychaeta,Phyllodocida,Polynoidae,Arctonoe,Species,254301,NA,Species,,,,,,, -Arctoraja parmifera,Arctoraja parmifera,Alaska skate,NA,NA,NA,NA,NA,NA,Species,1577324,NA,Species,,,,,,, -Arctozenus risso,Arctozenus risso,Spotted barracudina,Animalia,Chordata,Teleostei,Aulopiformes,Paralepididae,Arctozenus,Species,126352,6977,Species,,,,,,, -Arctozenus rissoi,Arctozenus risso,Spotted barracudina,Animalia,Chordata,Teleostei,Aulopiformes,Paralepididae,Arctozenus,Species,126352,6977,Species,,,,,,, -Arcturidae,Arcturidae,NA,Animalia,Arthropoda,Malacostraca,Isopoda,Arcturidae,NA,Family,118280,NA,Remove,,,,,,, -Arcturus,Arcturus,NA,Animalia,Arthropoda,Malacostraca,Isopoda,Arcturidae,Arcturus,Genus,118444,NA,Remove,,,,,,, -Arcturus sp.,Arcturus,NA,Animalia,Arthropoda,Malacostraca,Isopoda,Arcturidae,Arcturus,Genus,118444,NA,Remove,,,,,,, -Arcturus sp. 1 (Clark 2006),Arcturus sp. 1 (Clark 2006),spiky arcturid,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Arenaeus cribrarius,Arenaeus cribrarius,Speckled swimming crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Arenaeus,Species,158046,NA,Species,,,,,,, -Paguristes hummi,Areopaguristes hummi,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Paguristes,Species,520653,NA,Species,,,,,,, -Areopaguristes hummi,Areopaguristes hummi,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Paguristes,Species,520653,NA,Species,,,,,,, -Paguristes oxyophthalmus,Areopaguristes oxyophthalmus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Paguristes,Species,1261644,NA,Species,,,,,,, -Areopaguristes oxyophthalmus,Areopaguristes oxyophthalmus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Paguristes,Species,1261644,NA,Species,,,,,,, -Argentina sialis,Argentina sialis,Pacific argentine,Animalia,Chordata,Teleostei,Argentiniformes,Argentinidae,Argentina,Species,272897,2699,Species,,,,,,, -Argentina silus,Argentina silus,Atlantic argentine,Animalia,Chordata,Teleostei,Argentiniformes,Argentinidae,Argentina,Species,126715,2700,Species,,,,,,, -Argentina striata,Argentina striata,Striated argentine,Animalia,Chordata,Teleostei,Argentiniformes,Argentinidae,Argentina,Species,158718,2701,Species,,,,,,, -Argentinidae,Argentinidae,Argentine unid.,Animalia,Chordata,Teleostei,Argentiniformes,Argentinidae,NA,Family,125508,NA,Remove,,,,,,, -Argis,Argis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Argis,Genus,107006,NA,Remove,,,,,,, -Argis sp.,Argis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Argis,Genus,107006,NA,Remove,,,,,,, -Argis alaskensis,Argis alaskensis,Alaska argid,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Argis,Species,515536,NA,Species,,,,,,, -Argis crassa,Argis crassa,Rough argid,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Argis,Species,254488,NA,Species,,,,,,, -Argis dentata,Argis dentata,Arctic argid,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Argis,Species,107550,NA,Species,,,,,,, -Argis lar,Argis lar,Kuro shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Argis,Species,254487,NA,Species,,,,,,, -Argis levior,Argis levior,Nelson argid,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Argis,Species,515539,NA,Species,,,,,,, -Argis ovifer,Argis ovifer,Spliteye argid,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Argis,Species,515540,NA,Species,,,,,,, -Argis sp. cf. ovifer (CAS),Argis sp. cf. ovifer (CAS),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Argopecten gibbus,Argopecten gibbus,Calico scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Argopecten,Species,394271,NA,Species,,,,,,, -Argopecten irradians,Argopecten irradians,Atlantic bay scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Argopecten,Species,156817,NA,Species,,,,,,, -Argyropelecus,Argyropelecus,NA,Animalia,Chordata,Teleostei,Stomiiformes,Sternoptychidae,Argyropelecus,Genus,126196,NA,Remove,,,,,,, -Argyropelecus sp.,Argyropelecus,NA,Animalia,Chordata,Teleostei,Stomiiformes,Sternoptychidae,Argyropelecus,Genus,126196,NA,Remove,,,,,,, -Argyropelecus aculeatus,Argyropelecus aculeatus,Lovely hatchetfish,Animalia,Chordata,Teleostei,Stomiiformes,Sternoptychidae,Argyropelecus,Species,127306,130,Species,,,,,,, -Argyropelecus affinis,Argyropelecus affinis,Pacific hatchet fish,Animalia,Chordata,Teleostei,Stomiiformes,Sternoptychidae,Argyropelecus,Species,127307,40,Species,,,,,,, -Argyropelecus lychnus,Argyropelecus lychnus,Tropical hatchetfish,Animalia,Chordata,Teleostei,Stomiiformes,Sternoptychidae,Argyropelecus,Species,158836,11549,Species,,,,,,, -Argyropelecus sladeni,Argyropelecus sladeni,Lowcrest hachetfish,Animalia,Chordata,Teleostei,Stomiiformes,Sternoptychidae,Argyropelecus,Species,158837,NA,Species,,,,,,, -Arhynchobatidae,Arhynchobatidae,NA,Animalia,Chordata,Elasmobranchii,Rajiformes,Arhynchobatidae,NA,Family,714639,NA,Remove,,,,,,, -Ariomma,Ariomma,NA,Animalia,Chordata,Teleostei,Scombriformes,Ariommatidae,Ariomma,Genus,159591,NA,Remove,,,,,,, -Ariomma bondi,Ariomma bondi,Silver rag driftfish,Animalia,Chordata,Teleostei,Scombriformes,Ariommatidae,Ariomma,Species,159592,961,Species,,,,,,, -Ariomma melanum,Ariomma melana,Brown driftfish,Animalia,Chordata,Teleostei,Scombriformes,Ariommatidae,Ariomma,Species,403239,3916,Species,,,,,,, -Ariomma melana,Ariomma melana,Brown driftfish,Animalia,Chordata,Teleostei,Scombriformes,Ariommatidae,Ariomma,Species,403239,3916,Species,,,,,,, -Ariomma regulus,Ariomma regulus,Spotted driftfish,Animalia,Chordata,Teleostei,Scombriformes,Ariommatidae,Ariomma,Species,159594,962,Species,,,,,,, -Ariopsis felis,Ariopsis felis,Hardhead catfish,Animalia,Chordata,Teleostei,Siluriformes,Ariidae,Ariopsis,Species,158709,947,Species,,,,,,, -Arius felis,Ariopsis felis,Hardhead catfish,Animalia,Chordata,Teleostei,Siluriformes,Ariidae,Ariopsis,Species,158709,947,Species,,,,,,, -Ariosoma balearicum,Ariosoma balearicum,Bandtooth conger,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Ariosoma,Species,126283,1744,Species,,,,,,, -Ariosoma belearicum,Ariosoma balearicum,Bandtooth conger,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Ariosoma,Species,126283,1744,Species,,,,,,, -Ariosoma selenops,Ariosoma selenops,NA,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Ariosoma,Species,271736,47177,Species,,,,,,, -Fusinus couei,Aristofusus couei,Yucatan spindle,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Fusinus,Species,1318059,NA,Species,,,,,,, -Aristofusus couei,Aristofusus couei,Yucatan spindle,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Fusinus,Species,1318059,NA,Species,,,,,,, -Fusinus eucosmius,Aristofusus excavatus,Apricot spindle,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Fusinus,Species,1318056,NA,Species,,,,,,, -Aristofusus excavatus,Aristofusus excavatus,Apricot spindle,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Fusinus,Species,1318056,NA,Species,,,,,,, -Fusinus helenae,Aristofusus helenae,Brown spindle,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Fusinus,Species,1318060,NA,Species,,,,,,, -Aristofusus helenae,Aristofusus helenae,Brown spindle,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Fusinus,Species,1318060,NA,Species,,,,,,, -Aristostomias scintillans,Aristostomias scintillans,Shiny loosejaw,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,Aristostomias,Species,275007,11577,Species,,,,,,, -Sesarma cinereum,Armases cinereum,Squareback marsh crab,Animalia,Arthropoda,Malacostraca,Decapoda,Sesarmidae,Sesarma,Species,158049,NA,Species,,,,,,, -Armina californica,Armina californica,California armina,Animalia,Mollusca,Gastropoda,Nudibranchia,Arminidae,Armina,Species,558913,NA,Species,,,,,,, -Armina tigrina,Armina tigrina,Striped sea slug,Animalia,Mollusca,Gastropoda,Nudibranchia,Arminidae,Armina,Species,138807,NA,Species,,,,,,, -Armina wattla,Armina wattla,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Arminidae,Armina,Species,420619,NA,Species,,,,,,, -Artediellus,Artediellus,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Artediellus,Genus,126147,NA,Remove,,,,,,, -Artediellus sp,Artediellus,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Artediellus,Genus,126147,NA,Remove,,,,,,, -Artediellus sp.,Artediellus,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Artediellus,Genus,126147,NA,Remove,,,,,,, -Artediellus miacanthus,Artediellus miacanthus,Bride sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Artediellus,Species,274361,51389,Species,,,,,,, -Artediellus pacificus,Artediellus pacificus,Hookhorn sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Artediellus,Species,254517,11708,Species,,,,,,, -Artediellus scaber,Artediellus scaber,Rough hookear,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Artediellus,Species,127194,4042,Species,,,,,,, -Artedius fenestralis,Artedius fenestralis,Padded sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Artedius,Species,279700,4046,Species,,,,,,, -Artedius lateralis,Artedius lateralis,Smoothhead sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Artedius,Species,279702,4048,Species,,,,,,, -Artemisina arcigera,Artemisina arcigera,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Microcionidae,Artemisina,Species,132992,NA,Species,,,,,,, -Arthrogorgia,Arthrogorgia,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Arthrogorgia,Genus,267238,NA,Remove,,,,,,, -Arthrogorgia sp.,Arthrogorgia,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Arthrogorgia,Genus,267238,NA,Remove,,,,,,, -Arthrogorgia kinoshitai,Arthrogorgia kinoshitai,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Arthrogorgia,Species,289457,NA,Species,,,,,,, -Arthrogorgia otsukai,Arthrogorgia otsukai,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Arthrogorgia,Species,289458,NA,Species,,,,,,, -Arthrogorgia utinomi,Arthrogorgia utinomii,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Arthrogorgia,Species,289459,NA,Species,,,,,,, -Arthrogorgia utinomii,Arthrogorgia utinomii,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Arthrogorgia,Species,289459,NA,Species,,,,,,, -Arthropoda,Arthropoda,NA,Animalia,Arthropoda,NA,NA,NA,NA,Phylum,1065,NA,Remove,,,,,,, -Asbestopluma,Asbestopluma,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Cladorhizidae,Asbestopluma,Genus,131893,NA,Remove,,,,,,, -Asbestopluma sp. A (Clark 2006),Asbestopluma sp. A (Clark 2006),fuzzy sponge,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Ascidia,Ascidia,Sea squirt,Animalia,Chordata,Ascidiacea,Phlebobranchia,Ascidiidae,Ascidia,Genus,103483,NA,Remove,,,,,,, -Ascidian,Ascidia,Sea squirt,Animalia,Chordata,Ascidiacea,Phlebobranchia,Ascidiidae,Ascidia,Genus,103483,NA,Remove,,,,,,, -Ascidia paratropa,Ascidia paratropa,Glassy tunicate,Animalia,Chordata,Ascidiacea,Phlebobranchia,Ascidiidae,Ascidia,Species,250022,NA,Species,,,,,,, -Ascidiacea,Ascidiacea,Sea squirts,Animalia,Chordata,Ascidiacea,NA,NA,NA,Class,1839,NA,Remove,,,,,,, -Ascidian sp. A,Ascidian sp. A,cow-eye tunicate,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Ascidian sp. B,Ascidian sp. B,transparent tunicate,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Ascidiidae,Ascidiidae,NA,Animalia,Chordata,Ascidiacea,Phlebobranchia,Ascidiidae,NA,Family,103443,NA,Remove,,,,,,, -Radulinus taylori,Asemichthys taylori,Spinynose sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Radulinus,Species,316433,4052,Species,,,,,,, -Aspidophoroides monopterygius,Aspidophoroides monopterygius,Alligatorfish,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Aspidophoroides,Species,159459,4157,Species,,,,,,, -Aspidophoroides olrikii,Aspidophoroides olrikii,Arctic alligatorfish,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Aspidophoroides,Species,309268,4158,Species,,,,,,, -Astarte,Astarte,NA,Animalia,Mollusca,Bivalvia,Carditida,Astartidae,Astarte,Genus,137683,NA,Remove,,,,,,, -Astarte sp.,Astarte,NA,Animalia,Mollusca,Bivalvia,Carditida,Astartidae,Astarte,Genus,137683,NA,Remove,,,,,,, -Astarte arctica,Astarte arctica,Arctic astarte,Animalia,Mollusca,Bivalvia,Carditida,Astartidae,Astarte,Species,138817,NA,Species,,,,,,, -Tridonta rollandi,Astarte arctica,Arctic astarte,Animalia,Mollusca,Bivalvia,Carditida,Astartidae,Astarte,Species,138817,NA,Species,,,,,,, -Astarte borealis,Astarte borealis,Boreal astarte,Animalia,Mollusca,Bivalvia,Carditida,Astartidae,Astarte,Species,138818,NA,Species,,,,,,, -Astarte compacta,Astarte compacta,Compact astarte,Animalia,Mollusca,Bivalvia,Carditida,Astartidae,Astarte,Species,504824,NA,Species,,,,,,, -Astarte polaris,Astarte compacta,Compact astarte,Animalia,Mollusca,Bivalvia,Carditida,Astartidae,Astarte,Species,504824,NA,Species,,,,,,, -Astarte crenata,Astarte crenata,Crenulate astarte,Animalia,Mollusca,Bivalvia,Carditida,Astartidae,Astarte,Species,138820,NA,Species,,,,,,, -Astarte elliptica,Astarte elliptica,Elliptical astarte,Animalia,Mollusca,Bivalvia,Carditida,Astartidae,Astarte,Species,138821,NA,Species,,,,,,, -Astarte montagui,Astarte montagui,Narrow hinge astarte,Animalia,Mollusca,Bivalvia,Carditida,Astartidae,Astarte,Species,138823,NA,Species,,,,,,, -Asterias,Asterias,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Asterias,Genus,123219,NA,Remove,,,,,,, -Asterias sp.,Asterias,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Asterias,Genus,123219,NA,Remove,,,,,,, -Asterias amurensis,Asterias amurensis,North pacific seastar,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Asterias,Species,254497,NA,Species,,,,,,, -Asterias vulgaris,Asterias rubens,Common starfish,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Asterias,Species,123776,NA,Species,,,,,,, -Asteriidae,Asteriidae,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,NA,Family,123121,NA,Remove,,,,,,, -Asteroidea,Asteroidea,Star fishes,Animalia,Echinodermata,Asteroidea,NA,NA,NA,Class,123080,NA,Remove,,,,,,, -Asteronychidae,Asteronychidae,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Asteronychidae,NA,Family,123201,NA,Remove,,,,,,, -Asteronyx,Asteronyx,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Asteronychidae,Asteronyx,Genus,123578,NA,Remove,,,,,,, -Asteronyx sp.,Asteronyx,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Asteronychidae,Asteronyx,Genus,123578,NA,Remove,,,,,,, -Asteronyx longifissa,Asteronyx longifissus,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Asteronychidae,Asteronyx,Species,243097,NA,Species,,,,,,, -Asteronyx longifissus,Asteronyx longifissus,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Asteronychidae,Asteronyx,Species,243097,NA,Species,,,,,,, -Asteronyx loveni,Asteronyx loveni,Serpent sea star,Animalia,Echinodermata,Ophiuroidea,Euryalida,Asteronychidae,Asteronyx,Species,124951,NA,Species,,,,,,, -Asteroporpa,Asteroporpa (Asteroporpa),NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Asteroporpa,Genus,242546,NA,Remove,,,,,,, -Astroporpa,Asteroporpa (Asteroporpa),NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Astroporpa,Genus,242546,NA,Remove,,,,,,, -Asteroporpa annulata,Asteroporpa (Asteroporpa) annulata,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Asteroporpa,Species,243105,NA,Species,,,,,,, -Asteroschema,Asteroschema,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Euryalidae,Asteroschema,Genus,123581,NA,Remove,,,,,,, -Asteroschema sublaeve,Asteroschema sublaeve,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Euryalidae,Asteroschema,Species,382690,NA,Species,,,,,,, -Stelleroidea,Asterozoa,NA,Animalia,Echinodermata,Stelleroidea,NA,NA,NA,Class,148743,NA,Remove,,,,,,, -Asthenactis fisheri,Asthenactis fisheri,Fisher's myxasterid,Animalia,Echinodermata,Asteroidea,Velatida,Myxasteridae,Asthenactis,Species,292732,NA,Species,,,,,,, -Astichopus multifidus,Astichopus multifidus,NA,Animalia,Echinodermata,Holothuroidea,Synallactida,Stichopodidae,Astichopus,Species,241780,NA,Species,,,,,,, -Astrapogon,Astrapogon,NA,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Astrapogon,Genus,268418,NA,Remove,,,,,,, -Apogon alutus,Astrapogon alutus,Bronze cardinalfish,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Astrapogon,Species,279772,3533,Species,,,,,,, -Astrapogon alutus,Astrapogon alutus,Bronze cardinalfish,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Astrapogon,Species,279772,3533,Species,,,,,,, -Astrapogon puncticulatus,Astrapogon puncticulatus,Blackfin cardinalfish,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Astrapogon,Species,279773,3534,Species,,,,,,, -Astrapogon stellatus,Astrapogon stellatus,Conchfish,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Astrapogon,Species,279774,NA,Species,,,,,,, -Astrochele,Astrochele,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Astrochele,Genus,182883,NA,Remove,,,,,,, -Astrochele sp.,Astrochele,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Astrochele,Genus,182883,NA,Remove,,,,,,, -Astrochele laevis,Astrochele laevis,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Astrochele,Species,243169,NA,Species,,,,,,, -Astrochele sp. A (Clark 2006),Astrochele sp. A (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Astrocyclus caecilia,Astrocyclus caecilia,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Astrocyclus,Species,243182,NA,Species,,,,,,, -Astrogordius cacaoticum,Astrogordius cacaoticus,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Astrogordius,Species,245844,NA,Species,,,,,,, -Astrometis sertulifera,Astrometis sertulifera,Fragile rainbow star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Astrometis,Species,255044,NA,Species,,,,,,, -Astronebris tatafilius,Astronebris tatafilius,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Asteronychidae,Astronebris,Species,243202,NA,Species,,,,,,, -Astronesthinae,Astronesthinae,NA,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,NA,SubFamily,154228,NA,Remove,,,,,,, -Astropecten,Astropecten,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Astropecten,Genus,123245,NA,Remove,,,,,,, -Astropecten sp,Astropecten,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Astropecten,Genus,123245,NA,Remove,,,,,,, -Astropecten alligator,Astropecten alligator,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Astropecten,Species,178645,NA,Species,,,,,,, -Astropecten americanus,Astropecten americanus,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Astropecten,Species,158490,NA,Species,,,,,,, -Astropecten antillensis,Astropecten antillensis,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Astropecten,Species,178646,NA,Species,,,,,,, -Astropecten armatus,Astropecten armatus,Spiny sand star,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Astropecten,Species,292851,NA,Species,,,,,,, -Astropecten articulatus,Astropecten articulatus,Royal sea star,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Astropecten,Species,158491,NA,Species,,,,,,, -Astropecten comptus,Astropecten articulatus,Royal sea star,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Astropecten,Species,158491,NA,Species,,,,,,, -Astropecten californicus,Astropecten californicus,California sand star,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Astropecten,Species,368460,NA,Species,,,,,,, -Astropecten cingulatus,Astropecten cingulatus,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Astropecten,Species,178648,NA,Species,,,,,,, -Astropecten duplicatus,Astropecten duplicatus,Two-spined star fish,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Astropecten,Species,178650,NA,Species,,,,,,, -Astropecten ornatissimus,Astropecten ornatissimus,Orange sand star,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Astropecten,Species,380302,NA,Species,,,,,,, -Astropectinidae,Astropectinidae,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,NA,Family,123127,NA,Remove,,,,,,, -Astrophyton,Astrophyton,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Astrophyton,Genus,123583,NA,Remove,,,,,,, -Astrophyton muricatus,Astrophyton muricatum,Giant basket star,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Astrophyton,Species,243214,NA,Species,,,,,,, -Astrophyton muricatum,Astrophyton muricatum,Giant basket star,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Astrophyton,Species,243214,NA,Species,,,,,,, -Astropyga magnifica,Astropyga magnifica,NA,Animalia,Echinodermata,Echinoidea,Diadematoida,Diadematidae,Astropyga,Species,422486,NA,Species,,,,,,, -Astroscopus guttatus,Astroscopus guttatus,Northern stargazer,Animalia,Chordata,Teleostei,Perciformes,Uranoscopidae,Astroscopus,Species,159251,3703,Species,,,,,,, -Astroscopus y-graecum,Astroscopus ygraecum,Southern stargazer,Animalia,Chordata,Teleostei,Perciformes,Uranoscopidae,Astroscopus,Species,159252,3704,Species,,,,,,, -Atheresthes sp.,Atheresthes,NA,NA,NA,NA,NA,NA,NA,Genus,268428,NA,Remove,,,,,,, -Atheresthes evermanni,Atheresthes evermanni,Kamchatka flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Atheresthes,Species,279791,518,Species,,,,,,, -Atheresthes stomias,Atheresthes stomias,Arrowtooth flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Atheresthes,Species,279792,517,Species,,,,,,, -Atheresthes stomias and a. evermanni,Atheresthes stomias and A. evermanni,Arrowtooth and kamchatka flounders,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Atheresthes,Species,279792,517,Species,,,,,,, -Atherinidae,Atherinidae,NA,Animalia,Chordata,Teleostei,Atheriniformes,Atherinidae,NA,Family,125438,NA,Remove,,,,,,, -Atherinops affinis,Atherinops affinis,Topsmelt silverside,Animalia,Chordata,Teleostei,Atheriniformes,Atherinidae,Atherinops,Species,279812,3235,Species,,,,,,, -Antherinopsis californiensis,Atherinopsis californiensis,Jacksmelt,Animalia,Chordata,Teleostei,Atheriniformes,Atherinidae,Atherinopsis,Species,279813,3236,Species,,,,,,, -Pandalus propinquus,Atlantopandalus propinqvus,Similar shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Species,158351,NA,Species,,,,,,, -Atolla,Atolla,NA,Animalia,Cnidaria,Scyphozoa,Coronatae,Atollidae,Atolla,Genus,135248,NA,Remove,,,,,,, -Atolla sp.,Atolla,NA,Animalia,Cnidaria,Scyphozoa,Coronatae,Atollidae,Atolla,Genus,135248,NA,Remove,,,,,,, -Atrina,Atrina,NA,Animalia,Mollusca,Bivalvia,Ostreida,Pinnidae,Atrina,Genus,138351,NA,Remove,,,,,,, -Atrina rigida,Atrina rigida,Stiff pen shell,Animalia,Mollusca,Bivalvia,Ostreida,Pinnidae,Atrina,Species,420739,NA,Species,,,,,,, -Atrina seminuda,Atrina seminuda,Half naked pen shell,Animalia,Mollusca,Bivalvia,Ostreida,Pinnidae,Atrina,Species,420740,NA,Species,,,,,,, -Atrina serrata,Atrina serrata,Sawtooth penshell,Animalia,Mollusca,Bivalvia,Ostreida,Pinnidae,Atrina,Species,420741,NA,Species,,,,,,, -Colus spitzbergensis,Aulacofusus brevicauda,Thick ribbed whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,490735,NA,Species,,,,,,, -Aulacofusus brevicauda,Aulacofusus brevicauda,Thick ribbed whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,490735,NA,Species,,,,,,, -Colus calathus,Aulacofusus calathus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,490738,NA,Species,,,,,,, -Aulacofusus calathus,Aulacofusus calathus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,490738,NA,Species,,,,,,, -Colus esychus,Aulacofusus esychus,Esychus colus,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,576652,NA,Species,,,,,,, -Aulacofusus esychus,Aulacofusus esychus,Esychus colus,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,576652,NA,Species,,,,,,, -Colus herendeenii,Aulacofusus herendeeni,Thin-ribbed whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,490740,NA,Species,,,,,,, -Aulacofusus herendeeni,Aulacofusus herendeeni,Thin-ribbed whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,490740,NA,Species,,,,,,, -Colus ombronius,Aulacofusus ombronius,Shady whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,490743,NA,Species,,,,,,, -Aulacofusus ombronius,Aulacofusus ombronius,Shady whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,490743,NA,Species,,,,,,, -Colus periscelidus,Aulacofusus periscelidus,Garter whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,490744,NA,Species,,,,,,, -Aulacofusus periscelidus,Aulacofusus periscelidus,Garter whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,490744,NA,Species,,,,,,, -Aulorhynchus flavidus,Aulorhynchus flavidus,Tube snout,Animalia,Chordata,Teleostei,Perciformes,Aulorhynchidae,Aulorhynchus,Species,279839,3270,Species,,,,,,, -Aulosaccus schulzei,Aulosaccus schulzei,Vase sponge,Animalia,Porifera,Hexactinellida,Lyssacinosida,Rossellidae,Aulosaccus,Species,172025,NA,Species,,,,,,, -Aulostomus maculatus,Aulostomus maculatus,Trumpetfish,Animalia,Chordata,Teleostei,Syngnathiformes,Aulostomidae,Aulostomus,Species,278080,964,Species,,,,,,, -Aurelia,Aurelia,Moon jellyfishes,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Ulmaridae,Aurelia,Genus,135263,NA,Remove,,,,,,, -Aurelia sp.,Aurelia,Moon jellyfishes,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Ulmaridae,Aurelia,Genus,135263,NA,Remove,,,,,,, -Aurelia aurita,Aurelia aurita,Moon jelly,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Ulmaridae,Aurelia,Species,135306,NA,Species,,,,,,, -Aurelia labiata,Aurelia labiata,Pacific moon jelly,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Ulmaridae,Aurelia,Species,287213,NA,Species,,,,,,, -Aurelia limbata,Aurelia limbata,Brownbranded moon jelly,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Ulmaridae,Aurelia,Species,158199,NA,Species,,,,,,, -Macoma constricta,Austromacoma constricta,Constricted macoma,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Species,880005,NA,Species,,,,,,, -Austromacoma constricta,Austromacoma constricta,Constricted macoma,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Species,880005,NA,Species,,,,,,, -Auxis thazard,Auxis thazard,Frigate tuna,Animalia,Chordata,Teleostei,Scombriformes,Scombridae,Auxis,Species,127016,94,Species,,,,,,, -Avocettina infans,Avocettina infans,Avocet snipe eel,Animalia,Chordata,Teleostei,Anguilliformes,Nemichthyidae,Avocettina,Species,126304,5099,Species,,,,,,, -Axianassa arenaria,Axianassa arenaria,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Laomediidae,Axianassa,Species,421830,NA,Species,,,,,,, -Axiidae,Axiidae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Axiidae,NA,Family,106798,NA,Remove,,,,,,, -Axinella,Axinella,firm gray sponge,Animalia,Porifera,Demospongiae,Axinellida,Axinellidae,Axinella,Genus,131774,NA,Remove,,,,,,, -Axinella sp.,Axinella,firm gray sponge,Animalia,Porifera,Demospongiae,Axinellida,Axinellidae,Axinella,Genus,131774,NA,Remove,,,,,,, -Axinella blanca,Axinella blanca,Firm finger sponge,Animalia,Porifera,Demospongiae,Axinellida,Axinellidae,Axinella,Species,132468,NA,Species,,,,,,, -Axiopsis,Axiopsis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Axiidae,Axiopsis,Genus,246229,NA,Remove,,,,,,, -Munida forceps,Babamunida forceps,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Munididae,Munida,Species,1605925,NA,Species,,,,,,, -Bagre marinus,Bagre marinus,Gafftopsail catfish,Animalia,Chordata,Teleostei,Siluriformes,Ariidae,Bagre,Species,158713,959,Species,,,,,,, -Bairdiella chrysoura,Bairdiella chrysoura,Silver perch,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Bairdiella,Species,159303,1165,Species,,,,,,, -Bajacalifornia burragei,Bajacalifornia burragei,Sharpchin slickhead,Animalia,Chordata,Teleostei,Alepocephaliformes,Alepocephalidae,Bajacalifornia,Species,272857,5200,Species,,,,,,, -Bajacalifornia erimoensis,Bajacalifornia erimoensis,NA,Animalia,Chordata,Teleostei,Alepocephaliformes,Alepocephalidae,Bajacalifornia,Species,272858,58907,Species,,,,,,, -Bajacalifornia megalops,Bajacalifornia megalops,NA,NA,NA,NA,NA,NA,NA,Species,126687,NA,Species,,,,,,, -Balanus,Balanus,NA,Animalia,Arthropoda,Thecostraca,Balanomorpha,Balanidae,Balanus,Genus,106122,NA,Remove,,,,,,, -Balanus sp.,Balanus,NA,Animalia,Arthropoda,Thecostraca,Balanomorpha,Balanidae,Balanus,Genus,106122,NA,Remove,,,,,,, -Balanus balanus,Balanus balanus,Rough barnacle,Animalia,Arthropoda,Thecostraca,Balanomorpha,Balanidae,Balanus,Species,106213,NA,Species,,,,,,, -Balanus nubilus,Balanus nubilus,NA,Animalia,Arthropoda,Thecostraca,Balanomorpha,Balanidae,Balanus,Species,594745,NA,Species,,,,,,, -Balanus rostratus,Balanus rostratus,Rostrate barnacle,Animalia,Arthropoda,Thecostraca,Balanomorpha,Balanidae,Balanus,Species,254482,NA,Species,,,,,,, -Balamus trigonus,Balanus trigonus,NA,Animalia,Arthropoda,Thecostraca,Balanomorpha,Balanidae,Balanus,Species,106223,NA,Species,,,,,,, -Balanus trigonus,Balanus trigonus,NA,Animalia,Arthropoda,Thecostraca,Balanomorpha,Balanidae,Balanus,Species,106223,NA,Species,,,,,,, -Hemanthias aureorubens,Baldwinella aureorubens,Streamer bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Hemanthias,Species,1015364,3324,Species,,,,,,, -Baldwinella aureorubens,Baldwinella aureorubens,Streamer bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Hemanthias,Species,1015364,3324,Species,,,,,,, -Hemanthias vivanus,Baldwinella vivanus,Red barbier,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Hemanthias,Species,1019849,3327,Species,,,,,,, -Balistes capriscus,Balistes capriscus,Gray triggerfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Balistidae,Balistes,Species,154721,7327,Species,,,,,,, -Balistes vetula,Balistes vetula,Queen triggerfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Balistidae,Balistes,Species,127397,19,Species,,,,,,, -Balistidae,Balistidae,NA,Animalia,Chordata,Teleostei,Tetraodontiformes,Balistidae,NA,Family,125607,NA,Remove,,,,,,, -Balticina,Balticina,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Balticinidae,Balticina,Genus,146534,NA,Remove,,,,,,, -Halipteris,Balticina,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Balticinidae,Balticina,Genus,146534,NA,Remove,,,,,,, -Halipteris (deepsea),Balticina,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Balticinidae,Balticina,Genus,146534,NA,Remove,,,,,,, -Balticina sp.,Balticina,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Balticinidae,Balticina,Genus,146534,NA,Remove,,,,,,, -Halipteris sp. (deepsea),Balticina,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Balticinidae,Balticina,Genus,146534,NA,Remove,,,,,,, -Halipteris californica,Balticina californica,Short sea whip,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Halipteridae,Halipteris,Species,1392940,NA,Species,,,,,,, -Balticina californica,Balticina californica,Short sea whip,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Halipteridae,Halipteris,Species,1392940,NA,Species,,,,,,, -Halipteris finmarchia,Balticina finmarchica,Hammer-tipped sea pen,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Halipteridae,Halipteris,Species,584787,NA,Species,,,,,,, -Balticina finmarchica,Balticina finmarchica,Hammer-tipped sea pen,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Halipteridae,Halipteris,Species,584787,NA,Species,,,,,,, -Balticina sp. A (Stone 2015),Balticina sp. A (Stone 2015),maroon sea whip,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Halipteris willemoesi,Balticina willemoesi,Willemoes's white sea pen,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Halipteridae,Halipteris,Species,1393616,NA,Species,,,,,,, -Balticina willemoesi,Balticina willemoesi,Willemoes's white sea pen,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Halipteridae,Halipteris,Species,1393616,NA,Species,,,,,,, -Bankia setacea,Bankia setacea,Feathery shipworm,Animalia,Mollusca,Bivalvia,Myida,Teredinidae,Bankia,Species,527858,NA,Species,,,,,,, -Barbatia,Barbatia,NA,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Barbatia,Genus,137672,NA,Remove,,,,,,, -Barbatia candida,Barbatia candida,White beard ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Barbatia,Species,504386,NA,Species,,,,,,, -Barbatia domingensis,Barbatia domingensis,White miniature ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Barbatia,Species,582484,NA,Species,,,,,,, -Barnea truncata,Barnea truncata,Truncate barnea,Animalia,Mollusca,Bivalvia,Myida,Pholadidae,Barnea,Species,156750,NA,Species,,,,,,, -Bassozetus zenkevitchi,Bassozetus zenkevitchi,pelagic assfish,NA,NA,NA,NA,NA,NA,Species,272795,NA,Species,,,,,,, -Bathophilus,Bathophilus,NA,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,Bathophilus,Genus,126203,NA,Remove,,,,,,, -Bathophilus flemingi,Bathophilus flemingi,Highfin dragonfish,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,Bathophilus,Species,275046,11568,Species,,,,,,, -Bathyagonus,Bathyagonus,starsnout poacher unid.,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Bathyagonus,Genus,254303,NA,Remove,,,,,,, -Bathyagonus sp.,Bathyagonus,starsnout poacher unid.,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Bathyagonus,Genus,254303,NA,Remove,,,,,,, -Bathyagonus alascanus,Bathyagonus alascanus,Gray starsnout,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Bathyagonus,Species,254503,4159,Species,,,,,,, -Bathyagonus infraspinatus,Bathyagonus infraspinatus,Spinycheek starsnout,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Bathyagonus,Species,254504,4160,Species,,,,,,, -Bathyagonus nigripinnis,Bathyagonus nigripinnis,Blackfin poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Bathyagonus,Species,254505,4161,Species,,,,,,, -Bathyagonus pentacanthus,Bathyagonus pentacanthus,Bigeye poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Bathyagonus,Species,254506,4162,Species,,,,,,, -Bathyanthias cubensis,Bathyanthias cubensis,NA,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Bathyanthias,Species,279867,61262,Species,,,,,,, -Bathyanthias mexicana,Bathyanthias mexicanus,Yellowtail bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Bathyanthias,Species,279868,3338,Species,,,,,,, -Bathyanthias mexicanus,Bathyanthias mexicanus,Yellowtail bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Bathyanthias,Species,279868,3338,Species,,,,,,, -Bathybembix bairdii,Bathybembix bairdii,NA,Animalia,Mollusca,Gastropoda,Seguenziida,Calliotropidae,Bathybembix,Species,512110,NA,Species,,,,,,, -Congrina,Bathycongrus,NA,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Congrina,Genus,203953,NA,Remove,,,,,,, -Rhechias vicinalis,Bathycongrus vicinalis,Neighbor conger,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Rhechias,Species,276878,58546,Species,,,,,,, -Bathycongrus vicinalis,Bathycongrus vicinalis,Neighbor conger,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Rhechias,Species,276878,58546,Species,,,,,,, -Bathylagidae,Bathylagidae,Deep sea smelts,Animalia,Chordata,Teleostei,Argentiniformes,Bathylagidae,NA,Family,125509,NA,Remove,,,,,,, -Bathylagus,Bathylagus,blacksmelt unid.,Animalia,Chordata,Teleostei,Argentiniformes,Bathylagidae,Bathylagus,Genus,125888,NA,Remove,,,,,,, -Bathylagus sp.,Bathylagus,blacksmelt unid.,Animalia,Chordata,Teleostei,Argentiniformes,Bathylagidae,Bathylagus,Genus,125888,NA,Remove,,,,,,, -Bathylagus pacificus,Bathylagus pacificus,Slender blacksmelt,Animalia,Chordata,Teleostei,Argentiniformes,Bathylagidae,Bathylagus,Species,272919,22679,Species,,,,,,, -Bathylychnops exilis,Bathylychnops exilis,Javelin spookfish,Animalia,Chordata,Teleostei,Argentiniformes,Opisthoproctidae,Bathylychnops,Species,126730,9119,Species,,,,,,, -Bathymaster caeruleofasciatus,Bathymaster caeruleofasciatus,Alaskan ronquil,Animalia,Chordata,Teleostei,Perciformes,Bathymasteridae,Bathymaster,Species,279415,3690,Species,,,,,,, -Bathymaster leurolepis,Bathymaster leurolepis,Smallmouth ronquil,Animalia,Chordata,Teleostei,Perciformes,Bathymasteridae,Bathymaster,Species,254512,3691,Species,,,,,,, -Bathymaster signatus,Bathymaster signatus,Searcher,Animalia,Chordata,Teleostei,Perciformes,Bathymasteridae,Bathymaster,Species,254513,3692,Species,,,,,,, -Bathymasteridae,Bathymasteridae,Ronquils,Animalia,Chordata,Teleostei,Perciformes,Bathymasteridae,NA,Family,151388,NA,Remove,,,,,,, -Bathynectes longispina,Bathynectes longispina,Bathyal swimming crab,Animalia,Arthropoda,Malacostraca,Decapoda,Polybiidae,Bathynectes,Species,394995,NA,Species,,,,,,, -Bathypathes,Bathypathes,NA,Animalia,Cnidaria,Anthozoa,Antipatharia,Schizopathidae,Bathypathes,Genus,103304,NA,Remove,,,,,,, -Bathypathes sp.,Bathypathes,NA,Animalia,Cnidaria,Anthozoa,Antipatharia,Schizopathidae,Bathypathes,Genus,103304,NA,Remove,,,,,,, -Bathypathes patula,Bathypathes patula,Patulous black coral,Animalia,Cnidaria,Anthozoa,Antipatharia,Schizopathidae,Bathypathes,Species,103323,NA,Species,,,,,,, -Bathyplotes,Bathyplotes,NA,Animalia,Echinodermata,Holothuroidea,Synallactida,Synallactidae,Bathyplotes,Genus,123460,NA,Remove,,,,,,, -Bathyplotes sp.,Bathyplotes,NA,Animalia,Echinodermata,Holothuroidea,Synallactida,Synallactidae,Bathyplotes,Genus,123460,NA,Remove,,,,,,, -Benthoctopus,Bathypolypus,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Bathypolypodidae,Benthoctopus,Genus,138265,NA,Remove,,,,,,, -Bathypolypus sp.,Bathypolypus,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Bathypolypodidae,Benthoctopus,Genus,138265,NA,Remove,,,,,,, -Benthoctopus sp.,Bathypolypus,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Bathypolypodidae,Benthoctopus,Genus,138265,NA,Remove,,,,,,, -Bathypolypus arcticus,Bathypolypus arcticus,North atlantic octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Bathypolypodidae,Bathypolypus,Species,140596,NA,Species,,,,,,, -Bathyraja abyssicola,Bathyraja abyssicola,deepsea skate,NA,NA,NA,NA,NA,NA,Species,271503,NA,Species,,,,,,, -Bathyraja aleutica,Bathyraja aleutica,Aleutian skate,NA,NA,NA,NA,NA,NA,Species,271506,NA,Species,,,,,,, -Bathyraja interrupta,Bathyraja interrupta,Bering skate,NA,NA,NA,NA,NA,NA,Species,271515,NA,Species,,,,,,, -Bathyraja lindbergi,Bathyraja lindbergi,Commander skate,NA,NA,NA,NA,NA,NA,Species,271517,NA,Species,,,,,,, -Bathyraja maculata,Bathyraja maculata,whiteblotched skate,NA,NA,NA,NA,NA,NA,Species,271520,NA,Species,,,,,,, -Bathyraja mariposa,Bathyraja mariposa,butterfly skate,NA,NA,NA,NA,NA,NA,Species,271522,NA,Species,,,,,,, -Bathyraja minispinosa,Bathyraja minispinosa,whitebrow skate,NA,NA,NA,NA,NA,NA,Species,271524,NA,Species,,,,,,, -Bathyraja panthera,Bathyraja panthera,leopard skate,NA,NA,NA,NA,NA,NA,Species,712390,NA,Species,,,,,,, -Bathyraja smirnovi,Bathyraja smirnovi,golden skate,NA,NA,NA,NA,NA,NA,Species,271535,NA,Species,,,,,,, -Bathyraja sp.,Bathyraja spp.,Skate complex,Animalia,Chordata,Elasmobranchii,Rajiformes,Arhynchobatidae,Bathyraja,Species,105761,NA,Species,,,,,,, -Bathyraja,Bathyraja spp.,Skate complex,Animalia,Chordata,Elasmobranchii,Rajiformes,Arhynchobatidae,Bathyraja,Species,105761,NA,Species,,,,,,, -Bathyraja taranetzi,Bathyraja taranetzi,mud skate,NA,NA,NA,NA,NA,NA,Species,298834,NA,Species,,,,,,, -Bathyraja trachura,Bathyraja trachura,roughtail skate,NA,NA,NA,NA,NA,NA,Species,271538,NA,Species,,,,,,, -Bathyraja violacea,Bathyraja violacea,Okhotsk skate,NA,NA,NA,NA,NA,NA,Species,271540,NA,Species,,,,,,, -Dasyatis centroura,Bathytoshia centroura,Roughtail stingray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Dasyatidae,Dasyatis,Species,1017389,2572,Species,,,,,,, -Bathytoshia centroura,Bathytoshia centroura,Roughtail stingray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Dasyatidae,Dasyatis,Species,1017389,2572,Species,,,,,,, -Batrachoididae,Batrachoididae,Toadfishes,Animalia,Chordata,Teleostei,Batrachoidiformes,Batrachoididae,NA,Family,125450,NA,Remove,,,,,,, -Batrachonotus fragosus,Batrachonotus fragosus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Batrachonotus,Species,421962,NA,Species,,,,,,, -Leptochiton alveolus,Belknapchiton alveolus,NA,Animalia,Mollusca,Polyplacophora,Lepidopleurida,Leptochitonidae,Leptochiton,Species,1610477,NA,Species,,,,,,, -Belknapchiton alveolus,Belknapchiton alveolus,NA,Animalia,Mollusca,Polyplacophora,Lepidopleurida,Leptochitonidae,Leptochiton,Species,1610477,NA,Species,,,,,,, -Leptochiton belknapi,Belknapchiton belknapi,NA,Animalia,Mollusca,Polyplacophora,Lepidopleurida,Leptochitonidae,Leptochiton,Species,1610474,NA,Species,,,,,,, -Belknapchiton belknapi,Belknapchiton belknapi,NA,Animalia,Mollusca,Polyplacophora,Lepidopleurida,Leptochitonidae,Leptochiton,Species,1610474,NA,Species,,,,,,, -Bellator,Bellator,NA,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Bellator,Genus,159567,NA,Remove,,,,,,, -Bellator brachychir,Bellator brachychir,Shortfin searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Bellator,Species,276271,4012,Species,,,,,,, -Bellator egretta,Bellator egretta,Streamer searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Bellator,Species,276272,4013,Species,,,,,,, -Bellator militaris,Bellator militaris,Horned searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Bellator,Species,159568,4014,Species,,,,,,, -Bellator xenisma,Bellator xenisma,Splitnose searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Bellator,Species,276277,4015,Species,,,,,,, -Bembrops anatirostris,Bembrops anatirostris,Duckbill flathead,Animalia,Chordata,Teleostei,Perciformes,Percophidae,Bembrops,Species,159842,3696,Species,,,,,,, -Bembrops gobioides,Bembrops gobioides,Goby flathead,Animalia,Chordata,Teleostei,Perciformes,Percophidae,Bembrops,Species,159843,3697,Species,,,,,,, -Benthalbella,Benthalbella,NA,Animalia,Chordata,Teleostei,Aulopiformes,Scopelarchidae,Benthalbella,Genus,125681,NA,Remove,,,,,,, -Benthalbella sp.,Benthalbella,NA,Animalia,Chordata,Teleostei,Aulopiformes,Scopelarchidae,Benthalbella,Genus,125681,NA,Remove,,,,,,, -Benthalbella dentata,Benthalbella dentata,Northern pearleye,Animalia,Chordata,Teleostei,Aulopiformes,Scopelarchidae,Benthalbella,Species,254572,2730,Species,,,,,,, -Benthesicymus,Benthesicymus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Benthesicymidae,Benthesicymus,Genus,106811,NA,Remove,,,,,,, -Benthodesmus,Benthodesmus,NA,Animalia,Chordata,Teleostei,Scombriformes,Trichiuridae,Benthodesmus,Genus,126096,NA,Remove,,,,,,, -Benthodesmus pacificus,Benthodesmus pacificus,North pacific frostfish,Animalia,Chordata,Teleostei,Scombriformes,Trichiuridae,Benthodesmus,Species,274013,8550,Species,,,,,,, -Benthodesmus simonyi,Benthodesmus simonyi,Simony's frostfish,Animalia,Chordata,Teleostei,Scombriformes,Trichiuridae,Benthodesmus,Species,127087,8553,Species,,,,,,, -Benthopectinidae,Benthopectinidae,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Benthopectinidae,NA,Family,123126,NA,Remove,,,,,,, -Benthosema glaciale,Benthosema glaciale,Glacier lantern fish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Benthosema,Species,126580,21,Species,,,,,,, -Beringius,Beringius,True whelks,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Beringius,Genus,137699,NA,Remove,,,,,,, -Beringius sp.,Beringius,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Beringius,Genus,137699,NA,Remove,,,,,,, -Beringius behringi,Beringius behringii,Behring's whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Beringius,Species,160112,NA,Species,,,,,,, -Beringius behringii,Beringius behringii,Behring's whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Beringius,Species,160112,NA,Species,,,,,,, -Beringius crebricostatus,Beringius crebricostatus,Thick cord whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Beringius,Species,254474,NA,Species,,,,,,, -Beringius eyerdami,Beringius eyerdami,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Beringius,Species,490763,NA,Species,,,,,,, -Beringius kennicottii,Beringius kennicottii,Rotund whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Beringius,Species,580830,NA,Species,,,,,,, -Beringius rotundus,Beringius rotundus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Beringius,Species,137699,NA,Species,,,,,,, -Beringius sp. A (McLean and Clark),Beringius sp. A (McLean and Clark),Baxter Beringius,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Beringius sp. B (McLean and Clark),Beringius sp. B (McLean and Clark),two-channeled Beringius,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Beringius sp. C (McLean and Clark),Beringius sp. C (McLean and Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Beringius sp. D (McLean and Clark),Beringius sp. D (McLean and Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Beringius sp. eggs,Beringius sp. eggs,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Beringius sp. F (McLean and Clark),Beringius sp. F (McLean and Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Beringius sp. G (McLean and Clark),Beringius sp. G (McLean and Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Beringius sp. H (McLean and Clark),Beringius sp. H (McLean and Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Beringius sp. I (McLean and Clark),Beringius sp. I (McLean and Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Beringius sp. J (McLean and Clark),Beringius sp. J (McLean and Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Beringius stimpsoni,Beringius stimpsoni,Stimpson's whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Beringius,Species,490767,NA,Species,,,,,,, -Beringius undatus,Beringius undatus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Beringius,Species,490768,NA,Species,,,,,,, -Beringraja binoculata,Beringraja binoculata,Big skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Beringraja,Species,1021330,2556,Species,,,,,,, -Raja binoculata,Beringraja binoculata,Big skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Beringraja,Species,1021330,2556,Species,,,,,,, -Raja inornata,Beringraja inornata,California skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Species,1461134,2558,Species,,,,,,, -Raja rhina,Beringraja rhina,Longnose skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Species,1461133,2566,Species,,,,,,, -Beringraja rhina,Beringraja rhina,Longnose skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Species,1461133,2566,Species,,,,,,, -Raja stellulata,Beringraja stellulata,Starry skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Species,1461135,2570,Species,,,,,,, -Beroe,Beroe,NA,Animalia,Ctenophora,Nuda,Beroida,Beroidae,Beroe,Genus,1434803,NA,Remove,,,,,,, -Beroe sp.,Beroe,NA,Animalia,Ctenophora,Nuda,Beroida,Beroidae,Beroe,Genus,1434803,NA,Remove,,,,,,, -Beroe abyssicola,Beroe abyssicola,NA,NA,NA,NA,NA,NA,NA,Species,265150,NA,Species,,,,,,, -Beroe ovata,Beroe ovata,Brown comb jelly,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Berryteuthis magister,Berryteuthis magister,Magister armhook squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,Berryteuthis,Species,342286,NA,Species,,,,,,, -Bertella idiomorpha,Bertella idiomorpha,NA,Animalia,Chordata,Teleostei,Lophiiformes,Oneirodidae,Bertella,Species,279907,23258,Species,,,,,,, -Berthellina quadridens,Berthellina quadridens,NA,Animalia,Mollusca,Gastropoda,Pleurobranchida,Pleurobranchidae,Berthellina,Species,420584,NA,Species,,,,,,, -Bivalvia,Bivalvia,Bivalves,Animalia,Mollusca,Bivalvia,NA,NA,NA,Class,105,NA,Remove,,,,,,, -Pelecypoda,Bivalvia,Bivalves,Animalia,Mollusca,Bivalvia,NA,NA,NA,Class,105,NA,Remove,,,,,,, -Blenniidae,Blenniidae,Combtooth blennies,Animalia,Chordata,Teleostei,Blenniiformes,Blenniidae,NA,Family,125519,NA,Remove,,,,,,, -Blennioidei,Blenniiformes,NA,Animalia,Chordata,Teleostei,Perciformes,NA,NA,Genus,1517542,NA,Remove,,,,,,, -Blenniodei,Blenniodei,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Blepsias bilobus,Blepsias bilobus,Crested sculpin,Animalia,Chordata,Teleostei,Perciformes,Hemitripteridae,Blepsias,Species,254540,4053,Species,,,,,,, -Bodianus pulchellus,Bodianus pulchellus,Spotfin hogfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Bodianus,Species,273540,1066,Species,,,,,,, -Bolinia euryptera,Bolinia euryptera,Sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Bolinia,Species,398458,58277,Species,,,,,,, -Bolinopsis,Bolinopsis,NA,Animalia,Ctenophora,Tentaculata,Lobata,Bolinidae,Bolinopsis,Genus,106350,NA,Remove,,,,,,, -Bolinopsis sp.,Bolinopsis,NA,Animalia,Ctenophora,Tentaculata,Lobata,Bolinidae,Bolinopsis,Genus,106350,NA,Remove,,,,,,, -Bolitaenidae,Bolitaeninae,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Bolitaenidae,NA,Family,742052,NA,Remove,,,,,,, -Bollmannia,Bollmannia,NA,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Bollmannia,Genus,268559,NA,Remove,,,,,,, -Bollmannia boqueronensis,Bollmannia boqueronensis,White eye goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Bollmannia,Species,279927,3838,Species,,,,,,, -Bollmannia communis,Bollmannia communis,Ragged goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Bollmannia,Species,279929,3839,Species,,,,,,, -Boltenia,Boltenia,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Pyuridae,Boltenia,Genus,103514,NA,Remove,,,,,,, -Boltenia sp.,Boltenia,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Pyuridae,Boltenia,Genus,103514,NA,Remove,,,,,,, -Boltenia ecinata,Boltenia echinata,Cactus sea squirt,Animalia,Chordata,Ascidiacea,Stolidobranchia,Pyuridae,Boltenia,Species,103814,NA,Species,,,,,,, -Boltenia echinata,Boltenia echinata,Cactus sea squirt,Animalia,Chordata,Ascidiacea,Stolidobranchia,Pyuridae,Boltenia,Species,103814,NA,Species,,,,,,, -Boltenia ovifera,Boltenia ovifera,Stalked sea squirt,Animalia,Chordata,Ascidiacea,Stolidobranchia,Pyuridae,Boltenia,Species,103815,NA,Species,,,,,,, -Boltenia villosa,Boltenia villosa,Spiny headed sea squirt,Animalia,Chordata,Ascidiacea,Stolidobranchia,Pyuridae,Boltenia,Species,250073,NA,Species,,,,,,, -Bonneviella,Bonneviella,NA,Animalia,Cnidaria,Hydrozoa,Leptothecata,Bonneviellidae,Bonneviella,Genus,117009,NA,Remove,,,,,,, -Bonneviella sp.,Bonneviella,NA,Animalia,Cnidaria,Hydrozoa,Leptothecata,Bonneviellidae,Bonneviella,Genus,117009,NA,Remove,,,,,,, -Bonneviella sp. A (Clark 2006),Bonneviella sp. A (Clark 2006),champagne flute hydroid,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Boreogadus saida,Boreogadus saida,Arctic cod,Animalia,Chordata,Teleostei,Gadiformes,Gadidae,Boreogadus,Species,126433,319,Species,,,,,,, -Bentheogennema borealis,Boreogennema borealis,Northern blunt-tail shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Benthesicymidae,Bentheogennema,Species,1422238,NA,Species,,,,,,, -Boreogennema borealis,Boreogennema borealis,Northern blunt-tail shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Benthesicymidae,Bentheogennema,Species,1422238,NA,Species,,,,,,, -Boreoscala greenlandica,Boreoscala greenlandica,Greenland wentletrap,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Epitoniidae,Boreoscala,Species,523706,NA,Species,,,,,,, -Boreotrophon,Boreotrophon,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Boreotrophon,Genus,146731,NA,Remove,,,,,,, -Boreotrophon sp.,Boreotrophon,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Boreotrophon,Genus,146731,NA,Remove,,,,,,, -Boreotrophon alaskanus,Boreotrophon alaskanus,Alaskan trophon,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Boreotrophon,Species,398880,NA,Species,,,,,,, -Boreotrophon beringi,Boreotrophon beringi,Clathrate trophon,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Boreotrophon,Species,146732,NA,Species,,,,,,, -Boreotrophon clathratus,Boreotrophon clathratus,Clathrate trophon,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Boreotrophon,Species,146732,NA,Species,,,,,,, -Boreotrophon multicostatus,Boreotrophon multicostatus,Ribbed trophon,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Boreotrophon,Species,398930,NA,Species,,,,,,, -Boreotrophon pacificus,Boreotrophon pacificus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Boreotrophon,Species,398932,NA,Species,,,,,,, -Boreotrophon rotundatus,Boreotrophon rotundatus,rotund trophon,NA,NA,NA,NA,NA,NA,Species,398935,NA,Species,,,,,,, -Borostomias panamensis,Borostomias panamensis,Panama snaggletooth,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,Borostomias,Species,275052,5161,Species,,,,,,, -Bothidae,Bothidae,Lefteye flounders,Animalia,Chordata,Teleostei,Pleuronectiformes,Bothidae,NA,Family,125576,NA,Remove,,,,,,, -Bothrocara,Bothrocara,NA,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Bothrocara,Genus,234576,NA,Remove,,,,,,, -Bothrocara sp.,Bothrocara,NA,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Bothrocara,Genus,234576,NA,Remove,,,,,,, -Bothrocara brunneum,Bothrocara brunneum,Twoline eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Bothrocara,Species,279397,11657,Species,,,,,,, -Bothrocara hollandi,Bothrocara hollandi,Japan-sea eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Bothrocara,Species,279399,25013,Species,,,,,,, -Bothrocara molle,Bothrocara molle,Soft eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Bothrocara,Species,234593,24695,Species,,,,,,, -Bothrocara nyx,Bothrocara nyx,shadow eelpout,NA,NA,NA,NA,NA,NA,Species,254582,NA,Species,,,,,,, -Bothrocara pusillum,Bothrocara pusillum,Alaska eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Bothrocara,Species,279400,3130,Species,,,,,,, -Bothrocara sp. cf. brunneum group,Bothrocara sp. cf. brunneum group,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Bothrocara zestum,Bothrocara zestum,Western eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Bothrocara,Species,1566163,NA,Species,,,,,,, -Bothus,Bothus,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,Bothidae,Bothus,Genus,126110,NA,Remove,,,,,,, -Bothus lunatus,Bothus lunatus,Plate fish,Animalia,Chordata,Teleostei,Pleuronectiformes,Bothidae,Bothus,Species,274187,978,Species,,,,,,, -Bothus ocellatus,Bothus ocellatus,Eyed flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Bothidae,Bothus,Species,159275,4207,Species,,,,,,, -Bothus robinsi,Bothus robinsi,Twospot flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Bothidae,Bothus,Species,159277,4208,Species,,,,,,, -Botryllus schlosseri,Botryllus schlosseri,Golden star tunicate,Animalia,Chordata,Ascidiacea,Stolidobranchia,Styelidae,Botryllus,Species,103862,NA,Species,,,,,,, -Brachiopoda,Brachiopoda,Lamp shells,Animalia,Brachiopoda,NA,NA,NA,NA,Phylum,1803,NA,Remove,,,,,,, -Brachyura,Brachyura,NA,Animalia,Arthropoda,Malacostraca,Decapoda,NA,NA,InfraOrder,106673,NA,Remove,,,,,,, -Brain sponge,Brain sponge,NA,NA,NA,NA,NA,NA,NA,Remove,NA,NA,Remove,,,,,,, -Brama brama,Brama brama,Atlantic pomfret,Animalia,Chordata,Teleostei,Scombriformes,Bramidae,Brama,Species,126783,391,Species,,,,,,, -Brama japonica,Brama japonica,Pacific pomfret,Animalia,Chordata,Teleostei,Scombriformes,Bramidae,Brama,Species,273148,3555,Species,,,,,,, -Bregmaceros,Bregmaceros,NA,Animalia,Chordata,Teleostei,Gadiformes,Bregmacerotidae,Bregmaceros,Genus,125727,NA,Remove,,,,,,, -Bregmaceros atlanticus,Bregmaceros atlanticus,Antenna codlet,Animalia,Chordata,Teleostei,Gadiformes,Bregmacerotidae,Bregmaceros,Species,126431,3100,Species,,,,,,, -Bregmaceros cantori,Bregmaceros cantori,Striped codlet,Animalia,Chordata,Teleostei,Gadiformes,Bregmacerotidae,Bregmaceros,Species,158924,56859,Species,,,,,,, -Brevoortia,Brevoortia,NA,Animalia,Chordata,Teleostei,Clupeiformes,Alosidae,Brevoortia,Genus,158688,NA,Remove,,,,,,, -Brevoortia gunteri,Brevoortia gunteri,Finescale menhaden,Animalia,Chordata,Teleostei,Clupeiformes,Alosidae,Brevoortia,Species,275499,1588,Species,,,,,,, -Brevoortia patronus,Brevoortia patronus,Gulf menhaden,Animalia,Chordata,Teleostei,Clupeiformes,Alosidae,Brevoortia,Species,275500,1589,Species,,,,,,, -Brevoortia smithi,Brevoortia smithi,Yellowfin menhaden,Animalia,Chordata,Teleostei,Clupeiformes,Alosidae,Brevoortia,Species,158690,1591,Species,,,,,,, -Brevoortia tyrannus,Brevoortia tyrannus,Atlantic menhaden,Animalia,Chordata,Teleostei,Clupeiformes,Alosidae,Brevoortia,Species,158691,1592,Species,,,,,,, -Brisaster,Brisaster,NA,Animalia,Echinodermata,Echinoidea,Spatangoida,Schizasteridae,Brisaster,Genus,123427,NA,Remove,,,,,,, -Brisaster sp.,Brisaster,NA,Animalia,Echinodermata,Echinoidea,Spatangoida,Schizasteridae,Brisaster,Genus,123427,NA,Remove,,,,,,, -Brisaster latifrons,Brisaster latifrons,Northern heart urchin,Animalia,Echinodermata,Echinoidea,Spatangoida,Schizasteridae,Brisaster,Species,513143,NA,Species,,,,,,, -Brisaster owstoni,Brisaster owstoni,NA,Animalia,Echinodermata,Echinoidea,Spatangoida,Schizasteridae,Brisaster,Species,513067,NA,Species,,,,,,, -Brisaster townsendi,Brisaster townsendi,Northern heart urchin,Animalia,Echinodermata,Echinoidea,Spatangoida,Schizasteridae,Brisaster,Species,513144,NA,Species,,,,,,, -Brisingidae,Brisingidae,Brisingid sea star,Animalia,Echinodermata,Asteroidea,Brisingida,Brisingidae,NA,Family,123119,NA,Remove,,,,,,, -Brissidae,Brissidae,NA,Animalia,Echinodermata,Echinoidea,Spatangoida,Brissidae,NA,Family,123173,NA,Remove,,,,,,, -Brissopsis alta,Brissopsis alta,NA,Animalia,Echinodermata,Echinoidea,Spatangoida,Brissidae,Brissopsis,Species,422509,NA,Species,,,,,,, -Brissopsis atlantica,Brissopsis atlantica,NA,Animalia,Echinodermata,Echinoidea,Spatangoida,Brissidae,Brissopsis,Species,124372,NA,Species,,,,,,, -Brissopsis pacifica,Brissopsis pacifica,Pacific heart urchin,Animalia,Echinodermata,Echinoidea,Spatangoida,Brissidae,Brissopsis,Species,513150,NA,Species,,,,,,, -Brosme brosme,Brosme brosme,Cusk,Animalia,Chordata,Teleostei,Gadiformes,Lotidae,Brosme,Species,126447,51,Species,,,,,,, -Brosmophycis marginata,Brosmophycis marginata,Red brotula,Animalia,Chordata,Teleostei,Ophidiiformes,Bythitidae,Brosmophycis,Species,280000,3121,Species,,,,,,, -Brotula barbatum,Brotula barbata,Bearded brotula,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Brotula,Species,159067,486,Species,,,,,,, -Brotula barbata,Brotula barbata,Bearded brotula,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Brotula,Species,159067,486,Species,,,,,,, -Bryozoa,Bryozoa,Moss animals,Animalia,Bryozoa,NA,NA,NA,NA,Phylum,146142,NA,Remove,,,,,,, -Bryozoichthys,Bryozoichthys,NA,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Bryozoichthys,Genus,254311,NA,Remove,,,,,,, -Bryozoichthys sp.,Bryozoichthys,NA,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Bryozoichthys,Genus,254311,NA,Remove,,,,,,, -Bryozoichthys lysimus,Bryozoichthys lysimus,Nutcracker prickleback,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Bryozoichthys,Species,279418,3777,Species,,,,,,, -Bryozoichthys marjorius,Bryozoichthys marjorius,Pearly prickleback,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Bryozoichthys,Species,254575,3778,Species,,,,,,, -Buccinidae,Buccinidae,True whelks,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,NA,Family,149,NA,Remove,,,,,,, -Bathybuccinum,Buccinum,True whelks,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Genus,137701,NA,Remove,,,,,,, -Buccinum,Buccinum,True whelks,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Genus,137701,NA,Remove,,,,,,, -Buccinum sp.,Buccinum,True whelks,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Genus,137701,NA,Remove,,,,,,, -Buccinum aleuticum,Buccinum aleuticum,Aleut whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,490781,NA,Species,,,,,,, -Buccinum angulosum,Buccinum angulosum,Angular whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,138858,NA,Species,,,,,,, -Buccinum transliratum,Buccinum angulosum transliratum,Transect whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,SubSpecies,1606908,NA,Species,,,,,,, -Buccinum angulosum transliratum,Buccinum angulosum transliratum,Transect whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,SubSpecies,1606908,NA,Species,,,,,,, -Buccinum bulimuloideum,Buccinum bulimuloideum,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,490790,NA,Species,,,,,,, -Buccinum ciliatum,Buccinum ciliatum,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,138860,NA,Species,,,,,,, -Bathybuccinum clarki,Buccinum clarki,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,1522638,NA,Species,,,,,,, -Buccinum cnismatum,Buccinum cnismatum,Scratched whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,491398,NA,Species,,,,,,, -Buccinum eugrammatum,Buccinum eugrammatum,Lirate whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,490803,NA,Species,,,,,,, -Buccinum fringillum,Buccinum fringillum,Finch whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,423195,NA,Species,,,,,,, -Buccinum glaciale,Buccinum glaciale,Glacial whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,138864,NA,Species,,,,,,, -Buccinum picturatum,Buccinum mirandum picturatum,Painted whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,491435,NA,Species,,,,,,, -Buccinum mirandum picturatum,Buccinum mirandum picturatum,Painted whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,491435,NA,Species,,,,,,, -Buccinum moarchianum,Buccinum morchianum,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,138864,NA,Species,,,,,,, -Buccinum oedematum,Buccinum oedematum,Swollen whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,490835,NA,Species,,,,,,, -Bathybuccinum ovulum,Buccinum ovulum,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Bathybuccinum,Species,580743,NA,Species,,,,,,, -Buccinum ovulum,Buccinum ovulum,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Bathybuccinum,Species,580743,NA,Species,,,,,,, -Buccinum plectrum,Buccinum plectrum,Sinuous whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,160127,NA,Species,,,,,,, -Buccinum polare,Buccinum polare,Polar whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,138873,NA,Species,,,,,,, -Buccinum rondinum,Buccinum rondinum,Eroded whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,490844,NA,Species,,,,,,, -Buccinum scalariforme,Buccinum scalariforme,Ladder whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,138875,NA,Species,,,,,,, -Buccinum sigmatopleura,Buccinum sigmatopleura,Wavy whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,490851,NA,Species,,,,,,, -Buccinum simulatum,Buccinum simulatum,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,580865,NA,Species,,,,,,, -Buccinum sp. C (McLean and Clark),Buccinum sp. C (McLean and Clark),one-ribbed whelk,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Buccinum sp. E (McLean and Clark),Buccinum sp. E (McLean and Clark),two-ribbed chestnut whelk,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Buccinum sp. egg,Buccinum sp. egg,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Buccinum sp. F (McLean and Clark),Buccinum sp. F (McLean and Clark),crenulated whelk,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Buccinum strigillatum,Buccinum strigillatum,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,490857,NA,Species,,,,,,, -Buccinum tenellum,Buccinum tenellum,Pleated whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,580869,NA,Species,,,,,,, -Buccinum solenum,Buccinum terraenovae,Solen whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,490864,NA,Species,,,,,,, -Buccinum terraenovae,Buccinum terraenovae,Solen whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,490864,NA,Species,,,,,,, -Buccinum undatum,Buccinum undatum,Waved whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,138878,NA,Species,,,,,,, -Buccinum viridum,Buccinum viridum,Turban whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,490869,NA,Species,,,,,,, -Bugula,Bugula,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Bugulidae,Bugula,Genus,110839,NA,Remove,,,,,,, -Bugula sp.,Bugula,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Bugulidae,Bugula,Genus,110839,NA,Remove,,,,,,, -Bulbus fragilis,Bulbus fragilis,Fragile moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Bulbus,Species,146741,NA,Species,,,,,,, -Bulla striata,Bulla striata,Striate bubble,Animalia,Mollusca,Gastropoda,Cephalaspidea,Bullidae,Bulla,Species,138940,NA,Species,,,,,,, -Bursa granalaris cubaniana,Bursa granalaris,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Bursatella,Bursatella,NA,Animalia,Mollusca,Gastropoda,Aplysiida,Aplysiidae,Bursatella,Genus,137655,NA,Remove,,,,,,, -Bursatella leachii pleii,Bursatella leachii,NA,Animalia,Mollusca,Gastropoda,Aplysiida,Aplysiidae,Bursatella,SubSpecies,138759,NA,SubSpecies,,,,,,, -Bursidae,Bursidae,Frog snails,Animalia,Mollusca,Gastropoda,Littorinimorpha,Bursidae,NA,Family,22995,NA,Remove,,,,,,, -Busycon coarctatum,Busycoarctum coarctatum,Turnip whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862944,NA,Species,,,,,,, -Busycoarctum coarctatum,Busycoarctum coarctatum,Turnip whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862944,NA,Species,,,,,,, -Busycon,Busycon,True whelks,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Genus,160183,NA,Remove,,,,,,, -Busycon canaliculatum,Busycotypus canaliculatus,Channeled whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,160192,NA,Species,,,,,,, -Busycotypus canaliculatus,Busycotypus canaliculatus,Channeled whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,160192,NA,Species,,,,,,, -Busycon spiratum,Busycotypus spiratus,Pearwhelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,160183,NA,Species,,,,,,, -Cadlina luteomarginata,Cadlina luteomarginata,Yellow edge cadlina,Animalia,Mollusca,Gastropoda,Nudibranchia,Cadlinidae,Cadlina,Species,562476,NA,Species,,,,,,, -Cadlina modesta,Cadlina modesta,Modest cadlina,Animalia,Mollusca,Gastropoda,Nudibranchia,Cadlinidae,Cadlina,Species,564148,NA,Species,,,,,,, -Caecum,Caecum,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Caecidae,Caecum,Genus,137718,NA,Remove,,,,,,, -Calamus,Calamus,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Calamus,Genus,159240,NA,Remove,,,,,,, -Calamus arctifrons,Calamus arctifrons,Grass porgy,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Calamus,Species,275966,1220,Species,,,,,,, -Calamus bajonado,Calamus bajonado,Jolthead porgy,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Calamus,Species,159241,1221,Species,,,,,,, -Calamus calamus,Calamus calamus,Saucereye porgy,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Calamus,Species,159242,1222,Species,,,,,,, -Calamus leucosteus,Calamus leucosteus,Whitebone porgy,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Calamus,Species,275970,1225,Species,,,,,,, -Calamus nodosus,Calamus nodosus,Knobbed porgy,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Calamus,Species,159243,1226,Species,,,,,,, -Calamus penna,Calamus penna,Sheepshead porgy,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Calamus,Species,159245,1227,Species,,,,,,, -Calamus proridens,Calamus proridens,Littlehead porgy,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Calamus,Species,275973,1229,Species,,,,,,, -Calappa,Calappa,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Calappa,Genus,106873,NA,Remove,,,,,,, -Calappa flammea,Calappa flammea,Flame box crab,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Calappa,Species,158052,NA,Species,,,,,,, -Calappa galloides,Calappa galloides,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Calappa,Species,241042,NA,Species,,,,,,, -Calappa gallus,Calappa gallus,Rough box crab,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Calappa,Species,209502,NA,Species,,,,,,, -Calappa ocellata,Calappa ocellata,Ocellated box crab,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Calappa,Species,421918,NA,Species,,,,,,, -Calappa sulcata,Calappa sulcata,Yellow box crab,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Calappa,Species,394994,NA,Species,,,,,,, -Calappidae,Calappidae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,NA,Family,106747,NA,Remove,,,,,,, -Calappa tortugae,Calappula tortugae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Calappa,Species,876221,NA,Species,,,,,,, -Calappula tortugae,Calappula tortugae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Calappa,Species,876221,NA,Species,,,,,,, -Calcigorgia,Calcigorgia,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Malacalcyonacea incertae sedis,Calcigorgia,Genus,378315,NA,Remove,,,,,,, -Calcigorgia sp.,Calcigorgia,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Malacalcyonacea incertae sedis,Calcigorgia,Genus,378315,NA,Remove,,,,,,, -Calcigorgia beringi,Calcigorgia beringi,Bering sea fan coral,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Malacalcyonacea incertae sedis,Calcigorgia,Species,520678,NA,Species,,,,,,, -Calcigorgia spiculifera,Calcigorgia spiculifera,Pink gorgonian,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Malacalcyonacea incertae sedis,Calcigorgia,Species,378316,NA,Species,,,,,,, -Calinaticina oldroydii,Calinaticina oldroydii,Oldroyd's fragile moon snail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Calinaticina,Species,580690,NA,Species,,,,,,, -Calinaticina oldroyi,Calinaticina oldroydii,Oldroyd's fragile moon snail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Calinaticina,Species,580690,NA,Species,,,,,,, -Callechelys,Callechelys,NA,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Callechelys,Genus,158603,NA,Remove,,,,,,, -Calliactis,Calliactis,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Hormathiidae,Calliactis,Genus,100754,NA,Remove,,,,,,, -Calliactis tricolor,Calliactis tricolor,Hermit anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Hormathiidae,Calliactis,Species,283624,NA,Species,,,,,,, -Callianassa,Callianassa,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Callianassidae,Callianassa,Genus,107072,NA,Remove,,,,,,, -Callianassa sp.,Callianassa,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Callianassidae,Callianassa,Genus,107072,NA,Remove,,,,,,, -Callianassidae,Callianassidae,Ghost shrimps,Animalia,Arthropoda,Malacostraca,Decapoda,Callianassidae,NA,Family,106800,NA,Remove,,,,,,, -Olivella beatica,Callianax alectona,Beatic dwarf olive,Animalia,Mollusca,Gastropoda,Neogastropoda,Olividae,Olivella,Species,1424885,NA,Species,,,,,,, -Callianax alectona,Callianax alectona,Beatic dwarf olive,Animalia,Mollusca,Gastropoda,Neogastropoda,Olividae,Olivella,Species,1424885,NA,Species,,,,,,, -Olivella biplicata,Callianax biplicata,Purple olive snail,Animalia,Mollusca,Gastropoda,Neogastropoda,Olividae,Olivella,Species,1424883,NA,Species,,,,,,, -Callianax biplicata,Callianax biplicata,Purple olive snail,Animalia,Mollusca,Gastropoda,Neogastropoda,Olividae,Olivella,Species,1424883,NA,Species,,,,,,, -Callidactylus asper,Callidactylus asper,Spurfinger purse crab,Animalia,Arthropoda,Malacostraca,Decapoda,Leucosiidae,Callidactylus,Species,421927,NA,Species,,,,,,, -Callinectes,Callinectes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Callinectes,Genus,106921,NA,Remove,,,,,,, -Callinectes larvatus,Callinectes marginatus,Masked swimcrab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Callinectes,Species,241106,NA,Species,,,,,,, -Callinectes ornatus,Callinectes ornatus,Shelling crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Callinectes,Species,158053,NA,Species,,,,,,, -Callinectes sapidus,Callinectes sapidus,Blue crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Callinectes,Species,107379,NA,Species,,,,,,, -Callinectes similis,Callinectes similis,Lesser blue crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Callinectes,Species,158055,NA,Species,,,,,,, -Callionymidae,Callionymidae,Dragonets,Animalia,Chordata,Teleostei,Callionymiformes,Callionymidae,NA,Family,125522,NA,Remove,,,,,,, -Callionymus,Callionymus,NA,Animalia,Chordata,Teleostei,Callionymiformes,Callionymidae,Callionymus,Genus,125930,NA,Remove,,,,,,, -Paradiplogrammus bairdi,Callionymus bairdi,Lancer dragonet,Animalia,Chordata,Teleostei,Callionymiformes,Callionymidae,Paradiplogrammus,Species,159626,3824,Species,,,,,,, -Calliostoma,Calliostoma,NA,Animalia,Mollusca,Gastropoda,Trochida,Calliostomatidae,Calliostoma,Genus,138584,NA,Remove,,,,,,, -Calliostoma sp.,Calliostoma,NA,Animalia,Mollusca,Gastropoda,Trochida,Calliostomatidae,Calliostoma,Genus,138584,NA,Remove,,,,,,, -Calliostoma euglyptum,Calliostoma euglyptum,Sculptured topsnail,Animalia,Mollusca,Gastropoda,Trochida,Calliostomatidae,Calliostoma,Species,419414,NA,Species,,,,,,, -Calliostoma jujubinum,Calliostoma jujubinum,Mottled topsnail,Animalia,Mollusca,Gastropoda,Trochida,Calliostomatidae,Calliostoma,Species,419419,NA,Species,,,,,,, -Calliostoma pulchrum,Calliostoma pulchrum,NA,Animalia,Mollusca,Gastropoda,Trochida,Calliostomatidae,Calliostoma,Species,419424,NA,Species,,,,,,, -Calliostoma scalenum,Calliostoma scalenum,NA,Animalia,Mollusca,Gastropoda,Trochida,Calliostomatidae,Calliostoma,Species,419429,NA,Species,,,,,,, -Calliostoma variegatum,Calliostoma variegatum,NA,Animalia,Mollusca,Gastropoda,Trochida,Calliostomatidae,Calliostoma,Species,580418,NA,Species,,,,,,, -Calliotropis carlotta,Calliotropis carlotta,NA,Animalia,Mollusca,Gastropoda,Seguenziida,Calliotropidae,Calliotropis,Species,592777,NA,Species,,,,,,, -Swiftia pacifica,Callistephanus pacificus,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Plexauridae,Swiftia,Species,1567760,NA,Species,,,,,,, -Callistephanus pacificus,Callistephanus pacificus,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Plexauridae,Swiftia,Species,1567760,NA,Species,,,,,,, -Psammogorgia simplex,Callistephanus simplex,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Gorgoniidae,Psammogorgia,Species,1608733,NA,Species,,,,,,, -Swiftia simplex,Callistephanus simplex,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Plexauridae,Swiftia,Species,1608733,NA,Species,,,,,,, -Callistephanus simplex,Callistephanus simplex,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Plexauridae,Swiftia,Species,1608733,NA,Species,,,,,,, -Octopus macropus,Callistoctopus macropus,White spotted octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Octopodidae,Octopus,Species,534558,NA,Species,,,,,,, -Callogorgia,Callogorgia,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Callogorgia,Genus,125317,NA,Remove,,,,,,, -Fanellia,Callogorgia,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Callogorgia,Genus,125317,NA,Remove,,,,,,, -Callogorgia sp.,Callogorgia,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Callogorgia,Genus,125317,NA,Remove,,,,,,, -Fanellia compressa,Callogorgia compressa,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Fanellia,Species,292043,NA,Species,,,,,,, -Callogorgia compressa,Callogorgia compressa,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Fanellia,Species,292043,NA,Species,,,,,,, -Fanellia fraseri,Callogorgia fraseri,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Fanellia,Species,292044,NA,Species,,,,,,, -Callogorgia fraseri,Callogorgia fraseri,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Fanellia,Species,292044,NA,Species,,,,,,, -Callogorgia kinoshitae,Callogorgia kinoshitai,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Callogorgia,Species,1055877,NA,Species,,,,,,, -Callista eucymata,Callpita eucymata,Glory of-the-seas venus,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Callista,Species,507497,NA,Species,,,,,,, -Callpita eucymata,Callpita eucymata,Glory of-the-seas venus,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Callista,Species,507497,NA,Species,,,,,,, -Calocarides,Calocarides,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Axiidae,Calocarides,Genus,107068,NA,Remove,,,,,,, -Calocarides quinqueseriatus,Calocarides quinqueseriatus,Keeled lobster shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Axiidae,Calocarides,Species,246244,NA,Species,,,,,,, -Calyptraeidae,Calyptraeidae,Slipper limpets,Animalia,Mollusca,Gastropoda,Littorinimorpha,Calyptraeidae,NA,Family,141,NA,Remove,,,,,,, -Campanulariidae,Campanulariidae,Campanulariid hydroid,Animalia,Cnidaria,Hydrozoa,Leptothecata,Campanulariidae,NA,Family,1606,NA,Remove,,,,,,, -Cancellaria crawfordiana,Cancellaria crawfordiana,Crawford nutmeg,Animalia,Mollusca,Gastropoda,Neogastropoda,Cancellariidae,Cancellaria,Species,464702,NA,Species,,,,,,, -Cancellaria reticulata,Cancellaria reticulata,Common nutmeg,Animalia,Mollusca,Gastropoda,Neogastropoda,Cancellariidae,Cancellaria,Species,515781,NA,Species,,,,,,, -Cancellaridae,Cancellaridae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Cancer,Cancer,Cancer crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Cancer,Genus,106876,NA,Remove,,,,,,, -Cancer sp.,Cancer,Cancer crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Cancer,Genus,106876,NA,Remove,,,,,,, -Cancer borealis,Cancer borealis,Jonah crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Cancer,Species,158056,NA,Species,,,,,,, -Cancer irroratus,Cancer irroratus,Atlantic rock crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Cancer,Species,158057,NA,Species,,,,,,, -Cancer productus,Cancer productus,Red rock crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Cancer,Species,440382,NA,Species,,,,,,, -Cancridae,Cancridae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,NA,Family,106749,NA,Remove,,,,,,, -Cantharus,Cantharus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Pisaniidae,Cantharus,Genus,205348,NA,Remove,,,,,,, -Cantherhines macrocerus,Cantherhines macrocerus,American whitespotted filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Cantherhines,Species,276250,4277,Species,,,,,,, -Cantherhines pullus,Cantherhines pullus,Orangespotted filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Cantherhines,Species,159493,1082,Species,,,,,,, -Canthidermis maculatus,Canthidermis maculata,Rough triggerfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Balistidae,Canthidermis,Species,127398,4278,Species,,,,,,, -Canthidermis maculata,Canthidermis maculata,Rough triggerfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Balistidae,Canthidermis,Species,127398,4278,Species,,,,,,, -Canthidermis sufflamen,Canthidermis sufflamen,Ocean triggerfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Balistidae,Canthidermis,Species,127399,4279,Species,,,,,,, -Canthigaster,Canthigaster,NA,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Canthigaster,Genus,126238,NA,Remove,,,,,,, -Canthigaster jamestyleri,Canthigaster jamestyleri,Goldface toby,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Canthigaster,Species,275257,61202,Species,,,,,,, -Canthigaster rostrata,Canthigaster rostrata,Caribbean sharpnose-puffer,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Canthigaster,Species,127411,4291,Species,,,,,,, -Canthigaster rostratus,Canthigaster rostrata,Caribbean sharpnose-puffer,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Canthigaster,Species,127411,4291,Species,,,,,,, -Caprella,Caprella,skeleton shrimps,Animalia,Arthropoda,Malacostraca,Amphipoda,Caprellidae,Caprella,Genus,101430,NA,Remove,,,,,,, -Caprella sp.,Caprella,skeleton shrimps,Animalia,Arthropoda,Malacostraca,Amphipoda,Caprellidae,Caprella,Genus,101430,NA,Remove,,,,,,, -Caproidae,Caproidae,NA,Animalia,Chordata,Teleostei,Acanthuriformes,Caproidae,NA,Family,125613,NA,Remove,,,,,,, -Trichotropidae,Capulidae,Hairy snails,Animalia,Mollusca,Gastropoda,Littorinimorpha,Trichotropidae,NA,Family,139,NA,Remove,,,,,,, -Capulidae,Capulidae,Hairy snails,Animalia,Mollusca,Gastropoda,Littorinimorpha,Trichotropidae,NA,Family,139,NA,Remove,,,,,,, -Synagrops trispinosus,Caraibops trispinosus,Threespine bass,Animalia,Chordata,Teleostei,Acropomatiformes,Acropomatidae,Synagrops,Species,1486847,14337,Species,,,,,,, -Caraibops trispinosus,Caraibops trispinosus,Threespine bass,Animalia,Chordata,Teleostei,Acropomatiformes,Acropomatidae,Synagrops,Species,1486847,14337,Species,,,,,,, -Carangidae,Carangidae,Jacks and pompanos,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,NA,Family,125523,NA,Remove,,,,,,, -Caranx,Caranx,NA,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Caranx,Genus,125936,NA,Remove,,,,,,, -Caranx bartholomaei,Caranx bartholomaei,Yellow jack,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Caranx,Species,302312,1913,Species,,,,,,, -Caranx crysos,Caranx crysos,Blue runner,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Caranx,Species,126802,1933,Species,,,,,,, -Caranx hippos,Caranx hippos,Crevalle jack,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Caranx,Species,126803,71,Species,,,,,,, -Caranx latus,Caranx latus,Horse eye jack,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Caranx,Species,126804,1935,Species,,,,,,, -Caranx ruber,Caranx ruber,Bar jack,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Caranx,Species,302432,1918,Species,,,,,,, -Carapus bermudensis,Carapus bermudensis,Pearlfish,Animalia,Chordata,Teleostei,Ophidiiformes,Carapidae,Carapus,Species,158995,3128,Species,,,,,,, -Carcharhinidae,Carcharhinidae,Requiem sharks,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,NA,Family,105689,NA,Remove,,,,,,, -Carcharhinus acronotus,Carcharhinus acronotus,Blacknose shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,Carcharhinus,Species,158508,857,Species,,,,,,, -Carcharhinus brevipinna,Carcharhinus brevipinna,Spinner shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,Carcharhinus,Species,105788,865,Species,,,,,,, -Carcharhinus falciformis,Carcharhinus falciformis,Silky shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,Carcharhinus,Species,105789,868,Species,,,,,,, -Carcharhinus isodon,Carcharhinus isodon,Finetooth shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,Carcharhinus,Species,105791,872,Species,,,,,,, -Carcharhinus leucas,Carcharhinus leucas,Bull shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,Carcharhinus,Species,105792,873,Species,,,,,,, -Carcharhinus limbatus,Carcharhinus limbatus,Blacktip shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,Carcharhinus,Species,105793,874,Species,,,,,,, -Carcharhinus obscurus,Carcharhinus obscurus,Dusky shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,Carcharhinus,Species,105796,878,Species,,,,,,, -Carcharhinus plumbeus,Carcharhinus plumbeus,Sandbar shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,Carcharhinus,Species,105797,880,Species,,,,,,, -Carcharhinus porosus,Carcharhinus porosus,Smalltail shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,Carcharhinus,Species,217342,881,Species,,,,,,, -Carcharhinus signatus,Carcharhinus signatus,Night shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,Carcharhinus,Species,105798,883,Species,,,,,,, -Carcharias taurus,Carcharias taurus,Sand tiger shark,Animalia,Chordata,Elasmobranchii,Lamniformes,Odontaspididae,Carcharias,Species,105843,747,Species,,,,,,, -Carcinus maenas,Carcinus maenas,Green crab,Animalia,Arthropoda,Malacostraca,Decapoda,Carcinidae,Carcinus,Species,107381,NA,Species,,,,,,, -Cardiidae,Cardiidae,NA,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,NA,Family,229,NA,Remove,,,,,,, -Cardita,Cardita,NA,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,Cardita,Genus,137742,NA,Remove,,,,,,, -Cardita sp.,Cardita,NA,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,Cardita,Genus,137742,NA,Remove,,,,,,, -Cardita floridana,Cardites floridanus,Broad ribbed carditid,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,Cardites,Species,504861,NA,Species,,,,,,, -Carditidae,Carditidae,Cardita clams,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,NA,Family,22997,NA,Remove,,,,,,, -Careproctus,Careproctus,NA,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Genus,126156,NA,Remove,,,,,,, -Careproctus sp.,Careproctus,NA,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Genus,126156,NA,Remove,,,,,,, -Careproctus abbreviatus,Careproctus abbreviatus,NA,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,274402,51398,Species,,,,,,, -Careproctus bowersianus,Careproctus bowersianus,Bowers Bank snailfish,NA,NA,NA,NA,NA,NA,Species,274414,NA,Species,,,,,,, -Careproctus bromius,Careproctus bromius,boisterous snailfish,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Careproctus canus,Careproctus canus,Gray snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,274416,51477,Species,,,,,,, -Careproctus colletti,Careproctus colletti,Alaska snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,254547,24141,Species,,,,,,, -Careproctus comus,Careproctus comus,Comic snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,398460,64561,Species,,,,,,, -Careproctus cypselurus,Careproctus cypselurus,Falcate snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,274421,24127,Species,,,,,,, -Careproctus ectenes,Careproctus ectenes,Shovelhead snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,274424,50723,Species,,,,,,, -Careproctus faunus,Careproctus faunus,Mischievous snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,398463,64563,Species,,,,,,, -Careproctus furcellus,Careproctus furcellus,Emarginate snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,254548,24126,Species,,,,,,, -Careproctus gilberti,Careproctus gilberti,Smalldisk snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,367288,25161,Species,,,,,,, -Careproctus kamikawi,Careproctus kamikawai,NA,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,834998,67402,Species,,,,,,, -Careproctus lerikimae,Careproctus lerikimae,Dusty snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,1384967,68919,Species,,,,,,, -Careproctus lycopersicus,Careproctus lycopersicus,Tomato snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,834999,67403,Species,,,,,,, -Careproctus blacktail snailfish,Careproctus melanurus,Blacktail snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,254549,4179,Species,,,,,,, -Careproctus melanurus,Careproctus melanurus,Blacktail snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,254549,4179,Species,,,,,,, -Careproctus ostentum,Careproctus ostentum,Microdisk snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,274453,50718,Species,,,,,,, -Careproctus ovigerum,Careproctus ovigerus,Abyssal snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,274454,25166,Species,,,,,,, -Careproctus phasma,Careproctus phasma,Monster snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,274460,50786,Species,,,,,,, -Careproctus ranula,Careproctus ranula,Scotian snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,159523,54217,Species,,,,,,, -Careproctus rastrinus,Careproctus rastrinus,Salmon snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,274464,24131,Species,,,,,,, -Careproctus scottae,Careproctus scottae,Peachskin snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,274470,51406,Species,,,,,,, -Careproctus simus,Careproctus simus,Proboscis snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,274473,27968,Species,,,,,,, -Careproctus sp. cf. gilberti (Orr),Careproctus sp. cf. gilberti (Orr),dominator snailfish,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Careproctus sp. cf. melanurus (Orr et al.),Careproctus sp. cf. melanurus (Orr et al.),scorched snailfish,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Careproctus staufferi,Careproctus staufferi,Wry snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,1493316,NA,Species,,,,,,, -Careproctus zachirus,Careproctus zachirus,Paintbrush snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,274483,51484,Species,,,,,,, -Caretta caretta,Caretta caretta,Loggerhead turtle,Animalia,Chordata,NA,Testudines,Cheloniidae,Caretta,Species,137205,NA,Species,,,,,,, -Chlamys sentis,Caribachlamys sentis,Scaly scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Species,138315,NA,Species,,,,,,, -Caribachlamys sentis,Caribachlamys sentis,Scaly scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Species,138315,NA,Species,,,,,,, -Caridea,Caridea,Shrimps,Animalia,Arthropoda,Malacostraca,Decapoda,NA,NA,InfraOrder,106674,NA,Remove,,,,,,, -Carinaria cristata,Carinaria cristata,Glassy nautilus,Animalia,Mollusca,Gastropoda,Littorinimorpha,Carinariidae,Carinaria,Species,574935,NA,Species,,,,,,, -Carinariidae,Carinariidae,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Carinariidae,NA,Family,22998,NA,Remove,,,,,,, -Caristiidae,Caristiidae,Manefishes,Animalia,Chordata,Teleostei,Scombriformes,Caristiidae,NA,Family,125524,NA,Remove,,,,,,, -Caristius macropus,Caristius macropus,Manefish,Animalia,Chordata,Teleostei,Scombriformes,Caristiidae,Caristius,Species,126824,11831,Species,,,,,,, -Carpoporus papulosus,Carpoporus papulosus,Narrowfront rubble crab,Animalia,Arthropoda,Malacostraca,Decapoda,Xanthidae,Carpoporus,Species,422127,NA,Species,,,,,,, -Caryophyllia,Caryophyllia,Cupcorals,Animalia,Cnidaria,Anthozoa,Scleractinia,Caryophylliidae,Caryophyllia,Genus,135085,NA,Remove,,,,,,, -Caryophyllia sp.,Caryophyllia,Cupcorals,Animalia,Cnidaria,Anthozoa,Scleractinia,Caryophylliidae,Caryophyllia,Genus,135085,NA,Remove,,,,,,, -Caryophyllia alaskensis,Caryophyllia (Caryophyllia) alaskensis,Tan cup coral,Animalia,Cnidaria,Anthozoa,Scleractinia,Caryophylliidae,Caryophyllia,Species,286724,NA,Species,,,,,,, -Caryophyllia arnoldi,Caryophyllia (Caryophyllia) arnoldi,Arnold's stony coral,Animalia,Cnidaria,Anthozoa,Scleractinia,Caryophylliidae,Caryophyllia,Species,286728,NA,Species,,,,,,, -Caryophyllia sp. A,Caryophyllia sp. A,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Caryophylliidae,Caryophylliidae,Cupcorals,Animalia,Cnidaria,Anthozoa,Scleractinia,Caryophylliidae,NA,Family,135073,NA,Remove,,,,,,, -Cassianellidae,Cassianellidae,NA,Animalia,Mollusca,Bivalvia,Ostreida,Cassianellidae,NA,Family,833158,NA,Remove,,,,,,, -Cassidae,Cassidae,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cassidae,NA,Genus,22999,NA,Remove,,,,,,, -Cassididae,Cassididae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Cassiopea xamachama,Cassiopea xamachana,Upsidedown jellyfish,Animalia,Cnidaria,Scyphozoa,Rhizostomeae,Cassiopeidae,Cassiopea,Species,287172,NA,Species,,,,,,, -Cassiopea xamachana,Cassiopea xamachana,Upsidedown jellyfish,Animalia,Cnidaria,Scyphozoa,Rhizostomeae,Cassiopeidae,Cassiopea,Species,287172,NA,Species,,,,,,, -Cassis,Cassis,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cassidae,Cassis,Genus,206265,NA,Remove,,,,,,, -Cassis flammea,Cassis flammea,Flame helmet,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cassidae,Cassis,Species,419777,NA,Species,,,,,,, -Cassis madagascariensis,Cassis madagascariensis,Emperor helmet,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cassidae,Cassis,Species,419778,NA,Species,,,,,,, -Cassis tuberosa,Cassis tuberosa,King helmet,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cassidae,Cassis,Species,224977,NA,Species,,,,,,, -Buccinum castaneum,Castaneobuccinum castaneum,Chestnut whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,1699283,NA,Species,,,,,,, -Castaneobuccinum castaneum,Castaneobuccinum castaneum,Chestnut whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,1699283,NA,Species,,,,,,, -Buccinum triplostephanum,Castaneobuccinum triplostephanum,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Buccinum,Species,137701,NA,Species,,,,,,, -Cataetyx,Cataetyx,NA,Animalia,Chordata,Teleostei,Ophidiiformes,Bythitidae,Cataetyx,Genus,125849,NA,Remove,,,,,,, -Cataetyx rubrirostris,Cataetyx rubrirostris,Rubynose brotula,Animalia,Chordata,Teleostei,Ophidiiformes,Bythitidae,Cataetyx,Species,272767,56420,Species,,,,,,, -Molpadia arenicola,Caudina arenicola,Sweet potato,Animalia,Echinodermata,Holothuroidea,Molpadida,Molpadiidae,Molpadia,Species,1495289,NA,Species,,,,,,, -Caulolatilus,Caulolatilus,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Malacanthidae,Caulolatilus,Genus,159400,NA,Remove,,,,,,, -Caulolatilus chrysops,Caulolatilus chrysops,Atlantic goldeneye tilefish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Malacanthidae,Caulolatilus,Species,159403,983,Species,,,,,,, -Caulolatilus cyanops,Caulolatilus cyanops,Blackline tilefish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Malacanthidae,Caulolatilus,Species,159402,984,Species,,,,,,, -Caulolatilus intermedius,Caulolatilus intermedius,Anchor tilefish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Malacanthidae,Caulolatilus,Species,276216,986,Species,,,,,,, -Caulolatilus microps,Caulolatilus microps,Grey tilefish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Malacanthidae,Caulolatilus,Species,159404,987,Species,,,,,,, -Caulolatilus princeps,Caulolatilus princeps,Ocean whitefish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Malacanthidae,Caulolatilus,Species,276217,3539,Species,,,,,,, -Caulophryne jordani,Caulophryne jordani,Fanfin angler,Animalia,Chordata,Teleostei,Lophiiformes,Caulophrynidae,Caulophryne,Species,126534,23253,Species,,,,,,, -Cryptopodia concava,Celatopesia concava,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Cryptopodia,Species,422023,NA,Species,,,,,,, -Celieporidae,Celieporidae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Celleporina,Celleporina,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Celleporidae,Celleporina,Genus,110875,NA,Remove,,,,,,, -Celleporina sp.,Celleporina,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Celleporidae,Celleporina,Genus,110875,NA,Remove,,,,,,, -Celleporina ventricosa,Celleporina ventricosa,Coral bryozoan,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Celleporidae,Celleporina,Species,111279,NA,Species,,,,,,, -Centrolophidae,Centrolophidae,Medusafishes,Animalia,Chordata,Teleostei,Scombriformes,Centrolophidae,NA,Family,125526,NA,Remove,,,,,,, -Centropristis,Centropristis,NA,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Centropristis,Genus,159345,NA,Remove,,,,,,, -Centropristis ocyura,Centropristis ocyurus,Bank sea bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Centropristis,Species,159346,3316,Species,,,,,,, -Centropristis ocyurus,Centropristis ocyurus,Bank sea bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Centropristis,Species,159346,3316,Species,,,,,,, -Centropristis philadelphica,Centropristis philadelphica,Rock sea bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Centropristis,Species,159347,3317,Species,,,,,,, -Centropristis philadelphicus,Centropristis philadelphica,Rock sea bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Centropristis,Species,159347,3317,Species,,,,,,, -Centropristis striata,Centropristis striata,Black sea bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Centropristis,Species,159348,361,Species,,,,,,, -Centropristis striatus,Centropristis striata,Black sea bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Centropristis,Species,159348,361,Species,,,,,,, -Centroscyllium fabricii,Centroscyllium fabricii,Black dogfish,Animalia,Chordata,Elasmobranchii,Squaliformes,Etmopteridae,Centroscyllium,Species,105906,656,Species,,,,,,, -Centroscyllium nigrum,Centroscyllium nigrum,Combtooth dogfish,Animalia,Chordata,Elasmobranchii,Squaliformes,Etmopteridae,Centroscyllium,Species,271623,660,Species,,,,,,, -Centrostephanus longispinosus_rubricing,Centrostephanus longispinosus rubricing,NA,Animalia,Echinodermata,Echinoidea,Diadematoida,Diadematidae,Centrostephanus,Species,123394,NA,Species,,,,,,, -Centrostephanus longispinus rubricingulus,Centrostephanus longispinus rubricingulus,NA,Animalia,Echinodermata,Echinoidea,Diadematoida,Diadematidae,Centrostephanus,Species,422797,NA,Species,,,,,,, -Cephalopholis cruentata,Cephalopholis cruentata,Graysby,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Cephalopholis,Species,279146,12,Species,,,,,,, -Cephalopod,Cephalopoda,"Squids octopuses, nautilus, and ammonites",Animalia,Mollusca,Cephalopoda,NA,NA,NA,Class,11707,NA,Remove,,,,,,, -Cephalopoda,Cephalopoda,"Squids octopuses, nautilus, and ammonites",Animalia,Mollusca,Cephalopoda,NA,NA,NA,Class,11707,NA,Remove,,,,,,, -Cephaloscyllium ventriosum,Cephaloscyllium ventriosum,Swell shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Scyliorhinidae,Cephaloscyllium,Species,277105,802,Species,,,,,,, -Ceramaster,Ceramaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Ceramaster,Genus,123291,NA,Remove,,,,,,, -Ceramaster sp.,Ceramaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Ceramaster,Genus,123291,NA,Remove,,,,,,, -Ceramaster arcticus,Ceramaster arcticus,Arctic cookie star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Ceramaster,Species,368804,NA,Species,,,,,,, -Ceramaster clarki,Ceramaster clarki,Deep sea cookie star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Ceramaster,Species,368805,NA,Species,,,,,,, -Ceramaster japonicus,Ceramaster japonicus,Red cookie star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Ceramaster,Species,368808,NA,Species,,,,,,, -Ceramaster leptoceramus,Ceramaster leptoceramus,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Ceramaster,Species,368810,NA,Species,,,,,,, -Ceramaster patagonicus,Ceramaster patagonicus,Cookie star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Ceramaster,Species,213335,NA,Species,,,,,,, -Ceramaster stellatus,Ceramaster stellatus,Stellate cookie star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Ceramaster,Species,368813,NA,Species,,,,,,, -Ceratiidae,Ceratiidae,Seadevils,Animalia,Chordata,Teleostei,Lophiiformes,Ceratiidae,NA,Family,125487,NA,Remove,,,,,,, -Ceratopsion rugosum,Ceratopsion rugosum,NA,NA,NA,NA,NA,NA,NA,Species,168164,NA,Species,,,,,,, -Ceratoscopelus maderensis,Ceratoscopelus maderensis,Madeira lantern fish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Ceratoscopelus,Species,126585,621,Species,,,,,,, -Cerebratulus californienesis,Cerebratulus californiensis,Ribbon worm,Animalia,Nemertea,Pilidiophora,Heteronemertea,Lineidae,Cerebratulus,Species,147295,NA,Species,,,,,,, -Cerebratulus californiensis,Cerebratulus californiensis,Ribbon worm,Animalia,Nemertea,Pilidiophora,Heteronemertea,Lineidae,Cerebratulus,Species,147295,NA,Species,,,,,,, -Cerianthidae,Cerianthidae,NA,Animalia,Cnidaria,Anthozoa,Spirularia,Cerianthidae,NA,Family,100684,NA,Remove,,,,,,, -Cerianthus,Cerianthus,NA,Animalia,Cnidaria,Anthozoa,Spirularia,Cerianthidae,Cerianthus,Genus,100782,NA,Remove,,,,,,, -Cerithium,Cerithium,NA,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Cerithiidae,Cerithium,Genus,137760,NA,Remove,,,,,,, -Cerithium atratum,Cerithium atratum,Dark cerith,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Cerithiidae,Cerithium,Species,224572,NA,Species,,,,,,, -Cerithium eburneum,Cerithium eburneum,Ivory cerith,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Cerithiidae,Cerithium,Species,419521,NA,Species,,,,,,, -Cerodrillia,Cerodrillia,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Drilliidae,Cerodrillia,Genus,415180,NA,Remove,,,,,,, -Cetorhinus maximus,Cetorhinus maximus,Basking shark,Animalia,Chordata,Elasmobranchii,Lamniformes,Cetorhinidae,Cetorhinus,Species,105837,90,Species,,,,,,, -Geryon fenneri,Chaceon fenneri,Golden deepsea crab,Animalia,Arthropoda,Malacostraca,Decapoda,Geryonidae,Geryon,Species,394996,NA,Species,,,,,,, -Geryon quinquedens,Chaceon quinquedens,Red deepsea crab,Animalia,Arthropoda,Malacostraca,Decapoda,Geryonidae,Geryon,Species,158407,NA,Species,,,,,,, -Chaenophryne draco,Chaenophryne draco,Smooth dreamer,Animalia,Chordata,Teleostei,Lophiiformes,Oneirodidae,Chaenophryne,Species,126559,16895,Species,,,,,,, -Chaenophryne longiceps,Chaenophryne longiceps,Can opener smoothdream,Animalia,Chordata,Teleostei,Lophiiformes,Oneirodidae,Chaenophryne,Species,126560,16897,Species,,,,,,, -Chaenopsis ocellata,Chaenopsis ocellata,Bluethroat pikeblenny,Animalia,Chordata,Teleostei,Blenniiformes,Chaenopsidae,Chaenopsis,Species,280107,3713,Species,,,,,,, -Chaetaster nodosus,Chaetaster nodosus,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Chaetasteridae,Chaetaster,Species,177902,NA,Species,,,,,,, -Chaetodipterus faber,Chaetodipterus faber,Atlantic spadefish,Animalia,Chordata,Teleostei,Acanthuriformes,Ephippidae,Chaetodipterus,Species,159703,1024,Species,,,,,,, -Chaetodon,Chaetodon,NA,Animalia,Chordata,Teleostei,Acanthuriformes,Chaetodontidae,Chaetodon,Genus,125954,NA,Remove,,,,,,, -Chaetodon ocellatus,Chaetodon ocellatus,Spotfin butterflyfish,Animalia,Chordata,Teleostei,Acanthuriformes,Chaetodontidae,Chaetodon,Species,159662,3604,Species,,,,,,, -Chaetodon sedentarius,Chaetodon sedentarius,Reef butterflyfish,Animalia,Chordata,Teleostei,Acanthuriformes,Chaetodontidae,Chaetodon,Species,234107,3605,Species,,,,,,, -Chaetodon striatus,Chaetodon striatus,Banded butterflyfish,Animalia,Chordata,Teleostei,Acanthuriformes,Chaetodontidae,Chaetodon,Species,159663,3606,Species,,,,,,, -Chaetodontidae,Chaetodontidae,NA,Animalia,Chordata,Teleostei,Acanthuriformes,Chaetodontidae,NA,Family,125528,NA,Remove,,,,,,, -Chaetognatha,Chaetognatha,Arrow worms,Animalia,Chaetognatha,NA,NA,NA,NA,Phylum,2081,NA,Remove,,,,,,, -Chaetopterus,Chaetopterus,NA,Animalia,Annelida,Polychaeta,NA,Chaetopteridae,Chaetopterus,Genus,129229,NA,Remove,,,,,,, -Chaetopterus sp.,Chaetopterus,NA,Animalia,Annelida,Polychaeta,NA,Chaetopteridae,Chaetopterus,Genus,129229,NA,Remove,,,,,,, -Chama,Chama,NA,Animalia,Mollusca,Bivalvia,Venerida,Chamidae,Chama,Genus,137775,NA,Remove,,,,,,, -Chama congregata,Chama congregata,Corrugate jewelbox,Animalia,Mollusca,Bivalvia,Venerida,Chamidae,Chama,Species,420814,NA,Species,,,,,,, -Chama macerophylla,Chama macerophylla,Leafy jewelbox,Animalia,Mollusca,Bivalvia,Venerida,Chamidae,Chama,Species,397039,NA,Species,,,,,,, -Charybdis hellerii,Charybdis (Charybdis) hellerii,Spiny hands,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Charybdis,Species,107382,NA,Species,,,,,,, -Chascanopsetta lugubris,Chascanopsetta lugubris,Pelican flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Bothidae,Chascanopsetta,Species,219797,1323,Species,,,,,,, -Chasmocarcinus mississippiensis,Chasmocarcinus mississipiensis,Roughwrist soft crab,Animalia,Arthropoda,Malacostraca,Decapoda,Chasmocarcinidae,Chasmocarcinus,Species,440889,NA,Species,,,,,,, -Chauliodontinae,Chauliodontinae,Viperfish unid.,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,NA,SubFamily,154226,NA,Remove,,,,,,, -Chauliodus danae,Chauliodus danae,Dana viperfish,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,Chauliodus,Species,127337,11712,Species,,,,,,, -Chauliodus macouni,Chauliodus macouni,Pacific viperfish,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,Chauliodus,Species,275055,2714,Species,,,,,,, -Chauliodus sloani,Chauliodus sloani,Sloane's viperfish,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,Chauliodus,Species,127338,1786,Species,,,,,,, -Chaunax stigmaeus,Chaunax stigmaeus,Redeye gaper,Animalia,Chordata,Teleostei,Lophiiformes,Chaunacidae,Chaunax,Species,159151,3090,Species,,,,,,, -Cheilonereis cyclurus,Cheilonereis cyclurus,Red and-white-banded sea-nymph,Animalia,Annelida,Polychaeta,Phyllodocida,Nereididae,Cheilonereis,Species,332676,NA,Species,,,,,,, -Cheilopogon,Cheilopogon,NA,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Cheilopogon,Genus,125691,NA,Remove,,,,,,, -Cypselurus cyanopterus,Cheilopogon cyanopterus,Margined flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Cypselurus,Species,217862,7695,Species,,,,,,, -Cheilopogon cyanopterus,Cheilopogon cyanopterus,Margined flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Cypselurus,Species,217862,7695,Species,,,,,,, -Cypselurus exsiliens,Cheilopogon exsiliens,Bandwing flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Cypselurus,Species,126381,1027,Species,,,,,,, -Cheilopogon exsiliens,Cheilopogon exsiliens,Bandwing flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Cypselurus,Species,126381,1027,Species,,,,,,, -Cheilopogon furcatus,Cheilopogon furcatus,Spotfin flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Cheilopogon,Species,159261,1028,Species,,,,,,, -Cypselurus furcatus,Cheilopogon furcatus,Spotfin flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Cheilopogon,Species,159261,1028,Species,,,,,,, -Cypselurus heterurus,Cheilopogon heterurus,Mediterranean flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Cypselurus,Species,126382,1029,Species,,,,,,, -Cheilopogon heterurus,Cheilopogon heterurus,Mediterranean flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Cypselurus,Species,126382,1029,Species,,,,,,, -Cheilopogon melanurus,Cheilopogon melanurus,Atlantic flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Cheilopogon,Species,272157,1030,Species,,,,,,, -Cypselurus melanurus,Cheilopogon melanurus,Atlantic flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Cheilopogon,Species,272157,1030,Species,,,,,,, -Cheilotrema saturnum,Cheilotrema saturnum,Black croaker,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Cheilotrema,Species,280137,3580,Species,,,,,,, -Cheiraster,Cheiraster,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Benthopectinidae,Cheiraster,Genus,123240,NA,Remove,,,,,,, -Cheiraster sp.,Cheiraster,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Benthopectinidae,Cheiraster,Genus,123240,NA,Remove,,,,,,, -Cheiraster dawsoni,Cheiraster (Luidiaster) dawsoni,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Benthopectinidae,Cheiraster,Species,123240,NA,Species,,,,,,, -Cheiraster sp. A (Clark 2006),Cheiraster sp. A (Clark 2006),Aleutian fragile sea star,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Chelonia mydas,Chelonia mydas,Green sea turtle,Animalia,Chordata,NA,Testudines,Cheloniidae,Chelonia,Species,137206,NA,Species,,,,,,, -Chelyosoma orientale,Chelyosoma orientale,NA,Animalia,Chordata,Ascidiacea,Phlebobranchia,Corellidae,Chelyosoma,Species,250012,NA,Species,,,,,,, -Chelyosoma productum,Chelyosoma productum,Disc top tunicate,Animalia,Chordata,Ascidiacea,Phlebobranchia,Corellidae,Chelyosoma,Species,250013,NA,Species,,,,,,, -Chesnonia verrucosa,Chesnonia verrucosa,Warty poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Chesnonia,Species,254507,4167,Species,,,,,,, -Chiasmodon niger,Chiasmodon niger,Black swallower,Animalia,Chordata,Teleostei,Scombriformes,Chiasmodontidae,Chiasmodon,Species,126840,10192,Species,,,,,,, -Chiasmodontidae,Chiasmodontidae,Snaketooth fishes,Animalia,Chordata,Teleostei,Scombriformes,Chiasmodontidae,NA,Family,125529,NA,Remove,,,,,,, -Chicoreus,Chicoreus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Chicoreus,Genus,205487,NA,Remove,,,,,,, -Chicoreus florifer-dilectus,Chicoreus florifer,Flowery lace murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Murex,SubSpecies,558810,NA,SubSpecies,,,,,,, -Murex florifer dilectus,Chicoreus florifer,Flowery lace murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Murex,SubSpecies,558810,NA,SubSpecies,,,,,,, -Chicoreus florifer,Chicoreus florifer,Flowery lace murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Chicoreus,Species,558810,NA,Species,,,,,,, -Chilara taylori,Chilara taylori,Spotted cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Chilara,Species,280146,3107,Species,,,,,,, -Chilomycterus,Chilomycterus,NA,Animalia,Chordata,Teleostei,Tetraodontiformes,Diodontidae,Chilomycterus,Genus,126230,NA,Remove,,,,,,, -Chilomycterus antennatus,Chilomycterus antennatus,Bridled burrfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Diodontidae,Chilomycterus,Species,275239,4299,Species,,,,,,, -Chilomycterus antillarum,Chilomycterus antillarum,Web burrfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Diodontidae,Chilomycterus,Species,275240,4300,Species,,,,,,, -Chilomycterus atinga,Chilomycterus reticulatus,Spotfin burrfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Diodontidae,Chilomycterus,Species,219964,10206,Species,,,,,,, -Chilomycterus atringa,Chilomycterus reticulatus,Spotfin burrfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Diodontidae,Chilomycterus,Species,219964,10206,Species,,,,,,, -Chilomycterus reticulatus,Chilomycterus reticulatus,Spotfin burrfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Diodontidae,Chilomycterus,Species,219964,10206,Species,,,,,,, -Chilomycterus schoepfi,Chilomycterus schoepfii,Striped burrfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Diodontidae,Chilomycterus,Species,159488,6407,Species,,,,,,, -Chilomycterus schoepfii,Chilomycterus schoepfii,Striped burrfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Diodontidae,Chilomycterus,Species,159488,6407,Species,,,,,,, -Chione,Chione,NA,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Chione,Genus,206343,NA,Remove,,,,,,, -Chionoecetes,Chionoecetes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Chionoecetes,Genus,106898,NA,Remove,,,,,,, -Chionoecetes sp.,Chionoecetes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Chionoecetes,Genus,106898,NA,Remove,,,,,,, -Chionoecetes angulatus,Chionoecetes angulatus,Triangle tanner crab,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Chionoecetes,Species,442161,NA,Species,,,,,,, -Chionoecetes bairdi,Chionoecetes bairdi,Tanner crab,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Chionoecetes,Species,368558,NA,Species,,,,,,, -Chionoecetes hybrid,Chionoecetes hybrid,Hybrid Tanner crab,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Chionoecetes,Genus,106898,NA,Remove,,,,,,, -Chionoecetes opilio,Chionoecetes opilio,Snow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Chionoecetes,Species,107315,NA,Species,,,,,,, -Chionoecetes tanneri,Chionoecetes tanneri,Grooved tanner crab,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Chionoecetes,Species,442165,NA,Species,,,,,,, -Chiridota,Chiridota,NA,Animalia,Echinodermata,Holothuroidea,Apodida,Chiridotidae,Chiridota,Genus,123438,NA,Remove,,,,,,, -Chiridota sp.,Chiridota,NA,Animalia,Echinodermata,Holothuroidea,Apodida,Chiridotidae,Chiridota,Genus,123438,NA,Remove,,,,,,, -Chiridota albatrossii,Chiridota albatrossii,NA,Animalia,Echinodermata,Holothuroidea,Apodida,Chiridotidae,Chiridota,Species,528864,NA,Species,,,,,,, -Chirolophis,Chirolophis,NA,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Chirolophis,Genus,126086,NA,Remove,,,,,,, -Chirolophis sp.,Chirolophis,NA,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Chirolophis,Genus,126086,NA,Remove,,,,,,, -Chirolophis decoratus,Chirolophis decoratus,Decorated warbonnet,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Chirolophis,Species,254576,3780,Species,,,,,,, -Chirolophis nugator,Chirolophis nugator,Mosshead warbonnet,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Chirolophis,Species,254577,3781,Species,,,,,,, -Chirolophis snyderi,Chirolophis snyderi,Bearded warbonnet,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Chirolophis,Species,254578,23773,Species,,,,,,, -Chirolophis tarsodes,Chirolophis tarsodes,Matcheek warbonnet,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Chirolophis,Species,273991,3782,Species,,,,,,, -Balanus evermanni,Chirona evermanni,Deepwater giant barnacle,Animalia,Arthropoda,Thecostraca,Balanomorpha,Balanidae,Chirona,Species,733509,NA,Species,,,,,,, -Chirona evermanni,Chirona evermanni,Deepwater giant barnacle,Animalia,Arthropoda,Thecostraca,Balanomorpha,Balanidae,Chirona,Species,733509,NA,Species,,,,,,, -Chiropsalmus quadrumanus,Chiropsalmus quadrumanus,Four handed box jellyfish,Animalia,Cnidaria,Cubozoa,Chirodropida,Chiropsalmidae,Chiropsalmus,Species,157924,NA,Species,,,,,,, -Chirostylus,Chirostylus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Chirostylidae,Chirostylus,Genus,148414,NA,Remove,,,,,,, -Chirostylus sp.,Chirostylus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Chirostylidae,Chirostylus,Genus,148414,NA,Remove,,,,,,, -Chiroteuthis,Chiroteuthis,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Chiroteuthidae,Chiroteuthis,Genus,137777,NA,Remove,,,,,,, -Chiroteuthis sp.,Chiroteuthis,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Chiroteuthidae,Chiroteuthis,Genus,137777,NA,Remove,,,,,,, -Chiroteuthis calyx,Chiroteuthis calyx,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Chiroteuthidae,Chiroteuthis,Species,341796,NA,Species,,,,,,, -Chiton,Chiton,NA,Animalia,Mollusca,Polyplacophora,Chitonida,Chitonidae,Chiton,Genus,137779,NA,Remove,,,,,,, -Chitonotus pugetensis,Chitonotus pugetensis,Roughback sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Chitonotus,Species,280162,4055,Species,,,,,,, -Chlamylla,Chlamylla,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Paracoryphellidae,Chlamylla,Genus,422828,NA,Remove,,,,,,, -Chlamylla sp.,Chlamylla,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Paracoryphellidae,Chlamylla,Genus,422828,NA,Remove,,,,,,, -Chlamys,Chlamys,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Genus,138315,NA,Remove,,,,,,, -Chlamys sp.,Chlamys,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Genus,138315,NA,Remove,,,,,,, -Chlamys albida,Chlamys albida,White scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Species,391037,NA,Species,,,,,,, -Chlamys behringiana,Chlamys behringiana,Bering scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Species,391825,NA,Species,,,,,,, -Chlamys benedicti,Chlamys benedicti,Yellow spot scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Species,1638563,NA,Species,,,,,,, -Chlamys erythocomata,Chlamys erythocomata,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Species,138315,NA,Species,,,,,,, -Chlamys hastata,Chlamys hastata,Spiny scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Species,367964,NA,Species,,,,,,, -Chlamys hastata hericia,Chlamys hastata,Spiny scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Species,367964,NA,Species,,,,,,, -Chlamys islandica,Chlamys islandica,Iceland scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Species,140692,NA,Species,,,,,,, -Chlamys islandica clapper,Chlamys islandica clapper,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Remove,140692,NA,Remove,,,,,,, -Chlamys pseudoislandica,Chlamys pseudoislandica,NA,NA,NA,NA,NA,NA,NA,NotWrms,NA,NA,Species,,,,,,, -Chlamys rubida,Chlamys rubida,Reddish scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Species,254460,NA,Species,,,,,,, -Chlamys sp. cf. unalaskae (Clark and McLean),Chlamys sp. cf. unalaskae (Clark and McLean),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Chlamys unalaskae,Chlamys unalaskae,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Chlamys,Species,138315,NA,Species,,,,,,, -Chloeia,Chloeia,NA,Animalia,Annelida,Polychaeta,Amphinomida,Amphinomidae,Chloeia,Genus,129184,NA,Remove,,,,,,, -Chloeia viridis,Chloeia viridis,Fire worm,Animalia,Annelida,Polychaeta,Amphinomida,Amphinomidae,Chloeia,Species,129827,NA,Species,,,,,,, -Chlorophthalmidae,Chlorophthalmidae,Greeneyes,Animalia,Chordata,Teleostei,Aulopiformes,Chlorophthalmidae,NA,Family,125442,NA,Remove,,,,,,, -Chlorophthalmus sp,Chlorophthalmus,NA,Animalia,Chordata,Teleostei,Aulopiformes,Chlorophthalmidae,Chlorophthalmus,Genus,125664,NA,Remove,,,,,,, -Chlorophthalmus agassizi,Chlorophthalmus agassizi,Shortnose greeneye,Animalia,Chordata,Teleostei,Aulopiformes,Chlorophthalmidae,Chlorophthalmus,Species,126336,1808,Species,,,,,,, -Chloroscombrus chrysurus,Chloroscombrus chrysurus,Atlantic bumper,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Chloroscombrus,Species,159483,385,Species,,,,,,, -Chondrichthyes,Chondrichthyes,NA,Animalia,Chordata,NA,NA,NA,NA,Parvphylum,1517375,NA,Remove,,,,,,, -Chondrocladia concrescens,Chondrocladia (Chondrocladia) concrescens,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Cladorhizidae,Chondrocladia,Species,168213,NA,Species,,,,,,, -Chondrocladia gigantea,Chondrocladia (Chondrocladia) grandis,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Cladorhizidae,Chondrocladia,Species,1023293,NA,Species,,,,,,, -Chondrocladia grandis,Chondrocladia grandis,carnivorous cattail sponge,NA,NA,NA,NA,NA,NA,Species,1023293,NA,Species,,,,,,, -Solariella nuda,Chonospeira nuda,Naked solarelle,Animalia,Mollusca,Gastropoda,Trochida,Solariellidae,Solariella,Species,1424481,NA,Species,,,,,,, -Anthias tenuis,Choranthias tenuis,Threadnose bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Anthias,Species,1016916,3314,Species,,,,,,, -Chorilia,Chorilia,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Chorilia,Genus,439300,NA,Remove,,,,,,, -Chorilia sp.,Chorilia,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Chorilia,Genus,439300,NA,Remove,,,,,,, -Chorilia longipes,Chorilia longipes,Longhorn decorator crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Chorilia,Species,441520,NA,Species,,,,,,, -Choristodon,Choristodon,NA,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Choristodon,Genus,415199,NA,Remove,,,,,,, -Chromis enchrysurus,Chromis enchrysurus,Yellowtail reeffish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Chromis,Species,304153,3643,Species,,,,,,, -Chromis enchrysura,Chromis enchrysurus,Yellowtail reeffish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Chromis,Species,304153,3643,Species,,,,,,, -Chromis insolata,Chromis insolata,sunshinefish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Chromis,Species,273731,NA,Species,,,,,,, -Chromis scotti,Chromis scotti,Purple reeffish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Chromis,Species,273756,3647,Species,,,,,,, -Euplexaura marki,Chromoplexaura marki,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Euplexauridae,Euplexaura,Species,724231,NA,Species,,,,,,, -Chromoplexaura marki,Chromoplexaura marki,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Euplexauridae,Euplexaura,Species,724231,NA,Species,,,,,,, -Chrysaora,Chrysaora,Sea nettles,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Pelagiidae,Chrysaora,Genus,135261,NA,Remove,,,,,,, -Dactylometra,Chrysaora,Sea nettles,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Pelagiidae,Chrysaora,Genus,135261,NA,Remove,,,,,,, -Chrysaora sp.,Chrysaora,Sea nettles,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Pelagiidae,Chrysaora,Genus,135261,NA,Remove,,,,,,, -Chrysaora chesapeakei,Chrysaora chesapeakei,bay nettle,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Pelagiidae,Chrysaora,Species,1039867,NA,Species,,,,,,, -Pelagia colorata,Chrysaora colorata,Purple striped jelly,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Pelagiidae,Pelagia,Species,287204,NA,Species,,,,,,, -Chrysaora fuscens,Chrysaora fuscens,Pacific sea nettle,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Pelagiidae,Chrysaora,Species,135261,NA,Species,,,,,,, -Chrysaora fuscescens,Chrysaora fuscescens,Brown jellyfish,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Pelagiidae,Chrysaora,Species,287206,NA,Species,,,,,,, -Chrysaora melanaster,Chrysaora melanaster,NA,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Pelagiidae,Chrysaora,Species,287209,NA,Species,,,,,,, -Chrysaora quinquecirrha,Chrysaora quinquecirrha,Sea nettle,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Pelagiidae,Chrysaora,Species,220476,NA,Species,,,,,,, -Chrysopathes,Chrysopathes,NA,Animalia,Cnidaria,Anthozoa,Antipatharia,Cladopathidae,Chrysopathes,Genus,267316,NA,Remove,,,,,,, -Chrysopathes speciosa,Chrysopathes speciosa,Gaudy black coral,Animalia,Cnidaria,Anthozoa,Antipatharia,Cladopathidae,Chrysopathes,Species,289661,NA,Species,,,,,,, -Cidaridae,Cidaridae,NA,Animalia,Echinodermata,Echinoidea,Cidaroida,Cidaridae,NA,Family,123158,NA,Remove,,,,,,, -Cidarina cidaris,Cidarina cidaris,Adam spiny margarite,Animalia,Mollusca,Gastropoda,Seguenziida,Calliotropidae,Cidarina,Species,528712,NA,Species,,,,,,, -Cidaris,Cidaris,NA,Animalia,Echinodermata,Echinoidea,Cidaroida,Cidaridae,Cidaris,Genus,123377,NA,Remove,,,,,,, -Ciliatoclinocardium ciliatum,Ciliatocardium ciliatum,Hairy cockle,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Ciliatocardium ciliatum,Ciliatocardium ciliatum,Hairy cockle,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Fasciolaria hunteria,Cinctura hunteria,Banded tulip shell,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Fasciolaria,Species,607920,NA,Species,,,,,,, -Cinctura hunteria,Cinctura hunteria,Banded tulip shell,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Fasciolaria,Species,607920,NA,Species,,,,,,, -Fasciolaria lilium,Cinctura lilium,Banded tulip,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Fasciolaria,Species,607921,NA,Species,,,,,,, -Cinctura lilium�,Cinctura lilium,Banded tulip shell,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Cinctura,Species,607291,NA,Species,,,,,,, -Cirrhipathes,Cirrhipathes,NA,Animalia,Cnidaria,Anthozoa,Antipatharia,Antipathidae,Cirrhipathes,Genus,204279,NA,Remove,,,,,,, -Cirripedia,Cirripedia,Barnacles,Animalia,Arthropoda,Thecostraca,NA,NA,NA,SubClass,1082,NA,Remove,,,,,,, -Cistenides granulata,Cistenides granulata,Tusk coneworm,Animalia,Annelida,Polychaeta,Terebellida,Pectinariidae,Cistenides,Species,238377,NA,Species,,,,,,, -Citharichthys,Citharichthys,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Citharichthys,Genus,158786,NA,Remove,,,,,,, -Citharichthys sp,Citharichthys,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Citharichthys,Genus,158786,NA,Remove,,,,,,, -Citharichthys sp.,Citharichthys,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Citharichthys,Genus,158786,NA,Remove,,,,,,, -Citharichthys arctifrons,Citharichthys arctifrons,Gulf stream flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Citharichthys,Species,158791,4209,Species,,,,,,, -Citharichthys arenaceus,Citharichthys arenaceus,Sand whiff,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Citharichthys,Species,275685,4210,Species,,,,,,, -Citharichthys cornutus,Citharichthys cornutus,Horned whiff,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Citharichthys,Species,158792,4211,Species,,,,,,, -Citharichthys dinoceros,Citharichthys dinoceros,Spined whiff,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Citharichthys,Species,275686,57910,Species,,,,,,, -Citharichthys gymnorhinus,Citharichthys gymnorhinus,Anglefin whiff,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Citharichthys,Species,158793,4213,Species,,,,,,, -Citharichthys macrops,Citharichthys macrops,Spotted whiff,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Citharichthys,Species,159165,4214,Species,,,,,,, -Citharichthys sordidus,Citharichthys sordidus,Pacific sanddab,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Citharichthys,Species,275694,4215,Species,,,,,,, -Citharichthys spilopterus,Citharichthys spilopterus,Bay whiff,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Citharichthys,Species,159166,4216,Species,,,,,,, -Citharichthys stigmaeus,Citharichthys stigmaeus,Speckled sanddab,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Citharichthys,Species,275696,4217,Species,,,,,,, -Citharichthys xanthostigma,Citharichthys xanthostigma,Longfin sanddab,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Citharichthys,Species,275699,4218,Species,,,,,,, -Cladaster,Cladaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Cladaster,Genus,178095,NA,Remove,,,,,,, -Cladaster sp.,Cladaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Cladaster,Genus,178095,NA,Remove,,,,,,, -Cladaster validus,Cladaster validus,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Cladaster,Species,377832,NA,Species,,,,,,, -Cladocora,Cladocora,NA,Animalia,Cnidaria,Anthozoa,Scleractinia,Cladocoridae,Cladocora,Genus,135087,NA,Remove,,,,,,, -Cladocroce attu,Cladocroce attu,Rough hat sponge,Animalia,Porifera,Demospongiae,Haplosclerida,Chalinidae,Cladocroce,Species,737452,NA,Species,,,,,,, -Cladocroce infundibulum,Cladocroce infundibulum,NA,Animalia,Porifera,Demospongiae,Haplosclerida,Chalinidae,Cladocroce,Species,737451,NA,Species,,,,,,, -Cladocroce kiska,Cladocroce kiska,NA,Animalia,Porifera,Demospongiae,Haplosclerida,Chalinidae,Cladocroce,Species,737453,NA,Species,,,,,,, -Leucosolenia blanca,Clathrina blanca,NA,Animalia,Porifera,Calcarea,Leucosolenida,Leucosoleniidae,Leucosolenia,Species,233970,NA,Species,,,,,,, -Clavelina,Clavelina,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Clavelinidae,Clavelina,Genus,103453,NA,Remove,,,,,,, -Clavularia,Clavularia,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Clavulariidae,Clavularia,Genus,125286,NA,Remove,,,,,,, -Clavularia sp.,Clavularia,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Clavulariidae,Clavularia,Genus,125286,NA,Remove,,,,,,, -Clavularia evagorgiacrustans,Clavularia evagorgiacrustans,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Clavulariidae,Clavularia,Species,125286,NA,Species,,,,,,, -Clavularia incrustans,Clavularia incrustans,Encrusting coral,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Clavulariidae,Clavularia,Species,1475665,NA,Species,,,,,,, -Clavularia sp. cf. evagorgiacrustans (Bayer et al.),Clavularia sp. cf. evagorgiacrustans (Bayer et al.),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Clavus,Clavus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Drilliidae,Clavus,Genus,205108,NA,Remove,,,,,,, -Clepticus parrae,Clepticus parrae,Creole wrasse,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Clepticus,Species,280214,3656,Species,,,,,,, -Clibanarius,Clibanarius,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Clibanarius,Genus,106841,NA,Remove,,,,,,, -Clibanarius vittatus,Clibanarius vittatus,Thinstripe hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Clibanarius,Species,367528,NA,Species,,,,,,, -Clinidae,Clinidae,NA,Animalia,Chordata,Teleostei,Blenniiformes,Clinidae,NA,Family,125530,NA,Remove,,,,,,, -Clinocardium,Clinocardium,NA,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Clinocardium,Genus,156818,NA,Remove,,,,,,, -Clinocardium sp.,Clinocardium,NA,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Clinocardium,Genus,156818,NA,Remove,,,,,,, -Clinocardium nuttallii,Clinocardium nuttallii,Nuttall cockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Clinocardium,Species,381980,NA,Species,,,,,,, -Clinocottus acuticeps,Clinocottus acuticeps,Sharpnose sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Clinocottus,Species,280218,4056,Species,,,,,,, -Clinopegma magnum,Clinopegma magnum,Helmet whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Clinopegma,Species,490909,NA,Species,,,,,,, -Clupea harengus,Clupea harengus,Atlantic herring,Animalia,Chordata,Teleostei,Clupeiformes,Clupeidae,Clupea,Species,126417,24,Species,,,,,,, -Clupea pallasi,Clupea pallasii,Pacific herring,Animalia,Chordata,Teleostei,Clupeiformes,Clupeidae,Clupea,Species,151159,1520,Species,,,,,,, -Clupea pallasii,Clupea pallasii,Pacific herring,Animalia,Chordata,Teleostei,Clupeiformes,Clupeidae,Clupea,Species,151159,1520,Species,,,,,,, -Clupeidae,Clupeidae,"Herrings menhadens, sardins, shads",Animalia,Chordata,Teleostei,Clupeiformes,Clupeidae,NA,Family,125464,NA,Remove,,,,,,, -Clypeaster,Clypeaster,NA,Animalia,Echinodermata,Echinoidea,Clypeasteroida,Clypeasteridae,Clypeaster,Genus,205242,NA,Remove,,,,,,, -Clypeaster chesheri,Clypeaster chesheri,NA,Animalia,Echinodermata,Echinoidea,Clypeasteroida,Clypeasteridae,Clypeaster,Species,422494,NA,Species,,,,,,, -Clypeaster lamprus,Clypeaster lamprus,NA,Animalia,Echinodermata,Echinoidea,Clypeasteroida,Clypeasteridae,Clypeaster,Species,513185,NA,Species,,,,,,, -Clypeaster luetkeni,Clypeaster luetkeni,NA,Animalia,Echinodermata,Echinoidea,Clypeasteroida,Clypeasteridae,Clypeaster,Species,422496,NA,Species,,,,,,, -Clypeaster prostratus,Clypeaster prostratus,NA,Animalia,Echinodermata,Echinoidea,Clypeasteroida,Clypeasteridae,Clypeaster,Species,422497,NA,Species,,,,,,, -Clypeaster ravenelii,Clypeaster ravenelii,NA,Animalia,Echinodermata,Echinoidea,Clypeasteroida,Clypeasteridae,Clypeaster,Species,422498,NA,Species,,,,,,, -Clypeaster subdepressus,Clypeaster subdepressus,NA,Animalia,Echinodermata,Echinoidea,Clypeasteroida,Clypeasteridae,Clypeaster,Species,422499,NA,Species,,,,,,, -Clypeasteridae,Clypeasteridae,NA,Animalia,Echinodermata,Echinoidea,Clypeasteroida,Clypeasteridae,NA,Genus,196177,NA,Remove,,,,,,, -Clypeasteroida,Clypeasteroida,Sea biscuits,Animalia,Echinodermata,Echinoidea,Clypeasteroida,NA,NA,Order,123100,NA,Remove,,,,,,, -Clypeastridae,Clypeastridae,Sand dollars,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Cnemidocarpa,Cnemidocarpa,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Styelidae,Cnemidocarpa,Genus,103530,NA,Remove,,,,,,, -Cnemidocarpa finmarkiensis,Cnemidocarpa finmarkiensis,Shiny red sea squirt,Animalia,Chordata,Ascidiacea,Stolidobranchia,Styelidae,Cnemidocarpa,Species,103870,NA,Species,,,,,,, -Cnidaria,Cnidaria,Jellyfish and alike,Animalia,Cnidaria,NA,NA,NA,NA,Phylum,1267,NA,Remove,,,,,,, -Cyclocardia ventricosa,Coanicardita ventricosa,Stout cyclocardia,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,Cyclocardia,Species,1420845,NA,Species,,,,,,, -Coanicardita ventricosa,Coanicardita ventricosa,Stout cyclocardia,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,Cyclocardia,Species,1420845,NA,Species,,,,,,, -Coelenterata,Coelenterata,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Coelocerus spinosus,Coelocerus spinosus,Channelnose spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Coelocerus,Species,422004,NA,Species,,,,,,, -Coelopleurus floridanus,Coelopleurus floridanus,NA,Animalia,Echinodermata,Echinoidea,Arbacioida,Arbaciidae,Coelopleurus,Species,513202,NA,Species,,,,,,, -Caelorinchus,Coelorinchus,NA,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Caelorinchus,Genus,268809,NA,Remove,,,,,,, -Coelorinchus,Coelorinchus,NA,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Coelorinchus,Genus,268809,NA,Remove,,,,,,, -Coelorhynchus carminatus,Coelorinchus caelorhincus,Longnose grenadier,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Coelorhynchus,Species,398381,1726,Species,,,,,,, -Caelorinchus caribbaeus,Coelorinchus caribbaeus,Blackfin grenadier,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Caelorinchus,Species,280261,3102,Species,,,,,,, -Coelorinchus caribbaeus,Coelorinchus caribbaeus,Blackfin grenadier,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Caelorinchus,Species,280261,3102,Species,,,,,,, -Caelorinchus scaphopsis,Coelorinchus scaphopsis,Shoulderspot grenadier,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Caelorinchus,Species,280334,8465,Species,,,,,,, -Coenocyathus bowersi,Coenocyathus bowersi,NA,Animalia,Cnidaria,Anthozoa,Scleractinia,Caryophylliidae,Coenocyathus,Species,286780,NA,Species,,,,,,, -Colga pacifica,Colga pacifica,Pacific Colga,Animalia,Mollusca,Gastropoda,Nudibranchia,Polyceridae,Colga,Species,140829,NA,Species,,,,,,, -Collodes,Collodes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Collodes,Genus,158409,NA,Remove,,,,,,, -Collodes leptocheles,Collodes leptocheles,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Collodes,Species,421964,NA,Species,,,,,,, -Collodes robustus,Collodes robustus,Robust crab,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Collodes,Species,158410,NA,Species,,,,,,, -Collodes trispinosus,Collodes trispinosus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Collodes,Species,421966,NA,Species,,,,,,, -Cololabis saira,Cololabis saira,Pacific saury,Animalia,Chordata,Teleostei,Beloniformes,Scomberesocidae,Cololabis,Species,280366,303,Species,,,,,,, -Colossendeis,Colossendeis,NA,Animalia,Arthropoda,Pycnogonida,Pantopoda,Colossendeidae,Colossendeis,Genus,134586,NA,Remove,,,,,,, -Colossendeis sp.,Colossendeis,NA,Animalia,Arthropoda,Pycnogonida,Pantopoda,Colossendeidae,Colossendeis,Genus,134586,NA,Remove,,,,,,, -Colossendeis microsetosa,Colossendeis microsetosa,NA,Animalia,Arthropoda,Pycnogonida,Pantopoda,Colossendeidae,Colossendeis,Species,239788,NA,Species,,,,,,, -Colus,Colus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Genus,137704,NA,Remove,,,,,,, -Colus sp.,Colus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Genus,137704,NA,Remove,,,,,,, -Colus griseus,Colus griseus,Gray whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,573254,NA,Species,,,,,,, -Plicifusus griseus,Colus griseus,Gray whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,573254,NA,Species,,,,,,, -Colus capponius,Colus pulcius,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,423285,NA,Species,,,,,,, -Colus pulcius,Colus pulcius,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,423285,NA,Species,,,,,,, -Comactinia,Comactinia,NA,Animalia,Echinodermata,Crinoidea,Comatulida,Comatulidae,Comactinia,Genus,246690,NA,Remove,,,,,,, -Comactinia meridionalis,Comactinia meridionalis,NA,Animalia,Echinodermata,Crinoidea,Comatulida,Comatulidae,Comactinia,Species,246741,NA,Species,,,,,,, -Compressidens stearnsii,Compressidens stearnsii,Stearns toothshell,NA,NA,NA,NA,NA,NA,Species,344588,NA,Species,,,,,,, -Condylactis gigantea,Condylactis gigantea,Atlantic anemone,Animalia,Cnidaria,Hexacorallia,Actiniaria,Actiniidae,Condylactis,Species,283419,NA,Species, Florida pink-tipped anemone, giant anemone, giant caribbean anemone, giant Carribean anemone, Haitian pink-tipped anemone, pink-tipped anemone, purple-tipped anemone -Conger,Conger,NA,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Conger,Genus,125624,NA,Remove,,,,,,, -Conger oceanicus,Conger oceanicus,Conger eel,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Conger,Species,158566,300,Species,,,,,,, -Congridae,Congridae,NA,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,NA,Family,125427,NA,Remove,,,,,,, -Conidae,Conidae,Cone snails,Animalia,Mollusca,Gastropoda,Neogastropoda,Conidae,NA,Family,14107,NA,Remove,,,,,,, -Conodon nobilis,Conodon nobilis,Barred grunt,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Haemulidae,Conodon,Species,280386,401,Species,,,,,,, -Conus,Conus,Cone snails,Animalia,Mollusca,Gastropoda,Neogastropoda,Conidae,Conus,Genus,137813,NA,Remove,,,,,,, -Conus amphiurgus,Conus amphiurgus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Conidae,Conus,Species,420199,NA,Species,,,,,,, -Conus cancellatus,Conus cancellatus,Cancellate cone,Animalia,Mollusca,Gastropoda,Neogastropoda,Conidae,Conus,Species,420206,NA,Species,,,,,,, -Conus cancellatus cancellatus,Conus cancellatus cancellatus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Conidae,Conus,Species,715843,NA,Species,,,,,,, -Conus daucus,Conus daucus,Carrot cone,Animalia,Mollusca,Gastropoda,Neogastropoda,Conidae,Conus,Species,420208,NA,Species,,,,,,, -Conus spurius,Conus spurius,Alphabet cone,Animalia,Mollusca,Gastropoda,Neogastropoda,Conidae,Conus,Species,420223,NA,Species,,,,,,, -Conus stimpsoni,Conus stimpsoni,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Conidae,Conus,Species,420225,NA,Species,,,,,,, -Cookeolus japonicus,Cookeolus japonicus,Longfinned bullseye,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Priacanthidae,Cookeolus,Species,127003,3517,Species,,,,,,, -Coralliidae,Coralliidae,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Coralliidae,NA,Family,125280,NA,Remove,,,,,,, -Corallimorphus,Corallimorphus,NA,Animalia,Cnidaria,Anthozoa,Corallimorpharia,Corallimorphidae,Corallimorphus,Genus,100784,NA,Remove,,,,,,, -Corallimorphus sp.,Corallimorphus,NA,Animalia,Cnidaria,Anthozoa,Corallimorpharia,Corallimorphidae,Corallimorphus,Genus,100784,NA,Remove,,,,,,, -Corbulidae,Corbulidae,NA,Animalia,Mollusca,Bivalvia,Myida,Corbulidae,NA,Family,248,NA,Remove,,,,,,, -Corniger spinosus,Corniger spinosus,Spinycheek soldierfish,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Corniger,Species,280402,3246,Species,,,,,,, -Cornulum clathriata,Cornulum clathriata,Lattice sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Acarnidae,Cornulum,Species,167374,NA,Species,,,,,,, -Coronaster,Coronaster,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Coronaster,Genus,123232,NA,Remove,,,,,,, -Coronis scolopendra,Coronis scolopendra,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Nannosquillidae,Coronis,Species,409063,NA,Species,,,,,,, -Bairdiella batabana,Corvula batabana,Blue croaker,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Corvula,Species,314211,1162,Species,,,,,,, -Corvula batabana,Corvula batabana,Blue croaker,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Corvula,Species,314211,1162,Species,,,,,,, -Coryphaena equisetis,Coryphaena equiselis,Pompano dolphinfish,Animalia,Chordata,Teleostei,Carangiformes,Coryphaenidae,Coryphaena,Species,126845,7,Species,,,,,,, -Coryphaena hippurus,Coryphaena hippurus,Common dolphinfish,Animalia,Chordata,Teleostei,Carangiformes,Coryphaenidae,Coryphaena,Species,126846,6,Species,,,,,,, -Coryphaenoides,Coryphaenoides,NA,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Coryphaenoides,Genus,125748,NA,Remove,,,,,,, -Coryphaenoides sp.,Coryphaenoides,NA,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Coryphaenoides,Genus,125748,NA,Remove,,,,,,, -Coryphaenoides acrolepis,Coryphaenoides acrolepis,Pacific grenadier,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Coryphaenoides,Species,272313,8467,Species,,,,,,, -Coryphaenoides cinereus,Coryphaenoides cinereus,Popeye grenadier,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Coryphaenoides,Species,272326,8473,Species,,,,,,, -Coryphaenoides filifer,Coryphaenoides filifer,Filamented rattail,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Coryphaenoides,Species,272331,24679,Species,,,,,,, -Coryphaenoides longifilis,Coryphaenoides longifilis,longfin grenadier,NA,NA,NA,NA,NA,NA,Species,272336,NA,Species,,,,,,, -Coryphopterus punctipectophorus,Coryphopterus punctipectophorus,Spotted goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Coryphopterus,Species,276433,3849,Species,,,,,,, -Podochela lamelligera,Coryrhynchus lamelligerus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Inachidae,Podochela,Species,441862,NA,Species,,,,,,, -Coryrhynchus lamelligerus,Coryrhynchus lamelligerus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Inachidae,Podochela,Species,441862,NA,Species,,,,,,, -Podochela riisei,Coryrhynchus riisei,Longfinger neck crab,Animalia,Arthropoda,Malacostraca,Decapoda,Inachidae,Podochela,Species,441865,NA,Species,,,,,,, -Coryrhynchus riisei,Coryrhynchus riisei,Longfinger neck crab,Animalia,Arthropoda,Malacostraca,Decapoda,Inachidae,Podochela,Species,441865,NA,Species,,,,,,, -Coryrhynchus sidneyi,Coryrhynchus sidneyi,Shortfinger neck crab,Animalia,Arthropoda,Malacostraca,Decapoda,Inachidae,Coryrhynchus,Species,441866,NA,Species,,,,,,, -Podochela sidneyi,Coryrhynchus sidneyi,Shortfinger neck crab,Animalia,Arthropoda,Malacostraca,Decapoda,Inachidae,Coryrhynchus,Species,441866,NA,Species,,,,,,, -Corythoichthys albirostris,Cosmocampus albirostris,Whitenose pipefish,Animalia,Chordata,Teleostei,Syngnathiformes,Syngnathidae,Corythoichthys,Species,278055,3280,Species,,,,,,, -Cosmocampus albirostris,Cosmocampus albirostris,Whitenose pipefish,Animalia,Chordata,Teleostei,Syngnathiformes,Syngnathidae,Corythoichthys,Species,278055,3280,Species,,,,,,, -Anachis floridana,Costoanachis floridana,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Columbellidae,Anachis,Species,419993,NA,Species,,,,,,, -Costoanachis floridana,Costoanachis floridana,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Columbellidae,Anachis,Species,419993,NA,Species,,,,,,, -Cottidae,Cottidae,Sculpins,Animalia,Chordata,Teleostei,Perciformes,Cottidae,NA,Family,125589,NA,Remove,,,,,,, -Cranchia scabra,Cranchia scabra,Rough cranch squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Cranchiidae,Cranchia,Species,181386,NA,Species,,,,,,, -Cranchiidae,Cranchiidae,Glass squids,Animalia,Mollusca,Cephalopoda,Oegopsida,Cranchiidae,NA,Family,11774,NA,Remove,,,,,,, -Crangon,Crangon,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Crangon,Genus,107007,NA,Remove,,,,,,, -Crangon sp.,Crangon,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Crangon,Genus,107007,NA,Remove,,,,,,, -Crangon alaskensis,Crangon alaskensis,Alaska shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Crangon,Species,515542,NA,Species,,,,,,, -Crangon dalli,Crangon dalli,Ridged crangon,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Crangon,Species,254486,NA,Species,,,,,,, -Crangon franciscorum,Crangon franciscorum,California bay shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Crangon,Species,241261,NA,Species,,,,,,, -Crangon septemspinosa,Crangon septemspinosa,Sevenspine bay shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Crangon,Species,158355,NA,Species,,,,,,, -Crangonidae,Crangonidae,Crangonid shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,NA,Family,106782,NA,Remove,,,,,,, -Craniella,Craniella,puffball sponges,Animalia,Porifera,Demospongiae,Tetractinellida,Tetillidae,Craniella,Genus,132093,NA,Remove,,,,,,, -Craniella sp.,Craniella,puffball sponges,Animalia,Porifera,Demospongiae,Tetractinellida,Tetillidae,Craniella,Genus,132093,NA,Remove,,,,,,, -Craniella arb,Craniella arb,NA,Animalia,Porifera,Demospongiae,Tetractinellida,Tetillidae,Craniella,Species,171324,NA,Species,,,,,,, -Craniella craniana,Craniella craniana,Baseball sponge,Animalia,Porifera,Demospongiae,Tetractinellida,Tetillidae,Craniella,Species,171329,NA,Species,,,,,,, -Craniella sigmoancoratum,Craniella sigmoancoratum,Spiny ball sponge,Animalia,Porifera,Demospongiae,Tetractinellida,Tetillidae,Craniella,Species,293251,NA,Species,,,,,,, -Craniella sp. B,Craniella sp. B,knobby ball sponge,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Craniella spinosa,Craniella spinosa,Spiny tennis ball sponge,Animalia,Porifera,Demospongiae,Tetractinellida,Tetillidae,Craniella,Species,171352,NA,Species,,,,,,, -Craniella sputnika,Craniella sputnika,Spiky ball sponge,Animalia,Porifera,Demospongiae,Tetractinellida,Tetillidae,Craniella,Species,559368,NA,Species,,,,,,, -Craniella villosa,Craniella villosa,Tennis ball sponge,Animalia,Porifera,Demospongiae,Tetractinellida,Tetillidae,Craniella,Species,171357,NA,Species,,,,,,, -Crassadoma gigantea,Crassadoma gigantea,Giant rock-scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Crassadoma,Species,240774,NA,Species,,,,,,, -Crassatellidae,Crassatellidae,NA,Animalia,Mollusca,Bivalvia,Carditida,Crassatellidae,NA,Family,23013,NA,Remove,,,,,,, -Cyclocardia crassidens,Crassicardia crassidens,Thick cyclocardia,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,Cyclocardia,Species,1420848,NA,Species,,,,,,, -Crassicardia crassidens,Crassicardia crassidens,Thick cyclocardia,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,Cyclocardia,Species,1420848,NA,Species,,,,,,, -Cyclocardia crebricostata,Crassicardia crebricostata,Many rib cyclocardia,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,Cyclocardia,Species,1514455,NA,Species,,,,,,, -Crassicardia crebricostata,Crassicardia crebricostata,Many rib cyclocardia,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,Cyclocardia,Species,1514455,NA,Species,,,,,,, -Crella brunnea,Crella brunnea,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Crellidae,Crella,Species,131936,NA,Remove,,,,,,, -Crepidula,Crepidula,slipper shell,Animalia,Mollusca,Gastropoda,Littorinimorpha,Calyptraeidae,Crepidula,Genus,137722,NA,Remove,,,,,,, -Crepidula sp.,Crepidula,slipper shell,Animalia,Mollusca,Gastropoda,Littorinimorpha,Calyptraeidae,Crepidula,Genus,137722,NA,Remove,,,,,,, -Crepidula convexa,Crepidula convexa,Convex slippersnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Calyptraeidae,Crepidula,Species,160228,NA,Species,,,,,,, -Crepidula fornicata,Crepidula fornicata,Slipper limpet,Animalia,Mollusca,Gastropoda,Littorinimorpha,Calyptraeidae,Crepidula,Species,138963,NA,Species,,,,,,, -Crepidula maculosa,Crepidula maculosa,Spotted slippersnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Calyptraeidae,Crepidula,Species,419704,NA,Species,,,,,,, -Crepidula plana,Crepidula plana,Eastern white slippersnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Calyptraeidae,Crepidula,Species,160230,NA,Species,,,,,,, -Cribrinopsis,Cribrinopsis,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actiniidae,Cribrinopsis,Genus,100702,NA,Remove,,,,,,, -Cribrinopsis sp.,Cribrinopsis,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actiniidae,Cribrinopsis,Genus,100702,NA,Remove,,,,,,, -Cribrinopsis fernaldi,Cribrinopsis fernaldi,Chevron tentacle anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Actiniidae,Cribrinopsis,Species,283422,NA,Species,,,,,,, -Crinoidea,Crinoidea,Sea lilies and feather stars,Animalia,Echinodermata,Crinoidea,NA,NA,NA,Class,123081,NA,Remove,,,,,,, -Crispatotrochus foxi,Crispatotrochus foxi,Cup coral,Animalia,Cnidaria,Anthozoa,Scleractinia,Caryophylliidae,Crispatotrochus,Species,289737,NA,Species,,,,,,, -Bugula pacifica,Crisularia pacifica,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Bugulidae,Bugula,Species,834038,NA,Species,,,,,,, -Crisularia pacifica,Crisularia pacifica,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Bugulidae,Bugula,Species,834038,NA,Species,,,,,,, -Cronius ruber,Cronius ruber,Red swimcrab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Cronius,Species,241109,NA,Species,,,,,,, -Crossaster,Crossaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Crossaster,Genus,123336,NA,Remove,,,,,,, -Crossaster sp.,Crossaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Crossaster,Genus,123336,NA,Remove,,,,,,, -Crossaster borealis,Crossaster borealis,Grooved sun star,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Crossaster,Species,292707,NA,Species,,,,,,, -Crossaster papposus,Crossaster papposus,Common sunstar,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Crossaster,Species,124154,NA,Species,,,,,,, -Crossaster sp. A (Clark),Crossaster sp. A (Clark),white rose star,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Crossaster sp. B (Clark),Crossaster sp. B (Clark),pink rose star,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Crossata californica,Crossata californica,California frogsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Bursidae,Crossata,Species,580701,NA,Species,,,,,,, -Crustacea,Crustacea,Crustaceans,Animalia,Arthropoda,NA,NA,NA,NA,Subphylum,1066,NA,Remove,,,,,,, -Crustacea(infraorder),Crustacea,Crustaceans,Animalia,Arthropoda,NA,NA,NA,NA,Subphylum,1066,NA,Remove,,,,,,, -Crustacea(infraorder) anomura,Crustacea,Crustaceans,Animalia,Arthropoda,NA,NA,NA,NA,Subphylum,1066,NA,Remove,,,,,,, -Crustaceans,Crustacea,Crustaceans,Animalia,Arthropoda,NA,NA,NA,NA,Subphylum,1066,NA,Remove,,,,,,, -Crustacea shrimp,Crustacea shrimp,Crustacean shrimp,Animalia,Arthropoda,NA,NA,NA,NA,Subphylum,1066,NA,Remove,,,,,,, -Cryogorgia koolsae,Cryogorgia koolsae,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Malacalcyonacea incertae sedis,Cryogorgia,Species,289747,NA,Species,,,,,,, -Cryptacanthodes aleutensis,Cryptacanthodes aleutensis,Dwarf wrymouth,Animalia,Chordata,Teleostei,Perciformes,Cryptacanthodidae,Cryptacanthodes,Species,276390,3817,Species,,,,,,, -Cryptacanthodes giganteus,Cryptacanthodes giganteus,Giant wrymouth,Animalia,Chordata,Teleostei,Perciformes,Cryptacanthodidae,Cryptacanthodes,Species,276392,54155,Species,,,,,,, -Cryptacanthodes maculatus,Cryptacanthodes maculatus,Wrymouth,Animalia,Chordata,Teleostei,Perciformes,Cryptacanthodidae,Cryptacanthodes,Species,159675,3815,Species,,,,,,, -Cryptacanthodidae,Cryptacanthodidae,Wrymouths,Animalia,Chordata,Teleostei,Perciformes,Cryptacanthodidae,NA,Family,151391,NA,Remove,,,,,,, -Crypthelia,Crypthelia,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Crypthelia,Genus,117241,NA,Remove,,,,,,, -Crypthelia sp.,Crypthelia,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Crypthelia,Genus,117241,NA,Remove,,,,,,, -Crypthelia trophostega,Crypthelia trophostega,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Crypthelia,Species,285799,NA,Species,,,,,,, -Cryptochiton stelleri,Cryptochiton stelleri,Giant pacific chiton,Animalia,Mollusca,Polyplacophora,Chitonida,Acanthochitonidae,Cryptochiton,Species,240776,NA,Species,,,,,,, -Cryptolithodes,Cryptolithodes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Cryptolithodes,Genus,550614,NA,Remove,,,,,,, -Cryptolithodes sp.,Cryptolithodes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Cryptolithodes,Genus,550614,NA,Remove,,,,,,, -Cryptolithodes typica,Cryptolithodes typicus,Butterfly king crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Cryptolithodes,Species,550617,NA,Species,,,,,,, -Cryptolithodes typicus,Cryptolithodes typicus,Butterfly king crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Cryptolithodes,Species,550617,NA,Species,,,,,,, -Cryptomonadaceae,Cryptomonadaceae,NA,Chromista,Cryptophyta,Cryptophyceae,Cryptomonadales,Cryptomonadaceae,NA,Family,17644,NA,Remove,,,,,,, -Cryptonatica,Cryptonatica,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Cryptonatica,Genus,138238,NA,Remove,,,,,,, -Cryptonatica sp.,Cryptonatica,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Cryptonatica,Genus,138238,NA,Remove,,,,,,, -Cryptonatica affinis,Cryptonatica affinis,Arctic moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Cryptonatica,Species,140525,NA,Species,,,,,,, -Natica clausa,Cryptonatica affinis,Arctic moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Cryptonatica,Species,140525,NA,Species,,,,,,, -Cryptonatica aleutica,Cryptonatica aleutica,Aleutian moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Cryptonatica,Species,576533,NA,Species,,,,,,, -Cryptonatica russa,Cryptonatica russa,Russty moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Cryptonatica,Species,580692,NA,Species,,,,,,, -Cryptopsaras couesii,Cryptopsaras couesii,Triplewart seadevil,Animalia,Chordata,Teleostei,Lophiiformes,Ceratiidae,Cryptopsaras,Species,126538,3098,Species,,,,,,, -Cycloes bairdii,Cryptosoma bairdii,Shameface heart crab,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Cyclois,Species,440316,NA,Species,,,,,,, -Cryptosoma bairdii,Cryptosoma bairdii,Shameface heart crab,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Cyclois,Species,440316,NA,Species,,,,,,, -Cryptotomus roseus,Cryptotomus roseus,Bluelip parrotfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Scaridae,Cryptotomus,Species,277118,3674,Species,,,,,,, -Crystallichthys cyclospilus,Crystallichthys cyclospilus,Blotched snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Crystallichthys,Species,280451,4180,Species,,,,,,, -Ctenodiscus,Ctenodiscus,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Ctenodiscidae,Ctenodiscus,Genus,123258,NA,Remove,,,,,,, -Ctenodiscus sp.,Ctenodiscus,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Ctenodiscidae,Ctenodiscus,Genus,123258,NA,Remove,,,,,,, -Ctenodiscus crispatus,Ctenodiscus crispatus,Mud star,Animalia,Echinodermata,Asteroidea,Paxillosida,Ctenodiscidae,Ctenodiscus,Species,123915,NA,Species,,,,,,, -Parthenope serrata,Ctenodrilus serratus,Sawtooth elbow crab,Animalia,Annelida,Polychaeta,Terebellida,Cirratulidae,Parthenope,Species,129989,NA,Species,,,,,,, -Gobionellus boleosoma,Ctenogobius boleosoma,Darter goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobionellus,Species,159750,3858,Species,,,,,,, -Ctenogobius boleosoma,Ctenogobius boleosoma,Darter goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobionellus,Species,159750,3858,Species,,,,,,, -Ctenoides,Ctenoides,NA,Animalia,Mollusca,Bivalvia,Limida,Limidae,Ctenoides,Genus,390579,NA,Remove,,,,,,, -Ctenophora,Ctenophora,Comb jellies,Animalia,Ctenophora,NA,NA,NA,NA,Phylum,1248,NA,Remove,,,,,,, -Periclimenes americanus,Cuapetes americanus,American grass shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Palaemonidae,Periclimenes,Species,514508,NA,Species,,,,,,, -Periclimenes bermudensis,Cuapetes americanus,American grass shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Palaemonidae,Periclimenes,Species,514508,NA,Species,,,,,,, -Cubiceps,Cubiceps,NA,Animalia,Chordata,Teleostei,Scombriformes,Nomeidae,Cubiceps,Genus,126037,NA,Remove,,,,,,, -Cubiceps pauciradiatus,Cubiceps pauciradiatus,Bigeye cigarfish,Animalia,Chordata,Teleostei,Scombriformes,Nomeidae,Cubiceps,Species,159424,5049,Species,,,,,,, -Cubomedusae,Cubozoa,NA,Animalia,Cnidaria,NA,Cubomedusae,NA,NA,Order,135219,NA,Remove,,,,,,, -Cucumaria,Cucumaria,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,Cucumaria,Genus,123479,NA,Remove,,,,,,, -Cucumaria sp.,Cucumaria,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,Cucumaria,Genus,123479,NA,Remove,,,,,,, -Cucumaria fallax,Cucumaria fallax,Sea football,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,Cucumaria,Species,528995,NA,Species,,,,,,, -Cucumaria frondosa,Cucumaria frondosa,Orange footed sea cucumber,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,Cucumaria,Species,124612,NA,Species,,,,,,, -Cucumaria japonica,Cucumaria frondosa japonica,Black sea cucumber,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,Cucumaria,Species,529406,NA,Species,,,,,,, -Cucumaria frondosa japonica,Cucumaria frondosa japonica,Black sea cucumber,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,Cucumaria,Species,529406,NA,Species,,,,,,, -Cucumariidae,Cucumariidae,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,NA,Family,123187,NA,Remove,,,,,,, -Cumacea,Cumacea,cumacean unid.,NA,NA,NA,NA,NA,NA,Order,1137,NA,Remove,,,,,,, -Cyanea,Cyanea,NA,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Cyaneidae,Cyanea,Genus,135259,NA,Remove,,,,,,, -Cyanea sp.,Cyanea,NA,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Cyaneidae,Cyanea,Genus,135259,NA,Remove,,,,,,, -Cyanea capillata,Cyanea capillata,Lion's mane,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Cyaneidae,Cyanea,Species,135301,NA,Species,,,,,,, -Cyclocardia,Cyclocardia,NA,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,Cyclocardia,Genus,156830,NA,Remove,,,,,,, -Cyclocardia sp.,Cyclocardia,NA,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,Cyclocardia,Genus,156830,NA,Remove,,,,,,, -Cyclocardia borealis,Cyclocardia borealis,NA,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,Cyclocardia,Species,156832,NA,Species,,,,,,, -Cyclocardia ovata,Cyclocardia ovata,Ovate cyclocardia,Animalia,Mollusca,Bivalvia,Carditida,Carditidae,Cyclocardia,Species,504902,NA,Species,,,,,,, -Cyclocardia sp. cf. borealis (Clark 2006),Cyclocardia sp. cf. borealis (Clark 2006),northern carditid,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Cyclohelia,Cyclohelia,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Cyclohelia,Genus,267361,NA,Remove,,,,,,, -Cyclohelia sp.,Cyclohelia,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Cyclohelia,Genus,267361,NA,Remove,,,,,,, -Cyclohelia lamellata,Cyclohelia lamellata,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Cyclohelia,Species,289768,NA,Species,,,,,,, -Cyclopecten,Cyclopecten,NA,Animalia,Mollusca,Bivalvia,Pectinida,Propeamussiidae,Cyclopecten,Genus,138317,NA,Remove,,,,,,, -Cyclopecten sp.,Cyclopecten,NA,Animalia,Mollusca,Bivalvia,Pectinida,Propeamussiidae,Cyclopecten,Genus,138317,NA,Remove,,,,,,, -Cyclopecten davidsoni,Cyclopecten davidsoni,Salmon glass-scallop,Animalia,Mollusca,Bivalvia,Pectinida,Propeamussiidae,Cyclopecten,Species,391712,NA,Species,,,,,,, -Cyclopsetta,Cyclopsetta,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Cyclopsetta,Genus,158794,NA,Remove,,,,,,, -Cyclopsetta chittendeni,Cyclopsetta chittendeni,Mexican flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Cyclopsetta,Species,275700,979,Species,,,,,,, -Cyclopsetta fimbriata,Cyclopsetta fimbriata,Spotfin flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Cyclopsetta,Species,158795,4219,Species,,,,,,, -Cyclopteridae,Cyclopteridae,Lumpfishes,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,NA,Family,125590,NA,Remove,,,,,,, -Cyclopterinae,Cyclopterinae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Cyclopterus lumpus,Cyclopterus lumpus,Lumpfish,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Cyclopterus,Species,127214,62,Species,,,,,,, -Cyclothone,Cyclothone,NA,Animalia,Chordata,Teleostei,Stomiiformes,Gonostomatidae,Cyclothone,Genus,126187,NA,Remove,,,,,,, -Cyclothone sp.,Cyclothone,NA,Animalia,Chordata,Teleostei,Stomiiformes,Gonostomatidae,Cyclothone,Genus,126187,NA,Remove,,,,,,, -Cyclothone acclinidens,Cyclothone acclinidens,Benttooth bristlemouth,Animalia,Chordata,Teleostei,Stomiiformes,Gonostomatidae,Cyclothone,Species,127282,5116,Species,,,,,,, -Cyclothone atraria,Cyclothone atraria,Deep water bristlemouth,Animalia,Chordata,Teleostei,Stomiiformes,Gonostomatidae,Cyclothone,Species,274943,7384,Species,,,,,,, -Calappa angusta,Cyclozodion angustum,Nodose box crab,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Cyclozodion,Species,421921,NA,Species,,,,,,, -Cyclozodion tuberatum,Cyclozodion tuberatum,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Cyclozodion,Species,421922,NA,Species,,,,,,, -Cylichna alba,Cylichna alba,White cylichna,Animalia,Mollusca,Gastropoda,Cephalaspidea,Cylichnidae,Cylichna,Species,139474,NA,Species,,,,,,, -Cymatium,Cymatium,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cymatiidae,Cymatium,Genus,138426,NA,Remove,,,,,,, -Cymatium rubeculum-occidentale,Cymatium rubeculum occidentale,Ruby triton,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cymatiidae,Cymatium,Species,138426,NA,Species,,,,,,, -Cymatogaster aggregata,Cymatogaster aggregata,Shiner perch,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Embiotocidae,Cymatogaster,Species,280461,3626,Species,,,,,,, -Cymothoa,Cymothoa,NA,Animalia,Arthropoda,Malacostraca,Isopoda,Cymothoidae,Cymothoa,Genus,118409,NA,Remove,,,,,,, -Cymothoidae,Cymothoidae,NA,Animalia,Arthropoda,Malacostraca,Isopoda,Cymothoidae,NA,Family,118274,NA,Remove,,,,,,, -Cynoglossidae,Cynoglossidae,Tonguefishes,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,NA,Family,125578,NA,Remove,,,,,,, -Cynoscion,Cynoscion,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Cynoscion,Genus,159304,NA,Remove,,,,,,, -Cynoscion arenarius/nothus,Cynoscion,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Cynoscion,Genus,159304,NA,Remove,,,,,,, -Cynoscion arenarius,Cynoscion arenarius,Sand weakfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Cynoscion,Species,276077,1170,Species,,,,,,, -Cynoscion nebulosus,Cynoscion nebulosus,Spotted weakfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Cynoscion,Species,159312,405,Species,,,,,,, -Cynoscion nothus,Cynoscion nothus,Silver seatrout,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Cynoscion,Species,159305,1175,Species,,,,,,, -Cynoscion regalis,Cynoscion regalis,Weakfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Cynoscion,Species,159313,406,Species,,,,,,, -Cyphoma,Cyphoma,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Ovulidae,Cyphoma,Genus,394147,NA,Remove,,,,,,, -Cyphoma mcgintyi,Cyphoma mcgintyi,Purple flamingo tongue,Animalia,Mollusca,Gastropoda,Littorinimorpha,Ovulidae,Cyphoma,Species,419729,NA,Species,,,,,,, -Cypraea,Cypraea,Cowries,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cypraeidae,Cypraea,Genus,205978,NA,Remove,,,,,,, -Cypraeidae,Cypraeidae,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cypraeidae,NA,Family,23022,NA,Remove,,,,,,, -Cypselurus,Cypselurus,NA,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Cypselurus,Genus,206252,NA,Remove,,,,,,, -Cystisoma fabricii,Cystisoma fabricii,NA,Animalia,Arthropoda,Malacostraca,Amphipoda,Cystisomatidae,Cystisoma,Species,103243,NA,Species,,,,,,, -Cyttopsis rosea,Cyttopsis rosea,Rosy dory,Animalia,Chordata,Teleostei,Zeiformes,Parazenidae,Cyttopsis,Species,127425,4953,Species,,,,,,, -Dactylopterus volitans,Dactylopterus volitans,Flying gurnard,Animalia,Chordata,Teleostei,Dactylopteriformes,Dactylopteridae,Dactylopterus,Species,127232,1021,Species,,,,,,, -Danielum ixbauchac,Danielum ixbauchac,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pilumnidae,Danielum,Species,422092,NA,Species,,,,,,, -Dardanus,Dardanus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Dardanus,Genus,106842,NA,Remove,,,,,,, -Dardanus fucosus,Dardanus fucosus,Bareye hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Dardanus,Species,367581,NA,Species,,,,,,, -Dardanus insignis,Dardanus insignis,Red brocade hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Dardanus,Species,367585,NA,Species,,,,,,, -Dardanus venosus,Dardanus venosus,Stareye hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Dardanus,Species,367596,NA,Species,,,,,,, -Dasyatidae,Dasyatidae,Sting rays,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Dasyatidae,NA,Family,105708,NA,Remove,,,,,,, -Dasycottus setiger,Dasycottus setiger,Spinyhead sculpin,Animalia,Chordata,Teleostei,Perciformes,Psychrolutidae,Dasycottus,Species,280488,4085,Species,,,,,,, -Callianassa latispina,Dawsonius latispinus,Broadspine ghost shrimpg,Animalia,Arthropoda,Malacostraca,Decapoda,Callianassidae,Callianassa,Species,421828,NA,Species,,,,,,, -Dawnsonius latispinus,Dawsonius latispinus,Broadspine ghost shrimpg,Animalia,Arthropoda,Malacostraca,Decapoda,Ctenochelidae,Dawsonius,Species,421828,NA,Species,,,,,,, -Decapoda,Decapoda,Ten footed,Animalia,Arthropoda,Malacostraca,Decapoda,NA,NA,Order,1130,NA,Remove,,,,,,, -Decapodiformes,Decapodiformes,Squid unid.,Animalia,Mollusca,Cephalopoda,NA,NA,NA,SuperOrder,325342,NA,Remove,,,,,,, -Decapodiform,Decapodiformes,Squid unid.,Animalia,Mollusca,Cephalopoda,NA,NA,NA,SuperOrder,325342,NA,Remove,,,,,,, -Decapterus,Decapterus,NA,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Decapterus,Genus,125937,NA,Remove,,,,,,, -Decapterus macarellus,Decapterus macarellus,Mackerel scad,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Decapterus,Species,126807,993,Species,,,,,,, -Decapterus punctatus,Decapterus punctatus,Round scad,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Decapterus,Species,126808,994,Species,,,,,,, -Decapterus tabl,Decapterus tabl,Roughear scad,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Decapterus,Species,159484,995,Species,,,,,,, -Decodon,Decodon,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Decodon,Genus,203883,NA,Remove,,,,,,, -Decodon puellaris,Decodon puellaris,Red hogfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Decodon,Species,276747,3657,Species,,,,,,, -Delectopecten vancouverensis,Delectopecten vancouverensis,Vancouver scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Delectopecten,Species,391795,NA,Species,,,,,,, -Demospongiae,Demospongiae,Horny sponges,Animalia,Porifera,Demospongiae,NA,NA,NA,Class,164811,NA,Remove,,,,,,, -Dendostrea,Dendostrea,NA,Animalia,Mollusca,Bivalvia,Ostreida,Ostreidae,Dendostrea,Genus,415280,NA,Remove,,,,,,, -Ostrea frons,Dendostrea frons,Frond oyster,Animalia,Mollusca,Bivalvia,Ostreida,Ostreidae,Ostrea,Species,420779,NA,Species,,,,,,, -Dendostrea frons,Dendostrea frons,Frond oyster,Animalia,Mollusca,Bivalvia,Ostreida,Ostreidae,Ostrea,Species,420779,NA,Species,,,,,,, -Dendraster excentricus,Dendraster excentricus,Eccentric sand dollar,Animalia,Echinodermata,Echinoidea,Echinolampadacea,Dendrasteridae,Dendraster,Species,513215,NA,Species,,,,,,, -Dendrobeania,Dendrobeania,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Bugulidae,Dendrobeania,Genus,110842,NA,Remove,,,,,,, -Dendrobeania sp.,Dendrobeania,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Bugulidae,Dendrobeania,Genus,110842,NA,Remove,,,,,,, -Dendrochirotidae,Dendrochirotidae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Dendrodoris,Dendrodoris,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Dendrodorididae,Dendrodoris,Genus,137883,NA,Remove,,,,,,, -Dendronotidae,Dendronotidae,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Dendronotidae,NA,Family,186,NA,Remove,,,,,,, -Dendronotus,Dendronotus,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Dendronotidae,Dendronotus,Genus,137885,NA,Remove,,,,,,, -Dendronotus sp.,Dendronotus,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Dendronotidae,Dendronotus,Genus,137885,NA,Remove,,,,,,, -Dendronotus dalli,Dendronotus dalli,Dall's dendronotus,Animalia,Mollusca,Gastropoda,Nudibranchia,Dendronotidae,Dendronotus,Species,156709,NA,Species,,,,,,, -Dendronotus frondosus,Dendronotus frondosus,Frond aeolis,Animalia,Mollusca,Gastropoda,Nudibranchia,Dendronotidae,Dendronotus,Species,139523,NA,Species,,,,,,, -Dendronotus subramosus,Dendronotus subramosus,Stubby frond-aeolis,Animalia,Mollusca,Gastropoda,Nudibranchia,Dendronotidae,Dendronotus,Species,548244,NA,Species,,,,,,, -Dendrophyllia californica,Dendrophyllia californica,Tree coral,Animalia,Cnidaria,Anthozoa,Scleractinia,Dendrophylliidae,Dendrophyllia,Species,286965,NA,Species,,,,,,, -Dentalium,Dentalium,NA,Animalia,Mollusca,Scaphopoda,Dentaliida,Dentaliidae,Dentalium,Genus,137886,NA,Remove,,,,,,, -Dentalium sp.,Dentalium,NA,Animalia,Mollusca,Scaphopoda,Dentaliida,Dentaliidae,Dentalium,Genus,137886,NA,Remove,,,,,,, -Dermasterias imbricata,Dermasterias imbricata,Leather star,Animalia,Echinodermata,Asteroidea,Valvatida,Asteropseidae,Dermasterias,Species,240771,NA,Species,,,,,,, -Dermaturus mandti,Dermaturus mandtii,Wrinkled crab,Animalia,Arthropoda,Malacostraca,Decapoda,Hapalogastridae,Dermaturus,Species,590106,NA,Species,,,,,,, -Dermaturus mandtii,Dermaturus mandtii,Wrinkled crab,Animalia,Arthropoda,Malacostraca,Decapoda,Hapalogastridae,Dermaturus,Species,590106,NA,Species,,,,,,, -Dermochelys coriacea,Dermochelys coriacea,Leatherback turtle,Animalia,Chordata,NA,Testudines,Dermochelyidae,Dermochelys,Species,137209,NA,Species,,,,,,, -Desmodema lorum,Desmodema lorum,Whiptail ribbonfish,Animalia,Chordata,Teleostei,Lampriformes,Trachipteridae,Desmodema,Species,275872,3262,Species,,,,,,, -Desmophyllum dianthus,Desmophyllum dianthus,Cockscomb cup coral,Animalia,Cnidaria,Anthozoa,Scleractinia,Caryophylliidae,Desmophyllum,Species,135159,NA,Species,,,,,,, -Lophelia pertusa,Desmophyllum pertusum,Spider hazards coral,Animalia,Cnidaria,Anthozoa,Scleractinia,Caryophylliidae,Lophelia,Species,1245747,NA,Species,,,,,,, -Diadema antillarum,Diadema antillarum,Long spined sea urchin,Animalia,Echinodermata,Echinoidea,Diadematoida,Diadematidae,Diadema,Species,124332,NA,Species,,,,,,, -Diadematidae,Diadematidae,NA,Animalia,Echinodermata,Echinoidea,Diadematoida,Diadematidae,NA,Family,123163,NA,Remove,,,,,,, -Diaphus,Diaphus,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Diaphus,Genus,125819,NA,Remove,,,,,,, -Diaphus sp,Diaphus,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Diaphus,Genus,125819,NA,Remove,,,,,,, -Diaphus sp.,Diaphus,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Diaphus,Genus,125819,NA,Remove,,,,,,, -Diaphus dumerili,Diaphus dumerilii,Dumeril's lanternfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Diaphus,Species,126590,6590,Species,,,,,,, -Diaphus splendidus,Diaphus splendidus,Horned lanternfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Diaphus,Species,158893,10174,Species,,,,,,, -Diaphus theta,Diaphus theta,California headlightfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Diaphus,Species,272694,2732,Species,,,,,,, -Diapterus,Diapterus,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Gerreidae,Diapterus,Genus,159725,NA,Remove,,,,,,, -Diapterus auratus,Diapterus auratus,Irish mojarra,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Gerreidae,Diapterus,Species,159726,3563,Species,,,,,,, -Diaulula,Diaulula,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Discodorididae,Diaulula,Genus,415291,NA,Remove,,,,,,, -Diaulula sp. A (Clark 2006),Diaulula sp. A (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Dibranchus atlanticus,Dibranchus atlanticus,Atlantic batfish,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Dibranchus,Species,126558,4956,Species,,,,,,, -Dichelopandalus leptocerus,Dichelopandalus leptocerus,Bristled longbeak,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Dichelopandalus,Species,158356,NA,Species,,,,,,, -Dicrolene filamentosa,Dicrolene filamentosa,NA,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Dicrolene,Species,275892,56340,Species,,,,,,, -Dicrolene intronigra,Dicrolene introniger,Digitate cusk eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Dicrolene,Species,275895,8091,Species,,,,,,, -Dicrolene introniger,Dicrolene introniger,Digitate cusk eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Dicrolene,Species,275895,8091,Species,,,,,,, -Didemnidae,Didemnidae,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Didemnidae,NA,Genus,103439,NA,Remove,,,,,,, -Dimya argentea,Dimya argentea,Silver dimyid,Animalia,Mollusca,Bivalvia,Pectinida,Dimyidae,Dimya,Species,420774,NA,Species,,,,,,, -Dinocardium,Dinocardium,NA,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Dinocardium,Genus,156841,NA,Remove,,,,,,, -Diodon holocanthus,Diodon holocanthus,Longspined porcupinefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Diodontidae,Diodon,Species,127402,4659,Species,,,,,,, -Diodon hystrix,Diodon hystrix,Spot fin porcupinefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Diodontidae,Diodon,Species,127403,1022,Species,,,,,,, -Diodora aspera,Diodora aspera,Keyhole limpet,Animalia,Mollusca,Gastropoda,Lepetellida,Fissurellidae,Diodora,Species,367955,NA,Species,,,,,,, -Diodora cayenensis,Diodora cayenensis,Cayenne keyhole limpet,Animalia,Mollusca,Gastropoda,Lepetellida,Fissurellidae,Diodora,Species,160265,NA,Species,,,,,,, -Diogenidae,Diogenidae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,NA,Family,106736,NA,Remove,,,,,,, -Diplacanthopoma,Diplacanthopoma,NA,Animalia,Chordata,Teleostei,Ophidiiformes,Bythitidae,Diplacanthopoma,Genus,158993,NA,Remove,,,,,,, -Diplectrum,Diplectrum,NA,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Diplectrum,Genus,159349,NA,Remove,,,,,,, -Diplectrum bivittatum,Diplectrum bivittatum,Dwarf sand perch,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Diplectrum,Species,276176,3318,Species,,,,,,, -Diplectrum formosum,Diplectrum formosum,Sand perch,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Diplectrum,Species,159350,1203,Species,,,,,,, -Diplodus holbrooki,Diplodus holbrookii,Spottail seabream,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Diplodus,Species,273972,1231,Species,,,,,,, -Diplodus holbrookii,Diplodus holbrookii,Spottail seabream,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Diplodus,Species,273972,1231,Species,,,,,,, -Diplogrammus pauciradiatus,Diplogrammus pauciradiatus,Spotted dragonet,Animalia,Chordata,Teleostei,Callionymiformes,Callionymidae,Diplogrammus,Species,159615,3825,Species,,,,,,, -Diplopteraster,Diplopteraster,NA,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Diplopteraster,Genus,123331,NA,Remove,,,,,,, -Diplopteraster sp.,Diplopteraster,NA,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Diplopteraster,Genus,123331,NA,Remove,,,,,,, -Diplopteraster multipes,Diplopteraster multipes,Pincushion star,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Diplopteraster,Species,124128,NA,Species,,,,,,, -Diplosoma,Diplosoma,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Didemnidae,Diplosoma,Genus,103457,NA,Remove,,,,,,, -Dipsacaster,Dipsacaster,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Dipsacaster,Genus,178680,NA,Remove,,,,,,, -Dipsacaster sp.,Dipsacaster,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Dipsacaster,Genus,178680,NA,Remove,,,,,,, -Dipsacaster anoplus,Dipsacaster anoplus,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Dipsacaster,Species,345389,NA,Species,,,,,,, -Dipsacaster borealis,Dipsacaster borealis,Northern sand star,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Dipsacaster,Species,345390,NA,Species,,,,,,, -Dipsacaster eximius,Dipsacaster eximius,Extraordinary sand star,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Dipsacaster,Species,380338,NA,Species,,,,,,, -Dipsacaster eximus,Dipsacaster eximius,Extraordinary sand star,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Dipsacaster,Species,380338,NA,Species,,,,,,, -Dipturus laevis,Dipturus laevis,Barndoor skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Dipturus,Species,158548,2561,Species,,,,,,, -Raja laevis,Dipturus laevis,Barndoor skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Dipturus,Species,158548,2561,Species,,,,,,, -Raja olseni,Dipturus olseni,Spreadfin skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Species,271556,2563,Species,,,,,,, -Dipturus olseni,Dipturus olseni,Spreadfin skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Species,271556,2563,Species,,,,,,, -Dirona pellucida,Dirona pellucida,Golden dirona,Animalia,Mollusca,Gastropoda,Nudibranchia,Dironidae,Dirona,Species,576387,NA,Species,,,,,,, -Dironidae,Dironidae,dironid nudibranchs,NA,NA,NA,NA,NA,NA,Family,412591,NA,Remove,,,,,,, -Discodoris,Discodoris,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Discodorididae,Discodoris,Genus,137897,NA,Remove,,,,,,, -Discorsopagurus schmitti,Discorsopagurus schmitti,Tubeworm hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Discorsopagurus,Species,366310,NA,Species,,,,,,, -Dissodactylus crinitichelis,Dissodactylus crinitichelis,Seabiscuit pea crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pinnotheridae,Dissodactylus,Species,422151,NA,Species,,,,,,, -Distaplia,Distaplia,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Holozoidae,Distaplia,Genus,103464,NA,Remove,,,,,,, -Distaplia sp.,Distaplia,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Holozoidae,Distaplia,Genus,103464,NA,Remove,,,,,,, -Distaplia occidentalis,Distaplia occidentalis,Mushroom tunicate,Animalia,Chordata,Ascidiacea,Aplousobranchia,Holozoidae,Distaplia,Species,250152,NA,Species,,,,,,, -Distaplia smithi,Distaplia smithi,Stalked compound tunicate,Animalia,Chordata,Ascidiacea,Aplousobranchia,Holozoidae,Distaplia,Species,250160,NA,Species,,,,,,, -Distaplia sp. A (Clark 2006),Distaplia sp. A (Clark 2006),peach ascidian,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Distichopora,Distichopora,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Distichopora,Genus,205513,NA,Remove,,,,,,, -Distichopora sp.,Distichopora,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Distichopora,Genus,205513,NA,Remove,,,,,,, -Distichopora borealis,Distichopora borealis,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Distichopora,Species,288320,NA,Species,,,,,,, -Distichoptilum gracile,Distichoptilum gracile,Slender sea pen,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Protoptilidae,Distichoptilum,Species,128524,NA,Species,,,,,,, -Distorsio,Distorsio,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Personidae,Distorsio,Genus,138329,NA,Remove,,,,,,, -Distorsio clathrata,Distorsio clathrata,Atlantic distorsio,Animalia,Mollusca,Gastropoda,Littorinimorpha,Personidae,Distorsio,Species,419785,NA,Species,,,,,,, -Distorsio constricta,Distorsio constricta,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Personidae,Distorsio,Species,419786,NA,Species,,,,,,, -Distorsio mcgintyi,Distorsio mcgintyi,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Personidae,Distorsio,Species,476484,NA,Species,,,,,,, -Dolichopteryx,Dolichopteryx,Winged spookfish,Animalia,Chordata,Teleostei,Argentiniformes,Opisthoproctidae,Dolichopteryx,Genus,125895,NA,Remove,,,,,,, -Dolichopteryx longipes,Dolichopteryx longipes,Brownsnout spookfish,Animalia,Chordata,Teleostei,Argentiniformes,Opisthoproctidae,Dolichopteryx,Species,126731,9121,Species,,,,,,, -Archidorididae,Dorididae,Archidorid nudibranchs,Animalia,Mollusca,Gastropoda,Nudibranchia,Dorididae,NA,Family,9904,NA,Remove,,,,,,, -Dorididae,Dorididae,Archidorid nudibranchs,Animalia,Mollusca,Gastropoda,Nudibranchia,Dorididae,NA,Family,9904,NA,Remove,,,,,,, -Archidoris,Doris,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Dorididae,Archidoris,Genus,137914,NA,Remove,,,,,,, -Doris sp.,Doris,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Dorididae,Archidoris,Genus,137914,NA,Remove,,,,,,, -Doris,Doris,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Dorididae,Doris,Genus,137914,NA,Remove,,,,,,, -Archidoris montereyensis,Doris montereyensis,Monterey sea-lemon,Animalia,Mollusca,Gastropoda,Nudibranchia,Dorididae,Archidoris,Species,581816,NA,Species,,,,,,, -Doris montereyensis,Doris montereyensis,Monterey sea-lemon,Animalia,Mollusca,Gastropoda,Nudibranchia,Dorididae,Archidoris,Species,581816,NA,Species,,,,,,, -Archidoris odhneri,Doris odhneri,White night doris,Animalia,Mollusca,Gastropoda,Nudibranchia,Dorididae,Doris,Species,581817,NA,Species,,,,,,, -Doris odhneri,Doris odhneri,White night doris,Animalia,Mollusca,Gastropoda,Nudibranchia,Dorididae,Doris,Species,581817,NA,Species,,,,,,, -Dorosoma,Dorosoma,NA,Animalia,Chordata,Teleostei,Clupeiformes,Dorosomatidae,Dorosoma,Genus,159599,NA,Remove,,,,,,, -Dorosoma cepedianum,Dorosoma cepedianum,American gizzard shad,Animalia,Chordata,Teleostei,Clupeiformes,Dorosomatidae,Dorosoma,Species,159600,1604,Species,,,,,,, -Dorosoma petenense,Dorosoma petenense,Threadfin shad,Animalia,Chordata,Teleostei,Clupeiformes,Dorosomatidae,Dorosoma,Species,276310,1606,Species,,,,,,, -Doryteuthis,Doryteuthis,,Animalia,Mollusca,Cephalopoda,Myopsida,Loliginidae,Doryteuthis,Genus,410349,NA,Remove,,,,,,, -Doryteuthis sp,Doryteuthis sp,Inshore Squid sp. ,Animalia,Mollusca,Cephalopoda,Myopsida,Loliginidae,Doryteuthis,Genus,410349,NA,Genus,,,,,,, -Doryteuthis opalescens,Doryteuthis opalescens,California market squid,Animalia,Mollusca,Cephalopoda,Myopsida,Loliginidae,Doryteuthis,Species,574540,NA,Species,,,,,,, -Loligo opalescens,Doryteuthis opalescens,California market squid,Animalia,Mollusca,Cephalopoda,Myopsida,Loliginidae,Doryteuthis,Species,574540,NA,Species,,,,,,, -Loligo pealeii,Doryteuthis pealeii,Longfin inshore squid,Animalia,Mollusca,Cephalopoda,Myopsida,Loliginidae,Loligo,Species,574541,NA,Species,,,,,,, -Loligo pleii,Doryteuthis pleii,Slender inshore squid,Animalia,Mollusca,Cephalopoda,Myopsida,Loliginidae,Loligo,Species,574543,NA,Species,,,,,,, -Dosidicus gigas,Dosidicus gigas,Jumbo flying squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Ommastrephidae,Dosidicus,Species,342291,NA,Species,,,,,,, -Dosinia,Dosinia,NA,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Dosinia,Genus,138636,NA,Remove,,,,,,, -Dromalia alexandri,Dromalia alexandri,Sea dandelion,Animalia,Cnidaria,Hydrozoa,Siphonophorae,Rhodaliidae,Dromalia,Species,289842,NA,Species,,,,,,, -Dromidia,Dromidia,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Dromiidae,Dromidia,Genus,204862,NA,Remove,,,,,,, -Dromiidae,Dromiidae,Sponge crabs,Animalia,Arthropoda,Malacostraca,Decapoda,Dromiidae,NA,Family,106742,NA,Remove,,,,,,, -Bursa granularis cubaniana,Dulcerana cubaniana,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Bursidae,Bursa,Species,1472304,NA,Species,,,,,,, -Dysomma anguilla,Dysomma anguillare,Shortbelly eel,Animalia,Chordata,Teleostei,Anguilliformes,Synaphobranchidae,Dysomma,Species,221386,2659,Species,,,,,,, -Dysomma anguillare,Dysomma anguillare,Shortbelly eel,Animalia,Chordata,Teleostei,Anguilliformes,Synaphobranchidae,Dysomma,Species,221386,2659,Species,,,,,,, -Dyspanopeus texana,Dyspanopeus texanus,Gulf grassflat crab,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Dyspanopeus,Species,443955,NA,Species,,,,,,, -Neopanope texana,Dyspanopeus texanus,Gulf grassflat crab,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Dyspanopeus,Species,443955,NA,Species,,,,,,, -Echeneis,Echeneis,NA,Animalia,Chordata,Teleostei,Carangiformes,Echeneidae,Echeneis,Genus,125962,NA,Remove,,,,,,, -Echeneis naucrates,Echeneis naucrates,Sharksucker,Animalia,Chordata,Teleostei,Carangiformes,Echeneidae,Echeneis,Species,126848,2467,Species,,,,,,, -Echeneis neucratoides,Echeneis neucratoides,Whitefin sharksucker,Animalia,Chordata,Teleostei,Carangiformes,Echeneidae,Echeneis,Species,159678,3543,Species,,,,,,, -Lopholithodes,Echidnocerus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Lopholithodes,Genus,1550522,NA,Remove,,,,,,, -Echidnocerus sp.,Echidnocerus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Lopholithodes,Genus,1550522,NA,Remove,,,,,,, -Lopholithodes sp.,Echidnocerus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Lopholithodes,Genus,1550522,NA,Remove,,,,,,, -Lopholithodes mandtii,Echidnocerus cibarius,Puget sound king crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Lopholithodes,Species,1580332,NA,Species,,,,,,, -Echidnocerus cibarius,Echidnocerus cibarius,Puget sound king crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Lopholithodes,Species,1580332,NA,Species,,,,,,, -Lopholithodes foraminatus,Echidnocerus foraminatus,Brown box crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Lopholithodes,Species,590147,NA,Species,,,,,,, -Echidnocerus foraminatus,Echidnocerus foraminatus,Brown box crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Lopholithodes,Species,590147,NA,Species,,,,,,, -Echinacea,Echinacea,Sea urchins,Animalia,Echinodermata,Echinoidea,NA,NA,NA,SubterClass,149855,NA,Remove,,,,,,, -Echinarachnius parma,Echinarachnius parma,Common sand dollar,Animalia,Echinodermata,Echinoidea,Echinolampadacea,Echinarachniidae,Echinarachnius,Species,158062,NA,Species,,,,,,, -Echinaster,Echinaster,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Echinaster,Genus,123275,NA,Remove,,,,,,, -Echinaster modestus,Echinaster (Echinaster) modestus,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Echinaster,Species,178740,NA,Species,,,,,,, -Echinaster aff brasiliensis,Echinaster (Othilia) brasiliensis,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Echinaster,Species,178747,NA,Species,,,,,,, -Echinaster paucispinus,Echinaster (Othilia) paucispinus,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Echinaster,Species,178751,NA,Species,,,,,,, -Echinaster sentus,Echinaster (Othilia) sentus,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Echinaster,Species,178752,NA,Species,,,,,,, -Thyraster serpentarius,Echinaster (Othilia) serpentarius,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Thyraster,Species,178753,NA,Species,,,,,,, -Echinaster serpentarius,Echinaster (Othilia) serpentarius,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Thyraster,Species,178753,NA,Species,,,,,,, -Echinaster spinulosus,Echinaster (Othilia) spinulosus,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Echinaster,Species,178754,NA,Species,,,,,,, -Echinasteridae,Echinasteridae,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,NA,Genus,123132,NA,Remove,,,,,,, -Echinidae,Echinidae,NA,Animalia,Echinodermata,Echinoidea,Camarodonta,Echinidae,NA,Family,123160,NA,Remove,,,,,,, -Echinoclathria,Echinoclathria,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Microcionidae,Echinoclathria,Genus,167906,NA,Remove,,,,,,, -Echinoclathria sp.,Echinoclathria,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Microcionidae,Echinoclathria,Genus,167906,NA,Remove,,,,,,, -Echinoclathria beringensis,Echinoclathria beringensis,Hat sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Microcionidae,Echinoclathria,Species,167912,NA,Species,,,,,,, -Echinoclathria sp. A (Clark 2006),Echinoclathria sp. A (Clark 2006),fuzzy tree sponge,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Echinodermata,Echinodermata,Echinoderms,Animalia,Echinodermata,NA,NA,NA,NA,Phylum,1806,NA,Remove,,,,,,, -Echinoidea,Echinoidea,Sea urchins,Animalia,Echinodermata,Echinoidea,NA,NA,NA,Class,123082,NA,Remove,,,,,,, -Echinolampas depressa,Echinolampas depressa,NA,Animalia,Echinodermata,Echinoidea,Echinolampadacea,Echinolampadidae,Echinolampas,Species,422505,NA,Species,,,,,,, -Echinomuricea,Echinomuricea,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Paramuriceidae,Echinomuricea,Genus,177740,NA,Remove,,,,,,, -Echiodon dawsoni,Echiodon dawsoni,Chain pearlfish,Animalia,Chordata,Teleostei,Ophidiiformes,Carapidae,Echiodon,Species,158996,52423,Species,,,,,,, -Echiophis,Echiophis,NA,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Echiophis,Genus,158607,NA,Remove,,,,,,, -Echiophis sp,Echiophis,NA,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Echiophis,Genus,158607,NA,Remove,,,,,,, -Echiophis intertinctus,Echiophis intertinctus,Spotted spoon-nose eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Echiophis,Species,158609,2643,Species,,,,,,, -Echiophis punctifer,Echiophis punctifer,Stippled spoon-nose eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Echiophis,Species,158610,2645,Species,,,,,,, -Echiura,Echiura,Spoon worms,Animalia,Annelida,Polychaeta,NA,NA,NA,SubClass,1269,NA,Remove,,,,,,, -Ectoprocta,Ectoprocta,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Gobiosoma horsti,Elacatinus horsti,Yellowline goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobiosoma,Species,280605,3873,Species,,,,,,, -Elacatinus horsti,Elacatinus horsti,Yellowline goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobiosoma,Species,280605,3873,Species,,,,,,, -Gobiosoma oceanops,Elacatinus oceanops,Neon goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobiosoma,Species,280616,3876,Species,,,,,,, -Elacatinus oceanops,Elacatinus oceanops,Neon goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobiosoma,Species,280616,3876,Species,,,,,,, -Gobiosoma xanthiprora,Elacatinus xanthiprora,Yellowprow goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobiosoma,Species,280625,3878,Species,,,,,,, -Elacatinus xanthiprora,Elacatinus xanthiprora,Yellowprow goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobiosoma,Species,280625,3878,Species,,,,,,, -Elagatis bipinnulata,Elagatis bipinnulata,Rainbow runner,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Elagatis,Species,126809,412,Species,,,,,,, -Elassochirus,Elassochirus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Elassochirus,Genus,366319,NA,Remove,,,,,,, -Elassochirus sp.,Elassochirus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Elassochirus,Genus,366319,NA,Remove,,,,,,, -Elassochirus cavimanus,Elassochirus cavimanus,Purple hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Elassochirus,Species,366320,NA,Species,,,,,,, -Elassochirus gilli,Elassochirus gilli,Pacific red hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Elassochirus,Species,366321,NA,Species,,,,,,, -Elassochirus tenuimanus,Elassochirus tenuimanus,Widehand hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Elassochirus,Species,366322,NA,Species,,,,,,, -Elassodiscus,Elassodiscus,NA,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Elassodiscus,Genus,269048,NA,Remove,,,,,,, -Elassodiscus sp.,Elassodiscus,NA,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Elassodiscus,Genus,269048,NA,Remove,,,,,,, -Elassodiscus caudatus,Elassodiscus caudatus,Blackbelly snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Elassodiscus,Species,280629,51443,Species,,,,,,, -Elassodiscus tremebundus,Elassodiscus tremebundus,Blacklip snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Elassodiscus,Species,280631,51417,Species,,,,,,, -Eleginus gracilis,Eleginus gracilis,Saffron cod,Animalia,Chordata,Teleostei,Gadiformes,Gadidae,Eleginus,Species,254537,315,Species,,,,,,, -Ellisella,Ellisella,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Ellisellidae,Ellisella,Genus,125298,NA,Remove,,,,,,, -Gorgonellidae,Ellisellidae,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Gorgonellidae,NA,Family,125274,NA,Remove,,,,,,, -Elops saurus,Elops saurus,Ladyfish,Animalia,Chordata,Teleostei,Elopiformes,Elopidae,Elops,Species,157875,175,Species,,,,,,, -Elysia,Elysia,NA,Animalia,Mollusca,Gastropoda,NA,Plakobranchidae,Elysia,Genus,137928,NA,Remove,,,,,,, -Embiotoca lateralis,Embiotoca lateralis,Striped seaperch,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Embiotocidae,Embiotoca,Species,240740,3629,Species,,,,,,, -Embiotocidae,Embiotocidae,NA,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Embiotocidae,NA,Family,151386,NA,Remove,,,,,,, -Emblemaria atlantica,Emblemaria atlantica,Banner blenny,Animalia,Chordata,Teleostei,Blenniiformes,Chaenopsidae,Emblemaria,Species,280642,3715,Species,,,,,,, -Emblemaria piratula,Emblemaria piratula,Pirate blenny,Animalia,Chordata,Teleostei,Blenniiformes,Chaenopsidae,Emblemaria,Species,280655,3719,Species,,,,,,, -Emerita benedicti,Emerita benedicti,Benedict sand crab,Animalia,Arthropoda,Malacostraca,Decapoda,Hippidae,Emerita,Species,421884,NA,Species,,,,,,, -Emplectonema,Emplectonema,NA,Animalia,Nemertea,Hoplonemertea,Monostilifera,Emplectonematidae,Emplectonema,Genus,122404,NA,Remove,,,,,,, -Emplectonema sp.,Emplectonema,NA,Animalia,Nemertea,Hoplonemertea,Monostilifera,Emplectonematidae,Emplectonema,Genus,122404,NA,Remove,,,,,,, -Emplectonema sp. (Clark 2006),Emplectonema sp. (Clark 2006),black specked ribbon worm,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Enchelyopus cimbrius,Enchelyopus cimbrius,Fourbeard rockling,Animalia,Chordata,Teleostei,Gadiformes,Lotidae,Enchelyopus,Species,126450,1874,Species,,,,,,, -Encope aberrans,Encope aberrans,NA,Animalia,Echinodermata,Echinoidea,Echinolampadacea,Mellitidae,Encope,Species,422500,NA,Species,,,,,,, -Encope michelini,Encope michelini,Notched sand dollar,Animalia,Echinodermata,Echinoidea,Echinolampadacea,Mellitidae,Encope,Species,422501,NA,Species,,,,,,, -Engina turbinella,Engina turbinella,White spot engina,Animalia,Mollusca,Gastropoda,Neogastropoda,Pisaniidae,Engina,Species,234108,NA,Species,,,,,,, -Engraulidae,Engraulidae,Anchovies,Animalia,Chordata,Teleostei,Clupeiformes,Engraulidae,NA,Family,125465,NA,Remove,,,,,,, -Engraulis eurystole,Engraulis eurystole,Silver anchovy,Animalia,Chordata,Teleostei,Clupeiformes,Engraulidae,Engraulis,Species,158702,1662,Species,,,,,,, -Engraulis mordax,Engraulis mordax,Northern anchovy,Animalia,Chordata,Teleostei,Clupeiformes,Engraulidae,Engraulis,Species,272286,1664,Species,,,,,,, -Engyophrys senta,Engyophrys senta,Spiny flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Bothidae,Engyophrys,Species,159356,4220,Species,,,,,,, -Enidae,Enidae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Enophrys,Enophrys,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Enophrys,Genus,154468,NA,Remove,,,,,,, -Enophrys sp.,Enophrys,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Enophrys,Genus,154468,NA,Remove,,,,,,, -Enophrys bison,Enophrys bison,Buffalo sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Enophrys,Species,275355,4086,Species,,,,,,, -Enophrys diceraus,Enophrys diceraus,Antlered sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Enophrys,Species,154784,4087,Species,,,,,,, -Enophrys lucasi,Enophrys lucasi,Leister sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Enophrys,Species,254518,4088,Species,,,,,,, -Enophrys taurina,Enophrys taurina,Bull sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Enophrys,Species,275356,4089,Species,,,,,,, -Enteroctopus dofleini,Enteroctopus dofleini,North pacific giant octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Enteroctopodidae,Enteroctopus,Species,342305,NA,Species,,,,,,, -Octopus dofleini,Enteroctopus dofleini,North pacific giant octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Enteroctopodidae,Enteroctopus,Species,342305,NA,Species,,,,,,, -Entosphenus tridentata,Entosphenus tridentatus,Pacific lamprey,Animalia,Chordata,Petromyzonti,Petromyzontiformes,Petromyzontidae,Entosphenus,Species,314348,2529,Species,,,,,,, -Lampetra tridentata,Entosphenus tridentatus,Pacific lamprey,Animalia,Chordata,Petromyzonti,Petromyzontiformes,Petromyzontidae,Entosphenus,Species,314348,2529,Species,,,,,,, -Entosphenus tridentatus,Entosphenus tridentatus,Pacific lamprey,Animalia,Chordata,Petromyzonti,Petromyzontiformes,Petromyzontidae,Entosphenus,Species,314348,2529,Species,,,,,,, -Eopsetta jordani,Eopsetta jordani,Petrale sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Eopsetta,Species,280690,4237,Species,,,,,,, -Ephippididae,Ephippidae,Spadefishes,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Epigonus macrops,Epigonus macrops,Robust cardinalfish,Animalia,Chordata,Teleostei,Acropomatiformes,Epigonidae,Epigonus,Species,209380,14837,Species,,,,,,, -Epigonus pandionis,Epigonus pandionis,Bigeye,Animalia,Chordata,Teleostei,Acropomatiformes,Epigonidae,Epigonus,Species,159706,10770,Species,,,,,,, -Epinephelus adscensionis,Epinephelus adscensionis,Rock hind,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Epinephelus,Species,159351,14,Species,,,,,,, -Epinephelus drummondhayi,Epinephelus drummondhayi,Speckled hind,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Epinephelus,Species,273848,1204,Species,,,,,,, -Epinephelus guttatus,Epinephelus guttatus,Red hind,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Epinephelus,Species,159352,15,Species,,,,,,, -Epinephelus itajara,Epinephelus itajara,Atlantic goliath grouper,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Epinephelus,Species,159353,16,Species,,,,,,, -Epinephelus morio,Epinephelus morio,Red grouper,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Epinephelus,Species,159354,17,Species,,,,,,, -Epizoanthus scotinus,Epizoanthus scotinus,Orange encrusting anemone,Animalia,Cnidaria,Anthozoa,Zoantharia,Epizoanthidae,Epizoanthus,Species,283864,NA,Species,,,,,,, -Eptatretus,Eptatretus,NA,Animalia,Chordata,Myxini,Myxiniformes,Myxinidae,Eptatretus,Genus,206895,NA,Remove,,,,,,, -Eptatretus deani,Eptatretus deani,Black hagfish,Animalia,Chordata,Myxini,Myxiniformes,Myxinidae,Eptatretus,Species,279277,2511,Species,,,,,,, -Eptatretus stouti,Eptatretus stoutii,Pacific hagfish,Animalia,Chordata,Myxini,Myxiniformes,Myxinidae,Eptatretus,Species,279298,2512,Species,,,,,,, -Eptatretus stoutii,Eptatretus stoutii,Pacific hagfish,Animalia,Chordata,Myxini,Myxiniformes,Myxinidae,Eptatretus,Species,279298,2512,Species,,,,,,, -Eques,Eques,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Eques,Genus,296581,NA,Remove,,,,,,, -Equetus lanceolatus,Eques lanceolatus,Jackknife-fish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Equetus,Species,1389965,3584,Species,,,,,,, -Eques lanceolatus,Eques lanceolatus,Jackknife-fish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Equetus,Species,1389965,3584,Species,,,,,,, -Equetus,Equetus,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Equetus,Genus,159314,NA,Remove,,,,,,, -Equetus punctatus,Equetus punctatus,Spotted drum,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Equetus,Species,276097,3585,Species,,,,,,, -Eques punctatus,Equetus punctatus,Spotted drum,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Equetus,Species,276097,3585,Species,,,,,,, -Eratoidae,Eratoidae,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Eratoidae,NA,Family,23036,NA,Remove,,,,,,, -Podochela gracilipes,Ericerodes gracilipes,Unicorn neck crab,Animalia,Arthropoda,Malacostraca,Decapoda,Inachidae,Podochela,Species,441906,NA,Species,,,,,,, -Ericerodes gracilipes,Ericerodes gracilipes,Unicorn neck crab,Animalia,Arthropoda,Malacostraca,Decapoda,Inachidae,Podochela,Species,441906,NA,Species,,,,,,, -Erilepis zonifer,Erilepis zonifer,Skilfish,Animalia,Chordata,Teleostei,Perciformes,Anoplopomatidae,Erilepis,Species,280700,4031,Species,,,,,,, -Erimacrus sp.,Erimacrus,NA,NA,NA,NA,NA,NA,NA,Genus,439222,NA,Remove,,,,,,, -Erimacrus isenbeckii,Erimacrus isenbeckii,Hair crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cheiragonidae,Erimacrus,Species,440405,NA,Species,,,,,,, -Errinopora,Errinopora,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Errinopora,Genus,267421,NA,Remove,,,,,,, -Errinopora sp.,Errinopora,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Errinopora,Genus,267421,NA,Remove,,,,,,, -Errinopora dichotoma,Errinopora dichotoma,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Errinopora,Species,592149,NA,Species,,,,,,, -Errinopora fisheri,Errinopora fisheri,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Errinopora,Species,592146,NA,Species,,,,,,, -Errinopora nanneca,Errinopora nanneca,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Errinopora,Species,289914,NA,Species,,,,,,, -Errinopora pourtalesi,Errinopora pourtalesii,Pourtales's lace hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Errinopora,Species,289915,NA,Species,,,,,,, -Errinopora pourtalesii,Errinopora pourtalesii,Pourtales's lace hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Errinopora,Species,289915,NA,Species,,,,,,, -Errinopora sp. B (Clark 2006),Errinopora sp. B (Clark 2006),pale-edged hydrocoral,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Errinopora undulata,Errinopora undulata,Undulate-fan hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Errinopora,Species,592147,NA,Species,,,,,,, -Errinopora zarhyncha,Errinopora zarhyncha,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Errinopora,Species,289917,NA,Species,,,,,,, -Escharopsis sarsi,Escharopsis sarsi,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Umbonulidae,Escharopsis,Species,156081,NA,Species,,,,,,, -Etelis oculatus,Etelis oculatus,Queen snapper,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Lutjanidae,Etelis,Species,159789,1391,Species,,,,,,, -Ethusa,Ethusa,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Ethusidae,Ethusa,Genus,106882,NA,Remove,,,,,,, -Ethusa microphthalma,Ethusa microphthalma,Broadback sumo crab,Animalia,Arthropoda,Malacostraca,Decapoda,Ethusidae,Ethusa,Species,107284,NA,Species,,,,,,, -Etmopterus gracilispinis,Etmopterus gracilispinis,Broadbanded lanternshark,Animalia,Chordata,Elasmobranchii,Squaliformes,Etmopteridae,Etmopterus,Species,158523,678,Species,,,,,,, -Etmopterus princeps,Etmopterus princeps,Great lanternshark,Animalia,Chordata,Elasmobranchii,Squaliformes,Etmopteridae,Etmopterus,Species,105911,683,Species,,,,,,, -Etropus,Etropus,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Etropus,Genus,158797,NA,Remove,,,,,,, -Etropus sp,Etropus,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Etropus,Genus,158797,NA,Remove,,,,,,, -Etropus crossotus,Etropus crossotus,Fringed flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Etropus,Species,158799,4221,Species,,,,,,, -Etropus intermedius,Etropus crossotus,Fringed flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Etropus,Species,158799,4221,Species,,,,,,, -Etropus cyclosquamus,Etropus cyclosquamus,Shelf flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Etropus,Species,158800,58224,Species,,,,,,, -Etropus microstomus,Etropus microstomus,Smallmouth flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Etropus,Species,158801,4222,Species,,,,,,, -Etropus rimosus,Etropus rimosus,Gray flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Etropus,Species,158802,4223,Species,,,,,,, -Etrumeus teres,Etrumeus sadina,Round herring,Animalia,Chordata,Teleostei,Clupeiformes,Dussumieriidae,Etrumeus,Species,584793,1455,Species,,,,,,, -Eualus,Eualus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Eualus,Genus,106986,NA,Remove,,,,,,, -Eualus sp.,Eualus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Eualus,Genus,106986,NA,Remove,,,,,,, -Eualus barbatus,Eualus barbatus,Barbed eualid,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Eualus,Species,515222,NA,Species,,,,,,, -Eualus biunguis,Eualus biunguis,Deepsea eualid,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Eualus,Species,423365,NA,Species,,,,,,, -Eualus fabricii,Eualus fabricii,Arctic eualid,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Eualus,Species,158357,NA,Species,,,,,,, -Eualus gaimardii,Eualus gaimardii,Circumpolar eualid,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Eualus,Species,107504,NA,Species,,,,,,, -Eualus macilentus,Eualus macilentus,Greenland shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Eualus,Species,158359,NA,Species,,,,,,, -Eualus macrophthalmus,Eualus macrophthalmus,Big eyed shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Eualus,Species,515232,NA,Species,,,,,,, -Eualus suckleyi,Eualus suckleyi,Shortscale eualid,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Eualus,Species,423366,NA,Species,,,,,,, -Eualus townsendi,Eualus townsendi,Townsend eualid,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Eualus,Species,515240,NA,Species,,,,,,, -Euceramus praelongus,Euceramus praelongus,Olivepit porcelain crab,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,Euceramus,Species,421863,NA,Species,,,,,,, -Euchirograpsus americanus,Euchirograpsus americanus,American talon crab,Animalia,Arthropoda,Malacostraca,Decapoda,Plagusiidae,Euchirograpsus,Species,217262,NA,Species,,,,,,, -Eucidaris,Eucidaris,NA,Animalia,Echinodermata,Echinoidea,Cidaroida,Cidaridae,Eucidaris,Genus,204525,NA,Remove,,,,,,, -Eucidaris tribuloides,Eucidaris tribuloides,Slate pencil urchin,Animalia,Echinodermata,Echinoidea,Cidaroida,Cidaridae,Eucidaris,Species,396741,NA,Species,,,,,,, -Eucinostomus harengulus/jonesii,Eucinostomus,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Gerreidae,Eucinostomus,Genus,159731,NA,Remove,,,,,,, -Eucinostomus argenteus/gula,Eucinostomus,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Gerreidae,Eucinostomus,Genus,159731,NA,Remove,,,,,,, -Eucinostomus argenteus,Eucinostomus argenteus,Silver mojarra,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Gerreidae,Eucinostomus,Species,159732,1049,Species,,,,,,, -Eucinostomus gula,Eucinostomus gula,Silver jenny,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Gerreidae,Eucinostomus,Species,159733,1050,Species,,,,,,, -Eucinostomus harengulus,Eucinostomus harengulus,Tidewater mojarra,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Gerreidae,Eucinostomus,Species,276420,55039,Species,,,,,,, -Eucinostomus jonesii,Eucinostomus jonesii,Slender mojarra,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Gerreidae,Eucinostomus,Species,276422,3567,Species,,,,,,, -Eucinostomus melanopterus,Eucinostomus melanopterus,Flagfin mojarra,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Gerreidae,Eucinostomus,Species,276423,1052,Species,,,,,,, -Eucinostomus,Eucinostomus spp.,Mojarras,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Gerreidae,Eucinostomus,Genus,159731,NA,Species,,,,,,, -Eucrassatella,Eucrassatella,NA,Animalia,Mollusca,Bivalvia,Carditida,Crassatellidae,Eucrassatella,Genus,415362,NA,Remove,,,,,,, -Eucratea loricata,Eucratea loricata,Feathery bryozoan,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Eucrateidae,Eucratea,Species,111361,NA,Species,,,,,,, -Maynea californica,Eucryphycus californicus,Persimmon eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Maynea,Species,280736,3149,Species,,,,,,, -Eudistoma,Eudistoma,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polycitoridae,Eudistoma,Genus,103465,NA,Remove,,,,,,, -Eudistoma obscuratum,Eudistoma obscuratum,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polycitoridae,Eudistoma,Species,250234,NA,Species,,,,,,, -Eudistoma recifense,Eudistoma recifense,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polycitoridae,Eudistoma,Species,250247,NA,Species,,,,,,, -Eudistoma spiculiferum,Eudistoma spiculiferum,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polycitoridae,Eudistoma,Species,250255,NA,Species,,,,,,, -Eugorgia rubens,Eugorgia rubens,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Gorgoniidae,Eugorgia,Species,289935,NA,Species,,,,,,, -Euleptorhamphus velox,Euleptorhamphus velox,Flying halfbeak,Animalia,Chordata,Teleostei,Beloniformes,Hemiramphidae,Euleptorhamphus,Species,159276,3155,Species,,,,,,, -Asterophilidae,Eulimidae,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Asterophilidae,NA,Family,135,NA,Remove,,,,,,, -Eumecichthys fiski,Eumecichthys fiski,Unicorn crestfish,Animalia,Chordata,Teleostei,Lampriformes,Lophotidae,Eumecichthys,Species,217888,3260,Species,,,,,,, -Eumesogrammus praecisus,Eumesogrammus praecisus,Fourline snakeblenny,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Eumesogrammus,Species,159817,3783,Species,,,,,,, -Eumicrotremus,Eumicrotremus,NA,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Eumicrotremus,Genus,126159,NA,Remove,,,,,,, -Eumicrotremus sp.,Eumicrotremus,NA,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Eumicrotremus,Genus,126159,NA,Remove,,,,,,, -Eumicrotremus andriashevi,Eumicrotremus andriashevi,Pimpled lumpsucker,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Eumicrotremus,Species,254532,51419,Species,,,,,,, -Eumicrotremus birulai,Eumicrotremus asperrimus,Round lumpsucker,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Eumicrotremus,Species,254533,60669,Species,,,,,,, -Eumicrotremus asperrimus,Eumicrotremus asperrimus,Round lumpsucker,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Eumicrotremus,Species,254533,60669,Species,,,,,,, -Eumicrotremus barbatus,Eumicrotremus barbatus,Papillose lumpsucker,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Eumicrotremus,Species,254534,24059,Species,,,,,,, -Eumicrotremus gyrinops,Eumicrotremus gyrinops,Alaskan lumpsucker,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Eumicrotremus,Species,274492,50771,Species,,,,,,, -Eumicrotremus orbis,Eumicrotremus orbis,Pacific spiny lumpsucker,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Eumicrotremus,Species,254535,4184,Species,,,,,,, -Eumicrotremus phrynoides,Eumicrotremus phrynoides,Toad lumpsucker,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Eumicrotremus,Species,254536,51412,Species,,,,,,, -Eumicrotremus spinosus,Eumicrotremus spinosus,Atlantic spiny lumpsucker,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Eumicrotremus,Species,127217,4185,Species,,,,,,, -Eunice,Eunice,NA,Animalia,Annelida,Polychaeta,Eunicida,Eunicidae,Eunice,Genus,129278,NA,Remove,,,,,,, -Eunicea,Eunicea,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Plexauridae,Eunicea,Genus,291322,NA,Remove,,,,,,, -Eunicidae,Eunicidae,NA,Animalia,Annelida,Polychaeta,Eunicida,Eunicidae,NA,Family,966,NA,Remove,,,,,,, -Eunoe,Eunoe,NA,Animalia,Annelida,Polychaeta,Phyllodocida,Polynoidae,Eunoe,Genus,129487,NA,Remove,,,,,,, -Eunoe sp.,Eunoe,NA,Animalia,Annelida,Polychaeta,Phyllodocida,Polynoidae,Eunoe,Genus,129487,NA,Remove,,,,,,, -Eunoe depressa,Eunoe depressa,Depressed scale worm,Animalia,Annelida,Polychaeta,Phyllodocida,Polynoidae,Eunoe,Species,254455,NA,Species,,,,,,, -Eunoe nodosa,Eunoe nodosa,Giant scale worm,Animalia,Annelida,Polychaeta,Phyllodocida,Polynoidae,Eunoe,Species,130745,NA,Species,,,,,,, -Eunoe senta,Eunoe senta,Thorny scaleworm,Animalia,Annelida,Polychaeta,Phyllodocida,Polynoidae,Eunoe,Species,130747,NA,Species,,,,,,, -Eupentacta quinquesemita,Eupentacta quinquesemita,Stiff footed sea cucumber,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Sclerodactylidae,Eupentacta,Species,529305,NA,Species,,,,,,, -Euphausiacea,Euphausiacea,Krill,Animalia,Arthropoda,Malacostraca,Euphausiacea,NA,NA,Order,1128,NA,Remove,,,,,,, -Euphrosine multibranchiata,Euphrosine multibranchiata,Multi branched porcupine-worm,Animalia,Annelida,Polychaeta,Amphinomida,Euphrosinidae,Euphrosine,Species,333384,NA,Species,,,,,,, -Euphrosynoplax,Euphrosynoplax,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Euphrosynoplax,Genus,415371,NA,Remove,,,,,,, -Euphrosynoplax clausa,Euphrosynoplax clausa,Craggy bathyal crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Euphrosynoplax,Species,422112,NA,Species,,,,,,, -Euphylax,Euphylax,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Euphylax,Genus,439669,NA,Remove,,,,,,, -Euplexaura,Euplexaura,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Euplexauridae,Euplexaura,Genus,204195,NA,Remove,,,,,,, -Euplexaura sp.,Euplexaura,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Euplexauridae,Euplexaura,Genus,204195,NA,Remove,,,,,,, -Euryalina,Euryalida,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,NA,NA,SubOrder,242196,NA,Remove,,,,,,, -Euryalidae,Euryalidae,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Euryalidae,NA,Family,196223,NA,Remove,,,,,,, -Eurymen gyrinus,Eurymen gyrinus,Smoothcheek sculpin,Animalia,Chordata,Teleostei,Perciformes,Psychrolutidae,Eurymen,Species,254565,11715,Species,,,,,,, -Eurypanopeus depressus,Eurypanopeus depressus,Flatback mud crab,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Eurypanopeus,Species,158416,NA,Species,,,,,,, -Eurypharyngidae,Eurypharyngidae,Gulpers,Animalia,Chordata,Teleostei,Saccopharyngiformes,Eurypharyngidae,NA,Family,125584,NA,Remove,,,,,,, -Eurypharynx pelecanoides,Eurypharynx pelecanoides,Pelican eel,Animalia,Chordata,Teleostei,Saccopharyngiformes,Eurypharyngidae,Eurypharynx,Species,127165,4526,Species,,,,,,, -Euryplax nitida,Euryplax nitida,Glabrous broadface crab,Animalia,Arthropoda,Malacostraca,Decapoda,Euryplacidae,Euryplax,Species,422057,NA,Species,,,,,,, -Tellina alternata,Eurytellina alternata,Alternate tellin,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Tellina,Species,420867,NA,Species,,,,,,, -Eurytellina alternata,Eurytellina alternata,Alternate tellin,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Tellina,Species,420867,NA,Species,,,,,,, -Eurytellina nitens,Eurytellina nitens,NA,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Eurytellina,Species,420870,NA,Species,,,,,,, -Eurytium limosum,Eurytium limosum,Broadback mud crab,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Eurytium,Species,422077,NA,Species,,,,,,, -Eusergestes similis,Eusergestes similis,Constant prawn,Animalia,Arthropoda,Malacostraca,Decapoda,Sergestidae,Eusergestes,Species,514127,NA,Species,,,,,,, -Sergestes similis,Eusergestes similis,Constant prawn,Animalia,Arthropoda,Malacostraca,Decapoda,Sergestidae,Eusergestes,Species,514127,NA,Species,,,,,,, -Eusirus cuspidatus,Eusirus cuspidatus,Speckled amphipod,Animalia,Arthropoda,Malacostraca,Amphipoda,Eusiridae,Eusirus,Species,102199,NA,Species,,,,,,, -Euspira,Euspira,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Euspira,Genus,138239,NA,Remove,,,,,,, -Euspira sp.,Euspira,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Euspira,Genus,138239,NA,Remove,,,,,,, -Euspira pallida,Euspira pallida,Pale moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Euspira,Species,140536,NA,Species,,,,,,, -Lunatia pallida,Euspira pallida,Pale moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Euspira,Species,140536,NA,Species,,,,,,, -Euthynnus alletteratus,Euthynnus alletteratus,Little tunny,Animalia,Chordata,Teleostei,Scombriformes,Scombridae,Euthynnus,Species,127017,97,Species,,,,,,, -Euthyonacta solida,Euthyonacta solida,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,Euthyonacta,Species,422524,NA,Species,,,,,,, -Euvola,Euvola,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Euvola,Genus,205700,NA,Remove,,,,,,, -Pecten tereinus,Euvola chazaliei,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Euvola,Species,394062,NA,Species,,,,,,, -Euvola chazaliei,Euvola chazaliei,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Euvola,Species,394062,NA,Species,,,,,,, -Pecten laurenti,Euvola laurentii,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Pecten,Species,394071,NA,Species,,,,,,, -Euvola laurenti,Euvola laurentii,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Pecten,Species,394071,NA,Species,,,,,,, -Euvola marensis,Euvola marensis,Paper scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Euvola,Species,394068,NA,Species,,,,,,, -Euvola raveneli,Euvola raveneli,Round rib scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Euvola,Species,394070,NA,Species,,,,,,, -Pecten ravenelli,Euvola raveneli,Round rib scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Euvola,Species,394070,NA,Species,,,,,,, -Pecten ziczac,Euvola ziczac,Zigzag scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Pecten,Species,394073,NA,Species,,,,,,, -Euvola ziczac,Euvola ziczac,Zigzag scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Pecten,Species,394073,NA,Species,,,,,,, -Evasterias,Evasterias,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Evasterias,Genus,254332,NA,Remove,,,,,,, -Evasterias sp.,Evasterias,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Evasterias,Genus,254332,NA,Remove,,,,,,, -Evasterias echinosoma,Evasterias echinosoma,Giant sea star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Evasterias,Species,254498,NA,Species,,,,,,, -Evasterias retifera,Evasterias retifera,Western star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Evasterias,Species,255039,NA,Species,,,,,,, -Evasterias troschelii,Evasterias troschelii,Mottled star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Evasterias,Species,255040,NA,Species,,,,,,, -Evermannichthys spongicola,Evermannichthys spongicola,Sponge goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Evermannichthys,Species,367251,62534,Species,,,,,,, -Exhippolysmata oplophoroides,Exhippolysmata oplophoroides,Redleg humpback shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Lysmatidae,Exhippolysmata,Species,421776,NA,Species,,,,,,, -Exilioidea,Exilioidea,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Ptychatractidae,Exilioidea,Genus,415384,NA,Remove,,,,,,, -Exilioidea rectirostris,Exilioidea rectirostris,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Ptychatractidae,Exilioidea,Species,463447,NA,Species,,,,,,, -Exocoetidae,Exocoetidae,Flyingfishes,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,NA,Family,125452,NA,Remove,,,,,,, -Facciolella gilbertii,Facciolella gilbertii,Dogface witch-eel,Animalia,Chordata,Teleostei,Anguilliformes,Nettastomatidae,Facciolella,Species,271908,2620,Species,,,,,,, -Fariometra,Fariometra,NA,Animalia,Echinodermata,Crinoidea,Comatulida,Antedonidae,Fariometra,Genus,712221,NA,Remove,,,,,,, -Fariometra sp.,Fariometra,NA,Animalia,Echinodermata,Crinoidea,Comatulida,Antedonidae,Fariometra,Genus,712221,NA,Remove,,,,,,, -Farrea,Farrea,NA,Animalia,Porifera,Hexactinellida,Sceptrulophora,Farreidae,Farrea,Genus,132107,NA,Remove,,,,,,, -Farrea sp.,Farrea,NA,Animalia,Porifera,Hexactinellida,Sceptrulophora,Farreidae,Farrea,Genus,132107,NA,Remove,,,,,,, -Farrea beringiana,Farrea beringiana,Bering lace sponge,Animalia,Porifera,Hexactinellida,Sceptrulophora,Farreidae,Farrea,Species,171738,NA,Species,,,,,,, -Farrea convolulus,Farrea convolvulus,NA,Animalia,Porifera,Hexactinellida,Sceptrulophora,Farreidae,Farrea,Species,171739,NA,Species,,,,,,, -Fasciolaria,Fasciolaria,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Fasciolaria,Genus,138001,NA,Remove,,,,,,, -Fasciolaria tulipa,Fasciolaria tulipa,True tulip,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Fasciolaria,Species,420024,NA,Species,,,,,,, -Favarita cellulosa,Favartia cellulosa,Pitted murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Favartia,Species,723811,NA,Species,,,,,,, -Favartia cellulosa,Favartia cellulosa,Pitted murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Favartia,Species,723811,NA,Species,,,,,,, -Murex hildalgoi,Favartia hidalgoi,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Favartia,Species,738312,NA,Species,,,,,,, -Favartia hidalgoi,Favartia hidalgoi,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Favartia,Species,738312,NA,Species,,,,,,, -Faviidae,Faviidae,NA,Animalia,Cnidaria,Anthozoa,Scleractinia,Faviidae,NA,Family,196099,NA,Remove,,,,,,, -Felimare,Felimare,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Chromodorididae,Felimare,Genus,558624,NA,Remove,,,,,,, -Felimare picta,Felimare picta,Florida regal doris,Animalia,Mollusca,Gastropoda,Nudibranchia,Chromodorididae,Felimare,Species,597522,NA,Species,,,,,,, -Hypselodoris edenticulata,Felimare picta,Florida regal doris,Animalia,Mollusca,Gastropoda,Nudibranchia,Chromodorididae,Felimare,Species,597522,NA,Species,,,,,,, -Breviraja plutonia,Fenestraja plutonia,Pluto skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Breviraja,Species,158550,51799,Species,,,,,,, -Ficus,Ficus,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Ficidae,Ficus,Genus,205605,NA,Remove,,,,,,, -Ficus communis,Ficus ficus,Atlantic figsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Ficidae,Ficus,Species,214982,NA,Species,,,,,,, -Ficus ficus,Ficus ficus,Atlantic figsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Ficidae,Ficus,Species,214982,NA,Species,,,,,,, -Ficus papyratius,Ficus papyratia,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Ficidae,Ficus,Species,414662,NA,Species,,,,,,, -Ficus papyratia,Ficus papyratia,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Ficidae,Ficus,Species,414662,NA,Species,,,,,,, -Fissurellidae,Fissurellidae,NA,Animalia,Mollusca,Gastropoda,Lepetellida,Fissurellidae,NA,Family,111,NA,Remove,,,,,,, -Fistularia,Fistularia,NA,Animalia,Chordata,Teleostei,Syngnathiformes,Fistulariidae,Fistularia,Genus,159438,NA,Remove,,,,,,, -Fistularia sp,Fistularia,NA,Animalia,Chordata,Teleostei,Syngnathiformes,Fistulariidae,Fistularia,Genus,159438,NA,Remove,,,,,,, -Fistularia petimba,Fistularia petimba,Red cornetfish,Animalia,Chordata,Teleostei,Syngnathiformes,Fistulariidae,Fistularia,Species,159439,3276,Species,,,,,,, -Fistularia tabacaria,Fistularia tabacaria,Cornetfish,Animalia,Chordata,Teleostei,Syngnathiformes,Fistulariidae,Fistularia,Species,159440,3275,Species,,,,,,, -Flabellidae,Flabellidae,NA,Animalia,Cnidaria,Anthozoa,Scleractinia,Flabellidae,NA,Family,135075,NA,Remove,,,,,,, -Florometra,Florometra,NA,Animalia,Echinodermata,Crinoidea,Comatulida,Antedonidae,Florometra,Genus,173810,NA,Remove,,,,,,, -Florometra sp.,Florometra,NA,Animalia,Echinodermata,Crinoidea,Comatulida,Antedonidae,Florometra,Genus,173810,NA,Remove,,,,,,, -Florometra acririma,Florometra acririma,NA,Animalia,Echinodermata,Crinoidea,Comatulida,Antedonidae,Florometra,Genus,173810,NA,Remove,,,,,,, -Florometra asperrima,Florometra asperrima,Rough feather star,Animalia,Echinodermata,Crinoidea,Comatulida,Antedonidae,Florometra,Species,714293,NA,Species,,,,,,, -Florometra inexpectata,Florometra asperrima,Rough feather star,Animalia,Echinodermata,Crinoidea,Comatulida,Antedonidae,Florometra,Species,714293,NA,Species,,,,,,, -Florometra serratissima,Florometra serratissima,Common feather star,Animalia,Echinodermata,Crinoidea,Comatulida,Antedonidae,Florometra,Species,714272,NA,Species,,,,,,, -Fluffy sponge,Fluffy sponge,NA,NA,NA,NA,NA,NA,NA,Remove,NA,NA,Remove,,,,,,, -Flustrellidra corniculata,Flustrellidra corniculata,Spiny leather bryozoan,Animalia,Bryozoa,Gymnolaemata,Ctenostomatida,Flustrellidridae,Flustrellidra,Species,111620,NA,Species,,,,,,, -Foetorepus agassizi,Foetorepus agassizii,Spotfin dragonet,Animalia,Chordata,Teleostei,Callionymiformes,Callionymidae,Foetorepus,Species,276339,10187,Species,,,,,,, -Foetorepus agassizii,Foetorepus agassizii,Spotfin dragonet,Animalia,Chordata,Teleostei,Callionymiformes,Callionymidae,Foetorepus,Species,276339,10187,Species,,,,,,, -Antennarius ocellatus,Fowlerichthys ocellatus,Ocellated frogfish,Animalia,Chordata,Teleostei,Lophiiformes,Antennariidae,Antennarius,Species,712507,3085,Species,,,,,,, -Fowlerichthys ocellatus,Fowlerichthys ocellatus,Ocellated frogfish,Animalia,Chordata,Teleostei,Lophiiformes,Antennariidae,Antennarius,Species,712507,3085,Species,,,,,,, -Antennarius radiosus,Fowlerichthys radiosus,Singlespot frogfish,Animalia,Chordata,Teleostei,Lophiiformes,Antennariidae,Antennarius,Species,712508,3087,Species,,,,,,, -Fowlerichthys radiosus,Fowlerichthys radiosus,Singlespot frogfish,Animalia,Chordata,Teleostei,Lophiiformes,Antennariidae,Antennarius,Species,712508,3087,Species,,,,,,, -Frevillea,Frevillea,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Euryplacidae,Frevillea,Genus,415402,NA,Remove,,,,,,, -Frevillea hirsuta,Frevillea hirsuta,Tufted broadface crab,Animalia,Arthropoda,Malacostraca,Decapoda,Euryplacidae,Frevillea,Species,422059,NA,Species,,,,,,, -Frieleia halli,Frieleia halli,Hall lamp shell,Animalia,Brachiopoda,Rhynchonellata,Rhynchonellida,Frieleiidae,Frieleia,Species,235423,NA,Species,,,,,,, -Barbatia tenera,Fugleria tenera,Delicate ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Barbatia,Species,420720,NA,Species,,,,,,, -Fugleria tenera,Fugleria tenera,Delicate ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Barbatia,Species,420720,NA,Species,,,,,,, -Busycon plagosus,Fulguropsis plagosa,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862950,NA,Species,,,,,,, -Fulguropsis plagosa,Fulguropsis plagosa,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862950,NA,Species,,,,,,, -Fulguropsis spirata,Fulguropsis spirata,Pear whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Fulguropsis,Species,862945,NA,Species,,,,,,, -Laevicardium laevigatum,Fulvia laevigata,Eggcockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Laevicardium,Species,605734,NA,Species,,,,,,, -Funiculina quadrangularis,Funiculina quadrangularis,Tall sea pen,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Funiculinidae,Funiculina,Species,128506,NA,Species,,,,,,, -Fusinus,Fusinus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Fusinus,Genus,138002,NA,Remove,,,,,,, -Fusitriton,Fusitriton,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cymatiidae,Fusitriton,Genus,390535,NA,Remove,,,,,,, -Fusitriton sp.,Fusitriton,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cymatiidae,Fusitriton,Genus,390535,NA,Remove,,,,,,, -Fusitriton oregonensis,Fusitriton oregonensis,Oregon triton,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cymatiidae,Fusitriton,Species,476496,NA,Species,,,,,,, -Fusitriton oregonensis egg,Fusitriton oregonensis egg,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Gadella imberbis,Gadella imberbis,Beardless codling,Animalia,Chordata,Teleostei,Gadiformes,Moridae,Gadella,Species,158964,2010,Species,,,,,,, -Gadidae,Gadidae,Cods and haddocks,Animalia,Chordata,Teleostei,Gadiformes,Gadidae,NA,Family,125469,NA,Remove,,,,,,, -Gadus chalcogrammus,Gadus chalcogrammus,Walleye pollock,Animalia,Chordata,Teleostei,Gadiformes,Gadidae,Gadus,Species,300735,318,Species,,,,,,, -Theragra chalcogramma,Gadus chalcogrammus,Walleye pollock,Animalia,Chordata,Teleostei,Gadiformes,Gadidae,Gadus,Species,300735,318,Species,,,,,,, -Gadus macrocephalus,Gadus macrocephalus,Pacific cod,Animalia,Chordata,Teleostei,Gadiformes,Gadidae,Gadus,Species,254538,308,Species,,,,,,, -Gadus morhua,Gadus morhua,Atlantic cod,Animalia,Chordata,Teleostei,Gadiformes,Gadidae,Gadus,Species,126436,69,Species,,,,,,, -Gaidropsarus ensis,Gaidropsarus ensis,Threadfin rockling,Animalia,Chordata,Teleostei,Gadiformes,Lotidae,Gaidropsarus,Species,126453,8425,Species,,,,,,, -Galathea rostrata,Galathea rostrata,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Galatheidae,Galathea,Species,392255,NA,Species,,,,,,, -Galatheidae,Galatheidae,Galatheid crab unid.,Animalia,Arthropoda,Malacostraca,Decapoda,Galatheidae,NA,Family,106733,NA,Remove,,,,,,, -Galatheoidea,Galatheoidea,NA,Animalia,Arthropoda,Malacostraca,Decapoda,NA,NA,SuperFamily,106685,NA,Remove,,,,,,, -Galeocerdo cuvier,Galeocerdo cuvier,Tiger shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,Galeocerdo,Species,105799,886,Species,,,,,,, -Galeorhinus galeus,Galeorhinus galeus,Tope shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Triakidae,Galeorhinus,Species,105820,4642,Species,,,,,,, -Galiteuthis phyllura,Galiteuthis phyllura,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Cranchiidae,Galiteuthis,Species,341807,NA,Species,,,,,,, -Gammaridae,Gammaridae,Gammarid amphipod unid.,Animalia,Arthropoda,Malacostraca,Amphipoda,Gammaridae,NA,Family,101383,NA,Remove,,,,,,, -Gari californica,Gari californica,NA,Animalia,Mollusca,Bivalvia,Cardiida,Psammobiidae,Gari,Species,507139,NA,Species,,,,,,, -Gasterosteus aculeatus,Gasterosteus aculeatus,Three spined stickleback,Animalia,Chordata,Teleostei,Perciformes,Gasterosteidae,Gasterosteus,Species,126505,2420,Species,,,,,,, -Gastropod,Gastropoda,Sea snails,Animalia,Mollusca,Gastropoda,NA,NA,NA,Class,101,NA,Remove,,,,,,, -Gastropoda,Gastropoda,Sea snails,Animalia,Mollusca,Gastropoda,NA,NA,NA,Class,101,NA,Remove,,,,,,, -Gastropsetta frontalis,Gastropsetta frontalis,Shrimp flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Gastropsetta,Species,158820,4224,Species,,,,,,, -Gastropteron pacificum,Gastropteron pacificum,Pacific stomach wing,Animalia,Mollusca,Gastropoda,Cephalaspidea,Gastropteridae,Gastropteron,Species,511956,NA,Species,,,,,,, -Chirostylus spinifer,Gastroptychus spinifer,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Chirostylidae,Chirostylus,Species,392034,NA,Species,,,,,,, -Gastroptychus spinifer,Gastroptychus spinifer,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Chirostylidae,Chirostylus,Species,392034,NA,Species,,,,,,, -Gattyana ciliata,Gattyana ciliata,Ciliated scale worm,Animalia,Annelida,Polychaeta,Phyllodocida,Polynoidae,Gattyana,Species,254456,NA,Species,,,,,,, -Cantharus tinctus,Gemophos tinctus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Pisaniidae,Cantharus,Species,419969,NA,Species,,,,,,, -Gemophos tinctus,Gemophos tinctus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Pisaniidae,Cantharus,Species,419969,NA,Species,,,,,,, -Gempylus serpens,Gempylus serpens,Snake mackerel,Animalia,Chordata,Teleostei,Scombriformes,Gempylidae,Gempylus,Species,126862,1041,Species,,,,,,, -Genyonemus lineatus,Genyonemus lineatus,White croaker,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Genyonemus,Species,280830,422,Species,,,,,,, -Geodia,Geodia,NA,Animalia,Porifera,Demospongiae,Tetractinellida,Geodiidae,Geodia,Genus,132005,NA,Remove,,,,,,, -Geodinella,Geodia,NA,Animalia,Porifera,Demospongiae,Tetractinellida,Geodiidae,Geodia,Genus,132005,NA,Remove,,,,,,, -Geodia sp.,Geodia,NA,Animalia,Porifera,Demospongiae,Tetractinellida,Geodiidae,Geodia,Genus,132005,NA,Remove,,,,,,, -Geodia carolae,Geodia carolae,calcareous finger sponge,NA,NA,NA,NA,NA,NA,Species,1424278,NA,Species,,,,,,, -Geodia gibberosa,Geodia gibberosa,NA,Animalia,Porifera,Demospongiae,Tetractinellida,Geodiidae,Geodia,Species,170126,NA,Species,,,,,,, -Geodia mesotriaena,Geodia mesotriaena,Armoured ball sponge,Animalia,Porifera,Demospongiae,Tetractinellida,Geodiidae,Geodia,Species,134035,NA,Species,,,,,,, -Geodia starki,Geodia starki,Pita sponge,Animalia,Porifera,Demospongiae,Tetractinellida,Geodiidae,Geodia,Species,740291,NA,Species,,,,,,, -Geodinella lendenfeldi,Geodinella lendenfeldi,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Gephyreaster,Gephyreaster,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Pseudarchasteridae,Gephyreaster,Genus,254787,NA,Remove,,,,,,, -Gephyreaster sp.,Gephyreaster,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Pseudarchasteridae,Gephyreaster,Genus,254787,NA,Remove,,,,,,, -Gephyreaster swifti,Gephyreaster swifti,Gunpowder star,Animalia,Echinodermata,Asteroidea,Paxillosida,Pseudarchasteridae,Gephyreaster,Species,559194,NA,Species,,,,,,, -Gephyroberyx darwini,Gephyroberyx darwinii,Darwin's slimehead,Animalia,Chordata,Teleostei,Trachichthyiformes,Trachichthyidae,Gephyroberyx,Species,126401,4962,Species,,,,,,, -Gerreidae,Gerreidae,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Gerreidae,NA,Family,151456,NA,Remove,,,,,,, -Gerres cinereus,Gerres cinereus,Yellow fin mojarra,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Gerreidae,Gerres,Species,276954,1054,Species,,,,,,, -Gersemia,Gersemia,sea raspberry,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Alcyoniidae,Gersemia,Genus,146953,NA,Remove,,,,,,, -Gersemia sp.,Gersemia,sea raspberry,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Alcyoniidae,Gersemia,Genus,146953,NA,Remove,,,,,,, -Gersemia rubiformis,Gersemia rubiformis,Sea strawberry,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Alcyoniidae,Gersemia,Species,156103,NA,Species,,,,,,, -Gibbesia neglecta,Gibbesia neglecta,Lesser mantis shrimp,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,Gibbesia,Species,409251,NA,Species,,,,,,, -Squilla neglecta,Gibbesia neglecta,Lesser mantis shrimp,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,Gibbesia,Species,409251,NA,Species,,,,,,, -Gibbonsia metzi,Gibbonsia metzi,Striped kelpfish,Animalia,Chordata,Teleostei,Blenniiformes,Clinidae,Gibbonsia,Species,280835,3725,Species,,,,,,, -Gigantactis microdontis,Gigantactis microdontis,NA,Animalia,Chordata,Teleostei,Lophiiformes,Gigantactinidae,Gigantactis,Species,272567,52854,Species,,,,,,, -Gigantactis vanhoeffeni,Gigantactis vanhoeffeni,NA,Animalia,Chordata,Teleostei,Lophiiformes,Gigantactinidae,Gigantactis,Species,126542,16995,Species,,,,,,, -Gillellus,Gillellus,NA,Animalia,Chordata,Teleostei,Blenniiformes,Dactyloscopidae,Gillellus,Genus,269211,NA,Remove,,,,,,, -Ginglymostoma cirratum,Ginglymostoma cirratum,Nurse shark,Animalia,Chordata,Elasmobranchii,Orectolobiformes,Ginglymostomatidae,Ginglymostoma,Species,105846,2532,Species,,,,,,, -Glaucus atlanticus,Glaucus atlanticus,Blue glaucus,Animalia,Mollusca,Gastropoda,Nudibranchia,Glaucidae,Glaucus,Species,140022,NA,Species,,,,,,, -Glebocarcinus oregonensis,Glebocarcinus oregonensis,Pygmy rock crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Glebocarcinus,Species,440384,NA,Species,,,,,,, -Ventricolaria rigida,Globivenus rigida,Rigid venus,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Ventricolaria,Species,420937,NA,Species,,,,,,, -Globivenus rigida,Globivenus rigida,Rigid venus,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Ventricolaria,Species,420937,NA,Species,,,,,,, -Circomphalus strigillinus,Globivenus strigillina,Empress venus,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Circomphalus,Species,507661,NA,Species,,,,,,, -Globivenus strigillina,Globivenus strigillina,Empress venus,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Circomphalus,Species,507661,NA,Species,,,,,,, -Glycera,Glycera,Glycerine worm,Animalia,Annelida,Polychaeta,Phyllodocida,Glyceridae,Glycera,Genus,129296,NA,Remove,,,,,,, -Glycera sp.,Glycera,Glycerine worm,Animalia,Annelida,Polychaeta,Phyllodocida,Glyceridae,Glycera,Genus,129296,NA,Remove,,,,,,, -Glycymeris,Glycymeris,Bittersweet clams,Animalia,Mollusca,Bivalvia,Arcida,Glycymerididae,Glycymeris,Genus,138035,NA,Remove,,,,,,, -Glycymeris sp.,Glycymeris,Bittersweet clams,Animalia,Mollusca,Bivalvia,Arcida,Glycymerididae,Glycymeris,Genus,138035,NA,Remove,,,,,,, -Glycymeris septentrionalis,Glycymeris septentrionalis,Northern bittersweet,Animalia,Mollusca,Bivalvia,Arcida,Glycymerididae,Glycymeris,Species,504512,NA,Species,,,,,,, -Glyphocrangonidae,Glyphocrangonidae,Armored shrimps,Animalia,Arthropoda,Malacostraca,Decapoda,Glyphocrangonidae,NA,Family,106783,NA,Remove,,,,,,, -Glyptocephalus cynoglossus,Glyptocephalus cynoglossus,Witch flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Glyptocephalus,Species,127136,26,Species,,,,,,, -Glyptocephalus stelleri,Glyptocephalus stelleri,Korean flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Glyptocephalus,Species,274286,8843,Species,,,,,,, -Glyptocephalus zachirus,Glyptocephalus zachirus,Rex sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Glyptocephalus,Species,274287,4238,Species,,,,,,, -Glyptolithodes cristatipes,Glyptolithodes cristatipes,Peruvian centolla,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Glyptolithodes,Species,550620,NA,Species,,,,,,, -Glyptoplax smithii,Glyptoplax smithii,Truncate rubble crab,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Glyptoplax,Species,422078,NA,Species,,,,,,, -Glyptoxanthus erosus,Glyptoxanthus erosus,Eroded mud crab,Animalia,Arthropoda,Malacostraca,Decapoda,Xanthidae,Glyptoxanthus,Species,422131,NA,Species,,,,,,, -Glypturus,Glypturus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Callichiridae,Glypturus,Genus,415431,NA,Remove,,,,,,, -Glypturus acanthochirus,Glypturus acanthochirus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Callichiridae,Glypturus,Species,421822,NA,Species,,,,,,, -Gnatholepis thompsoni,Gnatholepis thompsoni,Goldspot goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gnatholepis,Species,277493,3855,Species,,,,,,, -Gnathophis bracheatopos,Gnathophis bracheatopos,Longeye conger,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Gnathophis,Species,271753,2626,Species,,,,,,, -Gobiesocidae,Gobiesocidae,NA,Animalia,Chordata,Teleostei,Gobiesociformes,Gobiesocidae,NA,Family,125477,NA,Remove,,,,,,, -Gobiesox punctulatus,Gobiesox punctulatus,Stippled clingfish,Animalia,Chordata,Teleostei,Gobiesociformes,Gobiesocidae,Gobiesox,Species,275678,3077,Species,,,,,,, -Gobiesox strumosus,Gobiesox strumosus,Skilletfish,Animalia,Chordata,Teleostei,Gobiesociformes,Gobiesocidae,Gobiesox,Species,158787,3079,Species,,,,,,, -Gobiidae,Gobiidae,Gobies,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,NA,Family,125537,NA,Remove,,,,,,, -Gobioidei,Gobiiformes,NA,Animalia,Chordata,Teleostei,Perciformes,NA,NA,SubOrder,1517500,NA,Remove,,,,,,, -Gobioides broussonneti,Gobioides broussonnetii,Violet goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobioides,Species,280887,3856,Species,,,,,,, -Gobioides broussonnetii,Gobioides broussonnetii,Violet goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobioides,Species,280887,3856,Species,,,,,,, -Gobionellus hastatus,Gobionellus oceanicus,Highfin goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobionellus,Species,159753,3862,Species,,,,,,, -Gobionellus oceanicus,Gobionellus oceanicus,Highfin goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobionellus,Species,159753,3862,Species,,,,,,, -Gobiosoma bosc,Gobiosoma bosc,Naked goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobiosoma,Species,159767,3870,Species,,,,,,, -Gobiosoma bosci,Gobiosoma bosc,Naked goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobiosoma,Species,159767,3870,Species,,,,,,, -Gobiosoma ginsburgi,Gobiosoma ginsburgi,Seaboard goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobiosoma,Species,159771,3871,Species,,,,,,, -Gobiosoma longipala,Gobiosoma longipala,Twoscale goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobiosoma,Species,276511,3874,Species,,,,,,, -Gonatidae,Gonatidae,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,NA,Family,11743,NA,Remove,,,,,,, -Gonatopsis,Gonatopsis,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,Gonatopsis,Genus,341428,NA,Remove,,,,,,, -Gonatopsis sp.,Gonatopsis,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,Gonatopsis,Genus,341428,NA,Remove,,,,,,, -Gonatopsis borealis,Gonatopsis borealis,Boreopacific gonate squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,Gonatopsis,Species,342326,NA,Species,,,,,,, -Gonatopsis okutanii,Gonatopsis okutanii,NA,NA,NA,NA,NA,NA,NA,Species,342330,NA,Species,,,,,,, -Gonatopsis sp. A (Jorgensen),Gonatopsis sp. A (Jorgensen),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Gonatus,Gonatus,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,Gonatus,Genus,138036,NA,Remove,,,,,,, -Gonatus sp.,Gonatus,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,Gonatus,Genus,138036,NA,Remove,,,,,,, -Gonatus berryi,Gonatus berryi,Berry armhook squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,Gonatus,Species,341855,NA,Species,,,,,,, -Gonatus californiensis,Gonatus californiensis,California armhook squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,Gonatus,Species,341856,NA,Species,,,,,,, -Gonatus madokai,Gonatus madokai,NA,NA,NA,NA,NA,NA,NA,Species,341858,NA,Species,,,,,,, -Gonatus middendorffi,Gonatus middendorffi,Shortarm gonate squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,Gonatus,Species,410362,NA,Species,,,,,,, -Gonatus onyx,Gonatus onyx,Clawed armhook squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,Gonatus,Species,341859,NA,Species,,,,,,, -Gonatus pyros,Gonatus pyros,Fiery armhook squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,Gonatus,Species,341861,NA,Species,,,,,,, -Goneplacidae,Goneplacidae,Angular crabs,Animalia,Arthropoda,Malacostraca,Decapoda,Goneplacidae,NA,Family,106757,NA,Remove,,,,,,, -Goneplax,Goneplax,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Goneplacidae,Goneplax,Genus,106888,NA,Remove,,,,,,, -Goniaster tesselatus,Goniaster tessellatus,Giant sunfish,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Goniaster,Species,124033,NA,Species,,,,,,, -Goniaster tessellatus,Goniaster tessellatus,Giant sunfish,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Goniaster,Species,124033,NA,Species,,,,,,, -Goniasteridae,Goniasteridae,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,NA,Family,123135,NA,Remove,,,,,,, -Gonodactylidae,Gonodactylidae,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Gonodactylidae,NA,Family,196127,NA,Remove,,,,,,, -Gonodactylus,Gonodactylus,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Gonodactylidae,Gonodactylus,Genus,205612,NA,Remove,,,,,,, -Gonostoma,Gonostoma,NA,Animalia,Chordata,Teleostei,Stomiiformes,Gonostomatidae,Gonostoma,Genus,126189,NA,Remove,,,,,,, -Gonostoma atlanticum,Gonostoma atlanticum,Atlantic fangjaw,Animalia,Chordata,Teleostei,Stomiiformes,Gonostomatidae,Gonostoma,Species,127293,5052,Species,,,,,,, -Gonostomatidae,Gonostomatidae,Bristlemouths,Animalia,Chordata,Teleostei,Stomiiformes,Gonostomatidae,NA,Family,125601,NA,Remove,,,,,,, -Gordiichthys,Gordiichthys,NA,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Gordiichthys,Genus,158618,NA,Remove,,,,,,, -Gorgonacea,Gorgonacea,Gorgonian corals,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Gorgonia,Gorgonia,Sea fans,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Gorgoniidae,Gorgonia,Genus,267453,NA,Remove,,,,,,, -Gorgonidae,Gorgonidae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Gorgonocephalidae,Gorgonocephalidae,Basket stars,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,NA,Family,123203,NA,Remove,,,,,,, -Gorgonocephalus,Gorgonocephalus,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Gorgonocephalus,Genus,123586,NA,Remove,,,,,,, -Gorgonocephalus sp.,Gorgonocephalus,NA,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Gorgonocephalus,Genus,123586,NA,Remove,,,,,,, -Gorgonocephalus arcticus,Gorgonocephalus arcticus,Northern basket star,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Gorgonocephalus,Species,124966,NA,Species,,,,,,, -Gorgonocephalus eucnemis,Gorgonocephalus eucnemis,Basket star,Animalia,Echinodermata,Ophiuroidea,Euryalida,Gorgonocephalidae,Gorgonocephalus,Species,124969,NA,Species,,,,,,, -Gorgonocephalus sp. cf. arcticus,Gorgonocephalus sp. cf. arcticus,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Grammatidae,Grammatidae,NA,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Grammatidae,NA,Family,151440,NA,Remove,,,,,,, -Grandicrepidula grandis,Grandicrepidula grandis,Great slippersnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Calyptraeidae,Grandicrepidula,Species,571646,NA,Species,,,,,,, -Graneledone,Graneledone,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Megaleledonidae,Graneledone,Genus,157018,NA,Remove,,,,,,, -Graneledone boreopacifica,Graneledone boreopacifica,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Megaleledonidae,Graneledone,Species,342222,NA,Species,,,,,,, -Graneledone sp. cf. boreopacifica (Nesis),Graneledone sp. cf. boreopacifica (Nesis),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Pleuroncodes planipes,Grimothea planipes,Pelagic red crab,Animalia,Arthropoda,Malacostraca,Decapoda,Munididae,Pleuroncodes,Species,1607504,NA,Species,,,,,,, -Munida quadrispina,Grimothea quadrispina,Pinch bug,Animalia,Arthropoda,Malacostraca,Decapoda,Munididae,Munida,Species,1607500,NA,Species,,,,,,, -Grimothea quadrispina,Grimothea quadrispina,Pinch bug,Animalia,Arthropoda,Malacostraca,Decapoda,Munididae,Munida,Species,1607500,NA,Species,,,,,,, -Gunterichthys longipenis,Gunterichthys longipenis,Gold brotula,Animalia,Chordata,Teleostei,Ophidiiformes,Bythitidae,Gunterichthys,Species,280948,3122,Species,,,,,,, -Acanthaxius hirsutimanus,Guyanacaris hirsutimana,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Axiidae,Acanthaxius,Species,741397,NA,Species,,,,,,, -Axiopsis hirsutimana,Guyanacaris hirsutimana,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Axiidae,Acanthaxius,Species,741397,NA,Species,,,,,,, -Calocaris hirsutimana,Guyanacaris hirsutimana,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Axiidae,Calocaris,Species,741397,NA,Species,,,,,,, -Guyanacaris hirsutimana,Guyanacaris hirsutimana,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Axiidae,Calocaris,Species,741397,NA,Species,,,,,,, -Gymnachirus,Gymnachirus,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,Achiridae,Gymnachirus,Genus,159268,NA,Remove,,,,,,, -Gymnachirus melas,Gymnachirus melas,Naked sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Achiridae,Gymnachirus,Species,159269,4257,Species,,,,,,, -Gymnachirus nudus,Gymnachirus nudus,Flabby sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Achiridae,Gymnachirus,Species,275995,7575,Species,,,,,,, -Gymnachirus texae,Gymnachirus texae,Fringed sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Achiridae,Gymnachirus,Species,275996,4258,Species,,,,,,, -Gymnelus,Gymnelus,NA,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Gymnelus,Genus,126102,NA,Remove,,,,,,, -Gymnelus sp.,Gymnelus,NA,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Gymnelus,Genus,126102,NA,Remove,,,,,,, -Gymnelus hemifasciatus,Gymnelus hemifasciatus,Halfbarred pout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Gymnelus,Species,254583,47878,Species,,,,,,, -Gymnelus viridis,Gymnelus viridis,Fish doctor,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Gymnelus,Species,127096,3131,Species,,,,,,, -Gymnocanthus,Gymnocanthus,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Gymnocanthus,Genus,126149,NA,Remove,,,,,,, -Gymnocanthus sp.,Gymnocanthus,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Gymnocanthus,Genus,126149,NA,Remove,,,,,,, -Gymnocanthus detrisus,Gymnocanthus detrisus,Purplegray sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Gymnocanthus,Species,274372,23956,Species,,,,,,, -Gymnocanthus galeatus,Gymnocanthus galeatus,Armorhead sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Gymnocanthus,Species,254514,4091,Species,,,,,,, -Gymnocanthus pistilliger,Gymnocanthus pistilliger,Threaded sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Gymnocanthus,Species,254519,11716,Species,,,,,,, -Gymnocanthus tricuspis,Gymnocanthus tricuspis,Arctic staghorn sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Gymnocanthus,Species,127198,4092,Species,,,,,,, -Gymnolaemata,Gymnolaemata,NA,Animalia,Bryozoa,Gymnolaemata,NA,NA,NA,Class,1795,NA,Remove,,,,,,, -Gymnothorax,Gymnothorax,NA,Animalia,Chordata,Teleostei,Anguilliformes,Muraenidae,Gymnothorax,Genus,125636,NA,Remove,,,,,,, -Gymnothorax funebris,Gymnothorax funebris,Green moray,Animalia,Chordata,Teleostei,Anguilliformes,Muraenidae,Gymnothorax,Species,158583,7546,Species,,,,,,, -Gymnothorax kolpos,Gymnothorax kolpos,Blacktail moray,Animalia,Chordata,Teleostei,Anguilliformes,Muraenidae,Gymnothorax,Species,271844,11927,Species,,,,,,, -Gymnothorax moringa,Gymnothorax moringa,Spotted moray,Animalia,Chordata,Teleostei,Anguilliformes,Muraenidae,Gymnothorax,Species,158584,7547,Species,,,,,,, -Gymnothorax nigromarginatus,Gymnothorax nigromarginatus,Blackedge moray,Animalia,Chordata,Teleostei,Anguilliformes,Muraenidae,Gymnothorax,Species,271860,2615,Species,,,,,,, -Gymnothorax ocellatus,Gymnothorax ocellatus,Ocellated moray,Animalia,Chordata,Teleostei,Anguilliformes,Muraenidae,Gymnothorax,Species,271865,1099,Species,,,,,,, -Gymnothorax saxicola,Gymnothorax saxicola,Honeycomb moray,Animalia,Chordata,Teleostei,Anguilliformes,Muraenidae,Gymnothorax,Species,158585,2616,Species,,,,,,, -Gymnothorax vicinus,Gymnothorax vicinus,Purplemouth moray,Animalia,Chordata,Teleostei,Anguilliformes,Muraenidae,Gymnothorax,Species,126302,7548,Species,,,,,,, -Gymnura altavela,Gymnura altavela,Spiny butterfly ray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Gymnuridae,Gymnura,Species,105856,2577,Species,,,,,,, -Gymnura micrura,Gymnura micrura,Smooth butterfly ray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Gymnuridae,Gymnura,Species,158529,2579,Species,,,,,,, -Habevolutopsius attenuatus,Habevolutopsius attenuatus,Threaded whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Habevolutopsius,Species,491022,NA,Species,,,,,,, -Lussivolutopsius filosus,Habevolutopsius attenuatus,Threaded whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Habevolutopsius,Species,491022,NA,Species,,,,,,, -Habevolutopsius hirasei,Habevolutopsius hirasei,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Habevolutopsius,Species,423415,NA,Species,,,,,,, -Brasilissa alta,Hadroconus altus,NA,Animalia,Mollusca,Gastropoda,Seguenziida,Seguenziidae,Basilissa,Species,419401,NA,Species,,,,,,, -Haemulidae,Haemulidae,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Haemulidae,NA,Family,125538,NA,Remove,,,,,,, -Haemulon,Haemulon,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Haemulidae,Haemulon,Genus,158806,NA,Remove,,,,,,, -Haemulon aurolineatum,Haemulon aurolineatum,Tomtate grunt,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Haemulidae,Haemulon,Species,158807,1128,Species,,,,,,, -Haemulon carbonarium,Haemulon carbonarium,Caesar grunt,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Haemulidae,Haemulon,Species,275724,1131,Species,,,,,,, -Haemulon plumieri,Haemulon plumierii,White grunt,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Haemulidae,Haemulon,Species,158808,1140,Species,,,,,,, -Haemulon plumierii,Haemulon plumierii,White grunt,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Haemulidae,Haemulon,Species,158808,1140,Species,,,,,,, -Haemulon sciurus,Haemulon sciurus,Bluestriped grunt,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Haemulidae,Haemulon,Species,275733,1141,Species,,,,,,, -Haemulon striatum,Haemulon striatum,Striped grunt,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Haemulidae,Haemulon,Species,275739,1143,Species,,,,,,, -Halargyreus johnsonii,Halargyreus johnsonii,Slender codling,Animalia,Chordata,Teleostei,Gadiformes,Moridae,Halargyreus,Species,126489,2012,Species,,,,,,, -Halicardia perplicata,Halicardia perplicata,NA,Animalia,Mollusca,Bivalvia,NA,Verticordiidae,Halicardia,Species,405861,NA,Species,,,,,,, -Halichoeres,Halichoeres,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Halichoeres,Genus,158813,NA,Remove,,,,,,, -Halichoeres bathyphilus,Halichoeres bathyphilus,Greenband wrasse,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Halichoeres,Species,158814,3659,Species,,,,,,, -Halichoeres bivittatus,Halichoeres bivittatus,Slippery dick,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Halichoeres,Species,158815,3660,Species,,,,,,, -Halichoeres caudalis,Halichoeres caudalis,Painted wrasse,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Halichoeres,Species,158816,3661,Species,,,,,,, -Halichoeres cyanocephalus,Halichoeres cyanocephalus,Yellowcheek wrasse,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Halichoeres,Species,275760,3662,Species,,,,,,, -Halichoeres garnoti,Halichoeres garnoti,Yellowhead wrasse,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Halichoeres,Species,275764,3663,Species,,,,,,, -Halichoeres radiatus,Halichoeres radiatus,Puddingwife wrasse,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Halichoeres,Species,275793,1068,Species,,,,,,, -Halichoerus grypus,Halichoerus grypus,Grey seal,Animalia,Chordata,Mammalia,Carnivora,Phocidae,Halichoerus,Species,137080,NA,Species,,,,,,, -Halichondria,Halichondria,NA,Animalia,Porifera,Demospongiae,Suberitida,Halichondriidae,Halichondria,Genus,131807,NA,Remove,,,,,,, -Halichondria sp.,Halichondria,NA,Animalia,Porifera,Demospongiae,Suberitida,Halichondriidae,Halichondria,Genus,131807,NA,Remove,,,,,,, -Halichondria sitiens,Halichondria (Eumastia) sitiens,Green tinged sponge,Animalia,Porifera,Demospongiae,Suberitida,Halichondriidae,Halichondria,Species,165789,NA,Species,,,,,,, -Halichondria oblonga,Halichondria (Halichondria) oblonga,NA,Animalia,Porifera,Demospongiae,Suberitida,Halichondriidae,Halichondria,Species,165848,NA,Species,,,,,,, -Halichondria panicea,Halichondria (Halichondria) panicea,Breadcrumb sponge,Animalia,Porifera,Demospongiae,Suberitida,Halichondriidae,Halichondria,Species,165853,NA,Species,,,,,,, -Haliclona,Haliclona,NA,Animalia,Porifera,Demospongiae,Haplosclerida,Chalinidae,Haliclona,Genus,131834,NA,Remove,,,,,,, -Haliclona sp.,Haliclona,NA,Animalia,Porifera,Demospongiae,Haplosclerida,Chalinidae,Haliclona,Genus,131834,NA,Remove,,,,,,, -Haliclona digitata,Haliclona digitata,NA,Animalia,Porifera,Demospongiae,Haplosclerida,Chalinidae,Haliclona,Species,184508,NA,Species,,,,,,, -"Haliclona sp. 2 (Stone et al., 2011)","Haliclona sp. 2 (Stone et al., 2011)",NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Halieutichthys sp,Halieutichthys sp,Batfishes,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Halieutichthys,Genus,159189,NA,Genus,,,,,,, -Halieutichthys aculeatus,Halieutichthys aculeatus,Pancake batfish,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Halieutichthys,Species,159190,3091,Species,,,,,,, -Haliphron atlanticus,Haliphron atlanticus,Seven-arm octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Alloposidae,Haliphron,Species,341781,NA,Species,,,,,,, -Halocynthia,Halocynthia,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Pyuridae,Halocynthia,Genus,103519,NA,Remove,,,,,,, -Halocynthia sp.,Halocynthia,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Pyuridae,Halocynthia,Genus,103519,NA,Remove,,,,,,, -Halocynthia aurantium,Halocynthia aurantium,Sea peach,Animalia,Chordata,Ascidiacea,Stolidobranchia,Pyuridae,Halocynthia,Species,250674,NA,Species,,,,,,, -Halocynthia hispidus,Halocynthia dumosa,Hairy tunicate,Animalia,Chordata,Ascidiacea,Stolidobranchia,Pyuridae,Halocynthia,Species,251556,NA,Species,,,,,,, -Halocynthia dumosa,Halocynthia dumosa,Hairy tunicate,Animalia,Chordata,Ascidiacea,Stolidobranchia,Pyuridae,Halocynthia,Species,251556,NA,Species,,,,,,, -Halocynthia igaboja,Halocynthia igaboja,Bristly tunicate,Animalia,Chordata,Ascidiacea,Stolidobranchia,Pyuridae,Halocynthia,Species,250677,NA,Species,,,,,,, -Halosydna brevisetosa,Halosydna brevisetosa,Short scaled worm,Animalia,Annelida,Polychaeta,Phyllodocida,Polynoidae,Halosydna,Species,333534,NA,Species,,,,,,, -Hamatoscalpellum columbianum,Hamatoscalpellum columbianum,Columbian barnacle,Animalia,Arthropoda,Thecostraca,Scalpellomorpha,Scalpellidae,Hamatoscalpellum,Species,535183,NA,Species,,,,,,, -Haminoea elegans,Haminoea elegans,NA,Animalia,Mollusca,Gastropoda,Cephalaspidea,Haminoeidae,Haminoea,Species,140071,NA,Species,,,,,,, -Haminoea succinea,Haminoea succinea,Amber glassy-bubble,Animalia,Mollusca,Gastropoda,Cephalaspidea,Haminoeidae,Haminoea,Species,420526,NA,Species,,,,,,, -Hapalogaster,Hapalogaster,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Hapalogastridae,Hapalogaster,Genus,254338,NA,Remove,,,,,,, -Hapalogaster sp.,Hapalogaster,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Hapalogastridae,Hapalogaster,Genus,254338,NA,Remove,,,,,,, -Hapalogaster grebnitzkii,Hapalogaster grebnitzkii,Soft crab,Animalia,Arthropoda,Malacostraca,Decapoda,Hapalogastridae,Hapalogaster,Species,254492,NA,Species,,,,,,, -Harengula,Harengula,NA,Animalia,Chordata,Teleostei,Clupeiformes,Dorosomatidae,Harengula,Genus,204605,NA,Remove,,,,,,, -Harengula jaguana,Harengula jaguana,Scaled sardine,Animalia,Chordata,Teleostei,Clupeiformes,Dorosomatidae,Harengula,Species,277551,1480,Species,,,,,,, -Harpa costata,Harpa costata,costate whelk,NA,NA,NA,NA,NA,NA,Species,208159,NA,Species,,,,,,, -Harriotta raleighana,Harriotta raleighana,Pacific longnose chimaera,Animalia,Chordata,Holocephali,Chimaeriformes,Rhinochimaeridae,Harriotta,Species,105829,5053,Species,,,,,,, -Colossendeis dofleini,Hedgpethia dofleini,NA,Animalia,Arthropoda,Pycnogonida,Pantopoda,Colossendeidae,Colossendeis,Species,240003,NA,Species,,,,,,, -Hedgpethia dofleini,Hedgpethia dofleini,NA,Animalia,Arthropoda,Pycnogonida,Pantopoda,Colossendeidae,Colossendeis,Species,240003,NA,Species,,,,,,, -Heilprinia timessus,Heilprinia timessa,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Heilprinia,Species,448405,NA,Species,,,,,,, -Heilprinia timessa,Heilprinia timessa,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Heilprinia,Species,448405,NA,Species,,,,,,, -Helicolenus dactylopterus,Helicolenus dactylopterus,Blackbelly rosefish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Helicolenus,Species,127251,76,Species,,,,,,, -Heliometra glacialis,Heliometra glacialis,NA,Animalia,Echinodermata,Crinoidea,Comatulida,Antedonidae,Heliometra,Species,124223,NA,Species,,,,,,, -Helix,Helix,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Hemanthias leptus,Hemanthias leptus,Longtail bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Hemanthias,Species,275929,3325,Species,,,,,,, -Hemicaranx amblyrhynchus,Hemicaranx amblyrhynchus,Bluntnose jack,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Hemicaranx,Species,159640,997,Species,,,,,,, -Hemilepidotus,Hemilepidotus,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Hemilepidotus,Genus,248338,NA,Remove,,,,,,, -Hemilepidotus sp.,Hemilepidotus,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Hemilepidotus,Genus,248338,NA,Remove,,,,,,, -Hemilepidotus gilberti,Hemilepidotus gilberti,Gilbert's irish lord,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Hemilepidotus,Species,254520,23903,Species,,,,,,, -Hemilepidotus hemilepidotus,Hemilepidotus hemilepidotus,Red irish lord,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Hemilepidotus,Species,254521,4093,Species,,,,,,, -Hemilepidotus jordani,Hemilepidotus jordani,Yellow irish lord,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Hemilepidotus,Species,254522,4094,Species,,,,,,, -Hemilepidotus papilio,Hemilepidotus papilio,Butterfly sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Hemilepidotus,Species,254523,4115,Species,,,,,,, -Hemilepidotus spinosus,Hemilepidotus spinosus,Brown irish lord,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Hemilepidotus,Species,279413,4095,Species,,,,,,, -Hemilepidotus zapus,Hemilepidotus zapus,Longfin irish lord,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Hemilepidotus,Species,279414,4096,Species,,,,,,, -Latirus mcgintyi,Hemipolygona mcgintyi,Mcginty's latirus,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Latirus,Species,420041,NA,Species,,,,,,, -Hemipolygona mcgintyi,Hemipolygona mcgintyi,Mcginty's latirus,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Latirus,Species,420041,NA,Species,,,,,,, -Hemiramphus balao,Hemiramphus balao,Balao halfbeak,Animalia,Chordata,Teleostei,Beloniformes,Hemiramphidae,Hemiramphus,Species,159278,1057,Species,,,,,,, -Hemiramphus brasiliensis,Hemiramphus brasiliensis,Ballyhoo halfbeak,Animalia,Chordata,Teleostei,Beloniformes,Hemiramphidae,Hemiramphus,Species,159279,1059,Species,,,,,,, -Hemisquilla californiensis,Hemisquilla californiensis,Blueleg mantis shrimp,Animalia,Arthropoda,Malacostraca,Stomatopoda,Hemisquillidae,Hemisquilla,Species,408961,NA,Species,,,,,,, -Hemisquillidae,Hemisquillidae,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Hemisquillidae,NA,Family,408957,NA,Remove,,,,,,, -Hemithirididae,Hemithirididae,hemithyrid brachiopods,NA,NA,NA,NA,NA,NA,Family,104027,NA,Remove,,,,,,, -Hemithiris psittacea,Hemithiris psittacea,Black brachiopod,Animalia,Brachiopoda,Rhynchonellata,Rhynchonellida,Hemithirididae,Hemithiris,Species,104054,NA,Species,,,,,,, -Hemithyrididae,Hemithyrididae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Hemitripterus americanus,Hemitripterus americanus,Sea raven,Animalia,Chordata,Teleostei,Perciformes,Hemitripteridae,Hemitripterus,Species,159518,4097,Species,,,,,,, -Hemitripterus bolini,Hemitripterus bolini,Bigmouth sculpin,Animalia,Chordata,Teleostei,Perciformes,Hemitripteridae,Hemitripterus,Species,254541,4098,Species,,,,,,, -Henricia,Henricia,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Genus,123276,NA,Remove,,,,,,, -Henricia sp.,Henricia,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Genus,123276,NA,Remove,,,,,,, -Henrici antillarum,Henricia antillarum,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,178755,NA,Species,,,,,,, -Henricia antillarum,Henricia antillarum,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,178755,NA,Species,,,,,,, -Henricia aspera,Henricia aspera,Sandpaper henricia,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,369100,NA,Species,,,,,,, -Henricia asthenactis,Henricia asthenactis,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,369103,NA,Species,,,,,,, -Henricia clarki,Henricia clarki,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,369104,NA,Species,,,,,,, -Henricia derjugini,Henricia derjugini,NA,NA,NA,NA,NA,NA,NA,Species,254496,NA,Species,,,,,,, -Henricia dyscrita,Henricia dyscrita,Short-spined Henricia,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,369106,NA,Species,,,,,,, -Henricia leviuscula,Henricia leviuscula,Pacific blood star,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,369117,NA,Species,,,,,,, -Henricia leviuscula leviuscula,Henricia leviuscula leviuscula,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,SubSpecies,369118,NA,SubSpecies,,,,,,, -Henricia multispina,Henricia leviuscula spiculifera,Spiny Henricia,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,369120,NA,Species,,,,,,, -Henricia leviuscula spiculifera,Henricia leviuscula spiculifera,Spiny Henricia,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,369120,NA,Species,,,,,,, -Henricia lineata,Henricia lineata,Lined blood star,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,509320,NA,Species,,,,,,, -Henricia longispina,Henricia longispina,Long spined henricia,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,369122,NA,Species,,,,,,, -Henricia aleutica,Henricia longispina aleutica,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,123276,NA,Species,,,,,,, -Henricia longispina aleutica,Henricia longispina aleutica,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,123276,NA,Species,,,,,,, -Henricia rhytisma,Henricia rhytisma,Mottled Henricia,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,509323,NA,Species,,,,,,, -Henricia sanguinolenta,Henricia sanguinolenta,Blood sea star,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,123974,NA,Species,,,,,,, -Henricia sp. B (Clark 2006),Henricia sp. B (Clark 2006),white Henricia,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Henricia sp. D (Clark 2006),Henricia sp. D (Clark 2006),fuzzy henricia,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Henricia sp. E (Clark 2006),Henricia sp. E (Clark 2006),slender pale Henricia,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Henricia tumida,Henricia tumida,Fat henricia,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Henricia,Species,369147,NA,Species,,,,,,, -Hepatus,Hepatus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Aethridae,Hepatus,Genus,158419,NA,Remove,,,,,,, -Hepatus epheliticus,Hepatus epheliticus,Calico box crab,Animalia,Arthropoda,Malacostraca,Decapoda,Aethridae,Hepatus,Species,158420,NA,Species,,,,,,, -Hepatus princeps,Hepatus princeps,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Aethridae,Hepatus,Species,158419,NA,Species,,,,,,, -Hepatus pudibundus,Hepatus pudibundus,Flecked box crab,Animalia,Arthropoda,Malacostraca,Decapoda,Aethridae,Hepatus,Species,344730,NA,Species,,,,,,, -Heptacarpus,Heptacarpus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Heptacarpus,Genus,248339,NA,Remove,,,,,,, -Heptacarpus sp.,Heptacarpus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Heptacarpus,Genus,248339,NA,Remove,,,,,,, -Heptacarpus flexus,Heptacarpus flexus,Slenderbeak coastal shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Heptacarpus,Species,423437,NA,Species,,,,,,, -Heptacarpus maxillipes,Heptacarpus maxillipes,Aleutian coastal shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Heptacarpus,Species,515258,NA,Species,,,,,,, -Hermissenda crassicornis,Hermissenda crassicornis,Hermissenda,Animalia,Mollusca,Gastropoda,Nudibranchia,Myrrhinidae,Hermissenda,Species,367883,NA,Species,,,,,,, -Hermodice,Hermodice,NA,Animalia,Annelida,Polychaeta,Amphinomida,Amphinomidae,Hermodice,Genus,129187,NA,Remove,,,,,,, -Hermodice carunculata,Hermodice carunculata,Bearded fireworms,Animalia,Annelida,Polychaeta,Amphinomida,Amphinomidae,Hermodice,Species,129831,NA,Species,,,,,,, -Hesionidae,Hesionidae,NA,Animalia,Annelida,Polychaeta,Phyllodocida,Hesionidae,NA,Family,946,NA,Remove,,,,,,, -Balanus hesperius,Hesperibalanus hesperius,Crab barnacle,Animalia,Arthropoda,Thecostraca,Balanomorpha,Balanidae,Balanus,Species,106122,NA,Species,,,,,,, -Hesperibalanus hesperius,Hesperibalanus hesperius,Crab barnacle,Animalia,Arthropoda,Thecostraca,Balanomorpha,Balanidae,Balanus,Species,106122,NA,Species,,,,,,, -Chonelasma calyx,Heterochone calyx,Fingered goblet sponge,Animalia,Porifera,Hexactinellida,Sceptrulophora,Aphrocallistidae,Heterochone,Species,171636,NA,Species,,,,,,, -Heterochone calyx,Heterochone calyx,Fingered goblet sponge,Animalia,Porifera,Hexactinellida,Sceptrulophora,Aphrocallistidae,Heterochone,Species,171636,NA,Species,,,,,,, -Heterochone tenera,Heterochone tenera,Tender glass sponge,Animalia,Porifera,Hexactinellida,Sceptrulophora,Aphrocallistidae,Heterochone,Species,171639,NA,Species,,,,,,, -Heterocrypta granulata,Heterocrypta granulata,Smooth elbow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Heterocrypta,Species,158422,NA,Species,,,,,,, -Heterocrypta occidentalis,Heterocrypta occidentalis,Sandflat elbow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Heterocrypta,Species,106915,NA,Species,,,,,,, -Heterodontidae,Heterodontidae,Bullhead sharks,Animalia,Chordata,Elasmobranchii,Heterodontiformes,Heterodontidae,NA,Family,148802,NA,Remove,,,,,,, -Heterodontus francisci,Heterodontus francisci,Horn shark,Animalia,Chordata,Elasmobranchii,Heterodontiformes,Heterodontidae,Heterodontus,Species,276694,739,Species,,,,,,, -Heteropolypus,Heteropolypus,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Coralliidae,Heteropolypus,Genus,345446,NA,Remove,,,,,,, -Anthomastus ritteri,Heteropolypus ritteri,Ritter's soft coral,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Coralliidae,Anthomastus,Species,724715,NA,Species,,,,,,, -Heteropora,Heteropora,NA,Animalia,Bryozoa,Stenolaemata,Cyclostomatida,Heteroporidae,Heteropora,Genus,248342,NA,Remove,,,,,,, -Heteropora sp.,Heteropora,NA,Animalia,Bryozoa,Stenolaemata,Cyclostomatida,Heteroporidae,Heteropora,Genus,248342,NA,Remove,,,,,,, -Cookeolus boops,Heteropriacanthus cruentatus,Glasseye snapper,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Priacanthidae,Heteropriacanthus,Species,127004,1150,Species,,,,,,, -Heteropriacanthus cruentatus,Heteropriacanthus cruentatus,Glasseye snapper,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Priacanthidae,Heteropriacanthus,Species,127004,1150,Species,,,,,,, -Priacanthus cruentatus,Heteropriacanthus cruentatus,Glasseye snapper,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Priacanthidae,Heteropriacanthus,Species,127004,1150,Species,,,,,,, -Heterozonias sp.,Heterozonias,NA,NA,NA,NA,NA,NA,NA,Genus,292712,NA,Remove,,,,,,, -Heterozonias alternatus,Heterozonias alternatus,Canonball sun star,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Heterozonias,Species,292713,NA,Species,,,,,,, -Hexactinellida,Hexactinellida,Glass sponges,Animalia,Porifera,Hexactinellida,NA,NA,NA,Class,22612,NA,Remove,,,,,,, -Hexagrammidae,Hexagrammidae,Greenlings,Animalia,Chordata,Teleostei,Perciformes,Hexagrammidae,NA,Family,154415,NA,Remove,,,,,,, -Hexagrammos,Hexagrammos,Greenlings,Animalia,Chordata,Teleostei,Perciformes,Hexagrammidae,Hexagrammos,Genus,240731,NA,Remove,,,,,,, -Hexagrammos sp.,Hexagrammos,Greenlings,Animalia,Chordata,Teleostei,Perciformes,Hexagrammidae,Hexagrammos,Genus,240731,NA,Remove,,,,,,, -Hexagrammos decagrammus,Hexagrammos decagrammus,Kelp greenling,Animalia,Chordata,Teleostei,Perciformes,Hexagrammidae,Hexagrammos,Species,240732,4032,Species,,,,,,, -Hexagrammos lagocephalus,Hexagrammos lagocephalus,Rock greenling,Animalia,Chordata,Teleostei,Perciformes,Hexagrammidae,Hexagrammos,Species,240735,4033,Species,,,,,,, -Hexagrammos octogrammus,Hexagrammos octogrammus,Masked greenling,Animalia,Chordata,Teleostei,Perciformes,Hexagrammidae,Hexagrammos,Species,254544,4034,Species,,,,,,, -Hexagrammos stelleri,Hexagrammos stelleri,Whitespotted greenling,Animalia,Chordata,Teleostei,Perciformes,Hexagrammidae,Hexagrammos,Species,254545,4035,Species,,,,,,, -Hexanchus griseus,Hexanchus griseus,Bluntnose sixgill shark,Animalia,Chordata,Elasmobranchii,Hexanchiformes,Hexanchidae,Hexanchus,Species,105833,637,Species,,,,,,, -Hexapanopeus,Hexapanopeus,Mud crab,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Hexapanopeus,Genus,158423,NA,Remove,,,,,,, -Hexapanopeus angustifrons,Hexapanopeus angustifrons,Smooth mud crab,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Hexapanopeus,Species,158424,NA,Species,,,,,,, -Hexapanopeus paulensis,Hexapanopeus paulensis,Knobbed mud crab,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Hexapanopeus,Species,422081,NA,Species,,,,,,, -Hexaplex fulvescens,Hexaplex fulvescens,Giant eastern murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Hexaplex,Species,596160,NA,Species,,,,,,, -Murex burryi,Hexaplex fulvescens,Giant eastern murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Hexaplex,Species,596160,NA,Species,,,,,,, -Muricanthus fulvescens,Hexaplex fulvescens,Giant eastern murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Hexaplex,Species,596160,NA,Species,,,,,,, -Hiatella,Hiatella,NA,Animalia,Mollusca,Bivalvia,Adapedonta,Hiatellidae,Hiatella,Genus,138068,NA,Remove,,,,,,, -Hiatella sp.,Hiatella,NA,Animalia,Mollusca,Bivalvia,Adapedonta,Hiatellidae,Hiatella,Genus,138068,NA,Remove,,,,,,, -Hiatella arctica,Hiatella arctica,Arctic hiatella,Animalia,Mollusca,Bivalvia,Adapedonta,Hiatellidae,Hiatella,Species,140103,NA,Species,,,,,,, -Hiatella azaria,Hiatella arctica,Arctic hiatella,Animalia,Mollusca,Bivalvia,Adapedonta,Hiatellidae,Hiatella,Species,140103,NA,Species,,,,,,, -Hinnites,Hinnites,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Hinnites,Genus,206520,NA,Remove,,,,,,, -Hinnites sp.,Hinnites,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Hinnites,Genus,206520,NA,Remove,,,,,,, -Hippasteria,Hippasteria,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Hippasteria,Genus,123297,NA,Remove,,,,,,, -Hippasteria sp.,Hippasteria,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Hippasteria,Genus,123297,NA,Remove,,,,,,, -Hippasteria californica,Hippasteria californica,Californian spiny star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Hippasteria,Species,254890,NA,Species,,,,,,, -Hippasteria heathi,Hippasteria heathi,Heath's spiny star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Hippasteria,Species,254893,NA,Species,,,,,,, -Hippasteria armata,Hippasteria leiopelta,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Hippasteria,Species,254896,NA,Species,,,,,,, -Hippasteria leiopelta,Hippasteria leiopelta,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Hippasteria,Species,254896,NA,Species,,,,,,, -Cryptopeltaster lepidonotus,Hippasteria lepidonotus,Pebbly star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Hippasteria,Species,762391,NA,Species,,,,,,, -Hippasteria lepidonotus,Hippasteria lepidonotus,Pebbly star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Hippasteria,Species,762391,NA,Species,,,,,,, -Hippasteria aleutica,Hippasteria phrygiana,Arctic cushion star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Hippasteria,Species,124043,NA,Species,,,,,,, -Hippasteria kurilensis,Hippasteria phrygiana,Arctic cushion star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Hippasteria,Species,124043,NA,Species,,,,,,, -Hippasteria phrygiana,Hippasteria phrygiana,Arctic cushion star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Hippasteria,Species,124043,NA,Species,,,,,,, -Hippasteria spinosa,Hippasteria phrygiana,Arctic cushion star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Hippasteria,Species,124043,NA,Species,,,,,,, -Hippasteria sp. B (Clark),Hippasteria sp. B (Clark),pale spiny star,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Hippasteria sp. C (Clark),Hippasteria sp. C (Clark),Bering spiny star,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Hippasteria sp. E (Clark),Hippasteria sp. E (Clark),Alaskan spiny star,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Hippocampus,Hippocampus,Seahorses,Animalia,Chordata,Teleostei,Syngnathiformes,Syngnathidae,Hippocampus,Genus,126224,NA,Remove,,,,,,, -Hippocampus erectus,Hippocampus erectus,Lined seahorse,Animalia,Chordata,Teleostei,Syngnathiformes,Syngnathidae,Hippocampus,Species,159445,3283,Species,,,,,,, -Hippocampus reidi,Hippocampus reidi,Longsnout seahorse,Animalia,Chordata,Teleostei,Syngnathiformes,Syngnathidae,Hippocampus,Species,159446,3285,Species,,,,,,, -Hippocampus zosterae,Hippocampus zosterae,Dwarf seahorse,Animalia,Chordata,Teleostei,Syngnathiformes,Syngnathidae,Hippocampus,Species,275213,3286,Species,,,,,,, -Hippodiplosia,Hippodiplosia,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Paralichthys oblongus,Hippoglossina oblonga,American fourspot flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Paralichthys,Species,158833,4229,Species,,,,,,, -Hippoglossina stomata,Hippoglossina stomata,Bigmouth flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Hippoglossina,Species,275827,4225,Species,,,,,,, -Hippoglossoides sp.,Hippoglossoides,NA,NA,NA,NA,NA,NA,NA,Genus,126115,NA,Remove,,,,,,, -Hippoglossoides elassodon,Hippoglossoides elassodon,Flathead sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Hippoglossoides,Species,274289,519,Species,,,,,,, -Hippoglossoides elassodon and h. robustus,Hippoglossoides elassodon and H. robustus,Flathead sole-bering flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Hippoglossoides,Species,274289,519,Species,,,,,,, -Hippoglossoides platessoides,Hippoglossoides platessoides,American plaice,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Hippoglossoides,Species,127137,4239,Species,,,,,,, -Hippoglossoides robustus,Hippoglossoides robustus,Bering flounder,NA,NA,NA,NA,NA,NA,Species,254561,NA,Species,,,,,,, -Hippoglossus hippoglossus,Hippoglossus hippoglossus,Atlantic halibut,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Hippoglossus,Species,127138,1371,Species,,,,,,, -Hippoglossus stenolepis,Hippoglossus stenolepis,Pacific halibut,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Hippoglossus,Species,274290,514,Species,,,,,,, -Hippolytidae,Hippolytidae,Humpback prawns,Animalia,Arthropoda,Malacostraca,Decapoda,Hippolytidae,NA,Family,106777,NA,Remove,,,,,,, -Hippoporina insculpta,Hippoporina insculpta,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Bitectiporidae,Hippoporina,Species,110825,NA,Species,,,,,,, -Hirudinea,Hirudinea,Leeches,Animalia,Annelida,Clitellata,NA,NA,NA,SubClass,2041,NA,Remove,,,,,,, -Hirundichthys affinis,Hirundichthys affinis,Fourwing flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Hirundichthys,Species,159265,7457,Species,,,,,,, -Hirundichthys rondeletii,Hirundichthys rondeletii,Black wing flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Hirundichthys,Species,126386,1035,Species,,,,,,, -Histioteuthis,Histioteuthis,jewel squids,Animalia,Mollusca,Cephalopoda,Oegopsida,Histioteuthidae,Histioteuthis,Genus,138074,NA,Remove,,,,,,, -Histioteuthis sp.,Histioteuthis,jewel squids,Animalia,Mollusca,Cephalopoda,Oegopsida,Histioteuthidae,Histioteuthis,Genus,138074,NA,Remove,,,,,,, -Histioteuthis heteropsis,Histioteuthis heteropsis,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Histioteuthidae,Histioteuthis,Species,341868,NA,Species,,,,,,, -Histodermella kagigunensis,Histodermella kagigunensis,Spud sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Coelosphaeridae,Histodermella,Species,736899,NA,Species,,,,,,, -Histrio histrio,Histrio histrio,Sargassumfish,Animalia,Chordata,Teleostei,Lophiiformes,Antennariidae,Histrio,Species,126533,3089,Species,,,,,,, -Holacanthus,Holacanthus,NA,Animalia,Chordata,Teleostei,Acanthuriformes,Pomacanthidae,Holacanthus,Genus,159282,NA,Remove,,,,,,, -Holacanthus bermudensis,Holacanthus bermudensis,Blue angelfish,Animalia,Chordata,Teleostei,Acanthuriformes,Pomacanthidae,Holacanthus,Species,159284,3608,Species,,,,,,, -Chaetodon ciliaris,Holacanthus ciliaris,Queen angelfish,Animalia,Chordata,Teleostei,Acanthuriformes,Pomacanthidae,Holacanthus,Species,276012,3609,Species,,,,,,, -Holacanthus ciliaris,Holacanthus ciliaris,Queen angelfish,Animalia,Chordata,Teleostei,Acanthuriformes,Pomacanthidae,Holacanthus,Species,276012,3609,Species,,,,,,, -Holocentridae,Holocentridae,NA,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,NA,Family,125458,NA,Remove,,,,,,, -Holocentrus adscensionis,Holocentrus adscensionis,Squirrelfish,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Holocentrus,Species,159378,1061,Species,,,,,,, -Holocentrus rufus,Holocentrus rufus,Longspine squirrelfish,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Holocentrus,Species,276189,1062,Species,,,,,,, -Holothuria,Holothuria,NA,Animalia,Echinodermata,Holothuroidea,Holothuriida,Holothuriidae,Holothuria,Genus,123456,NA,Remove,,,,,,, -Holothuria occidentalis,Holothuria (Cystipus) occidentalis,NA,Animalia,Echinodermata,Holothuroidea,Holothuriida,Holothuriidae,Holothuria,Species,241826,NA,Species,,,,,,, -Holothuria floridana,Holothuria (Halodeima) floridana,NA,Animalia,Echinodermata,Holothuroidea,Holothuriida,Holothuriidae,Holothuria,Species,210900,NA,Species,,,,,,, -Holothuria surinamensis,Holothuria (Semperothuria) surinamensis,NA,Animalia,Echinodermata,Holothuroidea,Holothuriida,Holothuriidae,Holothuria,Species,241858,NA,Species,,,,,,, -Holothuria princeps,Holothuria (Theelothuria) princeps,NA,Animalia,Echinodermata,Holothuroidea,Holothuriida,Holothuriidae,Holothuria,Species,210890,NA,Species,,,,,,, -Holothuria lentiginosa,Holothuria (Vaneyothuria) lentiginosa,NA,Animalia,Echinodermata,Holothuroidea,Holothuriida,Holothuriidae,Holothuria,Species,123456,NA,Species,,,,,,, -Holothuria lentiginosa enodis,Holothuria (Vaneyothuria) lentiginosa enodis,NA,Animalia,Echinodermata,Holothuroidea,Holothuriida,Holothuriidae,Holothuria,Species,422805,NA,Species,,,,,,, -Holothuriidae,Holothuriidae,Sea cucumbers,Animalia,Echinodermata,Holothuroidea,Holothuriida,Holothuriidae,NA,Family,731943,NA,Remove,,,,,,, -Holothuroidea,Holothuroidea,Sea cucumbers,Animalia,Echinodermata,Holothuroidea,NA,NA,NA,Class,123083,NA,Remove,,,,,,, -Homarus americanus,Homarus americanus,American lobster,Animalia,Arthropoda,Malacostraca,Decapoda,Nephropidae,Homarus,Species,156134,NA,Species,,,,,,, -Homola barbata,Homola barbata,Homole crab,Animalia,Arthropoda,Malacostraca,Decapoda,Homolidae,Homola,Species,107262,NA,Species,,,,,,, -Homolidae,Homolidae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Homolidae,NA,Family,106744,NA,Remove,,,,,,, -Hoplostethus mediterraneus,Hoplostethus mediterraneus,Mediterranean slimehead,Animalia,Chordata,Teleostei,Trachichthyiformes,Trachichthyidae,Hoplostethus,Species,126404,4964,Species,,,,,,, -Hoplostethus occidentalis,Hoplostethus occidentalis,Atlantic roughy,Animalia,Chordata,Teleostei,Trachichthyiformes,Trachichthyidae,Hoplostethus,Species,159415,15670,Species,,,,,,, -Hoplunnis,Hoplunnis,NA,Animalia,Chordata,Teleostei,Anguilliformes,Nettastomatidae,Hoplunnis,Genus,158589,NA,Remove,,,,,,, -Hoplunnis diomedianus,Hoplunnis diomediana,Blacktail pikeconger,Animalia,Chordata,Teleostei,Anguilliformes,Nettastomatidae,Hoplunnis,Species,275443,2621,Species,,,,,,, -Hoplunnis diomediana,Hoplunnis diomediana,Blacktail pikeconger,Animalia,Chordata,Teleostei,Anguilliformes,Nettastomatidae,Hoplunnis,Species,275443,2621,Species,,,,,,, -Hoplunnis macrurus,Hoplunnis macrura,Freckled pike-conger,Animalia,Chordata,Teleostei,Anguilliformes,Nettastomatidae,Hoplunnis,Species,275444,2622,Species,,,,,,, -Hoplunnis macrura,Hoplunnis macrura,Freckled pike-conger,Animalia,Chordata,Teleostei,Anguilliformes,Nettastomatidae,Hoplunnis,Species,275444,2622,Species,,,,,,, -Hoplunnis tenuis,Hoplunnis tenuis,Spotted pike-conger,Animalia,Chordata,Teleostei,Anguilliformes,Nettastomatidae,Hoplunnis,Species,158591,2623,Species,,,,,,, -Hormathiidae,Hormathiidae,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Hormathiidae,NA,Family,100672,NA,Remove,,,,,,, -Hormathiidae a,Hormathiidae sp. A,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Hormathiidae,NA,Species,100672,NA,Species,,,,,,, -Hormathiidae sp. A,Hormathiidae sp. A,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Hormathiidae,NA,Species,100672,NA,Species,,,,,,, -Howella brodiei,Howella brodiei,Pelagic basslet,Animalia,Chordata,Teleostei,Acropomatiformes,Howellidae,Howella,Species,126994,11780,Species,,,,,,, -Howella sherborni,Howella sherborni,Sherborn's pelagic bass,Animalia,Chordata,Teleostei,Acropomatiformes,Howellidae,Howella,Species,126995,5054,Species,,,,,,, -Humilaria kennerleyi,Humilaria kennerleyi,Kennerley venus,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Humilaria,Species,507686,NA,Species,,,,,,, -Hyalonema,Hyalonema,fiber optic sponge,Animalia,Porifera,Hexactinellida,Amphidiscosida,Hyalonematidae,Hyalonema,Genus,132096,NA,Remove,,,,,,, -Hyalonema sp.,Hyalonema,fiber optic sponge,Animalia,Porifera,Hexactinellida,Amphidiscosida,Hyalonematidae,Hyalonema,Genus,132096,NA,Remove,,,,,,, -Hyas,Hyas,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Hyas,Genus,106903,NA,Remove,,,,,,, -Hyas sp.,Hyas,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Hyas,Genus,106903,NA,Remove,,,,,,, -Hyas coarctatus,Hyas coarctatus,Arctic lyre crab,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Hyas,Species,107323,NA,Species,,,,,,, -Hyas lyratus,Hyas lyratus,Pacific lyre crab,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Hyas,Species,442167,NA,Species,,,,,,, -Hydractinia,Hydractinia,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Hydractiniidae,Hydractinia,Genus,117117,NA,Remove,,,,,,, -Hydractinia sp.,Hydractinia,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Hydractiniidae,Hydractinia,Genus,117117,NA,Remove,,,,,,, -Hydroidae,Hydroidae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Hydroidolina,Hydroidolina,Hydroid unid.,Animalia,Cnidaria,Hydrozoa,NA,NA,NA,SubClass,19494,NA,Remove,,,,,,, -Hydrolagus,Hydrolagus,NA,Animalia,Chordata,Holocephali,Chimaeriformes,Chimaeridae,Hydrolagus,Genus,105734,NA,Remove,,,,,,, -Hydrolagus colliei,Hydrolagus colliei,Spotted ratfish,Animalia,Chordata,Holocephali,Chimaeriformes,Chimaeridae,Hydrolagus,Species,271406,2589,Species,,,,,,, -Hydrozoa,Hydrozoa,Hydroids,Animalia,Cnidaria,Hydrozoa,NA,NA,NA,Class,1337,NA,Remove,,,,,,, -Hygophum reinhardtii,Hygophum reinhardtii,Reinhardt's lantern fish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Hygophum,Species,126604,4520,Species,,,,,,, -Hygophum taaningi,Hygophum taaningi,Taning's lanternfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Hygophum,Species,126605,16291,Species,,,,,,, -Hymenaster,Hymenaster,pancake star,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Hymenaster,Genus,123333,NA,Remove,,,,,,, -Hymenaster sp.,Hymenaster,pancake star,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Hymenaster,Genus,123333,NA,Remove,,,,,,, -Hymeniacidon assimilis,Hymeniacidon assimilis,Coalescent finger sponge,Animalia,Porifera,Demospongiae,Suberitida,Halichondriidae,Hymeniacidon,Species,132643,NA,Species,,,,,,, -Brisingella,Hymenodiscus,NA,Animalia,Echinodermata,Asteroidea,Brisingida,Brisingidae,Brisingella,Genus,381753,NA,Remove,,,,,,, -Hymenodiscus sp.,Hymenodiscus,NA,Animalia,Echinodermata,Asteroidea,Brisingida,Brisingidae,Brisingella,Genus,381753,NA,Remove,,,,,,, -Brisingella exilis,Hymenodiscus exilis,NA,Animalia,Echinodermata,Asteroidea,Brisingida,Brisingidae,Brisingella,Species,381763,NA,Species,,,,,,, -Hymenodiscus exilis,Hymenodiscus exilis,NA,Animalia,Echinodermata,Asteroidea,Brisingida,Brisingidae,Brisingella,Species,381763,NA,Species,,,,,,, -Hymenodora frontalis,Hymenodora frontalis,Pacific ambereye,Animalia,Arthropoda,Malacostraca,Decapoda,Acanthephyridae,Hymenodora,Species,514273,NA,Species,,,,,,, -Hypalometra defecta,Hypalometra defecta,NA,Animalia,Echinodermata,Crinoidea,Comatulida,Antedonidae,Hypalometra,Species,422444,NA,Species,,,,,,, -Dasyatis americana,Hypanus americanus,Southern stingray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Dasyatidae,Dasyatis,Species,1042856,1247,Species,,,,,,, -Hypanus americanus,Hypanus americanus,Southern stingray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Dasyatidae,Dasyatis,Species,1042856,1247,Species,,,,,,, -Dasyatis sabina,Hypanus sabinus,Atlantic stingray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Dasyatidae,Dasyatis,Species,1042864,2574,Species,,,,,,, -Hypanus sabinus,Hypanus sabinus,Atlantic stingray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Dasyatidae,Dasyatis,Species,1042864,2574,Species,,,,,,, -Dasyatis say,Hypanus say,Bluntnose stingray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Dasyatidae,Dasyatis,Species,1042865,2575,Species,,,,,,, -Hypanus say,Hypanus say,Bluntnose stingray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Dasyatidae,Dasyatis,Species,1042865,2575,Species,,,,,,, -Hyperoglyphe perciformis,Hyperoglyphe perciformis,Barrelfish,Animalia,Chordata,Teleostei,Scombriformes,Centrolophidae,Hyperoglyphe,Species,126832,3921,Species,,,,,,, -Hyperprosopon anale,Hyperprosopon anale,Spotfin surfperch,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Embiotocidae,Hyperprosopon,Species,281097,3630,Species,,,,,,, -Hypleurochilus,Hypleurochilus,NA,Animalia,Chordata,Teleostei,Blenniiformes,Blenniidae,Hypleurochilus,Genus,159601,NA,Remove,,,,,,, -Hypleurochilus bermudensis,Hypleurochilus bermudensis,Barred blenny,Animalia,Chordata,Teleostei,Blenniiformes,Blenniidae,Hypleurochilus,Species,276312,3758,Species,,,,,,, -Hypleurochilus geminatus,Hypleurochilus geminatus,Crested blenny,Animalia,Chordata,Teleostei,Blenniiformes,Blenniidae,Hypleurochilus,Species,159602,3759,Species,,,,,,, -Hypoconcha,Hypoconcha,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Dromiidae,Hypoconcha,Genus,415498,NA,Remove,,,,,,, -Hypoconcha arcuata,Hypoconcha arcuata,Granulate shellback crab,Animalia,Arthropoda,Malacostraca,Decapoda,Dromiidae,Hypoconcha,Species,1356300,NA,Species,,,,,,, -Hypoconcha sabulosa,Hypoconcha parasitica,Rough shellback crab,Animalia,Arthropoda,Malacostraca,Decapoda,Dromiidae,Hypoconcha,Species,421892,NA,Species,,,,,,, -Hypoconcha parasitica,Hypoconcha parasitica,Rough shellback crab,Animalia,Arthropoda,Malacostraca,Decapoda,Dromiidae,Hypoconcha,Species,421892,NA,Species,,,,,,, -Hypoconcha spinosissima,Hypoconcha spinosissima,Spiny shellback crab,Animalia,Arthropoda,Malacostraca,Decapoda,Dromiidae,Hypoconcha,Species,421893,NA,Species,,,,,,, -Hypomesus pretiosus,Hypomesus pretiosus,Surf smelt,Animalia,Chordata,Teleostei,Osmeriformes,Osmeridae,Hypomesus,Species,279422,255,Species,,,,,,, -Hypoplectrus,Hypoplectrus,NA,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Hypoplectrus,Genus,269456,NA,Remove,,,,,,, -Hypoplectrus floridae,Hypoplectrus floridae,NA,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Hypoplectrus,Species,712604,NA,Species,,,,,,, -Hypoplectrus puella,Hypoplectrus puella,Barred hamlet,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Hypoplectrus,Species,281120,12759,Species,,,,,,, -Hypoplectrus unicolor,Hypoplectrus unicolor,Butter hamlet,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Hypoplectrus,Species,281121,3329,Species,,,,,,, -Hyporhamphus meeki,Hyporhamphus meeki,American halfbeak,Animalia,Chordata,Teleostei,Beloniformes,Hemiramphidae,Hyporhamphus,Species,159280,53540,Species,,,,,,, -Hyporhamphus unifasciatus,Hyporhamphus unifasciatus,Common halfbeak,Animalia,Chordata,Teleostei,Beloniformes,Hemiramphidae,Hyporhamphus,Species,159281,1060,Species,,,,,,, -Epinephelus flavolimbatus,Hyporthodus flavolimbatus,Yellowedge grouper,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Hyporthodus,Species,475077,1205,Species,,,,,,, -Hyporthodus flavolimbatus,Hyporthodus flavolimbatus,Yellowedge grouper,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Hyporthodus,Species,475077,1205,Species,,,,,,, -Epinephelus mystacinus,Hyporthodus mystacinus,Misty grouper,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Epinephelus,Species,475099,1206,Species,,,,,,, -Epinephelus nigritus,Hyporthodus nigritus,Warsaw grouper,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Epinephelus,Species,475100,1207,Species,,,,,,, -Hyporthodus nigritus,Hyporthodus nigritus,Warsaw grouper,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Epinephelus,Species,475100,1207,Species,,,,,,, -Epinephelus niveatus,Hyporthodus niveatus,Snowy grouper,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Hyporthodus,Species,475101,1208,Species,,,,,,, -Hyporthodus niveatus,Hyporthodus niveatus,Snowy grouper,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Hyporthodus,Species,475101,1208,Species,,,,,,, -Hypsagonus quadricornis,Hypsagonus quadricornis,Fourhorn poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Hypsagonus,Species,254508,4164,Species,,,,,,, -Hypselodoris,Hypselodoris,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Chromodorididae,Hypselodoris,Genus,137784,NA,Remove,,,,,,, -Hypsoblennius hentz,Hypsoblennius hentz,Feather blenny,Animalia,Chordata,Teleostei,Blenniiformes,Blenniidae,Hypsoblennius,Species,276325,3763,Species,,,,,,, -Hypsoblennius hentzi,Hypsoblennius hentz,Feather blenny,Animalia,Chordata,Teleostei,Blenniiformes,Blenniidae,Hypsoblennius,Species,276325,3763,Species,,,,,,, -Icelinus,Icelinus,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelinus,Genus,269476,NA,Remove,,,,,,, -Icelinus sp.,Icelinus,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelinus,Genus,269476,NA,Remove,,,,,,, -Icelinus borealis,Icelinus borealis,Northern sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelinus,Species,281133,4099,Species,,,,,,, -Icelinus burchami,Icelinus burchami,Dusky sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelinus,Species,281134,4100,Species,,,,,,, -Icelinus filamentosus,Icelinus filamentosus,Threadfin sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelinus,Species,281136,4102,Species,,,,,,, -Icelinus fimbriatus,Icelinus fimbriatus,Fringed sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelinus,Species,281137,4103,Species,,,,,,, -Icelinus oculatus,Icelinus oculatus,Frogmouth sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelinus,Species,281139,4104,Species,,,,,,, -Icelinus tenuis,Icelinus tenuis,Spotfin sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelinus,Species,281142,4106,Species,,,,,,, -Icelus,Icelus,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelus,Genus,126150,NA,Remove,,,,,,, -Icelus sp.,Icelus,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelus,Genus,126150,NA,Remove,,,,,,, -Icelus canaliculatus,Icelus canaliculatus,Blacknose sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelus,Species,254524,23906,Species,,,,,,, -Icelus euryops,Icelus euryops,Wide-eye sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelus,Species,274379,50794,Species,,,,,,, -Icelus spatula,Icelus spatula,Spatulate sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelus,Species,127200,4108,Species,,,,,,, -Icelus spiniger,Icelus spiniger,Thorny sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelus,Species,254525,4109,Species,,,,,,, -Icelus uncinalis,Icelus uncinalis,Uncinate sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Icelus,Species,274388,51497,Species,,,,,,, -Icichthys lockingtoni,Icichthys lockingtoni,Medusafish,Animalia,Chordata,Teleostei,Scombriformes,Centrolophidae,Icichthys,Species,279354,3922,Species,,,,,,, -Icosteus aenigmaticus,Icosteus aenigmaticus,Ragfish,Animalia,Chordata,Teleostei,Scombriformes,Icosteidae,Icosteus,Species,281153,3929,Species,,,,,,, -Idiacanthus antrostomus,Idiacanthus antrostomus,Pacific blackdragon,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,Idiacanthus,Species,275151,11585,Species,,,,,,, -Idmidronea,Idmidronea,NA,Animalia,Bryozoa,Stenolaemata,Cyclostomatida,Tubuliporidae,Idmidronea,Genus,111052,NA,Remove,,,,,,, -Idmidronea sp.,Idmidronea,NA,Animalia,Bryozoa,Stenolaemata,Cyclostomatida,Tubuliporidae,Idmidronea,Genus,111052,NA,Remove,,,,,,, -Idoteidae,Idoteidae,NA,Animalia,Arthropoda,Malacostraca,Isopoda,Idoteidae,NA,Family,118283,NA,Remove,,,,,,, -Iliacantha,Iliacantha,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Leucosiidae,Iliacantha,Genus,415506,NA,Remove,,,,,,, -Iliacantha liodactylus,Iliacantha liodactylus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Leucosiidae,Iliacantha,Species,421930,NA,Species,,,,,,, -Iliacantha sparsa,Iliacantha sparsa,Shouldered purse crab,Animalia,Arthropoda,Malacostraca,Decapoda,Leucosiidae,Iliacantha,Species,421931,NA,Species,,,,,,, -Iliacantha subglobosa,Iliacantha subglobosa,Longfinger purse crab,Animalia,Arthropoda,Malacostraca,Decapoda,Leucosiidae,Iliacantha,Species,421932,NA,Species,,,,,,, -Illex,Illex,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Ommastrephidae,Illex,Genus,138278,NA,Remove,,,,,,, -Illex illecebrosus,Illex illecebrosus,Northern shortfin squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Ommastrephidae,Illex,Species,153087,NA,Species,,,,,,, -Inachidae,Inachidae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Inachidae,NA,Family,148427,NA,Remove,,,,,,, -Inachoides forceps,Inachoides forceps,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Inachoides,Species,421968,NA,Species,,,,,,, -Inflatella globosa,Inflatella globosa,Yellow ball sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Coelosphaeridae,Inflatella,Species,168899,NA,Species,,,,,,, -Invertebrata,Invertebrata,Invertebrate,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Iphinoe,Iphinoe,NA,Animalia,Arthropoda,Malacostraca,Cumacea,Bodotriidae,Iphinoe,Genus,110391,NA,Remove,,,,,,, -Iphinoe sp.,Iphinoe,NA,Animalia,Arthropoda,Malacostraca,Cumacea,Bodotriidae,Iphinoe,Genus,110391,NA,Remove,,,,,,, -Ircinia,Ircinia,NA,Animalia,Porifera,Demospongiae,Dictyoceratida,Irciniidae,Ircinia,Genus,131751,NA,Remove,,,,,,, -Munida angulata,Iridonida angulata,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Munididae,Munida,Species,1606699,NA,Species,,,,,,, -Munida irrasa,Iridonida irrasa,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Munididae,Munida,Species,1606705,NA,Species,,,,,,, -Munida pusilla,Iridonida pusilla,Common squat lobster,Animalia,Arthropoda,Malacostraca,Decapoda,Munididae,Munida,Species,1606709,NA,Species,,,,,,, -Munida spinifrons,Iridonida spinifrons,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Munididae,Munida,Species,1606716,NA,Species,,,,,,, -Iridopagurus,Iridopagurus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Iridopagurus,Genus,366476,NA,Remove,,,,,,, -Isidella,Isidella,articulated bamboo coral,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Keratoisididae,Isidella,Genus,125305,NA,Remove,,,,,,, -Isidella sp.,Isidella,articulated bamboo coral,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Keratoisididae,Isidella,Genus,125305,NA,Remove,,,,,,, -Isididae,Isididae,Bamboo coral unid.,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Isididae,NA,Family,125276,NA,Remove,,,,,,, -Neoesperiopsis,Isodictya,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Isodictyidae,Neoesperiopsis,Genus,131905,NA,Remove,,,,,,, -Isodictya palmata,Isodictya palmata,Common palmate sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Isodictyidae,Isodictya,Species,133247,NA,Species,,,,,,, -Isodictya rigida,Isodictya rigida,Orange finger sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Isodictyidae,Isodictya,Species,168470,NA,Species,,,,,,, -Isopoda,Isopoda,"Pillbugs slaters, and woodlice",Animalia,Arthropoda,Malacostraca,Isopoda,NA,NA,Order,1131,NA,Remove,,,,,,, -Isopsetta isolepis,Isopsetta isolepis,Butter sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Isopsetta,Species,281189,4242,Species,,,,,,, -Isostichopus,Isostichopus,NA,Animalia,Echinodermata,Holothuroidea,Synallactida,Stichopodidae,Isostichopus,Genus,367867,NA,Remove,,,,,,, -Isostichopus badionotus,Isostichopus badionotus,Chocolate chip sea cucumber,Animalia,Echinodermata,Holothuroidea,Synallactida,Stichopodidae,Isostichopus,Species,367868,NA,Species,,,,,,, -Isurus oxyrinchus,Isurus oxyrinchus,Shortfin mako,Animalia,Chordata,Elasmobranchii,Lamniformes,Lamnidae,Isurus,Species,105839,752,Species,,,,,,, -Janetogalathea californiensis,Janetogalathea californiensis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Munidopsidae,Janetogalathea,Species,392270,NA,Species,,,,,,, -Japelion,Japelion,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Japelion,Genus,490529,NA,Remove,,,,,,, -Japelion sp.,Japelion,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Japelion,Genus,490529,NA,Remove,,,,,,, -Japelion aleutica,Japelion aleutica,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Japelion,Species,490529,NA,Remove,,,,,,, -Japelion sp. A,Japelion sp. A,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Japetella,Japetella,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Amphitretidae,Japetella,Genus,137695,NA,Remove,,,,,,, -Japetella sp.,Japetella,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Amphitretidae,Japetella,Genus,137695,NA,Remove,,,,,,, -Japetella diaphana,Japetella diaphana,Diaphanous pelagic octopod,Animalia,Mollusca,Cephalopoda,Octopoda,Amphitretidae,Japetella,Species,138849,NA,Species,,,,,,, -Japetella heathi,Japetella heathi,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Amphitretidae,Japetella,Species,341790,NA,Species,,,,,,, -Javania,Javania,NA,Animalia,Cnidaria,Anthozoa,Scleractinia,Flabellidae,Javania,Genus,135115,NA,Remove,,,,,,, -Javania sp.,Javania,NA,Animalia,Cnidaria,Anthozoa,Scleractinia,Flabellidae,Javania,Genus,135115,NA,Remove,,,,,,, -Javania borealis,Javania borealis,Aleutian trumpet coral,Animalia,Cnidaria,Anthozoa,Scleractinia,Flabellidae,Javania,Species,287032,NA,Species,,,,,,, -Javania cailleti,Javania cailleti,Caillet's stony coral,Animalia,Cnidaria,Anthozoa,Scleractinia,Flabellidae,Javania,Species,135198,NA,Species,,,,,,, -Jenkinsia lamprotaenia,Jenkinsia lamprotaenia,Dwarf round herring,Animalia,Chordata,Teleostei,Clupeiformes,Spratelloididae,Jenkinsia,Species,281198,1461,Species,,,,,,, -Jordania zonope,Jordania zonope,Longfin sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Jordania,Species,398459,4110,Species,,,,,,, -Tetrapturus albidus,Kajikia albida,Atlantic white marlin,Animalia,Chordata,Teleostei,Carangiformes,Istiophoridae,Tetrapturus,Species,712906,219,Species,,,,,,, -Kali indica,Kali indica,NA,Animalia,Chordata,Teleostei,Scombriformes,Chiasmodontidae,Kali,Species,159666,16919,Species,,,,,,, -Kali normani,Kali kerberti,NA,Animalia,Chordata,Teleostei,Scombriformes,Chiasmodontidae,Kali,Species,302801,65579,Species,,,,,,, -Eucrassatella speciosa,Kalolophus speciosus,Beautiful crassatella,Animalia,Mollusca,Bivalvia,Carditida,Crassatellidae,Eucrassatella,Species,884192,NA,Species,,,,,,, -Kalolophus speciosus,Kalolophus speciosus,Beautiful crassatella,Animalia,Mollusca,Bivalvia,Carditida,Crassatellidae,Eucrassatella,Species,884192,NA,Species,,,,,,, -Kathetostoma albigutta,Kathetostoma albigutta,Lancer stargazer,Animalia,Chordata,Teleostei,Perciformes,Uranoscopidae,Kathetostoma,Species,159255,3706,Species,,,,,,, -Kathetostoma averruncus,Kathetostoma averruncus,Smooth stargazer,Animalia,Chordata,Teleostei,Perciformes,Uranoscopidae,Kathetostoma,Species,275989,3707,Species,,,,,,, -Clinocardium blandum,Keenocardium blandum,Low rib cockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Clinocardium,Species,381984,NA,Species,,,,,,, -Keenocardium blandum,Keenocardium blandum,Low rib cockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Clinocardium,Species,381984,NA,Species,,,,,,, -Clinocardium californiense,Keenocardium californiense californiense,Aleutian cockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Clinocardium,Species,381990,NA,Species,,,,,,, -Keenocardium californiense californiense,Keenocardium californiense californiense,Aleutian cockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Clinocardium,Species,381990,NA,Species,,,,,,, -Kellia laperousii,Kellia laperousii,Suborbicular kellyclam,Animalia,Mollusca,Bivalvia,Galeommatida,Lasaeidae,Kellia,Species,592764,NA,Species,,,,,,, -Keratoisis,Keratoisis,nodal bamboo coral unid.,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Keratoisididae,Keratoisis,Genus,125306,NA,Remove,,,,,,, -Keratoisis sp.,Keratoisis,nodal bamboo coral unid.,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Keratoisididae,Keratoisis,Genus,125306,NA,Remove,,,,,,, -Kyphosus incisor,Kyphosus incisor,Yellow sea chub,Animalia,Chordata,Teleostei,Centrarchiformes,Kyphosidae,Kyphosus,Species,126955,1064,Species,,,,,,, -Labidochirus splendescens,Labidochirus splendescens,Splendid hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Labidochirus,Species,248348,NA,Species,,,,,,, -Labridae,Labridae,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,NA,Family,125541,NA,Remove,,,,,,, -Labrisomus nuchipinnis,Labrisomus nuchipinnis,Hairy blenny,Animalia,Chordata,Teleostei,Blenniiformes,Labrisomidae,Labrisomus,Species,281260,3735,Species,,,,,,, -Lachnolaimus maximus,Lachnolaimus maximus,Hogfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Lachnolaimus,Species,158822,1071,Species,,,,,,, -Lactophrys trigonus,Lactophrys trigonus,Buffalo trunkfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Ostraciidae,Lactophrys,Species,158931,1107,Species,,,,,,, -Lactophrys triqueter,Lactophrys triqueter,Smooth trunkfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Ostraciidae,Lactophrys,Species,158932,1109,Species,,,,,,, -Laemonema barbatulum,Laemonema barbatulum,Shortbeard codling,Animalia,Chordata,Teleostei,Gadiformes,Moridae,Laemonema,Species,158979,28218,Species,,,,,,, -Laevicardium,Laevicardium,NA,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Laevicardium,Genus,137738,NA,Remove,,,,,,, -Laevicardium mortoni,Laevicardium mortoni,Yellow eggcockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Laevicardium,Species,156782,NA,Species,,,,,,, -Laevicardium pictum,Laevicardium pictum,Painted eggcockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Laevicardium,Species,381792,NA,Species,,,,,,, -Laevicardium serratum,Laevicardium serratum,NA,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Laevicardium,Species,381803,NA,Species,,,,,,, -Laevicardium sybariticum,Laevicardium sybariticum,Delicate eggcockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Laevicardium,Species,381769,NA,Species,,,,,,, -Lagocephalus,Lagocephalus,NA,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Lagocephalus,Genus,126240,NA,Remove,,,,,,, -Lagocephalus laevigatus,Lagocephalus laevigatus,Smooth puffer,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Lagocephalus,Species,158933,1239,Species,,,,,,, -Lagodon rhomboides,Lagodon rhomboides,Pinfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Lagodon,Species,159249,3576,Species,,,,,,, -Lamarcka imbricata,Lamarcka imbricata,NA,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Lamarcka,Species,1548267,NA,Species,,,,,,, -Lamellaria,Lamellaria,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Lamellaria,Genus,138101,NA,Remove,,,,,,, -Lamellaria sp.,Lamellaria,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Lamellaria,Genus,138101,NA,Remove,,,,,,, -Lamellaria sp. B (Clark and McLean),Lamellaria sp. B (Clark and McLean),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Lamellaria sp. C (Clark and McLean),Lamellaria sp. C (Clark and McLean),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Lamellaria sp. D (Clark and McLean),Lamellaria sp. D (Clark and McLean),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Lamellaria sp. F (McLean and Clark),Lamellaria sp. F (McLean and Clark),white lamellarid,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Lamellariidae,Lamellariinae,Lamellarid unid.,Animalia,Mollusca,Gastropoda,Littorinimorpha,Lamellariidae,NA,Family,224918,NA,Remove,,,,,,, -Lamellariinae,Lamellariinae,Lamellarid unid.,Animalia,Mollusca,Gastropoda,Littorinimorpha,Lamellariidae,NA,Family,224918,NA,Remove,,,,,,, -Lamna ditropis,Lamna ditropis,Salmon shark,Animalia,Chordata,Elasmobranchii,Lamniformes,Lamnidae,Lamna,Species,271421,755,Species,,,,,,, -Lamna nasus,Lamna nasus,Porbeagle,Animalia,Chordata,Elasmobranchii,Lamniformes,Lamnidae,Lamna,Species,105841,88,Species,,,,,,, -Lampanyctus,Lampanyctus,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Lampanyctus,Genus,125825,NA,Remove,,,,,,, -Lampanyctus sp.,Lampanyctus,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Lampanyctus,Genus,125825,NA,Remove,,,,,,, -Lampanyctus jordani,Lampanyctus jordani,Brokenline lanternfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Lampanyctus,Species,272712,23003,Species,,,,,,, -Lampanyctus regalis,Lampanyctus regalis,Pinpoint lampfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Lampanyctus,Species,301545,2734,Species,,,,,,, -Nannobrachium regale,Lampanyctus regalis,Pinpoint lampfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Lampanyctus,Species,301545,2734,Species,,,,,,, -Lampanyctus ritteri,Lampanyctus ritteri,Broadfin lampfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Lampanyctus,Species,301548,5371,Species,,,,,,, -Nannobrachium ritteri,Lampanyctus ritteri,Broadfin lampfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Lampanyctus,Species,301548,5371,Species,,,,,,, -Lampetra ayresii,Lampetra ayresii,Western river lamprey,Animalia,Chordata,Petromyzonti,Petromyzontiformes,Petromyzontidae,Lampetra,Species,271316,2522,Species,,,,,,, -Lamprogrammus niger,Lamprogrammus niger,NA,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Lamprogrammus,Species,126672,8974,Species,,,,,,, -Laqueus californianus,Laqueus erythraeus,California lamp shell,Animalia,Brachiopoda,Rhynchonellata,Terebratulida,Laqueidae,Laqueus,Species,235590,NA,Species,,,,,,, -Laqueus erythraeus,Laqueus erythraeus,California lamp shell,Animalia,Brachiopoda,Rhynchonellata,Terebratulida,Laqueidae,Laqueus,Species,235590,NA,Species,,,,,,, -Laqueus vancouverensis,Laqueus vancouveriensis,California lamp shell,Animalia,Brachiopoda,Rhynchonellata,Terebratulida,Laqueidae,Laqueus,Species,235595,NA,Species,,,,,,, -Laqueus vancouveriensis,Laqueus vancouveriensis,California lamp shell,Animalia,Brachiopoda,Rhynchonellata,Terebratulida,Laqueidae,Laqueus,Species,235595,NA,Species,,,,,,, -Larimus fasciatus,Larimus fasciatus,Banded drum,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Larimus,Species,159320,1182,Species,,,,,,, -Colus aphelus,Latisipho aphelus,Oblique whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,491057,NA,Species,,,,,,, -Latisipho aphelus,Latisipho aphelus,Oblique whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,491057,NA,Species,,,,,,, -Colus halli,Latisipho hallii,Shrew whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,491061,NA,Species,,,,,,, -Latisipho hallii,Latisipho hallii,Shrew whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,491061,NA,Species,,,,,,, -Colus hypolispus,Latisipho hypolispus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,491062,NA,Species,,,,,,, -Latisipho hypolispus,Latisipho hypolispus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,491062,NA,Species,,,,,,, -Colus jordani,Latisipho jordani,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,576315,NA,Species,,,,,,, -Latisipho jordani,Latisipho jordani,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,576315,NA,Species,,,,,,, -Latrunculia sp.,Latrunculia,NA,NA,NA,NA,NA,NA,NA,Genus,NA,NA,Remove,,,,,,, -Latrunculia,Latrunculia (Latrunculia),NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Latrunculiidae,Latrunculia,Genus,231637,NA,Remove,,,,,,, -Latrunculia oparinae,Latrunculia (Uniannulata) oparinae,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Latrunculiidae,Latrunculia,Species,880531,NA,Species,,,,,,, -Latrunculia sp. B (Clark 2006),Latrunculia sp. B (Clark 2006),smooth green sponge,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Leander tenuicornis,Leander tenuicornis,Brown grass shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Palaemonidae,Leander,Species,107612,NA,Species,,,,,,, -Lebbeus,Lebbeus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Lebbeus,Genus,106989,NA,Remove,,,,,,, -Lebbeus sp.,Lebbeus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Lebbeus,Genus,106989,NA,Remove,,,,,,, -Lebbeus grandimanus,Lebbeus grandimanus,Candy striped shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Lebbeus,Species,514541,NA,Species,,,,,,, -Lebbeus groenlandicus,Lebbeus groenlandicus,Spiny lebbeid,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Lebbeus,Species,107520,NA,Species,,,,,,, -Lebbeus polaris,Lebbeus polaris,Polar lebbeid,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Lebbeus,Species,107521,NA,Species,,,,,,, -Lebbeus washingtonianus,Lebbeus washingtonianus,Slope lebbeid,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Lebbeus,Species,378108,NA,Species,,,,,,, -Myriapora subgracilis,Leieschara subgracilis,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Myriaporidae,Myriapora,Species,865151,NA,Species,,,,,,, -Leieschara subgracilis,Leieschara subgracilis,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Myriaporidae,Myriapora,Species,865151,NA,Species,,,,,,, -Leiolambrus,Leiolambrus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Leiolambrus,Genus,415548,NA,Remove,,,,,,, -Leiolambrus granulosus,Leiolambrus granulosus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Leiolambrus,Species,415548,NA,Species,,,,,,, -Leiolambrus nitidus,Leiolambrus nitidus,White elbow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Leiolambrus,Species,422024,NA,Species,,,,,,, -Leiostomus xanthurus,Leiostomus xanthurus,Spot,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Leiostomus,Species,159322,429,Species,,,,,,, -Mellita sexiesperforata,Leodia sexiesperforata,Six holed keyhole urchin,Animalia,Echinodermata,Echinoidea,Echinolampadacea,Mellitidae,Leodia,Species,422502,NA,Species,,,,,,, -Leodia sexiesperforata,Leodia sexiesperforata,Six holed keyhole urchin,Animalia,Echinodermata,Echinoidea,Echinolampadacea,Mellitidae,Leodia,Species,422502,NA,Species,,,,,,, -Eunice valens,Leodice valens,White banded bobbit worm,Animalia,Annelida,Polychaeta,Eunicida,Eunicidae,Eunice,Species,336700,NA,Species,,,,,,, -Leodice valens,Leodice valens,White banded bobbit worm,Animalia,Annelida,Polychaeta,Eunicida,Eunicidae,Eunice,Species,336700,NA,Species,,,,,,, -Euvola diegensis,Leopecten diegensis,San diego scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Euvola,Species,394087,NA,Species,,,,,,, -Lepas,Lepas,Goose barnacles,Animalia,Arthropoda,Thecostraca,Scalpellomorpha,Lepadidae,Lepas,Genus,106087,NA,Remove,,,,,,, -Lepas sp.,Lepas,Goose barnacles,Animalia,Arthropoda,Thecostraca,Scalpellomorpha,Lepadidae,Lepas,Genus,106087,NA,Remove,,,,,,, -Lepeta,Lepeta,NA,Animalia,Mollusca,Gastropoda,NA,Lepetidae,Lepeta,Genus,138111,NA,Remove,,,,,,, -Lepidochelys kempi,Lepidochelys kempii,Kemp's ridley turtle,Animalia,Chordata,NA,Testudines,Cheloniidae,Lepidochelys,Species,137208,NA,Remove,,,,,,, -Lepidochelys kempii,Lepidochelys kempii,Kemp's ridley turtle,Animalia,Chordata,NA,Testudines,Cheloniidae,Lepidochelys,Species,137208,NA,Remove,,,,,,, -Lepidocybium flavobrunneum,Lepidocybium flavobrunneum,Escolar,Animalia,Chordata,Teleostei,Scombriformes,Gempylidae,Lepidocybium,Species,126863,1042,Species,,,,,,, -Lepidophanes,Lepidophanes,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Lepidophanes,Genus,125826,NA,Remove,,,,,,, -Lepidopsetta sp.,Lepidopsetta sp.,Rock soles,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Lepidopsetta,Species,269638,NA,Species,,,,,,, -Lepidopsetta bilineata,Lepidopsetta bilineata,Southern rock sole,NA,NA,NA,NA,NA,NA,Species,281305,NA,Species,,,,,,, -Lepidopsetta polyxystra,Lepidopsetta polyxystra,Northern rock sole,NA,NA,NA,NA,NA,NA,Species,281307,NA,Species,,,,,,, -Lepidopsetta,Lepidopsetta sp.,Rock soles,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Lepidopsetta,Species,269638,NA,Species,,,,,,, -Lepidopus xantusi,Lepidopus caudatus,Silver scabbardfish,Animalia,Chordata,Teleostei,Scombriformes,Trichiuridae,Lepidopus,Species,127088,645,Species,,,,,,, -Lepidopus fitchi,Lepidopus fitchi,Pacific scabbardfish,Animalia,Chordata,Teleostei,Scombriformes,Trichiuridae,Lepidopus,Species,274018,3910,Species,,,,,,, -Lepidozona,Lepidozona,NA,Animalia,Mollusca,Polyplacophora,Chitonida,Ischnochitonidae,Lepidozona,Genus,204533,NA,Remove,,,,,,, -Lepidozona sp.,Lepidozona,NA,Animalia,Mollusca,Polyplacophora,Chitonida,Ischnochitonidae,Lepidozona,Genus,204533,NA,Remove,,,,,,, -Lepophidium,Lepophidium,NA,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Lepophidium,Genus,158761,NA,Remove,,,,,,, -Lepophidium brevibarbe,Lepophidium brevibarbe,Blackedge cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Lepophidium,Species,275619,7553,Species,,,,,,, -Lepophidium crossotum,Lepophidium crossotum,NA,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Lepophidium,Species,834928,NA,Species,,,,,,, -Lepophidium entomelan,Lepophidium entomelan,Blackthroat cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Lepophidium,Species,834930,66839,Species,,,,,,, -Lepophidium jeannae,Lepophidium jeannae,Mottled cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Lepophidium,Species,159138,3110,Species,,,,,,, -Lepophidium profundorum,Lepophidium profundorum,Fawn cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Lepophidium,Species,158762,5420,Species,,,,,,, -Lepophidium staurophor,Lepophidium staurophor,Barred cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Lepophidium,Species,275627,12046,Species,,,,,,, -Leptagonus,Leptagonus,NA,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Leptagonus,Genus,126145,NA,Remove,,,,,,, -Leptagonus sp.,Leptagonus,NA,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Leptagonus,Genus,126145,NA,Remove,,,,,,, -Leptagonus decagonus,Leptagonus decagonus,Atlantic poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Leptagonus,Species,127191,4154,Species,,,,,,, -Leptasterias,Leptasterias,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Genus,123222,NA,Remove,,,,,,, -Leptasterias sp.,Leptasterias,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Genus,123222,NA,Remove,,,,,,, -Leptasterias camtschatica,Leptasterias (Hexasterias) camtschatica,Kamchatha six-rayed star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Species,369160,NA,Species,,,,,,, -Leptasterias coei,Leptasterias (Hexasterias) coei,Coe's six-rayed star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Species,369163,NA,Species,,,,,,, -Leptasterias polaris,Leptasterias (Hexasterias) polaris,Polar six-rayed star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Species,125154,NA,Species,,,,,,, -Leptasterias arctica,Leptasterias arctica,Arctic star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Species,369158,NA,Species,,,,,,, -Leptasterias truculenta,Leptasterias coei truculenta,Giant Aleutian six-rayed star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Species,123222,NA,Species,,,,,,, -Leptasterias coei truculenta,Leptasterias coei truculenta,Giant Aleutian six-rayed star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Species,123222,NA,Species,,,,,,, -Leptasterias groenlandica,Leptasterias groenlandica,Greenland star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Species,369176,NA,Species,,,,,,, -Leptasterias hexactis,Leptasterias hexactis,Delicate six-rayed star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Species,369177,NA,Species,,,,,,, -Leptasterias hylodes,Leptasterias hylodes,Aleutian star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Species,379714,NA,Species,,,,,,, -Leptasterias katharinae,Leptasterias katharinae,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Species,123222,NA,Species,,,,,,, -Leptasterias polaris katherinae,Leptasterias polaris katherinae,NA,NA,NA,NA,NA,NA,NA,subSpecies,379157,NA,subSpecies,,,,,,, -Leptasterias stolocantha,Leptasterias stolacantha,Rough skirted star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Species,379742,NA,Species,,,,,,, -Leptasterias stolacantha,Leptasterias stolacantha,Rough skirted star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Leptasterias,Species,379742,NA,Species,,,,,,, -Leptocephalus,Leptocephalus,Eel larvae,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Leptocephalus,Genus,843624,NA,Remove,,,,,,, -Leptochela,Leptochela,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pasiphaeidae,Leptochela,Genus,107050,NA,Remove,,,,,,, -Leptochela carinata,Leptochela carinata,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pasiphaeidae,Leptochela,Species,585682,NA,Species,,,,,,, -Leptochiton,Leptochiton,NA,Animalia,Mollusca,Polyplacophora,Lepidopleurida,Leptochitonidae,Leptochiton,Genus,138117,NA,Remove,,,,,,, -Leptochiton sp.,Leptochiton,NA,Animalia,Mollusca,Polyplacophora,Lepidopleurida,Leptochitonidae,Leptochiton,Genus,138117,NA,Remove,,,,,,, -Leptoclinus maculatus,Leptoclinus maculatus,Daubed shanny,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Leptoclinus,Species,127072,3788,Species,,,,,,, -Lumpenus maculatus,Leptoclinus maculatus,Daubed shanny,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Leptoclinus,Species,127072,3788,Species,,,,,,, -Leptocottus armatus,Leptocottus armatus,Pacific staghorn sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Leptocottus,Species,254345,4112,Species,,,,,,, -Leptodius,Leptodius,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Xanthidae,Leptodius,Genus,206884,NA,Remove,,,,,,, -Leptogorgia,Leptogorgia,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Gorgoniidae,Leptogorgia,Genus,125302,NA,Remove,,,,,,, -Leptogorgia chilensis,Leptogorgia chilensis,Red gorgonian,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Gorgoniidae,Leptogorgia,Species,286222,NA,Species,,,,,,, -Leptogorgia virgulata,Leptogorgia virgulata,Colorful sea whip,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Gorgoniidae,Leptogorgia,Species,158288,NA,Species,,,,,,, -Leptychaster,Leptychaster,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Leptychaster,Genus,123250,NA,Remove,,,,,,, -Leptychaster sp.,Leptychaster,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Leptychaster,Genus,123250,NA,Remove,,,,,,, -Leptychaster anomalus,Leptychaster anomalus,Pentagonal sand star,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Leptychaster,Species,368318,NA,Species,,,,,,, -Leptychaster arcticus,Leptychaster arcticus,Arctic sand star,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Leptychaster,Species,123896,NA,Species,,,,,,, -Leptychaster pacificus,Leptychaster pacificus,Pale star,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Leptychaster,Species,368322,NA,Species,,,,,,, -Lestidiops ringens,Lestidiops ringens,Slender barracudina,Animalia,Chordata,Teleostei,Aulopiformes,Paralepididae,Lestidiops,Species,272096,11599,Species,,,,,,, -Letharchus velifer,Letharchus velifer,Sailfin eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Letharchus,Species,158633,2648,Species,,,,,,, -Lethasterias,Lethasterias,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Lethasterias,Genus,178798,NA,Remove,,,,,,, -Lethasterias sp.,Lethasterias,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Lethasterias,Genus,178798,NA,Remove,,,,,,, -Lethasterias nanimensis,Lethasterias nanimensis,Black spined sea star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Lethasterias,Species,254499,NA,Species,,,,,,, -Lethotremus,Lethotremus,NA,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Lethotremus,Genus,254346,NA,Remove,,,,,,, -Lethotremus sp.,Lethotremus,NA,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Lethotremus,Genus,254346,NA,Remove,,,,,,, -Lethotremus muticus,Lethotremus muticus,Docked snailfish,Animalia,Chordata,Teleostei,Perciformes,Cyclopteridae,Lethotremus,Species,254348,50770,Species,,,,,,, -Leucandra,Leucandra,NA,Animalia,Porifera,Calcarea,Leucosolenida,Grantiidae,Leucandra,Genus,131704,NA,Remove,,,,,,, -Leucandra sp.,Leucandra,NA,Animalia,Porifera,Calcarea,Leucosolenida,Grantiidae,Leucandra,Genus,131704,NA,Remove,,,,,,, -Leucandra heathi,Leucandra heathi,Bristly case sponge,Animalia,Porifera,Calcarea,Leucosolenida,Grantiidae,Leucandra,Species,164324,NA,Species,,,,,,, -Leucandra sp. A (Clark 2006),Leucandra sp. A (Clark 2006),hairy vase sponge,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Leucandra tuba,Leucandra tuba,NA,Animalia,Porifera,Calcarea,Leucosolenida,Grantiidae,Leucandra,Species,164392,NA,Species,,,,,,, -Leucilla nuttingi,Leucilla nuttingi,NA,NA,NA,NA,NA,NA,NA,Species,164219,NA,Species,,,,,,, -Leucoraja erinacea,Leucoraja erinaceus,Little skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Leucoraja,Species,1577339,2557,Species,,,,,,, -Leucoraja garmani,Leucoraja garmani,Rosette skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Leucoraja,Species,158552,1253,Species,,,,,,, -Raja garmani,Leucoraja garmani,Rosette skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Leucoraja,Species,158552,1253,Species,,,,,,, -Raja lentiginosa,Leucoraja lentiginosa,Freckled skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Species,271564,11877,Species,,,,,,, -Leucoraja lentiginosa,Leucoraja lentiginosa,Freckled skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Species,271564,11877,Species,,,,,,, -Leucoraja ocellata,Leucoraja ocellata,Winter skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Leucoraja,Species,158553,2562,Species,,,,,,, -Leucosiidae,Leucosiidae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Leucosiidae,NA,Family,106758,NA,Remove,,,,,,, -Leucosolenia,Leucosolenia,Branching ball-sponge,Animalia,Porifera,Calcarea,Leucosolenida,Leucosoleniidae,Leucosolenia,Genus,131715,NA,Remove,,,,,,, -Leucosolenia sp.,Leucosolenia,Branching ball-sponge,Animalia,Porifera,Calcarea,Leucosolenida,Leucosoleniidae,Leucosolenia,Genus,131715,NA,Remove,,,,,,, -Leukoma staminea,Leukoma staminea,Pacific littleneck,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Leukoma,Species,507737,NA,Species,,,,,,, -Leuroglossus,Leuroglossus,NA,Animalia,Chordata,Teleostei,Argentiniformes,Bathylagidae,Leuroglossus,Genus,254349,NA,Remove,,,,,,, -Leuroglossus sp.,Leuroglossus,NA,Animalia,Chordata,Teleostei,Argentiniformes,Bathylagidae,Leuroglossus,Genus,254349,NA,Remove,,,,,,, -Leuroglossus schmidti,Leuroglossus schmidti,Northern smoothtongue,Animalia,Chordata,Teleostei,Argentiniformes,Bathylagidae,Leuroglossus,Species,254551,9462,Species,,,,,,, -Leuroglossus stilbius,Leuroglossus stilbius,California smoothtongue,Animalia,Chordata,Teleostei,Argentiniformes,Bathylagidae,Leuroglossus,Species,313514,2703,Species,,,,,,, -Libinia,Libinia,Spider crabs,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Libinia,Genus,106906,NA,Remove,,,,,,, -Libinia dubia,Libinia dubia,Longnose spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Libinia,Species,107335,NA,Species,,,,,,, -Libinia emarginata,Libinia emarginata,Portly spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Libinia,Species,158426,NA,Species,,,,,,, -Lillipathes,Lillipathes,NA,Animalia,Cnidaria,Anthozoa,Antipatharia,Schizopathidae,Lillipathes,Genus,267553,NA,Remove,,,,,,, -Lillipathes lilliei,Lillipathes lillei,NA,Animalia,Cnidaria,Anthozoa,Antipatharia,Schizopathidae,Lillipathes,Species,290291,NA,Species,,,,,,, -Lillipathes lillei,Lillipathes lillei,NA,Animalia,Cnidaria,Anthozoa,Antipatharia,Schizopathidae,Lillipathes,Species,290291,NA,Species,,,,,,, -Lillipathes sp. A (Clark 2006),Lillipathes sp. A (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Lillipathes sp. B (Clark 2006),Lillipathes sp. B (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Lima,Lima,NA,Animalia,Mollusca,Bivalvia,Limida,Limidae,Lima,Genus,138125,NA,Remove,,,,,,, -Limanda aspera,Limanda aspera,Yellowfin sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Limanda,Species,254562,520,Species,,,,,,, -Limanda sakhalinensis,Limanda sakhalinensis,Sakhalin sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Limanda,Species,274292,50421,Species,,,,,,, -Limaria,Limaria,NA,Animalia,Mollusca,Bivalvia,Limida,Limidae,Limaria,Genus,138126,NA,Remove,,,,,,, -Lima pellucida,Limaria pellucida,NA,Animalia,Mollusca,Bivalvia,Limida,Limidae,Lima,Species,420751,NA,Species,,,,,,, -Limaria pellucida,Limaria pellucida,NA,Animalia,Mollusca,Bivalvia,Limida,Limidae,Lima,Species,420751,NA,Species,,,,,,, -Limatula,Limatula,NA,Animalia,Mollusca,Bivalvia,Limida,Limidae,Limatula,Genus,138127,NA,Remove,,,,,,, -Limatula sp. A (Clark and McLean),Limatula sp. A (Clark and McLean),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Limneria prolongata,Limneria prolongata,Elongate lamellaria,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Limneria,Species,557157,NA,Species,,,,,,, -Velutina prolongata,Limneria prolongata,Elongate lamellaria,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Limneria,Species,557157,NA,Species,,,,,,, -Velutina undata,Limneria undata,Wavy lamellaria,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Velutina,Species,159903,NA,Species,,,,,,, -Limneria undata,Limneria undata,Wavy lamellaria,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Velutina,Species,159903,NA,Species,,,,,,, -Limopsis akutanica,Limopsis akutanica,Akutan limops,Animalia,Mollusca,Bivalvia,Arcida,Limopsidae,Limopsis,Species,504595,NA,Species,,,,,,, -Empleconia vaginata,Limopsis vaginata,Vaginate limops,Animalia,Mollusca,Bivalvia,Arcida,Limopsidae,Empleconia,Species,504591,NA,Species,,,,,,, -Limopsis vaginata,Limopsis vaginata,Vaginate limops,Animalia,Mollusca,Bivalvia,Arcida,Limopsidae,Empleconia,Species,504591,NA,Species,,,,,,, -Limulus polyphemus,Limulus polyphemus,Horseshoe crab,Animalia,Arthropoda,Merostomata,Xiphosurida,Limulidae,Limulus,Species,150514,NA,Species,,,,,,, -Linckia nodosoa,Linckia nodosa,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Ophidiasteridae,Linckia,Species,178189,NA,Species,,,,,,, -Linckia nodosa,Linckia nodosa,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Ophidiasteridae,Linckia,Species,178189,NA,Species,,,,,,, -Busycon candelabrum,Lindafulgur candelabrum,Splendid whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862940,NA,Species,,,,,,, -Lindafulgur candelabrum,Lindafulgur candelabrum,Splendid whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862940,NA,Species,,,,,,, -Busycon lyonsi,Lindafulgur lyonsi,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862942,NA,Species,,,,,,, -Lindafulgur lyonsi,Lindafulgur lyonsi,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862942,NA,Species,,,,,,, -Aequipecten muscosus,Lindapecten muscosus,Mossy scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Aequipecten,Species,393783,NA,Species,,,,,,, -Lindapecten muscosus,Lindapecten muscosus,Mossy scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Aequipecten,Species,393783,NA,Species,,,,,,, -Liocyma fluctosa,Liocyma fluctuosa,Wavy liocyma,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Liocyma,Species,141918,NA,Species,,,,,,, -Liocyma fluctuosa,Liocyma fluctuosa,Wavy liocyma,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Liocyma,Species,141918,NA,Species,,,,,,, -Liomesus,Liomesus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Liomesus,Genus,137708,NA,Remove,,,,,,, -Liomesus sp.,Liomesus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Liomesus,Genus,137708,NA,Remove,,,,,,, -Liopsetta glacialis,Liopsetta glacialis,Arctic flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Liopsetta,Species,275844,4244,Species,,,,,,, -Liparidae,Liparidae,Snailfishes,Animalia,Chordata,Teleostei,Perciformes,Liparidae,NA,Family,234519,NA,Remove,,,,,,, -Liparidae n. gen. (orr),Liparidae,Snailfishes,Animalia,Chordata,Teleostei,Perciformes,Liparidae,NA,Family,234519,NA,Remove,,,,,,, -Liparis,Liparis,Snailfishes,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Genus,126160,NA,Remove,,,,,,, -Liparis sp.,Liparis,Snailfishes,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Genus,126160,NA,Remove,,,,,,, -Liparis atlanticus,Liparis atlanticus,Atlantic seasnail,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Species,159524,4186,Species,,,,,,, -Liparis bathyarcticus,Liparis bathyarcticus,Nebulous snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Species,867958,67552,Species,,,,,,, -Liparis bristolensis,Liparis bristolensis,Bristol snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Species,254546,51426,Species,,,,,,, -Liparis callyodon,Liparis callyodon,Spotted snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Species,274505,4187,Species,,,,,,, -Liparis dennyi,Liparis dennyi,Marbled snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Species,254550,4191,Species,,,,,,, -Liparis fucensis,Liparis fucensis,Slipskin snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Species,274515,4193,Species,,,,,,, -Liparis gibbus,Liparis gibbus,Variegated snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Species,159526,4190,Species,,,,,,, -Liparis inquilinus,Liparis inquilinus,Inquiline snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Species,159528,4195,Species,,,,,,, -Liparis marmoratus,Liparis marmoratus,Festive snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Species,274522,51429,Species,,,,,,, -Liparis ochotensis,Liparis ochotensis,Okhotsk snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Species,274529,24113,Species,,,,,,, -Liparis pulchellus,Liparis pulchellus,Showy snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Species,274533,4198,Species,,,,,,, -Liparis tunicatus,Liparis tunicatus,Kelp snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Liparis,Species,154825,4200,Species,,,,,,, -Lipariscus nanus,Lipariscus nanus,Pygmy snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Lipariscus,Species,281365,24134,Species,,,,,,, -Bathylagus ochotensis,Lipolagus ochotensis,Eared blacksmelt,Animalia,Chordata,Teleostei,Argentiniformes,Bathylagidae,Bathylagus,Species,281374,12542,Species,,,,,,, -Lipolagus ochotensis,Lipolagus ochotensis,Eared blacksmelt,Animalia,Chordata,Teleostei,Argentiniformes,Bathylagidae,Bathylagus,Species,281374,12542,Species,,,,,,, -Liponema brevicorne,Liponema brevicorne,Tentacle shedding anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Liponematidae,Liponema,Species,593074,NA,Species,,,,,,, -Liponema brevicornis,Liponema brevicorne,Tentacle shedding anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Liponematidae,Liponema,Species,593074,NA,Species,,,,,,, -Lironeca,Lironeca,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Lirophora,Lirophora,NA,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Lirophora,Genus,415572,NA,Remove,,,,,,, -Chione latilirata,Lirophora latilirata,NA,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Chione,Species,420942,NA,Species,,,,,,, -Lirophora latilirata,Lirophora latilirata,NA,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Chione,Species,420942,NA,Species,,,,,,, -Chione clenchii,Lirophora obliterata,Clench venus,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Chione,Species,507762,NA,Species,,,,,,, -Lirophora clenchi,Lirophora obliterata,Clench venus,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Lirophora,Species,507762,NA,Species,,,,,,, -Lirophora obliterata,Lirophora obliterata,Clench venus,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Lirophora,Species,507762,NA,Species,,,,,,, -Lissocrangon stylirostris,Lissocrangon stylirostris,Smooth bay shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Lissocrangon,Species,515555,NA,Species,,,,,,, -Lithodes,Lithodes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Lithodes,Genus,106845,NA,Remove,,,,,,, -Lithodes sp.,Lithodes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Lithodes,Genus,106845,NA,Remove,,,,,,, -Lithodes aequispinus,Lithodes aequispinus,Golden king crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Lithodes,Species,550622,NA,Species,,,,,,, -Lithodes couesi,Lithodes couesi,Scarlet king crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Lithodes,Species,550625,NA,Species,,,,,,, -Lithodes maja,Lithodes maja,Norway king crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Lithodes,Species,107205,NA,Species,,,,,,, -Lithodidae,Lithodidae,Stone crabs and king crabs,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,NA,Family,106737,NA,Remove,,,,,,, -Lithophaga,Lithophaga,NA,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Lithophaga,Genus,138220,NA,Remove,,,,,,, -Lithophaga antillarum,Lithophaga antillarum,Giant datemussel,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Lithophaga,Species,420702,NA,Species,,,,,,, -Astrea americana,Lithopoma americanum,American star snail,Animalia,Mollusca,Gastropoda,Trochida,Turbinidae,Astraea,Species,413407,NA,Species,,,,,,, -Lithopoma americanum,Lithopoma americanum,American star snail,Animalia,Mollusca,Gastropoda,Trochida,Turbinidae,Astraea,Species,413407,NA,Species,,,,,,, -Astrea phoebia,Lithopoma phoebium,NA,Animalia,Mollusca,Gastropoda,Trochida,Turbinidae,Astraea,Species,413409,NA,Species,,,,,,, -Lithopoma phoebium,Lithopoma phoebium,NA,Animalia,Mollusca,Gastropoda,Trochida,Turbinidae,Astraea,Species,413409,NA,Species,,,,,,, -Litoscalpellum ursum,Litoscalpellum ursum,NA,Animalia,Arthropoda,Thecostraca,Scalpellomorpha,Scalpellidae,Litoscalpellum,Species,535209,NA,Species,,,,,,, -Livoneca,Livoneca,NA,Animalia,Arthropoda,Malacostraca,Isopoda,Cymothoidae,Livoneca,Genus,203846,NA,Remove,,,,,,, -Livoneca sp.,Livoneca,NA,Animalia,Arthropoda,Malacostraca,Isopoda,Cymothoidae,Livoneca,Genus,203846,NA,Remove,,,,,,, -Lironeca ovalis,Livoneca ovalis,NA,Animalia,Arthropoda,Malacostraca,Isopoda,Cymothoidae,Lironeca,Species,157894,NA,Species,,,,,,, -Livoneca ovalis,Livoneca ovalis,NA,Animalia,Arthropoda,Malacostraca,Isopoda,Cymothoidae,Lironeca,Species,157894,NA,Species,,,,,,, -Lobopilumnus agassizii,Lobopilumnus agassizii,Areolated hairy crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pilumnidae,Lobopilumnus,Species,422093,NA,Species,,,,,,, -Lobotes surinamensis,Lobotes surinamensis,Tripletail,Animalia,Chordata,Teleostei,Acanthuriformes,Lobotidae,Lobotes,Species,126973,1077,Species,,,,,,, -Loliginidae,Loliginidae,NA,Animalia,Mollusca,Cephalopoda,Myopsida,Loliginidae,NA,Family,11734,NA,Remove,,,,,,, -Loligo,Doryteuthis sp,Inshore Squid sp. ,Animalia,Mollusca,Cephalopoda,Myopsida,Loliginidae,Loligo,Genus,138139,NA,Genus,,,,,,, -Loliolopsis,Loliolopsis,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Lolliguncula,Lolliguncula,NA,Animalia,Mollusca,Cephalopoda,Myopsida,Loliginidae,Lolliguncula,Genus,157027,NA,Remove,,,,,,, -Lolliguncula brevis,Lolliguncula brevis,Atlantic brief squid,Animalia,Mollusca,Cephalopoda,Myopsida,Loliginidae,Lolliguncula,Species,157028,NA,Species,,,,,,, -Lonchopisthus,Lonchopisthus,NA,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Opistognathidae,Lonchopisthus,Genus,269721,NA,Remove,,,,,,, -Lonchopisthus micrognathus,Lonchopisthus micrognathus,Swordtail jawfish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Opistognathidae,Lonchopisthus,Species,281386,3683,Species,,,,,,, -Lonchiurus lanceolatus,Lonchurus lanceolatus,Longtail croaker,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Lonchiurus,Species,281389,1183,Species,,,,,,, -Lonchurus lanceolatus,Lonchurus lanceolatus,Longtail croaker,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Lonchiurus,Species,281389,1183,Species,,,,,,, -Lophaster,Lophaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Lophaster,Genus,123337,NA,Remove,,,,,,, -Lophaster sp.,Lophaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Lophaster,Genus,123337,NA,Remove,,,,,,, -Lophaster furcilliger,Lophaster furcilliger,Pink crested star,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Lophaster,Species,292719,NA,Species,,,,,,, -Lophaster vexator,Lophaster furcilliger,Pink crested star,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Lophaster,Species,292719,NA,Species,,,,,,, -Lophaster sp. A (Clark),Lophaster sp. A (Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Lophaster sp. B (Clark),Lophaster sp. B (Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Lophiiformes,Lophiiformes,NA,Animalia,Chordata,Teleostei,Lophiiformes,NA,NA,Order,10316,NA,Remove,,,,,,, -Lophiodes reticulatus,Lophiodes reticulatus,Reticulated goosefish,Animalia,Chordata,Teleostei,Lophiiformes,Lophiidae,Lophiodes,Species,278533,3082,Species,,,,,,, -Lophius,Lophius,NA,Animalia,Chordata,Teleostei,Lophiiformes,Lophiidae,Lophius,Genus,125802,NA,Remove,,,,,,, -Lophius americanus,Lophius americanus,Monkfish,Animalia,Chordata,Teleostei,Lophiiformes,Lophiidae,Lophius,Species,159184,532,Species,,,,,,, -Lophius gastrophysus,Lophius gastrophysus,Blackfin goosefish,Animalia,Chordata,Teleostei,Lophiiformes,Lophiidae,Lophius,Species,159185,1078,Species,,,,,,, -Lophogastrida,Lophogastrida,Opossum shrimps,Animalia,Arthropoda,Malacostraca,Lophogastrida,NA,NA,Order,149669,NA,Remove,,,,,,, -Lophogastrida a,Lophogastrida sp. A,Opossum shrimps,Animalia,Arthropoda,Malacostraca,Lophogastrida,NA,NA,Species,NA,NA,Species,,,,,,, -Lophogastrida sp. a,Lophogastrida Sp. A,Opossum shrimps,Animalia,Arthropoda,Malacostraca,Lophogastrida,NA,NA,Species,NA,NA,Species,,,,,,, -Lophogorgia,Lophogorgia,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Lopholatilus chamaeleonticeps,Lopholatilus chamaeleonticeps,Great northern tilefish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Malacanthidae,Lopholatilus,Species,159406,362,Species,,,,,,, -Lovenia cordiformis,Lovenia cordiformis,Sea porcupine,Animalia,Echinodermata,Echinoidea,Spatangoida,Loveniidae,Lovenia,Species,513372,NA,Species,,,,,,, -Loxorhynchus crispatus,Loxorhynchus crispatus,Moss crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Loxorhynchus,Species,441601,NA,Species,,,,,,, -Loxorhynchus grandis,Loxorhynchus grandis,Sheep crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Loxorhynchus,Species,441602,NA,Species,,,,,,, -Lucinoma annulatum,Lucinoma annulata,Ringed lucine,Animalia,Mollusca,Bivalvia,Lucinida,Lucinidae,Lucinoma,Species,464200,NA,Species,,,,,,, -Lucinoma annulata,Lucinoma annulata,Ringed lucine,Animalia,Mollusca,Bivalvia,Lucinida,Lucinidae,Lucinoma,Species,464200,NA,Species,,,,,,, -Luidia,Luidia,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Luidiidae,Luidia,Genus,123260,NA,Remove,,,,,,, -Luidia sp.,Luidia,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Luidiidae,Luidia,Genus,123260,NA,Remove,,,,,,, -Luidia alternata,Luidia alternata,Banded sea star,Animalia,Echinodermata,Asteroidea,Paxillosida,Luidiidae,Luidia,Species,178615,NA,Species,,,,,,, -Luidia alternata alternata,Luidia alternata alternata,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Luidiidae,Luidia,Species,178616,NA,Species,,,,,,, -Luidia asthenosoma,Luidia asthenosoma,Fringed sand star,Animalia,Echinodermata,Asteroidea,Paxillosida,Luidiidae,Luidia,Species,368107,NA,Species,,,,,,, -Luidia barbadensis,Luidia barbadensis,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Luidiidae,Luidia,Species,178621,NA,Species,,,,,,, -Luidia clathrata,Luidia clathrata,Lined sea star,Animalia,Echinodermata,Asteroidea,Paxillosida,Luidiidae,Luidia,Species,158497,NA,Species,,,,,,, -Luidia foliolata,Luidia foliolata,Gray sand star,Animalia,Echinodermata,Asteroidea,Paxillosida,Luidiidae,Luidia,Species,368114,NA,Species,,,,,,, -Luidia lawrencei,Luidia lawrencei,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Luidiidae,Luidia,Species,474112,NA,Species,,,,,,, -Luidia ludwigi scotti,Luidia ludwigi scotti,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Luidiidae,Luidia,SubSpecies,178633,NA,SubSpecies,,,,,,, -Luidia sagamina aciculata,Luidia sagamina aciculata,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Luidiidae,Luidia,SubSpecies,178636,NA,SubSpecies,,,,,,, -Luidia senegalensis,Luidia senegalensis,Nine armed sea star,Animalia,Echinodermata,Asteroidea,Paxillosida,Luidiidae,Luidia,Species,178641,NA,Species,,,,,,, -Lumpenella longirostris,Lumpenella longirostris,Longsnout prickleback,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Lumpenella,Species,254351,3785,Species,,,,,,, -Lumpenus,Lumpenus,NA,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Lumpenus,Genus,126088,NA,Remove,,,,,,, -Lumpenus sp.,Lumpenus,NA,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Lumpenus,Genus,126088,NA,Remove,,,,,,, -Lumpenus fabricii,Lumpenus fabricii,Slender eelblenny,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Lumpenus,Species,127073,3786,Species,,,,,,, -Lumpenus lumpretaeformis,Lumpenus lampretaeformis,Snakeblenny,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Lumpenus,Species,154675,1380,Species,,,,,,, -Lumpenus sagitta,Lumpenus sagitta,Snake prickleback,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Lumpenus,Species,254579,3790,Species,,,,,,, -Anadara ovalis,Lunarca ovalis,Blood ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Anadara,Species,420721,NA,Species,,,,,,, -Lunarca ovalis,Lunarca ovalis,Blood ark,Animalia,Mollusca,Bivalvia,Arcida,Arcidae,Anadara,Species,420721,NA,Species,,,,,,, -Cypraea cinera,Luria cinerea,Droppings cowry,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cypraeidae,Trona,Species,225254,NA,Species,,,,,,, -Luria cinerea,Luria cinerea,Droppings cowry,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cypraeidae,Trona,Species,225254,NA,Species,,,,,,, -Lutjanidae,Lutjanidae,Snappers,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Lutjanidae,NA,Family,151453,NA,Remove,,,,,,, -Lutjanus,Lutjanus,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Lutjanidae,Lutjanus,Genus,159791,NA,Remove,,,,,,, -Lutjanus analis,Lutjanus analis,Mutton snapper,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Lutjanidae,Lutjanus,Species,159792,1403,Species,,,,,,, -Lutjanus buccanella,Lutjanus buccanella,Blackfin snapper,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Lutjanidae,Lutjanus,Species,159794,NA,Species,,,,,,, -Lutjanus campechanus,Lutjanus campechanus,Red snapper,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Lutjanidae,Lutjanus,Species,159795,1423,Species,,,,,,, -Lutjanus griseus,Lutjanus griseus,Gray snapper,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Lutjanidae,Lutjanus,Species,159797,266,Species,,,,,,, -Lutjanus synagris,Lutjanus synagris,Lane snapper,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Lutjanidae,Lutjanus,Species,159800,181,Species,,,,,,, -Lutjanus vivanus,Lutjanus vivanus,Silk snapper,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Lutjanidae,Lutjanus,Species,159801,185,Species,,,,,,, -Lycenchelys,Lycenchelys,Slipskin,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycenchelys,Genus,126103,NA,Remove,,,,,,, -Lycenchelys sp.,Lycenchelys,Slipskin,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycenchelys,Genus,126103,NA,Remove,,,,,,, -Lycenchelys camchatica,Lycenchelys camchatica,Kamchatka eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycenchelys,Species,254591,48101,Species,,,,,,, -Lycenchelys crotalinus,Lycenchelys crotalinus,Snakehead eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycenchelys,Species,254592,11658,Species,,,,,,, -Lycenchelys jordani,Lycenchelys jordani,Shortjaw eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycenchelys,Species,274067,24699,Species,,,,,,, -Lycenchelys ratmanovi,Lycenchelys ratmanovi,NA,NA,NA,NA,NA,NA,NA,Species,254594,NA,Species,,,,,,, -Lycenchelys verrilli,Lycenchelys verrillii,Wolf eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycenchelys,Species,159258,3132,Species,,,,,,, -Lycodapus,Lycodapus,NA,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodapus,Genus,234573,NA,Remove,,,,,,, -Lycodapus sp.,Lycodapus,NA,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodapus,Genus,234573,NA,Remove,,,,,,, -Lycodapus dermatinus,Lycodapus dermatinus,NA,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodapus,Species,279387,48204,Species,,,,,,, -Lycodapus endemoscotus,Lycodapus endemoscotus,Deepwater slipskin,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodapus,Species,279388,25269,Species,,,,,,, -Lycodapus fierasfer,Lycodapus fierasfer,Blackmouth eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodapus,Species,279389,3133,Species,,,,,,, -Lycodapus leptus,Lycodapus leptus,slender eelpout,NA,NA,NA,NA,NA,NA,Species,279390,NA,Species,,,,,,, -Lycodapus mandibularis,Lycodapus mandibularis,Pallid eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodapus,Species,279391,3134,Species,,,,,,, -Lycodapus parviceps,Lycodapus parviceps,Smallhead eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodapus,Species,279393,3135,Species,,,,,,, -Lycodapus poecilus,Lycodapus poecilus,variform eelpout,NA,NA,NA,NA,NA,NA,Species,279394,NA,Species,,,,,,, -Lycodapus psarostomatus,Lycodapus psarostomatus,specklemouth eelpout,NA,NA,NA,NA,NA,NA,Species,279395,NA,Species,,,,,,, -Lycodes,Lycodes,NA,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Genus,126104,NA,Remove,,,,,,, -Lycodes sp.,Lycodes,NA,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Genus,126104,NA,Remove,,,,,,, -Lycodes akuugun,Lycodes akuugun,Bicolor eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Species,274091,62972,Species,,,,,,, -Lycodes beringi,Lycodes beringi,Bering eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Species,398582,64886,Species,,,,,,, -Lycodes brevipes,Lycodes brevipes,Shortfin eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Species,254595,3136,Species,,,,,,, -Lycodes concolor,Lycodes concolor,Ebony eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Species,367289,48216,Species,,,,,,, -Lycodes cortezianus,Lycodes cortezianus,Bigfin eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Species,274097,3129,Species,,,,,,, -Lycodes diapterus,Lycodes diapterus,Black eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Species,254597,3137,Species,,,,,,, -Lycodes mucosus,Lycodes mucosus,Saddled eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Species,254584,27463,Species,,,,,,, -Lycodes pacificus,Lycodes pacificus,Blackbelly eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Species,274116,3147,Species,,,,,,, -Lycodes palearis,Lycodes palearis,Wattled eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Species,254585,3140,Species,,,,,,, -Lycodes polaris,Lycodes polaris,Canadian eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Species,127111,3142,Species,,,,,,, -Lycodes raridens,Lycodes raridens,Marbled eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Species,254598,48262,Species,,,,,,, -Lycodes reticulatus,Lycodes reticulatus,Arctic eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Species,127112,3143,Species,,,,,,, -Lycodes turneri,Lycodes turneri,Polar eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lycodes,Species,254599,3146,Species,,,,,,, -Lycodema barbatum,Lyconema barbatum,Bearded eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lyconema,Species,281449,3148,Species,,,,,,, -Lyconema barbatum,Lyconema barbatum,Bearded eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Lyconema,Species,281449,3148,Species,,,,,,, -Lyopsetta exilis,Lyopsetta exilis,Slender sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Lyopsetta,Species,281452,4246,Species,,,,,,, -Lysiosquilla campechiensis,Lysiosquilla campechiensis,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Lysiosquillidae,Lysiosquilla,Species,409033,NA,Species,,,,,,, -Lysiosquilla scabricauda,Lysiosquilla scabricauda,Smooth mantis shrimp,Animalia,Arthropoda,Malacostraca,Stomatopoda,Lysiosquillidae,Lysiosquilla,Species,409037,NA,Species,,,,,,, -Lysmata,Lysmata,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lysmatidae,Lysmata,Genus,106992,NA,Remove,,,,,,, -Lysmata ankeri,Lysmata ankeri,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lysmatidae,Lysmata,Species,515360,NA,Species,,,,,,, -Lysmata pederseni,Lysmata pederseni,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lysmatidae,Lysmata,Species,421780,NA,Species,,,,,,, -Lysmata rathbunae,Lysmata rathbunae,Rathbun cleaner shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Lysmatidae,Lysmata,Species,421781,NA,Species,,,,,,, -Lysmata wurdemanni,Lysmata wurdemanni,Peppermint shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Lysmatidae,Lysmata,Species,158365,NA,Species,,,,,,, -Lytechinus,Lytechinus,NA,Animalia,Echinodermata,Echinoidea,Camarodonta,Toxopneustidae,Lytechinus,Genus,240777,NA,Remove,,,,,,, -Lytechinus euerces,Lytechinus euerces,NA,Animalia,Echinodermata,Echinoidea,Camarodonta,Toxopneustidae,Lytechinus,Species,422488,NA,Species,,,,,,, -Lytechinus anamesus,Lytechinus pictus,White sea urchin,Animalia,Echinodermata,Echinoidea,Camarodonta,Toxopneustidae,Lytechinus,Species,513378,NA,Species,,,,,,, -Lytechinus variegatus,Lytechinus variegatus,Variegated sea urchin,Animalia,Echinodermata,Echinoidea,Camarodonta,Toxopneustidae,Lytechinus,Species,367850,NA,Species,,,,,,, -Lytechinus variegatus carolinus,Lytechinus variegatus carolinus,NA,Animalia,Echinodermata,Echinoidea,Camarodonta,Toxopneustidae,Lytechinus,Species,422800,NA,Species,,,,,,, -Macoma,Macoma,NA,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Genus,138531,NA,Remove,,,,,,, -Macoma sp.,Macoma,NA,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Genus,138531,NA,Remove,,,,,,, -Macoma brota,Macoma brota,Heavy macoma,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Species,254466,NA,Species,,,,,,, -Macoma calcarea,Macoma calcarea,Chalky macoma,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Species,141580,NA,Species,,,,,,, -Macoma inquinata,Macoma inquinata,Pointed macoma,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Species,582759,NA,Species,,,,,,, -Macoma nasuta,Macoma nasuta,Bent nose macoma,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Species,582761,NA,Species,,,,,,, -Macoma pulleyi,Macoploma pulleyi,Delta macoma,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Species,879981,NA,Species,,,,,,, -Macoploma pulleyi,Macoploma pulleyi,Delta macoma,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Species,879981,NA,Species,,,,,,, -Macoma yoldiformis,Macoploma yoldiformis,Yoldia macoma,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Species,879988,NA,Species,,,,,,, -Macoploma yoldiformis,Macoploma yoldiformis,Yoldia macoma,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Species,879988,NA,Species,,,,,,, -Macrocoeloma,Macrocoeloma,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Macrocoeloma,Genus,415593,NA,Remove,,,,,,, -Macrocoeloma camptocerum,Macrocoeloma camptocerum,Florida decorator crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Macrocoeloma,Species,421974,NA,Species,,,,,,, -Macrocoeloma eutheca,Macrocoeloma eutheca,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Macrocoeloma,Species,421977,NA,Species,,,,,,, -Macrocoeloma nodipes,Macrocoeloma nodipes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Macrocoeloma,Species,442099,NA,Species,,,,,,, -Macrocoeloma trispinosum,Macrocoeloma trispinosum,Spongy decorator crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Macrocoeloma,Species,421982,NA,Species,,,,,,, -Cypraea cervus,Macrocypraea cervus,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cypraeidae,Cypraea,Species,419722,NA,Species,,,,,,, -Macrocypraea cervus,Macrocypraea cervus,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cypraeidae,Cypraea,Species,419722,NA,Species,,,,,,, -Macropinna microstoma,Macropinna microstoma,Barreleye,Animalia,Chordata,Teleostei,Argentiniformes,Opisthoproctidae,Macropinna,Species,281482,2704,Species,,,,,,, -Macrorhamphosus scolopax,Macroramphosus scolopax,Longspine snipefish,Animalia,Chordata,Teleostei,Syngnathiformes,Centriscidae,Macrorhamphosus,Species,127378,333,Species,,,,,,, -Macroregonia macrochira,Macroregonia macrochira,Long clawed spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Macroregonia,Species,442169,NA,Species,,,,,,, -Strombus costatus,Macrostrombus costatus,Milk conch,Animalia,Mollusca,Gastropoda,Littorinimorpha,Strombidae,Strombus,Species,1429775,NA,Species,,,,,,, -Macrostrombus costatus,Macrostrombus costatus,Milk conch,Animalia,Mollusca,Gastropoda,Littorinimorpha,Strombidae,Strombus,Species,1429775,NA,Species,,,,,,, -Macrouridae,Macrouridae,Grenadiers,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,NA,Family,125471,NA,Remove,,,,,,, -Macrourus berglax,Macrourus berglax,Roughhead grenadier,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Macrourus,Species,126472,331,Species,,,,,,, -Mactromeris,Mactromeris,NA,Animalia,Mollusca,Bivalvia,Venerida,Mactridae,Mactromeris,Genus,156862,NA,Remove,,,,,,, -Mactromeris sp.,Mactromeris,NA,Animalia,Mollusca,Bivalvia,Venerida,Mactridae,Mactromeris,Genus,156862,NA,Remove,,,,,,, -Mactromeris polynyma,Mactromeris polynyma,Arctic surfclam,Animalia,Mollusca,Bivalvia,Venerida,Mactridae,Mactromeris,Species,156863,NA,Species,,,,,,, -Madracis,Madracis,NA,Animalia,Cnidaria,Anthozoa,Scleractinia,Pocilloporidae,Madracis,Genus,135125,NA,Remove,,,,,,, -Magnisudis atlantica,Magnisudis atlantica,Duckbill barracudina,Animalia,Chordata,Teleostei,Aulopiformes,Paralepididae,Magnisudis,Species,126359,2727,Species,,,,,,, -Mithrax spinosissimus,Maguimithrax spinosissimus,Channel clinging crab,Animalia,Arthropoda,Malacostraca,Decapoda,Mithracidae,Mithrax,Species,987079,NA,Species,,,,,,, -Majidae,Majidae,Spider crabs,Animalia,Arthropoda,Malacostraca,Decapoda,Majidae,NA,Family,106760,NA,Remove,,,,,,, -Malacanthidae,Malacanthidae,Tilefishes,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Malacanthidae,NA,Family,151447,NA,Remove,,,,,,, -Malacanthus plumieri,Malacanthus plumieri,Sand tilefish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Malacanthidae,Malacanthus,Species,277261,3541,Species,,,,,,, -Malacocephalus laevis,Malacocephalus laevis,Softhead grenadier,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Malacocephalus,Species,272392,4989,Species,,,,,,, -Malacocephalus occidentalis,Malacocephalus occidentalis,Western softhead grenadier,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Malacocephalus,Species,158741,4990,Species,,,,,,, -Malacocottus,Malacocottus,NA,Animalia,Chordata,Teleostei,Perciformes,Psychrolutidae,Malacocottus,Genus,254405,NA,Remove,,,,,,, -Malacocottus sp.,Malacocottus,NA,Animalia,Chordata,Teleostei,Perciformes,Psychrolutidae,Malacocottus,Genus,254405,NA,Remove,,,,,,, -Malacocottus aleuticus,Malacocottus aleuticus,Whitetail sculpin,Animalia,Chordata,Teleostei,Perciformes,Psychrolutidae,Malacocottus,Species,279440,50813,Species,,,,,,, -Malacocottus kincaidi,Malacocottus kincaidi,Blackfin sculpin,Animalia,Chordata,Teleostei,Perciformes,Psychrolutidae,Malacocottus,Species,279442,4113,Species,,,,,,, -Malacocottus zonurus,Malacocottus zonurus,Darkfin sculpin,Animalia,Chordata,Teleostei,Perciformes,Psychrolutidae,Malacocottus,Species,254406,11730,Species,,,,,,, -Malacoraja senta,Malacoraja senta,Smooth skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Malacoraja,Species,158554,2568,Species,,,,,,, -Malacosteinae,Malacosteinae,Loosejaw unid.,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,NA,SubFamily,154693,NA,Remove,,,,,,, -Maldanidae,Maldanidae,Bamboo worms,Animalia,Annelida,Polychaeta,NA,Maldanidae,NA,Family,923,NA,Remove,,,,,,, -Malleus candeanus,Malleus candeanus,Caribbean hammer-oyster,Animalia,Mollusca,Bivalvia,Ostreida,Malleidae,Malleus,Species,420738,NA,Species,,,,,,, -Mallotus catervarius,Mallotus villosus,Capelin,Animalia,Chordata,Teleostei,Osmeriformes,Osmeridae,Mallotus,Species,126735,252,Species,,,,,,, -Mallotus villosus,Mallotus villosus,Capelin,Animalia,Chordata,Teleostei,Osmeriformes,Osmeridae,Mallotus,Species,126735,252,Species,,,,,,, -Mangelia carlottae,Mangelia carlottae,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Mangeliidae,Mangelia,Species,434330,NA,Species,,,,,,, -Manucomplanus,Manucomplanus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Manucomplanus,Genus,366517,NA,Remove,,,,,,, -Manucomplanus corallinus,Manucomplanus ungulatus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Manucomplanus,Species,366521,NA,Species,,,,,,, -Manucomplanus ungulatus,Manucomplanus ungulatus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Manucomplanus,Species,366521,NA,Species,,,,,,, -Margarites,Margarites,Margarite snails,Animalia,Mollusca,Gastropoda,Trochida,Margaritidae,Margarites,Genus,138592,NA,Remove,,,,,,, -Margarites sp.,Margarites,Margarite snails,Animalia,Mollusca,Gastropoda,Trochida,Margaritidae,Margarites,Genus,138592,NA,Remove,,,,,,, -Margarites costalis,Margarites costalis,Boreal rosy margarite,Animalia,Mollusca,Gastropoda,Trochida,Margaritidae,Margarites,Species,141819,NA,Species,,,,,,, -Margarites argentatus,Margarites olivaceus,NA,Animalia,Mollusca,Gastropoda,Trochida,Margaritidae,Margarites,Species,141822,NA,Species,,,,,,, -Margarites olivaceus,Margarites olivaceus,NA,Animalia,Mollusca,Gastropoda,Trochida,Margaritidae,Margarites,Species,141822,NA,Species,,,,,,, -Margarites pupillus,Margarites pupillus,Little margarite,Animalia,Mollusca,Gastropoda,Trochida,Margaritidae,Margarites,Species,528731,NA,Species,,,,,,, -Margarites sp. C (Clark and McLean),Margarites sp. C (Clark and McLean),silvery margarite,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Lamellaria perspicua,Marsenia perspicua,Transparent lamellaria,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Lamellaria,Species,1505994,NA,Species,,,,,,, -Maulisia,Maulisia,NA,Animalia,Chordata,Teleostei,Alepocephaliformes,Platytroctidae,Maulisia,Genus,125902,NA,Remove,,,,,,, -Maulisia sp.,Maulisia,NA,Animalia,Chordata,Teleostei,Alepocephaliformes,Platytroctidae,Maulisia,Genus,125902,NA,Remove,,,,,,, -Maulisia mauli,Maulisia mauli,Maul's searsid,Animalia,Chordata,Teleostei,Alepocephaliformes,Platytroctidae,Maulisia,Species,126742,10151,Species,,,,,,, -Maurolicus weitzmani,Maurolicus weitzmani,Atlantic pearlside,Animalia,Chordata,Teleostei,Stomiiformes,Sternoptychidae,Maurolicus,Species,158838,51611,Species,,,,,,, -Mediaster,Mediaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Mediaster,Genus,123298,NA,Remove,,,,,,, -Mediaster sp.,Mediaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Mediaster,Genus,123298,NA,Remove,,,,,,, -Mediaster aequalis,Mediaster aequalis,Vermillion star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Mediaster,Species,242160,NA,Species,,,,,,, -Mediaster tenellus,Mediaster tenellus,Delicate star,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Mediaster,Species,368837,NA,Species,,,,,,, -Megalobrachium,Megalobrachium,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,Megalobrachium,Genus,415614,NA,Remove,,,,,,, -Megalobrachium soriatum,Megalobrachium soriatum,Pentagonal porcelain crab,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,Megalobrachium,Species,421865,NA,Species,,,,,,, -Megalocottus platycephalus,Megalocottus platycephalus,Belligerent sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Megalocottus,Species,254411,4114,Species,,,,,,, -Megalops atlanticus,Megalops atlanticus,Tarpon,Animalia,Chordata,Teleostei,Elopiformes,Megalopidae,Megalops,Species,126430,1079,Species,,,,,,, -Megangulus bodegensis,Megangulus bodegensis,NA,NA,NA,NA,NA,NA,NA,Species,878288,NA,Species,,,,,,, -Tellina lutea,Megangulus luteus,Alaskan great tellin,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Tellina,Species,423511,NA,Species,,,,,,, -Megangulus luteus,Megangulus luteus,Alaskan great tellin,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Tellina,Species,423511,NA,Species,,,,,,, -Macrocallista maculata,Megapitaria maculata,Calico clam,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Macrocallista,Species,863029,NA,Species,,,,,,, -Megapitaria maculata,Megapitaria maculata,Calico clam,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Macrocallista,Species,863029,NA,Species,,,,,,, -Megasurcula,Megasurcula,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Pseudomelatomidae,Megasurcula,Genus,432503,NA,Remove,,,,,,, -Megasurcula carpenteriana,Megasurcula carpenteriana,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Pseudomelatomidae,Megasurcula,Species,579016,NA,Species,,,,,,, -Megayoldia thraciaeformis,Megayoldia thraciaeformis,Broad yoldia,Animalia,Mollusca,Bivalvia,Nuculanida,Yoldiidae,Megayoldia,Species,141983,NA,Species,,,,,,, -Meiosquilla,Meiosquilla,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,Meiosquilla,Genus,148536,NA,Remove,,,,,,, -Meiosquilla quadridens,Meiosquilla quadridens,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,Meiosquilla,Species,409280,NA,Species,,,,,,, -Melamphaes lugubris,Melamphaes lugubris,Highsnout melamphid,Animalia,Chordata,Teleostei,Beryciformes,Melamphaidae,Melamphaes,Species,274932,16586,Species,,,,,,, -Melamphaidae,Melamphaidae,Bigscale fishes,Animalia,Chordata,Teleostei,Beryciformes,Melamphaidae,NA,Family,125599,NA,Remove,,,,,,, -Melanocetus johnsonii,Melanocetus johnsonii,Humpback anglerfish,Animalia,Chordata,Teleostei,Lophiiformes,Melanocetidae,Melanocetus,Species,126556,2292,Species,,,,,,, -Melanogrammus aeglefinus,Melanogrammus aeglefinus,Haddock,Animalia,Chordata,Teleostei,Gadiformes,Gadidae,Melanogrammus,Species,126437,1381,Species,,,,,,, -Melanonidae,Melanonidae,NA,Animalia,Chordata,Teleostei,Gadiformes,Melanonidae,NA,Family,125472,NA,Remove,,,,,,, -Melanonus zugmayeri,Melanonus zugmayeri,Arrowtail,Animalia,Chordata,Teleostei,Gadiformes,Melanonidae,Melanonus,Species,126483,5118,Species,,,,,,, -Melanostigma atlanticum,Melanostigma atlanticum,Atlantic soft pout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Melanostigma,Species,127120,3150,Species,,,,,,, -Melanostigma pammelas,Melanostigma pammelas,Midwater eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Melanostigma,Species,274134,5156,Species,,,,,,, -Melanostomiinae,Melanostomiinae,Scaleless dragonfish unid.,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,NA,SubFamily,154229,NA,Remove,,,,,,, -Mellita,Mellita,NA,Animalia,Echinodermata,Echinoidea,Echinolampadacea,Mellitidae,Mellita,Genus,158064,NA,Remove,,,,,,, -Mellita quinquesperforata,Mellita quinquiesperforata,Keyhole sand dollar,Animalia,Echinodermata,Echinoidea,Echinolampadacea,Mellitidae,Mellita,Species,158065,NA,Species,,,,,,, -Mellita testudinata,Mellita quinquiesperforata,Keyhole sand dollar,Animalia,Echinodermata,Echinoidea,Echinolampadacea,Mellitidae,Mellita,Species,158065,NA,Species,,,,,,, -Mellita quinquiesperforata,Mellita quinquiesperforata,Keyhole sand dollar,Animalia,Echinodermata,Echinoidea,Echinolampadacea,Mellitidae,Mellita,Species,158065,NA,Species,,,,,,, -Melongenidae,Melongenidae,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Melongenidae,NA,Family,160182,NA,Remove,,,,,,, -Membras martinica,Membras martinica,Rough silverside,Animalia,Chordata,Teleostei,Atheriniformes,Atherinopsidae,Membras,Species,159220,3240,Species,,,,,,, -Menidia beryllina,Menidia beryllina,Inland silverside,Animalia,Chordata,Teleostei,Atheriniformes,Atherinopsidae,Menidia,Species,159227,3241,Species,,,,,,, -Menidia menidia,Menidia menidia,Atlantic silverside,Animalia,Chordata,Teleostei,Atheriniformes,Atherinopsidae,Menidia,Species,159228,339,Species,,,,,,, -Menippe,Menippe,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Menippidae,Menippe,Genus,205910,NA,Remove,,,,,,, -Menippe adina,Menippe adina,Gulf stone crab,Animalia,Arthropoda,Malacostraca,Decapoda,Menippidae,Menippe,Species,422069,NA,Species,,,,,,, -Menippe mercenaria,Menippe mercenaria,Florida stone crab,Animalia,Arthropoda,Malacostraca,Decapoda,Menippidae,Menippe,Species,422070,NA,Species,,,,,,, -Menticirrhus americanus,Menticirrhus americanus,Southern kingfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Menticirrhus,Species,159326,409,Species,,,,,,, -Menticirrhus littoralis,Menticirrhus littoralis,Gulf kingfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Menticirrhus,Species,159327,411,Species,,,,,,, -Menticirrhus saxatilis,Menticirrhus saxatilis,Northern kingfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Menticirrhus,Species,159329,410,Species,,,,,,, -Meoma ventricosa,Meoma ventricosa,Red heart urchin,Animalia,Echinodermata,Echinoidea,Spatangoida,Brissidae,Meoma,Species,367846,NA,Species,,,,,,, -Meoma ventricosa ventricosa,Meoma ventricosa ventricosa,NA,Animalia,Echinodermata,Echinoidea,Spatangoida,Brissidae,Meoma,Species,422804,NA,Species,,,,,,, -Mercenaria,Mercenaria,NA,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Mercenaria,Genus,138642,NA,Remove,,,,,,, -Mercenaria campechiensis,Mercenaria campechiensis,Southern hardshell clam,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Mercenaria,Species,422678,NA,Species,,,,,,, -Mercenaria mercenaria,Mercenaria mercenaria,Northern quahog,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Mercenaria,Species,141919,NA,Species,,,,,,, -Merlucciidae,Merlucciidae,Merluccid hakes,Animalia,Chordata,Teleostei,Gadiformes,Merlucciidae,NA,Family,125473,NA,Remove,,,,,,, -Merluccius sp,Merluccius,NA,Animalia,Chordata,Teleostei,Gadiformes,Merlucciidae,Merluccius,Genus,125762,NA,Remove,,,,,,, -Merluccius albidus,Merluccius albidus,Offshore hake,Animalia,Chordata,Teleostei,Gadiformes,Merlucciidae,Merluccius,Species,158748,1080,Species,,,,,,, -Merluccius bilinearis,Merluccius bilinearis,Silver hake,Animalia,Chordata,Teleostei,Gadiformes,Merlucciidae,Merluccius,Species,158962,323,Species,,,,,,, -Merluccius productus,Merluccius productus,Pacific hake,Animalia,Chordata,Teleostei,Gadiformes,Merlucciidae,Merluccius,Species,272458,326,Species,,,,,,, -Strongylocentrotus franciscanus,Mesocentrotus franciscanus,Red sea urchin,Animalia,Echinodermata,Echinoidea,Camarodonta,Strongylocentrotidae,Strongylocentrotus,Species,591102,NA,Species,,,,,,, -Mesocentrotus franciscanus,Mesocentrotus franciscanus,Red sea urchin,Animalia,Echinodermata,Echinoidea,Camarodonta,Strongylocentrotidae,Strongylocentrotus,Species,591102,NA,Species,,,,,,, -Mesopenaeus tropicalis,Mesopenaeus tropicalis,Salmon shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Solenoceridae,Mesopenaeus,Species,377474,NA,Species,,,,,,, -Cancer anthonyi,Metacarcinus anthonyi,Yellow rock crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Metacarcinus,Species,440385,NA,Species,,,,,,, -Cancer gracilis,Metacarcinus gracilis,Graceful rock crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Metacarcinus,Species,440387,NA,Species,,,,,,, -Metacarcinus gracilis,Metacarcinus gracilis,Graceful rock crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Metacarcinus,Species,440387,NA,Species,,,,,,, -Cancer magister,Metacarcinus magister,Dungeness crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Metacarcinus,Species,440388,NA,Species,,,,,,, -Metacarcinus magister,Metacarcinus magister,Dungeness crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Metacarcinus,Species,440388,NA,Species,,,,,,, -Metacrangon,Metacrangon,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Metacrangon,Genus,107008,NA,Remove,,,,,,, -Metacrangon sp.,Metacrangon,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Metacrangon,Genus,107008,NA,Remove,,,,,,, -Metacrangon variabilis,Metacrangon variabilis,Deepsea spinyhead,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Metacrangon,Species,515746,NA,Species,,,,,,, -Metapenaeopsis,Metapenaeopsis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Metapenaeopsis,Genus,106817,NA,Remove,,,,,,, -Metapenaeopsis goodei,Metapenaeopsis goodei,Caribbean velvet shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Metapenaeopsis,Species,377493,NA,Species,,,,,,, -Metoporhaphis,Metoporhaphis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Inachidae,Metoporhaphis,Genus,415630,NA,Remove,,,,,,, -Metoporhaphis calcarata,Metoporhaphis calcarata,False arrow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Inachidae,Metoporhaphis,Species,421950,NA,Species,,,,,,, -Metridium,Metridium,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Metridiidae,Metridium,Genus,100770,NA,Remove,,,,,,, -Metridium sp.,Metridium,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Metridiidae,Metridium,Genus,100770,NA,Remove,,,,,,, -Metridium farcimen,Metridium farcimen,Giant plumose anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Metridiidae,Metridium,Species,283704,NA,Species,,,,,,, -Metridium farcimen (=metridium giganteum),Metridium farcimen,Giant plumose anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Metridiidae,Metridium,Species,283704,NA,Species,,,,,,, -Metridium senile,Metridium senile,Clonal plumose anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Metridiidae,Metridium,Species,100982,NA,Species,,,,,,, -Nemocardium transversum,Microcardium tinctum,Transverse micro-cockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Nemocardium,Species,381847,NA,Species,,,,,,, -Microcardium tinctum,Microcardium tinctum,Transverse micro-cockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Nemocardium,Species,381847,NA,Species,,,,,,, -Microcardium transversum,Microcardium tinctum,Transverse micro-cockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Nemocardium,Species,381847,NA,Species,,,,,,, -Microcottus sellaris,Microcottus sellaris,Brightbelly sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Microcottus,Species,254404,4116,Species,,,,,,, -Microgadus proximus,Microgadus proximus,Pacific tomcod,Animalia,Chordata,Teleostei,Gadiformes,Gadidae,Microgadus,Species,275873,1879,Species,,,,,,, -Microgadus tomcod,Microgadus tomcod,Atlantic tomcod,Animalia,Chordata,Teleostei,Gadiformes,Gadidae,Microgadus,Species,158928,316,Species,,,,,,, -Microgobius,Microgobius,NA,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Microgobius,Genus,158803,NA,Remove,,,,,,, -Microgobius gulosus,Microgobius gulosus,Clown goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Microgobius,Species,158804,3891,Species,,,,,,, -Microgobius thalassiunus,Microgobius thalassinus,Green goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Microgobius,Species,158805,3893,Species,,,,,,, -Microgobius thalassinus,Microgobius thalassinus,Green goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Microgobius,Species,158805,3893,Species,,,,,,, -Micropanope,Micropanope,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Micropanope,Genus,246346,NA,Remove,,,,,,, -Micropanope sculptipes,Micropanope sculptipes,Sculptured mud crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Micropanope,Species,422137,NA,Species,,,,,,, -Microphrys,Microphrys,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Mithracidae,Microphrys,Genus,415637,NA,Remove,,,,,,, -Micropogonias undulatus,Micropogonias undulatus,Atlantic croaker,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Micropogonias,Species,151158,408,Species,,,,,,, -Microporina,Microporina,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Microporidae,Microporina,Genus,160494,NA,Remove,,,,,,, -Microporina sp.,Microporina,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Microporidae,Microporina,Genus,160494,NA,Remove,,,,,,, -Microporina articulata,Microporina articulata,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Microporidae,Microporina,Species,160496,NA,Species,,,,,,, -Microspathodon chrysurus,Microspathodon chrysurus,Yellowtail damselfish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Microspathodon,Species,281571,1122,Species,,,,,,, -Embassichthys bathybius,Microstomus bathybius,Deep-sea sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Embassichthys,Species,305684,4236,Species,,,,,,, -Microstomus bathybius,Microstomus bathybius,Deep-sea sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Embassichthys,Species,305684,4236,Species,,,,,,, -Microstomus pacificus,Microstomus pacificus,Dover sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Microstomus,Species,274294,4247,Species,,,,,,, -Rochinia crassa,Minyorhyncha crassa,Inflated spiny crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Rochinia,Species,1252733,NA,Species,,,,,,, -Mithrax forceps,Mithraculus forceps,Red ridged clinging crab,Animalia,Arthropoda,Malacostraca,Decapoda,Mithracidae,Mithrax,Species,421988,NA,Species,,,,,,, -Mithraculus forceps,Mithraculus forceps,Red ridged clinging crab,Animalia,Arthropoda,Malacostraca,Decapoda,Mithracidae,Mithrax,Species,421988,NA,Species,,,,,,, -Mithrax,Mithrax,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Mithracidae,Mithrax,Genus,158428,NA,Remove,,,,,,, -Mithrax hispidus,Mithrax hispidus,Coral clinging crab,Animalia,Arthropoda,Malacostraca,Decapoda,Mithracidae,Mithrax,Species,158429,NA,Species,,,,,,, -Mithrax pleuracanthus,Mithrax pleuracanthus,Shaggy clinging crab,Animalia,Arthropoda,Malacostraca,Decapoda,Mithracidae,Mithrax,Species,454040,NA,Species,,,,,,, -Mnemiopsis,Mnemiopsis,NA,Animalia,Ctenophora,Tentaculata,Lobata,Bolinidae,Mnemiopsis,Genus,106355,NA,Remove,,,,,,, -Mnemiopsis mccradyi,Mnemiopsis leidyi,Sea walnut,Animalia,Ctenophora,Tentaculata,Lobata,Bolinidae,Mnemiopsis,Species,106401,NA,Species,,,,,,, -Manta birostris,Mobula birostris,Giant manta,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Myliobatidae,Manta,Species,1026118,2061,Species,,,,,,, -Mobula hypostoma,Mobula hypostoma,Devil ray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Myliobatidae,Mobula,Species,158530,2586,Species,,,,,,, -Modiolus,Modiolus,NA,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Modiolus,Genus,138223,NA,Remove,,,,,,, -Modiolus americanus,Modiolus americanus,Tulip mussel,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Modiolus,Species,420705,NA,Species,,,,,,, -Modiolus modiolus,Modiolus modiolus,Northern horsemussel,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Modiolus,Species,140467,NA,Species,,,,,,, -Moira atropus,Moira atropos,NA,Animalia,Echinodermata,Echinoidea,Spatangoida,Schizasteridae,Moira,Species,158067,NA,Species,,,,,,, -Moira atropos,Moira atropos,NA,Animalia,Echinodermata,Echinoidea,Spatangoida,Schizasteridae,Moira,Species,158067,NA,Species,,,,,,, -Mola mola,Mola mola,Ocean sunfish,Animalia,Chordata,Teleostei,Tetraodontiformes,Molidae,Mola,Species,127405,1732,Species,,,,,,, -Molgula,Molgula,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Molgulidae,Molgula,Genus,103509,NA,Remove,,,,,,, -Molgula sp.,Molgula,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Molgulidae,Molgula,Genus,103509,NA,Remove,,,,,,, -Molgula griffithsii,Molgula griffithsii,Sea grape,Animalia,Chordata,Ascidiacea,Stolidobranchia,Molgulidae,Molgula,Species,250885,NA,Species,,,,,,, -Molgula occidentalis,Molgula occidentalis,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Molgulidae,Molgula,Species,103790,NA,Species,,,,,,, -Molgula retortiformis,Molgula retortiformis,Sea clod,Animalia,Chordata,Ascidiacea,Stolidobranchia,Molgulidae,Molgula,Species,103796,NA,Species,,,,,,, -Mollusca,Mollusca,Molluscs,Animalia,Mollusca,NA,NA,NA,NA,Phylum,51,NA,Remove,,,,,,, -Moloha faxoni,Moloha faxoni,Pacific carrier crab,Animalia,Arthropoda,Malacostraca,Decapoda,Homolidae,Moloha,Species,440204,NA,Species,,,,,,, -Molpadia,Molpadia,NA,Animalia,Echinodermata,Holothuroidea,Molpadida,Molpadiidae,Molpadia,Genus,123540,NA,Remove,,,,,,, -Molpadia sp.,Molpadia,NA,Animalia,Echinodermata,Holothuroidea,Molpadida,Molpadiidae,Molpadia,Genus,123540,NA,Remove,,,,,,, -Molpadia barbouri,Molpadia barbouri,NA,Animalia,Echinodermata,Holothuroidea,Molpadida,Molpadiidae,Molpadia,Species,148820,NA,Species,,,,,,, -Molpadia cubana,Molpadia cubana,NA,Animalia,Echinodermata,Holothuroidea,Molpadida,Molpadiidae,Molpadia,Species,148822,NA,Species,,,,,,, -Molpadia intermedia,Molpadia intermedia,Sweet potato sea cucumber,Animalia,Echinodermata,Holothuroidea,Molpadida,Molpadiidae,Molpadia,Species,529545,NA,Species,,,,,,, -Molpadia oolitica,Molpadia oolitica,NA,Animalia,Echinodermata,Holothuroidea,Molpadida,Molpadiidae,Molpadia,Genus,124802,NA,Remove,,,,,,, -Molpadiidae,Molpadiidae,NA,Animalia,Echinodermata,Holothuroidea,Molpadida,Molpadiidae,NA,Family,123196,NA,Remove,,,,,,, -Molpidida,Molpidida,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Monacanthus,Monacanthus,NA,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Monacanthus,Genus,159496,NA,Remove,,,,,,, -Monacanthus ciliatus,Monacanthus ciliatus,Fringed filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Monacanthus,Species,159497,4280,Species,,,,,,, -Monacanthus tuckeri,Monacanthus tuckeri,Slender filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Monacanthus,Species,159499,NA,Species,,,,,,, -Monanchora alaskensis,Monanchora alaskensis,Alaskan horny sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Crambeidae,Monanchora,Species,169015,NA,Species,,,,,,, -Stelodoryx alaskensis,Monanchora alaskensis,Alaskan horny sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Crambeidae,Monanchora,Species,169015,NA,Species,,,,,,, -Monanchora pulchra,Monanchora pulchra,Yellow leafy sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Crambeidae,Monanchora,Species,169022,NA,Species,,,,,,, -Monolene sessilicauda,Monolene sessilicauda,Deepwater flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Bothidae,Monolene,Species,159213,4227,Species,,,,,,, -Cymatium krebsii,Monoplex krebsii,Krebs hairy triton,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cymatiidae,Cymatium,Species,476525,NA,Species,,,,,,, -Monoplex krebsii,Monoplex krebsii,Krebs hairy triton,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cymatiidae,Cymatium,Species,476525,NA,Species,,,,,,, -Cymatium parthenopeum,Monoplex parthenopeus,Giant triton,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cymatiidae,Cymatium,Species,476531,NA,Species,,,,,,, -Monoplex parthenopeus,Monoplex parthenopeus,Giant triton,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cymatiidae,Cymatium,Species,476531,NA,Species,,,,,,, -Cymatium pileare,Monoplex pilearis,Common hairy triton,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cymatiidae,Cymatium,Species,476533,NA,Species,,,,,,, -Monoplex pilearis,Monoplex pilearis,Common hairy triton,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cymatiidae,Cymatium,Species,476533,NA,Species,,,,,,, -Mopalia,Mopalia,NA,Animalia,Mollusca,Polyplacophora,Chitonida,Mopaliidae,Mopalia,Genus,385567,NA,Remove,,,,,,, -Mopalia egretta,Mopalia egretta,Egret plumped mopalia,Animalia,Mollusca,Polyplacophora,Chitonida,Mopaliidae,Mopalia,Species,386344,NA,Species,,,,,,, -Mopalia swanii,Mopalia swanii,Swan's mopalia,Animalia,Mollusca,Polyplacophora,Chitonida,Mopaliidae,Mopalia,Species,386361,NA,Species,,,,,,, -Mopaliidae,Mopaliidae,NA,Animalia,Mollusca,Polyplacophora,Chitonida,Mopaliidae,NA,Family,23074,NA,Remove,,,,,,, -Moreiradromia,Moreiradromia,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Dromiidae,Moreiradromia,Genus,415655,NA,Remove,,,,,,, -Cryptodromiopsis antillensis,Moreiradromia antillensis,Hairy sponge crab,Animalia,Arthropoda,Malacostraca,Decapoda,Dromiidae,Cryptodromiopsis,Species,421894,NA,Species,,,,,,, -Dromidia antillensis,Moreiradromia antillensis,Hairy sponge crab,Animalia,Arthropoda,Malacostraca,Decapoda,Dromiidae,Dromidia,Species,421894,NA,Species,,,,,,, -Moreiradromia antillensis,Moreiradromia antillensis,Hairy sponge crab,Animalia,Arthropoda,Malacostraca,Decapoda,Dromiidae,Dromidia,Species,421894,NA,Species,,,,,,, -Moridae,Moridae,NA,Animalia,Chordata,Teleostei,Gadiformes,Moridae,NA,Family,125474,NA,Remove,,,,,,, -Morone americana,Morone americana,White perch,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Moronidae,Morone,Species,151177,355,Species,,,,,,, -Morone saxatilis,Morone saxatilis,Striped bass,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Moronidae,Morone,Species,151179,353,Species,,,,,,, -Mugil,Mugil,NA,Animalia,Chordata,Teleostei,Mugiliformes,Mugilidae,Mugil,Genus,126032,NA,Remove,,,,,,, -Mugil cephalus,Mugil cephalus,Flathead grey mullet,Animalia,Chordata,Teleostei,Mugiliformes,Mugilidae,Mugil,Species,126983,785,Species,,,,,,, -Mugil curema,Mugil curema,White mullet,Animalia,Chordata,Teleostei,Mugiliformes,Mugilidae,Mugil,Species,159416,1086,Species,,,,,,, -Mullidae,Mullidae,NA,Animalia,Chordata,Teleostei,Mulliformes,Mullidae,NA,Family,125547,NA,Remove,,,,,,, -Mulloidichthys martinicus,Mulloidichthys martinicus,Yellow goatfish,Animalia,Chordata,Teleostei,Mulliformes,Mullidae,Mulloidichthys,Species,277991,1092,Species,,,,,,, -Mullus,Mullus,NA,Animalia,Chordata,Teleostei,Mulliformes,Mullidae,Mullus,Genus,126034,NA,Remove,,,,,,, -Mullus auratus,Mullus auratus,Red goatfish,Animalia,Chordata,Teleostei,Mulliformes,Mullidae,Mullus,Species,159418,1093,Species,,,,,,, -Munida,Munida,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Munididae,Munida,Genus,106835,NA,Remove,,,,,,, -Munidopsis,Munidopsis,Squat lobsters,Animalia,Arthropoda,Malacostraca,Decapoda,Munidopsidae,Munidopsis,Genus,106836,NA,Remove,,,,,,, -Munidopsis sp.,Munidopsis,Squat lobsters,Animalia,Arthropoda,Malacostraca,Decapoda,Munidopsidae,Munidopsis,Genus,106836,NA,Remove,,,,,,, -Munidopsis hystrix,Munidopsis hystrix,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Munidopsidae,Munidopsis,Species,392539,NA,Species,,,,,,, -Munidopsis quadrata,Munidopsis quadrata,Four-cornered squat lobster,Animalia,Arthropoda,Malacostraca,Decapoda,Munidopsidae,Munidopsis,Species,392590,NA,Species,,,,,,, -Munidopsis robusta,Munidopsis robusta,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Munidopsidae,Munidopsis,Species,392596,NA,Species,,,,,,, -Munidopsis a,Munidopsis sp. A,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Munidopsidae,Munidopsis,Species,NA,NA,Species,,,,,,, -Munidopsis sp. A,Munidopsis sp. A,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Munidopsidae,Munidopsis,Species,NA,NA,Species,,,,,,, -Munidopsis verrilli,Munidopsis verrilli,Verrill pinch bug,NA,NA,NA,NA,NA,NA,Species,392640,NA,Species,,,,,,, -Muraena retifera,Muraena retifera,Reticulate moray,Animalia,Chordata,Teleostei,Anguilliformes,Muraenidae,Muraena,Species,158586,2618,Species,,,,,,, -Muraenidae,Muraenidae,NA,Animalia,Chordata,Teleostei,Anguilliformes,Muraenidae,NA,Family,125431,NA,Remove,,,,,,, -Murex,Murex,Murex snails,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Murex,Genus,138196,NA,Remove,,,,,,, -Muricea,Muricea,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Plexauridae,Muricea,Genus,177745,NA,Remove,,,,,,, -Muriceides,Muriceides,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Paramuriceidae,Muriceides,Genus,125310,NA,Remove,,,,,,, -Muriceides sp.,Muriceides,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Paramuriceidae,Muriceides,Genus,125310,NA,Remove,,,,,,, -Muriceides nigra,Muriceides nigra,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Paramuriceidae,Muriceides,Species,286365,NA,Species,,,,,,, -Muricidae,Muricidae,Murex snails,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,NA,Family,148,NA,Remove,,,,,,, -Musculus,Musculus,NA,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Musculus,Genus,138225,NA,Remove,,,,,,, -Musculus sp.,Musculus,NA,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Musculus,Genus,138225,NA,Remove,,,,,,, -Musculus discors,Musculus discors,Discordant mussel,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Musculus,Species,140472,NA,Species,,,,,,, -Musculus olivaceus,Musculus discors,Discordant mussel,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Musculus,Species,140472,NA,Species,,,,,,, -Musculus niger,Musculus niger,Black mussel,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Musculus,Species,140474,NA,Species,,,,,,, -Mustelus,Mustelus,NA,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Triakidae,Mustelus,Genus,105732,NA,Remove,,,,,,, -Mustelus sp.,Mustelus,NA,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Triakidae,Mustelus,Genus,105732,NA,Remove,,,,,,, -Mustelus sp,Mustelus,NA,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Triakidae,Mustelus,Genus,105732,NA,Remove,,,,,,, -Mustelus californicus,Mustelus californicus,Gray smooth-hound,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Triakidae,Mustelus,Species,271381,2538,Species,,,,,,, -Mustelus canis,Mustelus canis,Smooth dogfish,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Triakidae,Mustelus,Species,158518,2539,Species,,,,,,, -Mustelus henlei,Mustelus henlei,Brown smooth-hound,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Triakidae,Mustelus,Species,271386,2540,Species,,,,,,, -Mustelus lunulatus,Mustelus lunulatus,Sicklefin smooth-hound,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Triakidae,Mustelus,Species,271389,2541,Species,,,,,,, -Mustelus norrisi,Mustelus norrisi,Narrowfin smooth-hound,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Triakidae,Mustelus,Species,271392,2542,Species,,,,,,, -Mustelus sinusmexicanus,Mustelus sinusmexicanus,Gulf smooth-hound,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Triakidae,Mustelus,Species,271394,50773,Species,,,,,,, -Benthoctopus leioderma,Muusoctopus leioderma,Smoothskin octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Bathypolypodidae,Benthoctopus,Species,1043781,NA,Species,,,,,,, -Muusoctopus leioderma,Muusoctopus leioderma,Smoothskin octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Bathypolypodidae,Benthoctopus,Species,1043781,NA,Species,,,,,,, -Benthoctopus oregonensis,Muusoctopus oregonensis,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Bathypolypodidae,Benthoctopus,Species,527160,NA,Species,,,,,,, -Muusoctopus oregonensis,Muusoctopus oregonensis,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Bathypolypodidae,Benthoctopus,Species,527160,NA,Species,,,,,,, -Benthoctopus sibiricus,Muusoctopus sibiricus,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Bathypolypodidae,Benthoctopus,Species,527164,NA,Species,,,,,,, -Muusoctopus sibiricus,Muusoctopus sibiricus,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Bathypolypodidae,Benthoctopus,Species,527164,NA,Species,,,,,,, -Mya,Mya,Gaper clams,Animalia,Mollusca,Bivalvia,Myida,Myidae,Mya,Genus,138211,NA,Remove,,,,,,, -Mya sp.,Mya,Gaper clams,Animalia,Mollusca,Bivalvia,Myida,Myidae,Mya,Genus,138211,NA,Remove,,,,,,, -Mya arenaria,Mya arenaria,Softshell clam,Animalia,Mollusca,Bivalvia,Myida,Myidae,Mya,Species,140430,NA,Species,,,,,,, -Mya baxteri,Mya baxteri,NA,Animalia,Mollusca,Bivalvia,Myida,Myidae,Mya,Species,505900,NA,Species,,,,,,, -Mya elegans,Mya elegans,NA,Animalia,Mollusca,Bivalvia,Myida,Myidae,Mya,Genus,138211,NA,Remove,,,,,,, -Mya pseudoarenaria,Mya pseudoarenaria,False softshell,Animalia,Mollusca,Bivalvia,Myida,Myidae,Mya,Species,156249,NA,Species,,,,,,, -Mya truncata,Mya truncata,Truncate softshell,Animalia,Mollusca,Bivalvia,Myida,Myidae,Mya,Species,140431,NA,Species,,,,,,, -Mycale,Mycale,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Mycalidae,Mycale,Genus,131907,NA,Remove,,,,,,, -Mycale sp.,Mycale,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Mycalidae,Mycale,Genus,131907,NA,Remove,,,,,,, -Mycale adhaerens,Mycale (Aegogropila) adhaerens,Smooth scallop sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Mycalidae,Mycale,Species,168518,NA,Species,,,,,,, -Mycale carlilei,Mycale (Carmia) carlilei,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Mycalidae,Mycale,Species,225435,NA,Species,,,,,,, -Mycale bellabellensis,Mycale (Mycale) loveni,Loven's horny sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Mycalidae,Mycale,Species,168642,NA,Species,,,,,,, -Mycale loveni,Mycale (Mycale) loveni,Loven's horny sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Mycalidae,Mycale,Species,168642,NA,Species,,,,,,, -Mycale tylota,Mycale (Mycale) tylota,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Mycalidae,Mycale,Species,168664,NA,Species,,,,,,, -Mycale sp. A (Clark 2006),Mycale sp. A (Clark 2006),red mycale,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Mycteroperca,Mycteroperca,NA,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Mycteroperca,Genus,126069,NA,Remove,,,,,,, -Mycteroperca bonaci,Mycteroperca bonaci,Black grouper,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Mycteroperca,Species,159231,1209,Species,,,,,,, -Mycteroperca interstitialis,Mycteroperca interstitialis,Yellowmouth grouper,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Mycteroperca,Species,273878,1211,Species,,,,,,, -Mycteroperca microlepis,Mycteroperca microlepis,Gag,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Mycteroperca,Species,273880,1212,Species,,,,,,, -Mycteroperca phenax,Mycteroperca phenax,Scamp,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Mycteroperca,Species,159233,1213,Species,,,,,,, -Mycteroperca venenosa,Mycteroperca venenosa,Yellowfin grouper,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Mycteroperca,Species,273885,1216,Species,,,,,,, -Myctophidae,Myctophidae,Lanternfishes,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,NA,Family,125498,NA,Remove,,,,,,, -Myctophinae,Myctophinae,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,NA,Species,395001,NA,Species,,,,,,, -Myctophum humboldti,Myctophum punctatum,Spotted lanternfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Myctophum,Species,126627,1328,Species,,,,,,, -Myctophum punctatum,Myctophum punctatum,Spotted lanternfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Myctophum,Species,126627,1328,Species,,,,,,, -Myliobatidae,Myliobatidae,NA,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Myliobatidae,NA,Family,105710,NA,Remove,,,,,,, -Myliobatis californica,Myliobatis californica,Bat eagle ray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Myliobatidae,Myliobatis,Species,271485,2582,Species,,,,,,, -Myliobatis freminvillei,Myliobatis freminvillei,Bullnose eagle ray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Myliobatidae,Myliobatis,Species,399783,1251,Species,,,,,,, -Myliobatis freminvillii,Myliobatis freminvillei,Bullnose eagle ray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Myliobatidae,Myliobatis,Species,399783,1251,Species,,,,,,, -Myliobatis goodei,Myliobatis goodei,Southern eagle ray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Myliobatidae,Myliobatis,Species,271487,2583,Species,,,,,,, -Myopsida,Myopsida,NA,Animalia,Mollusca,Cephalopoda,Myopsida,NA,NA,Order,11728,NA,Remove,,,,,,, -Myoxocephalus,Myoxocephalus,Stellate sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Myoxocephalus,Genus,126152,NA,Remove,,,,,,, -Myoxocephalus sp.,Myoxocephalus,Stellate sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Myoxocephalus,Genus,126152,NA,Remove,,,,,,, -Myoxocephalus aenaeus,Myoxocephalus aenaeus,Grubby,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Myoxocephalus,Species,159519,4117,Species,,,,,,, -Myoxocephalus jaok,Myoxocephalus jaok,Plain sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Myoxocephalus,Species,254527,4118,Species,,,,,,, -Myoxocephalus octodecemspinosus,Myoxocephalus octodecemspinosus,Longhorn sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Myoxocephalus,Species,159520,4120,Species,,,,,,, -Myoxocephalus polyacanthocephalus,Myoxocephalus polyacanthocephalus,Great sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Myoxocephalus,Species,254528,4121,Species,,,,,,, -Myoxocephalus quadricornis,Myoxocephalus quadricornis,Fourhorn sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Myoxocephalus,Species,254529,4122,Species,,,,,,, -Myoxocephalus scorpioides,Myoxocephalus scorpioides,Arctic sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Myoxocephalus,Species,127202,4123,Species,,,,,,, -Myoxocephalus scorpius,Myoxocephalus scorpius,Shorthorn sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Myoxocephalus,Species,127203,1329,Species,,,,,,, -Myra elegans,Myra elegans,elegant soft shell,NA,NA,NA,NA,NA,NA,Species,238387,NA,Species,,,,,,, -Myriapora,Myriapora,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Myriaporidae,Myriapora,Genus,110949,NA,Remove,,,,,,, -Myriapora sp.,Myriapora,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Myriaporidae,Myriapora,Genus,110949,NA,Remove,,,,,,, -Myriapora orientalis,Myriapora orientalis,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Myriaporidae,Myriapora,Species,423543,NA,Species,,,,,,, -Myrichthys oculatus,Myrichthys ocellatus,Goldspotted eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Myrichthys,Species,275486,2651,Species,,,,,,, -Ophichthus ocellatus,Myrichthys ocellatus,Goldpotted eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Myrichthys,Species,275486,2651,Species,,,,,,, -Myrichthys ocellatus,Myrichthys ocellatus,Goldpotted eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Myrichthys,Species,275486,2651,Species,,,,,,, -Myriotrochus rinkii,Myriotrochus rinkii,Rink's footless sea cucumber,Animalia,Echinodermata,Holothuroidea,Apodida,Myriotrochidae,Myriotrochus,Species,124446,NA,Species,,,,,,, -Myripristis jacobus,Myripristis jacobus,Blackbar soldierfish,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Myripristis,Species,159385,1063,Species,,,,,,, -Myrophis punctatus,Myrophis punctatus,Speckled worm-eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Myrophis,Species,158643,2652,Species,,,,,,, -Myropsis,Myropsis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Leucosiidae,Myropsis,Genus,158430,NA,Remove,,,,,,, -Myropsis quinquespinosa,Myropsis quinquespinosa,Fivespine purse crab,Animalia,Arthropoda,Malacostraca,Decapoda,Leucosiidae,Myropsis,Species,158431,NA,Species,,,,,,, -Mysida,Mysida,Mysid shrimps,Animalia,Arthropoda,Malacostraca,Mysida,NA,NA,Order,149668,NA,Remove,,,,,,, -Mysidae,Mysidae,NA,Animalia,Arthropoda,Malacostraca,Mysida,Mysidae,NA,Family,119822,NA,Remove,,,,,,, -Mytilidae,Mytilidae,Mussel unid.,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,NA,Family,211,NA,Remove,,,,,,, -Mytilus,Mytilus,NA,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Mytilus,Genus,138228,NA,Remove,,,,,,, -Mytilus sp.,Mytilus,NA,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Mytilus,Genus,138228,NA,Remove,,,,,,, -Mytilus californianus,Mytilus californianus,California mussel,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Mytilus,Species,367837,NA,Species,,,,,,, -Mytilus edulis,Mytilus edulis,Blue mussel,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Mytilus,Species,140480,NA,Species,,,,,,, -Mytilus trossulus,Mytilus trossulus,Foolish mussel,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Mytilus,Species,140482,NA,Species,,,,,,, -Myxilla parasitica,Myxilla (Ectyomyxilla) parasitica,Parasitic horny sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Myxillidae,Myxilla,Species,169437,NA,Species,,,,,,, -Myxilla lacunosa,Myxilla (Myxilla) lacunosa,Sulphur horny sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Myxillidae,Myxilla,Species,1382889,NA,Species,,,,,,, -Myxilla brunnea,Myxilla brunnea,soft brown sponge,NA,NA,NA,NA,NA,NA,Species,133874,NA,Species,,,,,,, -Myxine glutinosa,Myxine glutinosa,Atlantic hagfish,Animalia,Chordata,Myxini,Myxiniformes,Myxinidae,Myxine,Species,101170,2513,Species,,,,,,, -Myxinidae,Myxinidae,Hagfishes,Animalia,Chordata,Myxini,Myxiniformes,Myxinidae,NA,Family,101162,NA,Remove,,,,,,, -Myxoderma platyacanthum,Myxoderma platyacanthum,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Zoroasteridae,Myxoderma,Species,255084,NA,Species,,,,,,, -Myxoderma sacculatum,Myxoderma sacculatum,Giant slimy star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Zoroasteridae,Myxoderma,Species,255087,NA,Species,,,,,,, -Limanda ferruginea,Myzopsetta ferruginea,Yellowtail flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Limanda,Species,1571969,521,Species,,,,,,, -Limanda proboscidea,Myzopsetta proboscidea,Longhead dab,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Limanda,Species,319505,4243,Species,,,,,,, -Myzopsetta proboscidea,Myzopsetta proboscidea,Longhead dab,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Limanda,Species,319505,4243,Species,,,,,,, -Nalbantichthys elongatus,Nalbantichthys elongatus,Thinskin eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Nalbantichthys,Species,281630,47907,Species,,,,,,, -Nannobrachium,Nannobrachium,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Nannobrachium,Genus,158908,NA,Remove,,,,,,, -Nannobrachium sp.,Nannobrachium,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Nannobrachium,Genus,158908,NA,Remove,,,,,,, -Nanoplax xanthiformis,Nanoplax xanthiformis,Rough squareback crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Nanoplax,Species,422113,NA,Species,,,,,,, -Nansenia candida,Nansenia candida,Bluethroat argentine,Animalia,Chordata,Teleostei,Argentiniformes,Microstomatidae,Nansenia,Species,272926,12233,Species,,,,,,, -Narcine,Narcine,NA,Animalia,Chordata,Elasmobranchii,Torpediniformes,Narcinidae,Narcine,Genus,157865,NA,Remove,,,,,,, -Narcine bancroftii,Narcine bancroftii,Lesser electric ray,Animalia,Chordata,Elasmobranchii,Torpediniformes,Narcinidae,Narcine,Species,275386,NA,Species,,,,,,, -Narcine brasiliensis,Narcine brasiliensis,Brazilian electric ray,Animalia,Chordata,Elasmobranchii,Torpediniformes,Narcinidae,Narcine,Species,157866,2551,Species,,,,,,, -Narcissia trigonaria,Narcissia trigonaria,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Ophidiasteridae,Narcissia,Species,124097,NA,Species,,,,,,, -Naria acicularis,Naria acicularis,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cypraeidae,Naria,Species,1075023,NA,Species,,,,,,, -Cypraea spurca,Naria spurca,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cypraeidae,Cypraea,Species,1075013,NA,Species,,,,,,, -Naria spurca,Naria spurca,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cypraeidae,Cypraea,Species,1075013,NA,Species,,,,,,, -Natica,Natica,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Natica,Genus,138240,NA,Remove,,,,,,, -Natica sp.,Natica,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Natica,Genus,138240,NA,Remove,,,,,,, -Natica canrena,Naticarius canrena,Colorful moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Natica,Species,419760,NA,Species,,,,,,, -Naticarius canrena,Naticarius canrena,Colorful moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Natica,Species,419760,NA,Species,,,,,,, -Naticidae,Naticidae,Moon snails,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,NA,Family,145,NA,Remove,,,,,,, -Naucrates ductor,Naucrates ductor,Pilotfish,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Naucrates,Species,126811,998,Species,,,,,,, -Nautichthys,Nautichthys,NA,Animalia,Chordata,Teleostei,Perciformes,Hemitripteridae,Nautichthys,Genus,254400,NA,Remove,,,,,,, -Nautichthys sp.,Nautichthys,NA,Animalia,Chordata,Teleostei,Perciformes,Hemitripteridae,Nautichthys,Genus,254400,NA,Remove,,,,,,, -Nautichthys oculofasciatus,Nautichthys oculofasciatus,Sailfin sculpin,Animalia,Chordata,Teleostei,Perciformes,Hemitripteridae,Nautichthys,Species,254542,4125,Species,,,,,,, -Nautichthys pribilovius,Nautichthys pribilovius,Eyeshade sculpin,Animalia,Chordata,Teleostei,Perciformes,Hemitripteridae,Nautichthys,Species,254543,4126,Species,,,,,,, -Nautichthys robustus,Nautichthys robustus,Shortmast sculpin,Animalia,Chordata,Teleostei,Perciformes,Hemitripteridae,Nautichthys,Species,254401,4127,Species,,,,,,, -Nearchaster,Nearchaster,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Benthopectinidae,Nearchaster,Genus,370821,NA,Remove,,,,,,, -Nearchaster sp.,Nearchaster,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Benthopectinidae,Nearchaster,Genus,370821,NA,Remove,,,,,,, -Nearchaster aciculosus,Nearchaster (Nearchaster) aciculosus,Needle spined fragile star,Animalia,Echinodermata,Asteroidea,Paxillosida,Benthopectinidae,Nearchaster,Species,370821,NA,Species,,,,,,, -Nearchaster pedicellaris,Nearchaster (Nearchaster) pedicellaris,Pedicillate fragile star,Animalia,Echinodermata,Asteroidea,Paxillosida,Benthopectinidae,Nearchaster,Species,370821,NA,Species,,,,,,, -Nearchaster variabilis,Nearchaster (Nearchaster) variabilis,Variable fragile star,Animalia,Echinodermata,Asteroidea,Paxillosida,Benthopectinidae,Nearchaster,Species,370821,NA,Species,,,,,,, -Nectoliparis pelagicus,Nectoliparis pelagicus,Tadpole snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Nectoliparis,Species,281641,4201,Species,,,,,,, -Nematocarcinus,Nematocarcinus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Nematocarcinidae,Nematocarcinus,Genus,107015,NA,Remove,,,,,,, -Nematoda,Nematoda,Roundworms,Animalia,Nematoda,NA,NA,NA,NA,Phylum,799,NA,Remove,,,,,,, -Nemausa,Nemausa,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Mithracidae,Nemausa,Genus,415683,NA,Remove,,,,,,, -Mithrax acuticornis,Nemausa acuticornis,Sharphorn clinging crab,Animalia,Arthropoda,Malacostraca,Decapoda,Mithracidae,Mithrax,Species,421996,NA,Species,,,,,,, -Nemausa acuticornis,Nemausa acuticornis,Sharphorn clinging crab,Animalia,Arthropoda,Malacostraca,Decapoda,Mithracidae,Mithrax,Species,421996,NA,Species,,,,,,, -Nemertea,Nemertea,Ribbon worms,Animalia,Nemertea,NA,NA,NA,NA,Phylum,152391,NA,Remove,,,,,,, -Nemichthyidae,Nemichthyidae,Snipe eels,Animalia,Chordata,Teleostei,Anguilliformes,Nemichthyidae,NA,Family,125432,NA,Remove,,,,,,, -Nemichthys larseni,Nemichthys larseni,Pale snipe eel,Animalia,Chordata,Teleostei,Anguilliformes,Nemichthyidae,Nemichthys,Species,271905,59502,Species,,,,,,, -Nemichthys scolopaceus,Nemichthys scolopaceus,Slender snipe eel,Animalia,Chordata,Teleostei,Anguilliformes,Nemichthyidae,Nemichthys,Species,126306,2660,Species,,,,,,, -Neoberingius,Neoberingius,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neoberingius,Genus,575806,NA,Remove,,,,,,, -Neoberingius sp.,Neoberingius,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neoberingius,Genus,575806,NA,Remove,,,,,,, -Beringius frielei,Neoberingius frielei,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neoberingius,Species,580900,NA,Species,,,,,,, -Neoberingius frielei,Neoberingius frielei,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neoberingius,Species,580900,NA,Species,,,,,,, -Neobythites gillii,Neobythites gilli,Twospot brotula,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Neobythites,Species,276615,47856,Species,,,,,,, -Neobythites marginatus,Neobythites marginatus,Stripefin brotula,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Neobythites,Species,276624,54476,Species,,,,,,, -Neoclinus blanchardi,Neoclinus blanchardi,Sarcastic fringehead,Animalia,Chordata,Teleostei,Blenniiformes,Chaenopsidae,Neoclinus,Species,281679,3740,Species,,,,,,, -Neoconger mucronatus,Neoconger mucronatus,Ridged eel,Animalia,Chordata,Teleostei,Anguilliformes,Moringuidae,Neoconger,Species,158580,2604,Species,,,,,,, -Crangon abyssorum,Neocrangon abyssorum,Abyssal crangon,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Crangon,Species,515583,NA,Species,,,,,,, -Neocrangon abyssorum,Neocrangon abyssorum,Abyssal crangon,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Crangon,Species,515583,NA,Species,,,,,,, -Crangon communis,Neocrangon communis,Gray shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Crangon,Species,423552,NA,Species,,,,,,, -Neocrangon communis,Neocrangon communis,Gray shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Crangon,Species,423552,NA,Species,,,,,,, -Neoepinnula americanus,Neoepinnula americana,American sackfish,Animalia,Chordata,Teleostei,Scombriformes,Gempylidae,Neoepinnula,Species,159712,8479,Species,,,,,,, -Neoepinnula americana,Neoepinnula americana,American sackfish,Animalia,Chordata,Teleostei,Scombriformes,Gempylidae,Neoepinnula,Species,159712,8479,Species,,,,,,, -Neogastropoda,Neogastropoda,Neogastropods whelks & cone shells,Animalia,Mollusca,Gastropoda,Neogastropoda,NA,NA,Order,146,NA,Remove,,,,,,, -Neognathophausia,Neognathophausia,NA,Animalia,Arthropoda,Malacostraca,Lophogastrida,Gnathophausiidae,Neognathophausia,Genus,119827,NA,Remove,,,,,,, -Neognathophausia sp.,Neognathophausia,NA,Animalia,Arthropoda,Malacostraca,Lophogastrida,Gnathophausiidae,Neognathophausia,Genus,119827,NA,Remove,,,,,,, -Neognathophausia gigas,Neognathophausia gigas,Giant red mysid,Animalia,Arthropoda,Malacostraca,Lophogastrida,Gnathophausiidae,Neognathophausia,Species,119931,NA,Species,,,,,,, -Neognathophausia ingens,Neognathophausia ingens,Giant red mysid,Animalia,Arthropoda,Malacostraca,Lophogastrida,Gnathophausiidae,Neognathophausia,Species,220999,NA,Species,,,,,,, -Neognathophausia a,Neognathophausia sp. A,NA,Animalia,Arthropoda,Malacostraca,Lophogastrida,Gnathophausiidae,Neognathophausia,Species,NA,NA,Species,,,,,,, -Neognathophausia sp. a,Neognathophausia sp. A,NA,Animalia,Arthropoda,Malacostraca,Lophogastrida,Gnathophausiidae,Neognathophausia,Species,NA,NA,Species,,,,,,, -Neogonodactylus,Neogonodactylus,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Gonodactylidae,Neogonodactylus,Species,408934,NA,Species,,,,,,, -Gonodactylus bredini,Neogonodactylus bredini,Split-thumb mantis shrimp,Animalia,Arthropoda,Malacostraca,Stomatopoda,Gonodactylidae,Neogonodactylus,Species,408938,NA,Species,,,,,,, -Neogonodactylus bredini,Neogonodactylus bredini,Split-thumb mantis shrimp,Animalia,Arthropoda,Malacostraca,Stomatopoda,Gonodactylidae,Neogonodactylus,Species,408938,NA,Species,,,,,,, -Gonodactylus torus,Neogonodactylus torus,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Gonodactylidae,Gonodactylus,Species,408954,NA,Species,,,,,,, -Neogonodactylus torus,Neogonodactylus torus,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Gonodactylidae,Gonodactylus,Species,408954,NA,Species,,,,,,, -Neoiphinoe coronata,Neoiphinoe coronata,Crowned hairysnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Capulidae,Neoiphinoe,Species,576321,NA,Species,,,,,,, -Neolithodes diomedeae,Neolithodes diomedeae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Neolithodes,Species,378126,NA,Species,,,,,,, -Neomenia,Neomenia,NA,Animalia,Mollusca,Solenogastres,NA,Neomeniidae,Neomenia,Genus,138249,NA,Remove,,,,,,, -Neomenia sp.,Neomenia,NA,Animalia,Mollusca,Solenogastres,NA,Neomeniidae,Neomenia,Genus,138249,NA,Remove,,,,,,, -Neomenia cf. yamamotoi (Clark 2006),Neomenia cf. yamamotoi (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,367834,NA,Species,,,,,,, -Neomenia efgamatoi,Neomenia efgamatoi,NA,Animalia,Mollusca,Solenogastres,NA,Neomeniidae,Neomenia,Species,138249,NA,Species,,,,,,, -Neomenia yamamoti,Neomenia yamamotoi,NA,Animalia,Mollusca,Solenogastres,NA,Neomeniidae,Neomenia,Species,367834,NA,Species,,,,,,, -Neomeniomorpha,Neomeniomorpha,Solenogaster unidentified,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Neomerinthe beanorum,Neomerinthe beanorum,NA,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Neomerinthe,Species,276261,48366,Species,,,,,,, -Neomerinthe hemingwayi,Neomerinthe hemingwayi,Spinycheek scorpionfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Neomerinthe,Species,159554,3930,Species,,,,,,, -Neon yellow vase sponge,Neon yellow vase sponge,NA,NA,NA,NA,NA,NA,NA,Remove,NA,NA,Remove,,,,,,, -Holocentrus marianus,Neoniphon marianus,Longjaw squirrelfish,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Holocentrus,Species,276205,3249,Species,,,,,,, -Neoniphon marianus,Neoniphon marianus,Longjaw squirrelfish,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Holocentrus,Species,276205,3249,Species,,,,,,, -Neopanope,Neopanope,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Neopanope,Genus,148439,NA,Remove,,,,,,, -Neoscopelidae,Neoscopelidae,NA,Animalia,Chordata,Teleostei,Myctophiformes,Neoscopelidae,NA,Family,125499,NA,Remove,,,,,,, -Neoscopelus macrolepidotus,Neoscopelus macrolepidotus,Large scaled lantern fish,Animalia,Chordata,Teleostei,Myctophiformes,Neoscopelidae,Neoscopelus,Species,126634,7422,Species,,,,,,, -Terebra dislocata,Neoterebra dislocata,Eastern auger,Animalia,Mollusca,Gastropoda,Neogastropoda,Terebridae,Terebra,Species,1416382,NA,Species,,,,,,, -Callianassa californiensis,Neotrypaea californiensis,Bay ghost shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Callianassidae,Callianassa,Species,465347,NA,Species,,,,,,, -Neoturris breviconis,Neoturris breviconis,Blob top jelly,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Pandeidae,Neoturris,Species,285143,NA,Species,,,,,,, -Nephropsis,Nephropsis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Nephropidae,Nephropsis,Genus,106864,NA,Remove,,,,,,, -Nephropsis aculeata,Nephropsis aculeata,Florida lobsterette,Animalia,Arthropoda,Malacostraca,Decapoda,Nephropidae,Nephropsis,Species,382862,NA,Species,,,,,,, -Nephtheidae,Nephtheidae,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Nephtheidae,NA,Family,146762,NA,Remove,,,,,,, -Nephtyidae,Nephtyidae,Catworms,Animalia,Annelida,Polychaeta,Phyllodocida,Nephtyidae,NA,Family,956,NA,Remove,,,,,,, -Neptunea,Neptunea,True whelks,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Genus,137710,NA,Remove,,,,,,, -Neptunea sp.,Neptunea,True whelks,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Genus,137710,NA,Remove,,,,,,, -Neptunea alexeyevi,Neptunea alexeyevi,Sinuous neptune,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,457369,NA,Species,,,,,,, -Neptunea amianta,Neptunea amianta,White neptune,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,423554,NA,Species,,,,,,, -Neptunea borealis,Neptunea borealis,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,254478,NA,Species,,,,,,, -Neptunea gyroscopoides,Neptunea gyroscopoides,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,457372,NA,Species,,,,,,, -Neptunea heros,Neptunea heros,Northern neptune whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,254479,NA,Species,,,,,,, -Neptunea humboldtiana,Neptunea humboldtiana,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,491171,NA,Species,,,,,,, -Neptunea insularis,Neptunea insularis,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,491172,NA,Species,,,,,,, -Neptunea ithia,Neptunea ithia,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,491174,NA,Species,,,,,,, -Neptunea lyrata,Neptunea lyrata,Lyre whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,254477,NA,Species,,,,,,, -Neptunea middendorffii,Neptunea middendorffiana,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,160405,NA,Species,,,,,,, -Neptunea middendorffiana,Neptunea middendorffiana,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,160405,NA,Species,,,,,,, -Neptunea phoenicea,Neptunea phoenicea,Phoenician whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,580903,NA,Species,,,,,,, -Neptunea pribiloffensis,Neptunea pribiloffensis,Pribilof whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,491185,NA,Species,,,,,,, -Neptunea smirnia,Neptunea smirnia,Smirnia whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,491189,NA,Species,,,,,,, -Neptunea sp. A (McLean and Clark),Neptunea sp. A (McLean and Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Neptunea sp. B (McLean and Clark),Neptunea sp. B (McLean and Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Neptunea sp. C (McLean and Clark),Neptunea sp. C (McLean and Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Neptunea sp. E (Clark and McLean),Neptunea sp. E (Clark and McLean),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Neptunea sp. egg,Neptunea sp. egg,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Neptunea sp. G (Clark and McLean),Neptunea sp. G (Clark and McLean),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Neptunea stilesi,Neptunea stilesi,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,491190,NA,Species,,,,,,, -Neptunea tabulata,Neptunea tabulata,Tabled whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,491192,NA,Species,,,,,,, -Neptunea ventricosa,Neptunea ventricosa,Fat whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Neptunea,Species,156264,NA,Species,,,,,,, -Nereidae,Nereidae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Nereididae,Nereididae,Ragworms,Animalia,Annelida,Polychaeta,Phyllodocida,Nereididae,NA,Family,22496,NA,Remove,,,,,,, -Nereis,Nereis,NA,Animalia,Annelida,Polychaeta,Phyllodocida,Nereididae,Nereis,Genus,129379,NA,Remove,,,,,,, -Nereis sp.,Nereis,NA,Animalia,Annelida,Polychaeta,Phyllodocida,Nereididae,Nereis,Genus,129379,NA,Remove,,,,,,, -Nerocila acuminata,Nerocila acuminata,NA,Animalia,Arthropoda,Malacostraca,Isopoda,Cymothoidae,Nerocila,Species,118906,NA,Species,,,,,,, -Nesiarchus nasutus,Nesiarchus nasutus,Black gemfish,Animalia,Chordata,Teleostei,Scombriformes,Gempylidae,Nesiarchus,Species,126865,7573,Species,,,,,,, -Nettastomatidae,Nettastomatidae,NA,Animalia,Chordata,Teleostei,Anguilliformes,Nettastomatidae,NA,Family,125433,NA,Remove,,,,,,, -Neverita,Neverita,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Neverita,Genus,138241,NA,Remove,,,,,,, -Neverita duplicata,Neverita duplicata,Shark eye,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Neverita,Species,160407,NA,Species,,,,,,, -Euspira lewisii,Neverita lewisii,Lewis's moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Euspira,Species,718659,NA,Species,,,,,,, -Lunatia lewisii,Neverita lewisii,Lewis's moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Lunatia,Species,718659,NA,Species,,,,,,, -Neverita lewisii,Neverita lewisii,Lewis's moonsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Lunatia,Species,718659,NA,Species,,,,,,, -Nezumia bairdi,Nezumia bairdii,Marlin spike grenadier,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Nezumia,Species,183289,3104,Species,,,,,,, -Nezumia liolepis,Nezumia liolepis,Smooth grenadier,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Nezumia,Species,272416,8522,Species,,,,,,, -Nezumia stelgidolepis,Nezumia stelgidolepis,California grenadier,Animalia,Chordata,Teleostei,Gadiformes,Macrouridae,Nezumia,Species,272428,3106,Species,,,,,,, -Nibilia,Nibilia,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Nibilia,Genus,415698,NA,Remove,,,,,,, -Nibilia antilocapra,Nibilia antilocapra,Shorthorn spiny crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Nibilia,Species,441624,NA,Species,,,,,,, -Nicholsina usta,Nicholsina usta,Emerald parrotfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Scaridae,Nicholsina,Species,159298,1151,Species,,,,,,, -Niso aeglees,Niso aeglees,Brown line niso,Animalia,Mollusca,Gastropoda,Littorinimorpha,Eulimidae,Niso,Species,419851,NA,Species,,,,,,, -Tellina nitens,Nitidotellina unifasciata,NA,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Tellina,Species,878460,NA,Species,,,,,,, -Nodipecten,Nodipecten,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Nodipecten,Genus,138321,NA,Remove,,,,,,, -Nodipecten fragosus,Nodipecten fragosus,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Nodipecten,Species,394382,NA,Species,,,,,,, -Lyropecten nodosus,Nodipecten nodosus,Lion's paw,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Lyropecten,Species,225252,NA,Species,,,,,,, -Nodipecten nodosus,Nodipecten nodosus,Lion's paw,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Lyropecten,Species,225252,NA,Species,,,,,,, -Nodulotrophon coronatus,Nodulotrophon coronatus,Crown trophon,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Nodulotrophon,Species,399228,NA,Species,,,,,,, -Noetia ponderosa,Noetia ponderosa,Ponderous ark,Animalia,Mollusca,Bivalvia,Arcida,Noetiidae,Noetia,Species,156909,NA,Species,,,,,,, -Notacanthus chemnitzii,Notacanthus chemnitzii,snubnosed spiny eel,NA,NA,NA,NA,NA,NA,Species,126643,NA,Species,,,,,,, -Notarchus punctatus,Notarchus punctatus,NA,Animalia,Mollusca,Gastropoda,Aplysiida,Aplysiidae,Notarchus,Species,139595,NA,Species,,,,,,, -Nothria conchylega,Nothria conchylega,Gravel tube worm,Animalia,Annelida,Polychaeta,Eunicida,Onuphidae,Nothria,Species,130467,NA,Species,,,,,,, -Notomastus,Notomastus,NA,Animalia,Annelida,Polychaeta,NA,Capitellidae,Notomastus,Genus,129220,NA,Remove,,,,,,, -Notostomobdella,Notostomum,NA,Animalia,Annelida,Clitellata,Rhynchobdellida,Piscicolidae,Notostomum,Genus,116938,NA,Remove,,,,,,, -Notostomum,Notostomum,NA,Animalia,Annelida,Clitellata,Rhynchobdellida,Piscicolidae,Notostomum,Genus,116938,NA,Remove,,,,,,, -Notostomum sp.,Notostomum,NA,Animalia,Annelida,Clitellata,Rhynchobdellida,Piscicolidae,Notostomum,Genus,116938,NA,Remove,,,,,,, -Notostomum cyclostomum,Notostomum cyclostomum,Striped sea leech,Animalia,Annelida,Clitellata,Rhynchobdellida,Piscicolidae,Notostomum,Species,370644,NA,Species,,,,,,, -Notostomus,Notostomus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Acanthephyridae,Notostomus,Genus,107025,NA,Remove,,,,,,, -Notostomus sp.,Notostomus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Acanthephyridae,Notostomus,Genus,107025,NA,Remove,,,,,,, -Notostomus japonicus,Notostomus japonicus,Japanese spinyridge,Animalia,Arthropoda,Malacostraca,Decapoda,Acanthephyridae,Notostomus,Species,514275,NA,Species,,,,,,, -Nucella lamellosa,Nucella lamellosa,Frilled dogwinkle,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Nucella,Species,404218,NA,Species,,,,,,, -Nucula,Nucula,Nut clams,Animalia,Mollusca,Bivalvia,Nuculida,Nuculidae,Nucula,Genus,138262,NA,Remove,,,,,,, -Nucula sp.,Nucula,Nut clams,Animalia,Mollusca,Bivalvia,Nuculida,Nuculidae,Nucula,Genus,138262,NA,Remove,,,,,,, -Nuculana,Nuculana,NA,Animalia,Mollusca,Bivalvia,Nuculanida,Nuculanidae,Nuculana,Genus,138259,NA,Remove,,,,,,, -Nuculana sp.,Nuculana,NA,Animalia,Mollusca,Bivalvia,Nuculanida,Nuculanidae,Nuculana,Genus,138259,NA,Remove,,,,,,, -Nuculana buccata,Nuculana pernula,Northern nutclam,Animalia,Mollusca,Bivalvia,Nuculanida,Nuculanidae,Nuculana,Species,140579,NA,Species,,,,,,, -Nuculana fossa,Nuculana pernula,Northern nutclam,Animalia,Mollusca,Bivalvia,Nuculanida,Nuculanidae,Nuculana,Species,140579,NA,Species,,,,,,, -Nuculana pernula,Nuculana pernula,Northern nutclam,Animalia,Mollusca,Bivalvia,Nuculanida,Nuculanidae,Nuculana,Species,140579,NA,Species,,,,,,, -Nudibranchia,Nudibranchia,Sea slugs,Animalia,Mollusca,Gastropoda,Nudibranchia,NA,NA,Order,1762,NA,Remove,,,,,,, -Nudibranchia a,Nudibranchia sp. A,Sea slug,Animalia,Mollusca,Gastropoda,Nudibranchia,NA,NA,Species,NA,NA,Species,,,,,,, -Nudibranchia sp. A,Nudibranchia sp. A,Sea slug,Animalia,Mollusca,Gastropoda,Nudibranchia,NA,NA,Species,NA,NA,Species,,,,,,, -Occella dodecaedron,Occella dodecaedron,Bering poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Occella,Species,254398,4165,Species,,,,,,, -Oceanactis,Oceanactis,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Oractiidae,Oceanactis,Genus,267642,NA,Remove,,,,,,, -Oceanactis sp.,Oceanactis,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Oractiidae,Oceanactis,Genus,267642,NA,Remove,,,,,,, -Oceanactis diomedeae,Oceanactis diomedeae,Grape anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Oractiidae,Oceanactis,Species,290509,NA,Species,,,,,,, -Oractis diomedeae,Oceanactis diomedeae,Grape anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Oractiidae,Oceanactis,Species,290509,NA,Species,,,,,,, -Ocnus pygmaeus,Ocnus pygmaeus,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,Ocnus,Species,422525,NA,Species,,,,,,, -Octocorallia,Octocorallia,Octocorals,Animalia,Cnidaria,Anthozoa,NA,NA,NA,SubClass,1341,NA,Remove,,,,,,, -Octopoda,Octopoda,Octopuses,Animalia,Mollusca,Cephalopoda,Octopoda,NA,NA,Order,11718,NA,Remove,,,,,,, -Octopodidae,Octopodidae,Octopus unid.,Animalia,Mollusca,Cephalopoda,Octopoda,Octopodidae,NA,Family,11782,NA,Remove,,,,,,, -Octopoteuthis deletron,Octopoteuthis deletron,Octopus squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Octopoteuthidae,Octopoteuthis,Species,342057,NA,Species,,,,,,, -Octopus,Octopus,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Octopodidae,Octopus,Genus,138268,NA,Remove,,,,,,, -Octopus sp.,Octopus,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Octopodidae,Octopus,Genus,138268,NA,Remove,,,,,,, -Octopus briareus,Octopus briareus,Caribbean reef octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Octopodidae,Octopus,Species,341954,NA,Species,,,,,,, -Octopus californicus,Octopus californicus,North pacific bigeye octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Octopodidae,Octopus,Species,341958,NA,Species,,,,,,, -Octopus joubini,Octopus joubini,Atlantic pygmy octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Octopodidae,Octopus,Species,341985,NA,Species,,,,,,, -Octopus rubescens,Octopus rubescens,East pacific red octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Octopodidae,Octopus,Species,342023,NA,Species,,,,,,, -Octopus vulgaris,Octopus vulgaris,Common octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Octopodidae,Octopus,Species,140605,NA,Species,,,,,,, -Oculina diffusa,Oculina diffusa,Diffuse ivory bush coral,Animalia,Cnidaria,Anthozoa,Scleractinia,Oculinidae,Oculina,Species,287097,NA,Species,,,,,,, -Ocypode,Ocypode,Ghost crabs,Animalia,Arthropoda,Malacostraca,Decapoda,Ocypodidae,Ocypode,Genus,106970,NA,Remove,,,,,,, -Ocypode quadrata,Ocypode quadrata,Atlantic ghost crab,Animalia,Arthropoda,Malacostraca,Decapoda,Ocypodidae,Ocypode,Species,158432,NA,Species,,,,,,, -Ocyurus chrysurus,Ocyurus chrysurus,Yellowtail snapper,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Lutjanidae,Ocyurus,Species,159803,188,Species,,,,,,, -Odontaster,Odontaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Odontasteridae,Odontaster,Genus,123310,NA,Remove,,,,,,, -Odontaster crassus,Odontaster crassus,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Odontasteridae,Odontaster,Species,254912,NA,Species,,,,,,, -Odontaster sp. B (Clark),Odontaster sp. B (Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Odontodactylus brevirostris,Odontodactylus brevirostris,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Odontodactylidae,Odontodactylus,Species,220296,NA,Species,,,,,,, -Odontohenricia,Odontohenricia,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Odontohenricia,Genus,291581,NA,Remove,,,,,,, -Odontohenricia sp.,Odontohenricia,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Odontohenricia,Genus,291581,NA,Remove,,,,,,, -Odontohenricia ahearnae,Odontohenricia ahearnae,NA,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Odontohenricia,Species,509318,NA,Species,,,,,,, -Odontohenricia fisheri,Odontohenricia fisheri,Fisher's toothed henricia,Animalia,Echinodermata,Asteroidea,Spinulosida,Echinasteridae,Odontohenricia,Species,369149,NA,Species,,,,,,, -Odontohenricia sp. A (Clark),Odontohenricia sp. A (Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Odontohenricia sp. B (Clark),Odontohenricia sp. B (Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Odontohenricia sp. E (Clark 2006),Odontohenricia sp. E (Clark 2006),giant toothed Henricia,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Odontopyxis trispinosa,Odontopyxis trispinosa,Pygmy poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Odontopyxis,Species,281836,4168,Species,,,,,,, -Odontoscion dentex,Odontoscion dentex,Reef croaker,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Odontoscion,Species,281837,1185,Species,,,,,,, -Oenopota,Oenopota,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Mangeliidae,Oenopota,Genus,137826,NA,Remove,,,,,,, -Oenopota sp.,Oenopota,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Mangeliidae,Oenopota,Genus,137826,NA,Remove,,,,,,, -Oenopota harpa,Oenopota harpa,Harp turrid,Animalia,Mollusca,Gastropoda,Neogastropoda,Mangeliidae,Oenopota,Species,139320,NA,Species,,,,,,, -Ogcocephalidae,Ogcocephalidae,Batfishes,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,NA,Family,125495,NA,Remove,,,,,,, -Ogcocephalus,Ogcocephalus,NA,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Ogcocephalus,Genus,159191,NA,Remove,,,,,,, -Ogcocephalus corniger,Ogcocephalus corniger,Longnose batfish,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Ogcocephalus,Species,159192,3095,Species,,,,,,, -Ogcocephalus cubifrons,Ogcocephalus cubifrons,NA,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Ogcocephalus,Species,275905,27085,Species,,,,,,, -Ogcocephalus declivirostris,Ogcocephalus declivirostris,Slantbrow batfish,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Ogcocephalus,Species,275907,12030,Species,,,,,,, -Ogcocephalus nasutus,Ogcocephalus nasutus,Shortnose batfish,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Ogcocephalus,Species,275908,3092,Species,,,,,,, -Ogcocephalus pantostictus,Ogcocephalus pantostictus,Spotted batfish,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Ogcocephalus,Species,275910,12029,Species,,,,,,, -Ogcocephalus parvus,Ogcocephalus parvus,Roughback batfish,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Ogcocephalus,Species,159193,3093,Species,,,,,,, -Ogcocephalus pumilus,Ogcocephalus pumilus,Dwarf batfish,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Ogcocephalus,Species,275912,28244,Species,,,,,,, -Ogcocephalus radiatus,Ogcocephalus radiatus,Polka-dot batfish,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Ogcocephalus,Species,275913,3094,Species,,,,,,, -Ogcocephalus rostellum,Ogcocephalus rostellum,Palefin batfish,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Ogcocephalus,Species,159194,12028,Species,,,,,,, -Ogcocephalus vespertilio,Ogcocephalus vespertilio,Seadevil,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Ogcocephalus,Species,159195,47677,Species,,,,,,, -Berryteuthis anonychus,Okutania anonycha,Smallfin gonate squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,Berryteuthis,Species,1468871,NA,Species,,,,,,, -Okutania anonycha,Okutania anonycha,Smallfin gonate squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Gonatidae,Berryteuthis,Species,1468871,NA,Species,,,,,,, -Oligoplites saurus,Oligoplites saurus,Leatherjacket,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Oligoplites,Species,159645,1001,Species,,,,,,, -Oliva,Oliva,Olive snails,Animalia,Mollusca,Gastropoda,Neogastropoda,Olividae,Oliva,Genus,205393,NA,Remove,,,,,,, -Oliva fulgurator,Oliva fulgurator,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Olividae,Oliva,Species,448107,NA,Species,,,,,,, -Americoliva bollingi,Oliva nivosa bollingi,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Olividae,Americoliva,Species,1482537,NA,Species,,,,,,, -Oliva reticularis,Oliva reticularis,Netted olive,Animalia,Mollusca,Gastropoda,Neogastropoda,Olividae,Oliva,Species,420126,NA,Species,,,,,,, -Oliva sayana,Oliva sayana,Lettered olive,Animalia,Mollusca,Gastropoda,Neogastropoda,Olividae,Oliva,Species,208387,NA,Species,,,,,,, -Oliva scripta,Oliva scripta,Caribbean olive,Animalia,Mollusca,Gastropoda,Neogastropoda,Olividae,Oliva,Species,420127,NA,Species,,,,,,, -Ommastrephes bartrami,Ommastrephes bartramii,Neon flying squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Ommastrephidae,Ommastrephes,Species,181382,NA,Species,,,,,,, -Ommastrephidae,Ommastrephidae,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Ommastrephidae,NA,Family,11760,NA,Remove,,,,,,, -Onchidiopsis,Onchidiopsis,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Onchidiopsis,Genus,138628,NA,Remove,,,,,,, -Onchidiopsis sp.,Onchidiopsis,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Onchidiopsis,Genus,138628,NA,Remove,,,,,,, -Onchidiopsis brevipes,Onchidiopsis brevipes,Spherical blob snail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Onchidiopsis,Species,576626,NA,Species,,,,,,, -Onchidiopsis clarki,Onchidiopsis clarki,Warty blobsnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Onchidiopsis,Species,833066,NA,Species,,,,,,, -Onchidiopsis glacialis,Onchidiopsis glacialis,Icy lamellaria,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Onchidiopsis,Species,141896,NA,Species,,,,,,, -Onchidiopsis sp. A (Clark and McLean),Onchidiopsis sp. A (Clark and McLean),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Onchidorididae,Onchidorididae,onchidoridid nudibranchs,NA,NA,NA,NA,NA,NA,Family,175,NA,Remove,,,,,,, -Onchidoris bilamellata,Onchidoris bilamellata,Barnacle eating onchidoris,Animalia,Mollusca,Gastropoda,Nudibranchia,Onchidorididae,Onchidoris,Species,150457,NA,Species,,,,,,, -Oncorhynchus,Oncorhynchus,salmon unid.,Animalia,Chordata,Teleostei,Salmoniformes,Salmonidae,Oncorhynchus,Genus,126140,NA,Remove,,,,,,, -Oncorhynchus sp.,Oncorhynchus,salmon unid.,Animalia,Chordata,Teleostei,Salmoniformes,Salmonidae,Oncorhynchus,Genus,126140,NA,Remove,,,,,,, -Oncorhynchus gorbuscha,Oncorhynchus gorbuscha,Pink salmon,Animalia,Chordata,Teleostei,Salmoniformes,Salmonidae,Oncorhynchus,Species,127182,240,Species,,,,,,, -Oncorhynchus keta,Oncorhynchus keta,Chum salmon,Animalia,Chordata,Teleostei,Salmoniformes,Salmonidae,Oncorhynchus,Species,127183,241,Species,,,,,,, -Oncorhynchus kisutch,Oncorhynchus kisutch,Coho salmon,Animalia,Chordata,Teleostei,Salmoniformes,Salmonidae,Oncorhynchus,Species,127184,245,Species,,,,,,, -Oncorhynchus mykiss,Oncorhynchus mykiss,Rainbow trout,Animalia,Chordata,Teleostei,Salmoniformes,Salmonidae,Oncorhynchus,Species,127185,239,Species,,,,,,, -Oncorhynchus nerka,Oncorhynchus nerka,Sockeye salmon,Animalia,Chordata,Teleostei,Salmoniformes,Salmonidae,Oncorhynchus,Species,254569,243,Species,,,,,,, -Oncorhynchus tshawytscha,Oncorhynchus tshawytscha,Chinook salmon,Animalia,Chordata,Teleostei,Salmoniformes,Salmonidae,Oncorhynchus,Species,158075,244,Species,,,,,,, -Oneirodes,Oneirodes,NA,Animalia,Chordata,Teleostei,Lophiiformes,Oneirodidae,Oneirodes,Genus,125811,NA,Remove,,,,,,, -Oneirodes sp.,Oneirodes,NA,Animalia,Chordata,Teleostei,Lophiiformes,Oneirodidae,Oneirodes,Genus,125811,NA,Remove,,,,,,, -Oneirodes acanthias,Oneirodes acanthias,Spiny dreamer,Animalia,Chordata,Teleostei,Lophiiformes,Oneirodidae,Oneirodes,Species,272620,12545,Species,,,,,,, -Oneirodes bulbosus,Oneirodes bulbosus,Bulb fish,Animalia,Chordata,Teleostei,Lophiiformes,Oneirodidae,Oneirodes,Species,254553,23256,Species,,,,,,, -Oneirodes thompsoni,Oneirodes thompsoni,Alaska dreamer,Animalia,Chordata,Teleostei,Lophiiformes,Oneirodidae,Oneirodes,Species,254554,23257,Species,,,,,,, -Oneirodidae,Oneirodidae,Dreamers,Animalia,Chordata,Teleostei,Lophiiformes,Oneirodidae,NA,Family,125496,NA,Remove,,,,,,, -Xenophora caribaea,Onustus caribaeus,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Xenophoridae,Xenophora,Species,468051,NA,Species,,,,,,, -Onustus caribaeus,Onustus caribaeus,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Xenophoridae,Onustus,Species,468051,NA,Species,,,,,,, -Onychoteuthidae,Onychoteuthidae,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Onychoteuthidae,NA,Family,11742,NA,Remove,,,,,,, -Onychoteuthis banksi,Onychoteuthis banksii,Hooked squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Onychoteuthidae,Onychoteuthis,Species,140649,NA,Species,,,,,,, -Onychoteuthis banksii,Onychoteuthis banksii,Hooked squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Onychoteuthidae,Onychoteuthis,Species,140649,NA,Species,,,,,,, -Onychoteuthis borealijaponicus,Onychoteuthis borealijaponica,Boreal clubhook squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Onychoteuthidae,Onychoteuthis,Species,342069,NA,Species,,,,,,, -Onychoteuthis borealijaponica,Onychoteuthis borealijaponica,Boreal clubhook squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Onychoteuthidae,Onychoteuthis,Species,342069,NA,Species,,,,,,, -Moroteuthis robusta,Onykia robusta,Robust clubhook squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Onychoteuthidae,Moroteuthis,Species,410385,NA,Species,,,,,,, -Onykia robusta,Onykia robusta,Robust clubhook squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Onychoteuthidae,Moroteuthis,Species,410385,NA,Species,,,,,,, -Ophiacantha,Ophiacantha,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiacanthidae,Ophiacantha,Genus,123587,NA,Remove,,,,,,, -Ophiacantha sp.,Ophiacantha,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiacanthidae,Ophiacantha,Genus,123587,NA,Remove,,,,,,, -Ophiacantha diplasia,Ophiacantha diplasia,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiacanthidae,Ophiacantha,Species,244734,NA,Species,,,,,,, -Ophiacantha enneactis,Ophiacantha enneactis,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiacanthidae,Ophiacantha,Species,243348,NA,Species,,,,,,, -Ophiacantha sp. A,Ophiacantha sp. A,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Ophiactis,Ophiactis,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiactidae,Ophiactis,Genus,123620,NA,Remove,,,,,,, -Ophiactis algicola,Ophiactis algicola,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiactidae,Ophiactis,Species,243434,NA,Species,,,,,,, -Ophiactis quinqueradia,Ophiactis quinqueradia,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiactidae,Ophiactis,Species,243464,NA,Species,,,,,,, -Ophichthidae,Ophichthidae,Snake eels,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,NA,Family,125434,NA,Remove,,,,,,, -Ophichthus,Ophichthus,NA,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Ophichthus,Genus,125647,NA,Remove,,,,,,, -Ophichthus cruentifer,Ophichthus cruentifer,Margined snake eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Ophichthus,Species,158644,2654,Species,,,,,,, -Ophichthus gomesi,Ophichthus gomesii,Shrimp eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Ophichthus,Species,271955,1104,Species,,,,,,, -Ophichthus gomesii,Ophichthus gomesii,Shrimp eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Ophichthus,Species,271955,1104,Species,,,,,,, -Ophichthus ophis,Ophichthus ophis,Spotted snake eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Ophichthus,Species,126315,1105,Species,,,,,,, -Ophichthus puncticeps,Ophichthus puncticeps,Palespotted eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Ophichthus,Species,158646,2656,Species,,,,,,, -Ophichthus rex,Ophichthus rex,King snake eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Ophichthus,Species,271977,12008,Species,,,,,,, -Ophidiasteridae,Ophidiasteridae,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Ophidiasteridae,NA,Family,123137,NA,Remove,,,,,,, -Ophidiidae,Ophidiidae,Cusk eels,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,NA,Family,125505,NA,Remove,,,,,,, -Ophidion,Ophidion,Cusk eels,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Ophidion,Genus,125863,NA,Remove,,,,,,, -Ophidion antipholus,Ophidion antipholus,Longnose cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Ophidion,Species,272815,62523,Species,,,,,,, -Ophidion dromio,Ophidion dromio,Shorthead cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Ophidion,Species,272818,62524,Species,,,,,,, -Ophidion grayi,Ophidion grayi,Blotched cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Ophidion,Species,272823,3112,Species,,,,,,, -Ophidion beani,Ophidion holbrookii,Bank cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Ophidion,Species,272824,3113,Species,,,,,,, -Ophidion holbrooki,Ophidion holbrookii,Bank cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Ophidion,Species,272824,3113,Species,,,,,,, -Ophidion holbrookii,Ophidion holbrookii,Bank cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Ophidion,Species,272824,3113,Species,,,,,,, -Ophidion josephi,Ophidion josephi,Crested cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Ophidion,Species,272827,56337,Species,,,,,,, -Ophidion welshi,Ophidion josephi,Crested cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Ophidion,Species,272827,56337,Species,,,,,,, -Ophidion marginatum,Ophidion marginatum,Striped cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Ophidion,Species,158767,3114,Species,,,,,,, -Ophidion scrippsae,Ophidion scrippsae,Basketweave cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Ophidion,Species,272835,3115,Species,,,,,,, -Ophidion selenops,Ophidion selenops,Mooneye cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Ophidion,Species,158768,3116,Species,,,,,,, -Ophioblennius,Ophioblennius,NA,Animalia,Chordata,Teleostei,Blenniiformes,Blenniidae,Ophioblennius,Genus,125919,NA,Remove,,,,,,, -Ophioblennius atlanticus,Ophioblennius atlanticus,NA,Animalia,Chordata,Teleostei,Blenniiformes,Blenniidae,Ophioblennius,Species,126769,3768,Species,,,,,,, -Ophioderma,Ophioderma,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiodermatidae,Ophioderma,Genus,123547,NA,Remove,,,,,,, -Ophioderma appressum,Ophioderma appressum,Harlequin brittle star,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiodermatidae,Ophioderma,Species,245143,NA,Species,,,,,,, -Ophioderma brevispinum,Ophioderma brevispinum,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiodermatidae,Ophioderma,Species,245516,NA,Species,,,,,,, -Ophioderma brevispina,Ophioderma brevispinum,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiodermatidae,Ophioderma,Species,245516,NA,Species,,,,,,, -Ophioderma cinereum,Ophioderma cinereum,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiodermatidae,Ophioderma,Species,245142,NA,Species,,,,,,, -Ophioderma devaneyi,Ophioderma devaneyi,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiodermatidae,Ophioderma,Species,243633,NA,Species,,,,,,, -Ophioderma phoenium,Ophioderma phoenium,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiodermatidae,Ophioderma,Species,243643,NA,Species,,,,,,, -Ophioderma rubicundum,Ophioderma rubicundum,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiodermatidae,Ophioderma,Species,244931,NA,Species,,,,,,, -Ophiodermatidae,Ophiodermatidae,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiodermatidae,NA,Family,123197,NA,Remove,,,,,,, -Ophiodon elongatus,Ophiodon elongatus,Lingcod,Animalia,Chordata,Teleostei,Perciformes,Hexagrammidae,Ophiodon,Species,240745,509,Species,,,,,,, -Ophiolebes,Ophiolebes,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiacanthidae,Ophiolebes,Genus,123594,NA,Remove,,,,,,, -Ophiolebes sp.,Ophiolebes,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiacanthidae,Ophiolebes,Genus,123594,NA,Remove,,,,,,, -Ophiolebes sp. A (Clark 2006),Ophiolebes sp. A (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Ophiolebes sp. B (Clark 2006),Ophiolebes sp. B (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Ophiolebes sp. C (Clark 2006),Ophiolebes sp. C (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Ophiolebes sp. D (Clark 2006),Ophiolebes sp. D (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Ophiolebes sp. F (Clark 2006),Ophiolebes sp. F (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Ophiolepididae,Ophiolepididae,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiolepididae,NA,Family,242200,NA,Remove,,,,,,, -Ophiolepis,Ophiolepis,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiolepididae,Ophiolepis,Genus,123564,NA,Remove,,,,,,, -Ophiolepis elegans,Ophiolepis elegans,Elegant brittle star,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiolepididae,Ophiolepis,Species,243691,NA,Species,,,,,,, -Ophiomusium lymani,Ophiomusa lymani,NA,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiosphalmidae,Ophiomusium,Species,245559,NA,Species,,,,,,, -Ophiomyxa,Ophiomyxa,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiomyxidae,Ophiomyxa,Genus,123631,NA,Remove,,,,,,, -Ophiomyxa flaccida,Ophiomyxa flaccida,Limy brittle star,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiomyxidae,Ophiomyxa,Species,243863,NA,Species,,,,,,, -Ophiomyxa tumida,Ophiomyxa tumida,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiomyxidae,Ophiomyxa,Species,243865,NA,Species,,,,,,, -Ophiomyxidae,Ophiomyxidae,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiomyxidae,NA,Family,123209,NA,Remove,,,,,,, -Ophionereis,Ophionereis,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophionereididae,Ophionereis,Genus,123553,NA,Remove,,,,,,, -Ophionereis reticulata,Ophionereis reticulata,Reticulated brittle star,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophionereididae,Ophionereis,Species,124833,NA,Species,,,,,,, -Ophiopholis,Ophiopholis,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiopholidae,Ophiopholis,Genus,123622,NA,Remove,,,,,,, -Ophiopholis sp.,Ophiopholis,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiopholidae,Ophiopholis,Genus,123622,NA,Remove,,,,,,, -Ophiopholis aculeata,Ophiopholis aculeata,Daisy brittle star,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiopholidae,Ophiopholis,Species,125125,NA,Species,,,,,,, -Ophiopholis japonica,Ophiopholis japonica,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiopholidae,Ophiopholis,Species,243915,NA,Species,,,,,,, -Ophiopholis kennerleyi,Ophiopholis kennerlyi,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiopholidae,Ophiopholis,Species,243916,NA,Species,,,,,,, -Ophiopholis kennerlyi,Ophiopholis kennerlyi,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiopholidae,Ophiopholis,Species,243916,NA,Species,,,,,,, -Ophiopholis longispina,Ophiopholis longispina,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiopholidae,Ophiopholis,Species,245866,NA,Species,,,,,,, -Ophiophthalmus cataleimmoidus,Ophiophthalmus cataleimmoidus,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiacanthidae,Ophiophthalmus,Species,245721,NA,Species,,,,,,, -Ophiophthalmus normani,Ophiophthalmus normani,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiacanthidae,Ophiophthalmus,Species,245720,NA,Species,,,,,,, -Ophiopthalmus normani,Ophiophthalmus normani,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiacanthidae,Ophiophthalmus,Species,245720,NA,Species,,,,,,, -Ophioplocus esmarki,Ophioplocus esmarki,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Hemieuryalidae,Ophioplocus,Species,243980,NA,Species,,,,,,, -Ophioscolex,Ophioscolex,NA,Animalia,Echinodermata,Ophiuroidea,Ophioscolecida,Ophioscolecidae,Ophioscolex,Genus,123633,NA,Remove,,,,,,, -Ophioscolex sp.,Ophioscolex,NA,Animalia,Echinodermata,Ophiuroidea,Ophioscolecida,Ophioscolecidae,Ophioscolex,Genus,123633,NA,Remove,,,,,,, -Ophioscolex corynetes,Ophioscolex corynetes,NA,Animalia,Echinodermata,Ophiuroidea,Ophioscolecida,Ophioscolecidae,Ophioscolex,Species,244043,NA,Species,,,,,,, -Ophiosemnotes brevispina,Ophiosemnotes brevispina,Short spined brittle star,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiacanthidae,Ophiosemnotes,Species,244051,NA,Species,,,,,,, -Ophiosemnotes pachybactra,Ophiosemnotes pachybactra,Thick spined brittle star,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiacanthidae,Ophiosemnotes,Species,244053,NA,Species,,,,,,, -Ophiosemnotes tylota,Ophiosemnotes tylota,NA,Animalia,Echinodermata,Ophiuroidea,Ophiacanthida,Ophiacanthidae,Ophiosemnotes,Species,244056,NA,Species,,,,,,, -Ophiomusium jolliensis,Ophiosphalma jolliense,Brittle star sp.,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiosphalmidae,Ophiosphalma,Species,246611,NA,Species,,,,,,, -Ophiosphalma jolliensis,Ophiosphalma jolliense,Brittle star sp.,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiosphalmidae,Ophiosphalma,Species,246611,NA,Species,,,,,,, -Ophiosphalma sp. cf. jolliense,Ophiosphalma sp. cf. jolliense,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Ophiostigma isocantha,Ophiostigma isocanthum,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Amphiuridae,Ophiostigma,Species,244070,NA,Species,,,,,,, -Ophiostigma isocanthum,Ophiostigma isocanthum,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Amphiuridae,Ophiostigma,Species,244070,NA,Species,,,,,,, -Ophiothricidae,Ophiothricidae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Ophiothrix,Ophiothrix,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiotrichidae,Ophiothrix,Genus,123626,NA,Remove,,,,,,, -Ophiothrix suensoni,Ophiothrix (Acanthophiothrix) suensonii,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiotrichidae,Ophiothrix,Species,244148,NA,Species,,,,,,, -Ophiothrix angulata,Ophiothrix (Ophiothrix) angulata,Angular brittle star,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiotrichidae,Ophiothrix,Species,244162,NA,Species,,,,,,, -Ophiothrix spiculata,Ophiothrix (Ophiothrix) spiculata,Pacific spiny brittlestar,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiotrichidae,Ophiothrix,Species,244192,NA,Species,,,,,,, -Ophiothrix angulata var violacea,Ophiothrix angulata violacea,Angular britle star,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiotrichidae,Ophiothrix,Species,244404,NA,Species,,,,,,, -Ophiothrix angulata var megalaspsis,Ophiothrix angulata megalaspsis,Angular britle star,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiotrichidae,Ophiothrix,Species,244119,NA,Species,,,,,,, -Ophiothrix angulata var phlogina,Ophiothrix angulata phlogina,Angular britle star,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiotrichidae,Ophiothrix,Species,244126,NA,Species,,,,,,, -Ophiothrix lineata,Ophiothrix lineata,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiotrichidae,Ophiothrix,Species,244115,NA,Species,,,,,,, -Ophiotrichidae,Ophiotrichidae,NA,Animalia,Echinodermata,Ophiuroidea,Amphilepidida,Ophiotrichidae,NA,Genus,123208,NA,Remove,,,,,,, -Ophiura,Ophiura,NA,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiuridae,Ophiura,Genus,123574,NA,Remove,,,,,,, -Ophiura sp.,Ophiura,NA,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiuridae,Ophiura,Genus,123574,NA,Remove,,,,,,, -Ophiura cryptolepis,Ophiura cryptolepis,NA,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiuridae,Ophiura,Species,244266,NA,Species,,,,,,, -Ophiura luetkenii,Ophiura luetkenii,Gray brittle star,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiuridae,Ophiura,Species,244282,NA,Species,,,,,,, -Ophiura quadrispina,Ophiura quadrispina,Four spined brittle star,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiuridae,Ophiura,Species,244297,NA,Species,,,,,,, -Ophiura sarsi,Ophiura sarsii,Notched brittle star,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiuridae,Ophiura,Species,124934,NA,Species,,,,,,, -Ophiura sarsii,Ophiura sarsii,Notched brittle star,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiuridae,Ophiura,Species,124934,NA,Species,,,,,,, -Ophiurida,Ophiurida,NA,Animalia,Echinodermata,Ophiuroidea,Ophiurida,NA,NA,Order,123117,NA,Remove,,,,,,, -Ophiuridae,Ophiuridae,NA,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiuridae,NA,Family,123200,NA,Remove,,,,,,, -Ophiuroidea,Ophiuroidea,Brittle stars,Animalia,Echinodermata,Ophiuroidea,NA,NA,NA,Class,123084,NA,Remove,,,,,,, -Opisthobranchia,Opisthobranchia,Sea slugs,Animalia,Mollusca,Gastropoda,NA,NA,NA,InfraClass,382226,NA,Remove,,,,,,, -Opisthonema oglinum,Opisthonema oglinum,Atlantic thread herring,Animalia,Chordata,Teleostei,Clupeiformes,Dorosomatidae,Opisthonema,Species,158695,1486,Species,,,,,,, -Opisthoproctidae,Opisthoproctidae,Barreleyes,Animalia,Chordata,Teleostei,Argentiniformes,Opisthoproctidae,NA,Family,125512,NA,Remove,,,,,,, -Grimpoteuthis albatrossi,Opisthoteuthis albatrossi,NA,Animalia,Mollusca,Cephalopoda,Octopoda,Grimpoteuthidae,Grimpoteuthis,Species,410386,NA,Species,,,,,,, -Opisthoteuthis californiana,Opisthoteuthis californiana,Flapjack octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Opisthoteuthidae,Opisthoteuthis,Species,342092,NA,Species,,,,,,, -Opisthoteuthis sp. cf. californiana (Jorgensen),Opisthoteuthis sp. cf. californiana (Jorgensen),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Opistognathus,Opistognathus,NA,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Opistognathidae,Opistognathus,Genus,159746,NA,Remove,,,,,,, -Opistognathus aurifrons,Opistognathus aurifrons,Yellowhead jawfish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Opistognathidae,Opistognathus,Species,276442,NA,Species,,,,,,, -Opistognathus lonchurus,Opistognathus lonchurus,Moustache jawfish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Opistognathidae,Opistognathus,Species,276462,NA,Species,,,,,,, -Oplophoridae,Oplophoridae,oplophorid shrimps,NA,NA,NA,NA,NA,NA,Family,106786,NA,Remove,,,,,,, -Opsanus,Opsanus,Toadfish,Animalia,Chordata,Teleostei,Batrachoidiformes,Batrachoididae,Opsanus,Genus,158781,NA,Remove,,,,,,, -Opsanus beta,Opsanus beta,Gulf toadfish,Animalia,Chordata,Teleostei,Batrachoidiformes,Batrachoididae,Opsanus,Species,275645,NA,Species,,,,,,, -Opsanus pardus,Opsanus pardus,Leopard toadfish,Animalia,Chordata,Teleostei,Batrachoidiformes,Batrachoididae,Opsanus,Species,275648,3068,Species,,,,,,, -Opsanus tau,Opsanus tau,Oyster toadfish,Animalia,Chordata,Teleostei,Batrachoidiformes,Batrachoididae,Opsanus,Species,158782,3069,Species,,,,,,, -Orange encrusting sponge,Orange encrusting sponge,NA,NA,NA,NA,NA,NA,NA,Remove,NA,NA,Remove,,,,,,, -Orange sponge,Orange sponge,NA,NA,NA,NA,NA,NA,NA,Remove,NA,NA,Remove,,,,,,, -Oreaster reticulatus,Oreaster reticulatus,Cushioned star,Animalia,Echinodermata,Asteroidea,Valvatida,Oreasteridae,Oreaster,Species,178210,NA,Species,,,,,,, -Oregonia,Oregonia,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Oregonia,Genus,439494,NA,Remove,,,,,,, -Oregonia sp.,Oregonia,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Oregonia,Genus,439494,NA,Remove,,,,,,, -Oregonia bifurca,Oregonia bifurca,Splitnose crab,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Oregonia,Species,442170,NA,Species,,,,,,, -Oregonia gracilis,Oregonia gracilis,Graceful decorator crab,Animalia,Arthropoda,Malacostraca,Decapoda,Oregoniidae,Oregonia,Species,442171,NA,Species,,,,,,, -Orthasterias,Orthasterias,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Orthasterias,Genus,146038,NA,Remove,,,,,,, -Orthasterias sp.,Orthasterias,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Orthasterias,Genus,146038,NA,Remove,,,,,,, -Orthasterias koehleri,Orthasterias koehleri,Rainbow star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Orthasterias,Species,255048,NA,Species,,,,,,, -Orthopristis chrysoptera,Orthopristis chrysoptera,Pigfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Haemulidae,Orthopristis,Species,158810,5,Species,,,,,,, -Orthopristis chrysopterus,Orthopristis chrysoptera,Pigfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Haemulidae,Orthopristis,Species,158810,5,Species,,,,,,, -Osachila semilevis,Osachila semilevis,Thinlip jewelbox crab,Animalia,Arthropoda,Malacostraca,Decapoda,Aethridae,Osachila,Species,421924,NA,Species,,,,,,, -Osachila tuberosa,Osachila tuberosa,Thicklip jewelbox crab,Animalia,Arthropoda,Malacostraca,Decapoda,Aethridae,Osachila,Species,421925,NA,Species,,,,,,, -Oscarella lobularis,Oscarella lobularis,Bubble oscar sponge,Animalia,Porifera,Homoscleromorpha,Homosclerophorida,Oscarellidae,Oscarella,Species,133928,NA,Species,,,,,,, -Osmeridae,Osmeridae,Smelts,Animalia,Chordata,Teleostei,Osmeriformes,Osmeridae,NA,Family,125513,NA,Remove,,,,,,, -Osmerus mordax,Osmerus mordax,Rainbow smelt,Animalia,Chordata,Teleostei,Osmeriformes,Osmeridae,Osmerus,Species,126737,253,Species,,,,,,, -Ostichthys trachypoma,Ostichthys trachypoma,Bigeye soldierfish,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Ostichthys,Species,159399,3252,Species,,,,,,, -Ostichthys trachypomus,Ostichthys trachypoma,Bigeye soldierfish,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Ostichthys,Species,159399,3252,Species,,,,,,, -Ostrea equestris,Ostrea equestris,Crested oyster,Animalia,Mollusca,Bivalvia,Ostreida,Ostreidae,Ostrea,Species,156924,NA,Species,,,,,,, -Ostrea permollis,Ostrea permollis,NA,Animalia,Mollusca,Bivalvia,Ostreida,Ostreidae,Ostrea,Species,1391840,NA,Species,,,,,,, -Ostreoida,Ostreoida,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Otophidium dormitator,Otophidium dormitator,Sleeper cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Otophidium,Species,275632,3118,Species,,,,,,, -Otophidium omostigmum,Otophidium omostigma,Polka-dot cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Otophidium,Species,158771,3119,Species,,,,,,, -Otophidium omostigma,Otophidium omostigma,Polka-dot cusk-eel,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Otophidium,Species,158771,3119,Species,,,,,,, -Otukaia beringensis,Otukaia beringensis,Bering topsnail,Animalia,Mollusca,Gastropoda,Trochida,Calliostomatidae,Otukaia,Species,1308693,NA,Species,,,,,,, -Ovalipes,Ovalipes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Ovalipidae,Ovalipes,Genus,158433,NA,Remove,,,,,,, -Ovalipes sp,Ovalipes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Ovalipidae,Ovalipes,Genus,158433,NA,Remove,,,,,,, -Ovalipes floridanus,Ovalipes floridanus,Florida lady crab,Animalia,Arthropoda,Malacostraca,Decapoda,Ovalipidae,Ovalipes,Species,422042,NA,Species,,,,,,, -Ovalipes ocellatus,Ovalipes ocellatus,Ocellate lady crab,Animalia,Arthropoda,Malacostraca,Decapoda,Ovalipidae,Ovalipes,Species,158434,NA,Species,,,,,,, -Ovalipes stephensoni,Ovalipes stephensoni,Coarsehand lady crab,Animalia,Arthropoda,Malacostraca,Decapoda,Ovalipidae,Ovalipes,Species,158435,NA,Species,,,,,,, -Oxylebius pictus,Oxylebius pictus,Painted greenling,Animalia,Chordata,Teleostei,Perciformes,Hexagrammidae,Oxylebius,Species,240743,4036,Species,,,,,,, -Oxyporhamphus micropterus,Oxyporhamphus micropterus,Bigwing halfbeak,Animalia,Chordata,Teleostei,Beloniformes,Hemiramphidae,Oxyporhamphus,Species,217871,12112,Species,,,,,,, -Pachastrellidae,Pachastrellidae,NA,Animalia,Porifera,Demospongiae,Tetractinellida,Pachastrellidae,NA,Family,131665,NA,Remove,,,,,,, -Pachastrellidae sp. 1,Pachastrellidae sp. 1,mushroom sponge,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Pachycheles,Pachycheles,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,Pachycheles,Genus,205958,NA,Remove,,,,,,, -Pachycheles ackleianus,Pachycheles ackleianus,Red reef porcelain crab,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,Pachycheles,Species,421867,NA,Species,,,,,,, -Pachycheles rugimanus,Pachycheles rugimanus,Sculptured porcelain crab,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,Pachycheles,Species,421871,NA,Species,,,,,,, -Paelopatides confundus,Paelopatides confundens,Disguised sea cucumber,Animalia,Echinodermata,Holothuroidea,Synallactida,Synallactidae,Paelopatides,Species,148759,NA,Species,,,,,,, -Paelopatides confundens,Paelopatides confundens,Disguised sea cucumber,Animalia,Echinodermata,Holothuroidea,Synallactida,Synallactidae,Paelopatides,Species,148759,NA,Species,,,,,,, -Pagrus,Pagrus,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Pagrus,Genus,126080,NA,Remove,,,,,,, -Pagrus pagrus,Pagrus pagrus,Red porgy,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Pagrus,Species,127063,1756,Species,,,,,,, -Pagrus sedecim,Pagrus pagrus,Red porgy,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Pagrus,Species,127063,1756,Species,,,,,,, -Paguridae,Paguridae,Hermit crabs,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,NA,Family,106738,NA,Remove,,,,,,, -Paguristes,Paguristes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Paguristes,Genus,106844,NA,Remove,,,,,,, -Paguristes lymani,Paguristes lymani,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Paguristes,Species,368250,NA,Species,,,,,,, -Paguristes puncticeps,Paguristes puncticeps,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Paguristes,Species,368275,NA,Species,,,,,,, -Paguristes sericeus,Paguristes sericeus,Blue-eyed hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Paguristes,Species,368285,NA,Species,,,,,,, -Paguristes tortugae,Paguristes tortugae,Band-eye hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Paguristes,Species,368299,NA,Species,,,,,,, -Paguristes triangulatus,Paguristes triangulatus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Paguristes,Species,368300,NA,Species,,,,,,, -Paguristes turgidus,Paguristes turgidus,Orange hairy hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Paguristes,Species,368303,NA,Species,,,,,,, -Paguroidea,Paguroidea,NA,Animalia,Arthropoda,Malacostraca,Decapoda,NA,NA,SuperFamily,106687,NA,Remove,,,,,,, -Pagurus,Pagurus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Genus,106854,NA,Remove,,,,,,, -Pagurus sp.,Pagurus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Genus,106854,NA,Remove,,,,,,, -Pagurus aleuticus,Pagurus aleuticus,Aleutian hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366647,NA,Species,,,,,,, -Pagurus annulipes,Pagurus annulipes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,158401,NA,Species,,,,,,, -Pagurus armatus,Pagurus armatus,Armed hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366655,NA,Species,,,,,,, -Pagurus beringanus,Pagurus beringanus,Bering hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366657,NA,Species,,,,,,, -Pagurus brandti,Pagurus brandti,Sponge hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366661,NA,Species,,,,,,, -Pagurus bullisi,Pagurus bullisi,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366663,NA,Species,,,,,,, -Pagurus capillatus,Pagurus capillatus,Hairy hermit crab,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,254489,NA,Species,,,,,,, -Pagurus carolinensis,Pagurus carolinensis,Wormreef hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366665,NA,Species,,,,,,, -Pagurus caurinus,Pagurus caurinus,Greenmark hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366667,NA,Species,,,,,,, -Pagurus confragosus,Pagurus confragosus,Knobbyhand hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366670,NA,Species,,,,,,, -Pagurus cornutus,Pagurus cornutus,Hornyhand hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366673,NA,Species,,,,,,, -Pagurus dalli,Pagurus dalli,Whiteknee hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366676,NA,Species,,,,,,, -Pagurus defensus,Pagurus defensus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366679,NA,Species,,,,,,, -Pagurus hirsutiusculus,Pagurus hirsutiusculus,Hairy hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366699,NA,Species,,,,,,, -Pagurus impressus,Pagurus impressus,Palmate hermit crab,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366704,NA,Species,,,,,,, -Pagurus kennerlyi,Pagurus kennerlyi,Bluespine hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366712,NA,Species,,,,,,, -Pagurus longicarpus,Pagurus longicarpus,Longwrist hermit crab,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,158403,NA,Species,,,,,,, -Pagurus ochotensis,Pagurus ochotensis,Alaskan hermit crab,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366742,NA,Species,,,,,,, -Pagurus pollicaris,Pagurus pollicaris,Gray hermit crab,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366751,NA,Species,,,,,,, -Pagurus rathbuni,Pagurus rathbuni,Longfinger hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,254491,NA,Species,,,,,,, -Pagurus samuelis,Pagurus samuelis,Blueband hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366786,NA,Species,,,,,,, -Pagurus setosus,Pagurus setosus,Setose hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366787,NA,Species,,,,,,, -Pagurus stevensae,Pagurus stevensae,Stevens hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366798,NA,Species,,,,,,, -Pagurus tanneri,Pagurus tanneri,Longhand hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366801,NA,Species,,,,,,, -Pagurus townsendi,Pagurus townsendi,Townsend hermit crab,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,366802,NA,Species,,,,,,, -Pagurus trigonocheirus,Pagurus trigonocheirus,Fuzzy hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Pagurus,Species,254490,NA,Species,,,,,,, -Palaemonetes,Palaemon,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Palaemonidae,Palaemonetes,Genus,107032,NA,Remove,,,,,,, -Gnathophyllidae,Palaemonidae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Gnathophyllidae,NA,Family,106788,NA,Remove,,,,,,, -Palicidae,Palicidae,Stilt crabs,Animalia,Arthropoda,Malacostraca,Decapoda,Palicidae,NA,Family,106774,NA,Remove,,,,,,, -Palicus,Palicus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Palicidae,Palicus,Genus,106972,NA,Remove,,,,,,, -Palicus affinis,Palicus affinis,Antillian stilt crab,Animalia,Arthropoda,Malacostraca,Decapoda,Palicidae,Palicus,Species,422171,NA,Species,,,,,,, -Palicus alternata,Palicus alternatus,Labile stilt crab,Animalia,Arthropoda,Malacostraca,Decapoda,Palicidae,Palicus,Species,422172,NA,Species,,,,,,, -Palicus alternatus,Palicus alternatus,Labile stilt crab,Animalia,Arthropoda,Malacostraca,Decapoda,Palicidae,Palicus,Species,422172,NA,Species,,,,,,, -Palicus faxoni,Palicus faxoni,Finned stilt crab,Animalia,Arthropoda,Malacostraca,Decapoda,Palicidae,Palicus,Species,422177,NA,Species,,,,,,, -Palicus obesa,Palicus obesus,Inflated stilt crab,Animalia,Arthropoda,Malacostraca,Decapoda,Palicidae,Palicus,Genus,106972,NA,Remove,,,,,,, -Pallasina barbata,Pallasina barbata,Tubenose poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Pallasina,Species,254396,4169,Species,,,,,,, -Pallenopsis schmidti,Pallenopsis schmitti,NA,Animalia,Arthropoda,Pycnogonida,Pantopoda,Pallenopsidae,Pallenopsis,Species,240258,NA,Species,,,,,,, -Pallenopsis schmitti,Pallenopsis schmitti,NA,Animalia,Arthropoda,Pycnogonida,Pantopoda,Pallenopsidae,Pallenopsis,Species,240258,NA,Species,,,,,,, -Pandalidae,Pandalidae,Pandalid shrimps,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,NA,Family,106789,NA,Remove,,,,,,, -Pandalopsis,Pandalus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Genus,107044,NA,Remove,,,,,,, -Pandalus,Pandalus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Genus,107044,NA,Remove,,,,,,, -Pandalus sp.,Pandalus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Genus,107044,NA,Remove,,,,,,, -Pandalopsis aleutica,Pandalus aleuticus,Aleutian bigeye,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalopsis,Species,1337976,NA,Species,,,,,,, -Pandalus aleuticus,Pandalus aleuticus,Aleutian bigeye,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalopsis,Species,1337976,NA,Species,,,,,,, -Pandalopsis ampla,Pandalus amplus,Deepwater bigeye,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalopsis,Species,1337980,NA,Species,,,,,,, -Pandalus amplus,Pandalus amplus,Deepwater bigeye,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalopsis,Species,1337980,NA,Species,,,,,,, -Pandalus borealis,Pandalus borealis,Atlantic northern shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Species,107649,NA,Species,,,,,,, -Pandalus danae,Pandalus danae,Dock shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Species,515462,NA,Species,,,,,,, -Pandalopsis dispar,Pandalus dispar,Sidestripe shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalopsis,Species,1337983,NA,Species,,,,,,, -Pandalus dispar,Pandalus dispar,Sidestripe shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalopsis,Species,1337983,NA,Species,,,,,,, -Pandalus eous,Pandalus eous,Northern shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Species,515463,NA,Species,,,,,,, -Pandalus eous (=borealis),Pandalus eous,Northern shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Species,515463,NA,Species,,,,,,, -Pandalus goniurus,Pandalus goniurus,Humpy shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Species,254483,NA,Species,,,,,,, -Pandalus hypsinotus,Pandalus hypsinotus,Coonstriped shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Species,515467,NA,Species,,,,,,, -Pandalus jordani,Pandalus jordani,Ocean shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Species,515469,NA,Species,,,,,,, -Pandalopsis lamelligera,Pandalus lamelligerus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalopsis,Species,589462,NA,Species,,,,,,, -Pandalopsis longirostris,Pandalus longirostris,Northern longbeak,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalopsis,Species,1337991,NA,Species,,,,,,, -Pandalus longirostris,Pandalus longirostris,Northern longbeak,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalopsis,Species,1337991,NA,Species,,,,,,, -Pandalus montagui,Pandalus montagui,Aesop shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Species,107651,NA,Species,,,,,,, -Pandalus platyceros,Pandalus platyceros,Spot shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Species,423632,NA,Species,,,,,,, -Pandalus sp. cf. lamelligerus,Pandalus sp. cf. lamelligerus,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Pandalus sp. cf. tridens (CAS),Pandalus sp. cf. tridens (CAS),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Pandalus stenolepis,Pandalus stenolepis,Roughpatch shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Species,514361,NA,Species,,,,,,, -Pandalus tridens,Pandalus tridens,Yellowleg pandalid,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Pandalus,Species,423633,NA,Species,,,,,,, -Pannychia,Pannychia,NA,Animalia,Echinodermata,Holothuroidea,Elasipodida,Laetmogonidae,Pannychia,Genus,123525,NA,Remove,,,,,,, -Pannychia sp.,Pannychia,NA,Animalia,Echinodermata,Holothuroidea,Elasipodida,Laetmogonidae,Pannychia,Genus,123525,NA,Remove,,,,,,, -Pannychia moseleyi,Pannychia moseleyi,Deep sea papillate cucumber,Animalia,Echinodermata,Holothuroidea,Elasipodida,Laetmogonidae,Pannychia,Species,241954,NA,Species,,,,,,, -Panomya,Panomya,NA,Animalia,Mollusca,Bivalvia,Adapedonta,Hiatellidae,Panomya,Genus,138069,NA,Remove,,,,,,, -Panomya sp.,Panomya,NA,Animalia,Mollusca,Bivalvia,Adapedonta,Hiatellidae,Panomya,Genus,138069,NA,Remove,,,,,,, -Panomya arctica,Panomya norvegica,Arctic roughmya,Animalia,Mollusca,Bivalvia,Adapedonta,Hiatellidae,Panomya,Species,140105,NA,Species,,,,,,, -Panomya norvegica,Panomya norvegica,Arctic roughmya,Animalia,Mollusca,Bivalvia,Adapedonta,Hiatellidae,Panomya,Species,140105,NA,Species,,,,,,, -Panopea abrupta,Panopea abrupta,Pacific geoduck clam,Animalia,Mollusca,Bivalvia,Adapedonta,Hiatellidae,Panopea,Species,505401,NA,Species,,,,,,, -Panopea generosa,Panopea generosa,Pacific geoduck,Animalia,Mollusca,Bivalvia,Adapedonta,Hiatellidae,Panopea,Species,545994,NA,Species,,,,,,, -Panopeus,Panopeus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Panopeus,Genus,106937,NA,Remove,,,,,,, -Panopeus herbstii,Panopeus herbstii,Atlantic mud crab,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Panopeus,Species,158436,NA,Species,,,,,,, -Panopeus occidentalis,Panopeus occidentalis,Furrowed mud crab,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Panopeus,Species,422086,NA,Species,,,,,,, -Panulirus argus,Panulirus argus,Caribbean spiny lobster,Animalia,Arthropoda,Malacostraca,Decapoda,Palinuridae,Panulirus,Species,382891,NA,Species,,,,,,, -Panulirus interruptus,Panulirus interruptus,Mexican spiny loster,Animalia,Arthropoda,Malacostraca,Decapoda,Palinuridae,Panulirus,Species,382898,NA,Species,,,,,,, -Papyridea,Papyridea,NA,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Papyridea,Genus,206914,NA,Remove,,,,,,, -Papyridea soleniformis,Papyridea soleniformis,Spiny papercockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Papyridea,Species,225385,NA,Species,,,,,,, -Parablennius marmoreus,Parablennius marmoreus,Seaweed blenny,Animalia,Chordata,Teleostei,Blenniiformes,Blenniidae,Parablennius,Species,159609,3769,Species,,,,,,, -Parabornia squillina,Parabornia squillina,Squillaclam,Animalia,Mollusca,Bivalvia,Galeommatida,Lasaeidae,Parabornia,Species,420827,NA,Species,,,,,,, -Paracaudina chilensis_obesacauda,Paracaudina chilensis obesacauda,NA,Animalia,Echinodermata,Holothuroidea,Molpadida,Caudinidae,Paracaudina,Species,225803,NA,Species,,,,,,, -Paracaudina chilensis obesacauda,Paracaudina chilensis obesacauda,NA,Animalia,Echinodermata,Holothuroidea,Molpadida,Caudinidae,Paracaudina,Species,225803,NA,Species,,,,,,, -Paraclinus marmoratus,Paraclinus marmoratus,Marbled blenny,Animalia,Chordata,Teleostei,Blenniiformes,Labrisomidae,Paraclinus,Species,282027,3748,Species,,,,,,, -Paraclinus nigripinnis,Paraclinus nigripinnis,Blackfin blenny,Animalia,Chordata,Teleostei,Blenniiformes,Labrisomidae,Paraclinus,Species,282031,3749,Species,,,,,,, -Paraconger,Paraconger,NA,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Paraconger,Genus,125627,NA,Remove,,,,,,, -Paraconger caudilimbatus,Paraconger caudilimbatus,Margintail conger,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Paraconger,Species,158569,2631,Species,,,,,,, -Paracrangon echinata,Paracrangon echinata,Horned shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Paracrangon,Species,515591,NA,Species,,,,,,, -Paractaea nodosa,Paractaea nodosa,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Xanthidae,Paractaea,Species,444050,NA,Species,,,,,,, -Actaea rufopunctata,Paractaea rufopunctata,Nodose rubble crab,Animalia,Arthropoda,Malacostraca,Decapoda,Xanthidae,Actaea,Species,209046,NA,Species,,,,,,, -Paractaea rufopunctata,Paractaea rufopunctata,Nodose rubble crab,Animalia,Arthropoda,Malacostraca,Decapoda,Xanthidae,Actaea,Species,209046,NA,Species,,,,,,, -Paragorgia,Paragorgia,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Coralliidae,Paragorgia,Genus,125326,NA,Remove,,,,,,, -Paragorgia sp.,Paragorgia,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Coralliidae,Paragorgia,Genus,125326,NA,Remove,,,,,,, -Paragorgia arborea,Paragorgia arborea,Bubblegum coral,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Coralliidae,Paragorgia,Species,125418,NA,Species,,,,,,, -Paragorgia nodosa,Paragorgia arborea,Bubblegum coral,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Coralliidae,Paragorgia,Species,125418,NA,Species,,,,,,, -Paragorgia pacifica,Paragorgia arborea var. pacifica,Bubblegum coral,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Coralliidae,Paragorgia,Variety,1647393,NA,Variety,,,,,,, -Paragorgia arborea var. pacifica,Paragorgia arborea var. pacifica,Bubblegum coral,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Coralliidae,Paragorgia,Variety,1647393,NA,Variety,,,,,,, -Parahollardia lineata,Parahollardia lineata,Jambeau,Animalia,Chordata,Teleostei,Tetraodontiformes,Triacanthodidae,Parahollardia,Species,282046,4272,Species,,,,,,, -Paralabrax nebulifer,Paralabrax nebulifer,Barred sand bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Paralabrax,Species,282059,3337,Species,,,,,,, -Paralepidae,Paralepididae,Barracudinas,Animalia,Chordata,Teleostei,Aulopiformes,Paralepididae,NA,Family,125447,NA,Remove,,,,,,, -Paralepididae,Paralepididae,Barracudinas,Animalia,Chordata,Teleostei,Aulopiformes,Paralepididae,NA,Family,125447,NA,Remove,,,,,,, -Paralepis coregonoides,Paralepis coregonoides,Sharpchin barracudina,Animalia,Chordata,Teleostei,Aulopiformes,Paralepididae,Paralepis,Species,126361,1757,Species,,,,,,, -Paralichthyidae,Paralichthyidae,Large tooth flounders,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,NA,Family,154168,NA,Remove,,,,,,, -Paralichthyinae,Paralichthyidae,Large tooth flounders,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,NA,Family,154168,NA,Remove,,,,,,, -Paralichthys,Paralichthys,Flounders,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Paralichthys,Genus,158823,NA,Remove,,,,,,, -Paralichthys sp,Paralichthys,Flounders,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Paralichthys,Genus,158823,NA,Remove,,,,,,, -Paralichthys albigutta,Paralichthys albigutta,Gulf flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Paralichthys,Species,158825,980,Species,,,,,,, -Paralichthys californicus,Paralichthys californicus,California flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Paralichthys,Species,275809,4228,Species,,,,,,, -Paralichthys dentatus,Paralichthys dentatus,Summer flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Paralichthys,Species,158826,1338,Species,,,,,,, -Paralichthys lethostigma,Paralichthys lethostigma,Southern flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Paralichthys,Species,158829,981,Species,,,,,,, -Paralichthys squamilentus,Paralichthys squamilentus,Broad flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Paralichthys,Species,158827,4230,Species,,,,,,, -Paraliparis,Paraliparis,NA,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Paraliparis,Genus,126161,NA,Remove,,,,,,, -Paraliparis sp.,Paraliparis,NA,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Paraliparis,Genus,126161,NA,Remove,,,,,,, -Paraliparis adustus,Paraliparis adustus,Brown snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Paraliparis,Species,474964,65369,Species,,,,,,, -Paraliparis albeolus,Paraliparis albeolus,White snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Paraliparis,Species,274546,51442,Species,,,,,,, -Paraliparis cephalus,Paraliparis cephalus,Swellhead snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Paraliparis,Species,274562,25260,Species,,,,,,, -Paraliparis dactylosus,Paraliparis dactylosus,Red snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Paraliparis,Species,274568,51445,Species,,,,,,, -Paraliparis deani,Paraliparis deani,Prickly snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Paraliparis,Species,274570,4202,Species,,,,,,, -Paraliparis grandis,Paraliparis grandis,grand snailfish,NA,NA,NA,NA,NA,NA,Species,274581,NA,Species,,,,,,, -Paraliparis holomelas,Paraliparis holomelas,Ebony snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Paraliparis,Species,274583,50719,Species,,,,,,, -Paraliparis paucidens,Paraliparis paucidens,toothless snailfish,NA,NA,NA,NA,NA,NA,Species,274603,NA,Species,,,,,,, -Paraliparis pectoralis,Paraliparis pectoralis,Pectoral snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Paraliparis,Species,274604,51463,Species,,,,,,, -Paraliparis penicillus,Paraliparis penicillus,comet snailfish,NA,NA,NA,NA,NA,NA,Species,712576,NA,Species,,,,,,, -Paraliparis rosaceus,Paraliparis rosaceus,Pink snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Paraliparis,Species,274608,24139,Species,,,,,,, -Paraliparis sp. cf. dactylosus (Orr and Baldwin),Paraliparis sp. cf. dactylosus (Orr and Baldwin),bluntnose snailfish,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Paraliparis sp. cf. pectoralis (Orr and Baldwin),Paraliparis sp. cf. pectoralis (Orr and Baldwin),rusty snailfish,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Paraliparis sp. cf. ulochir (Orr and Baldwin),Paraliparis sp. cf. ulochir (Orr and Baldwin),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Paraliparis ulochir,Paraliparis ulochir,Broadfin snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Paraliparis,Species,274612,50720,Species,,,,,,, -Paralithodes,Paralithodes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Paralithodes,Genus,106847,NA,Remove,,,,,,, -Paralithodes sp.,Paralithodes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Paralithodes,Genus,106847,NA,Remove,,,,,,, -Paralithodes brevipes,Paralithodes brevipes,Brown king crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Paralithodes,Species,254494,NA,Species,,,,,,, -Paralithodes californiensis,Paralithodes californiensis,California king crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Paralithodes,Species,550644,NA,Species,,,,,,, -Paralithodes camtschaticus,Paralithodes camtschaticus,Red king crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Paralithodes,Species,233889,NA,Species,,,,,,, -Paralithodes platypus,Paralithodes platypus,Blue king crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Paralithodes,Species,254493,NA,Species,,,,,,, -Paralithodes rathbuni,Paralithodes rathbuni,Forknose king crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Paralithodes,Species,550645,NA,Species,,,,,,, -Paralomis,Paralomis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Paralomis,Genus,106848,NA,Remove,,,,,,, -Paralomis sp.,Paralomis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Paralomis,Genus,106848,NA,Remove,,,,,,, -Paralomis manningi,Paralomis manningi,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Paralomis,Species,550587,NA,Species,,,,,,, -Paralomis multispina,Paralomis multispina,Many spine spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Paralomis,Species,378131,NA,Species,,,,,,, -Paralomis sp. A (Clark 2006),Paralomis sp. A (Clark 2006),spiny spider crab,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Paralomis sp. B (Clark 2006),Paralomis sp. B (Clark 2006),short spine spider crab,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Paralomis verrilli,Paralomis verrilli,NA,NA,NA,NA,NA,NA,NA,Species,378132,NA,Species,,,,,,, -Acanthogorgiidae,Paramuriceidae,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Acanthogorgiidae,NA,Family,151540,NA,Remove,,,,,,, -Paranthias furcifer,Paranthias furcifer,Creole fish,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Paranthias,Species,282084,1217,Species,,,,,,, -Paranthus,Paranthus,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,Paranthus,Genus,100712,NA,Remove,,,,,,, -Paranthus rapiformis,Paranthus rapiformis,Sea onion,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,Paranthus,Species,158254,NA,Species,,,,,,, -Parantipathes,Parantipathes,NA,Animalia,Cnidaria,Anthozoa,Antipatharia,Schizopathidae,Parantipathes,Genus,103306,NA,Remove,,,,,,, -Parantipathes sp.,Parantipathes,NA,Animalia,Cnidaria,Anthozoa,Antipatharia,Schizopathidae,Parantipathes,Genus,103306,NA,Remove,,,,,,, -Parapasiphae sulcatifrons,Parapasiphae sulcatifrons,Grooveback shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pasiphaeidae,Parapasiphae,Species,107673,NA,Species,,,,,,, -Parapenaeus,Parapenaeus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Parapenaeus,Genus,106819,NA,Remove,,,,,,, -Parapenaeus americanus,Parapenaeus americanus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Parapenaeus,Species,377558,NA,Species,,,,,,, -Parapenaeus politus,Parapenaeus politus,Rose shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Parapenaeus,Species,377562,NA,Species,,,,,,, -Paraphelliactis pabista,Paraphelliactis pabista,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Hormathiidae,Paraphelliactis,Species,290677,NA,Species,,,,,,, -Synagrops spinosa,Parascombrops spinosus,Keelcheek bass,Animalia,Chordata,Teleostei,Acropomatiformes,Acropomatidae,Synagrops,Species,1486846,14336,Species,,,,,,, -Synagrops spinosus,Parascombrops spinosus,Keelcheek bass,Animalia,Chordata,Teleostei,Acropomatiformes,Acropomatidae,Synagrops,Species,1486846,14336,Species,,,,,,, -Parascombrops spinosus,Parascombrops spinosus,Keelcheek bass,Animalia,Chordata,Teleostei,Acropomatiformes,Acropomatidae,Synagrops,Species,1486846,14336,Species,,,,,,, -Parasquilla coccinea,Parasquilla coccinea,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Parasquillidae,Parasquilla,Species,409160,NA,Species,,,,,,, -Parastenella,Parastenella,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Parastenella,Genus,267700,NA,Remove,,,,,,, -Parastenella sp. A (Clark 2006),Parastenella sp. A (Clark 2006),sugar coral,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Parastichopus,Parastichopus,NA,Animalia,Echinodermata,Holothuroidea,Synallactida,Stichopodidae,Parastichopus,Genus,123458,NA,Remove,,,,,,, -Parastichopus sp.,Parastichopus,NA,Animalia,Echinodermata,Holothuroidea,Synallactida,Stichopodidae,Parastichopus,Genus,123458,NA,Remove,,,,,,, -Parasudis truculenta,Parasudis truculenta,Longnose greeneye,Animalia,Chordata,Teleostei,Aulopiformes,Chlorophthalmidae,Parasudis,Species,158868,2726,Species,,,,,,, -Pareques,Pareques,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Pareques,Genus,270286,NA,Remove,,,,,,, -Equetus acuminatus,Pareques acuminatus,High hat,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Equetus,Species,282139,3583,Species,,,,,,, -Equetus pulcher,Pareques acuminatus,High hat,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Equetus,Species,282139,3583,Species,,,,,,, -Pareques acuminatus,Pareques acuminatus,High hat,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Equetus,Species,282139,3583,Species,,,,,,, -Equetus iwamotoi,Pareques iwamotoi,Blackbar drum,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Pareques,Species,315192,4660,Species,,,,,,, -Pareques iwamotoi,Pareques iwamotoi,Blackbar drum,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Pareques,Species,315192,4660,Species,,,,,,, -Equetus umbrosus,Pareques umbrosus,Cubbyu,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Pareques,Species,282143,3586,Species,,,,,,, -Pareques umbrosus,Pareques umbrosus,Cubbyu,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Pareques,Species,282143,3586,Species,,,,,,, -Parexocoetus,Parexocoetus,NA,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Parexocoetus,Genus,125694,NA,Remove,,,,,,, -Parexocoetus brachypterus,Parexocoetus brachypterus,Sailfin flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Parexocoetus,Species,217872,1037,Species,,,,,,, -Paricelinus hopliticus,Paricelinus hopliticus,Thornback sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Paricelinus,Species,282147,4133,Species,,,,,,, -Parmaturus xaniurus,Parmaturus xaniurus,Filetail catshark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Pentanchidae,Parmaturus,Species,282166,833,Species,,,,,,, -Apogon affinis,Paroncheilus affinis,Bigtooth cardinalfish,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Apogon,Species,320100,3520,Species,,,,,,, -Parophrys vetulus,Parophrys vetulus,English sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Parophrys,Species,254393,4248,Species,,,,,,, -Parthenope,Parthenope,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Parthenope,Genus,106916,NA,Remove,,,,,,, -Parthenope agonus,Parthenope agona,Elbow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Parthenope,Species,106916,NA,Species,,,,,,, -Parthenopidae,Parthenopidae,Elbow crabs,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,NA,Family,106761,NA,Remove,,,,,,, -Parvamussium alaskense,Parvamussium alaskense,Alaska glass-scallop,Animalia,Mollusca,Bivalvia,Pectinida,Propeamussiidae,Parvamussium,Species,391634,NA,Species,,,,,,, -Pasiphaea multidentata,Pasiphaea multidentata,Pink glass shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pasiphaeidae,Pasiphaea,Species,107676,NA,Species,,,,,,, -Pasiphaea pacifica,Pasiphaea pacifica,Pacific glass shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pasiphaeidae,Pasiphaea,Species,514245,NA,Species,,,,,,, -Pasiphaea tarda,Pasiphaea tarda,Crimson pasiphaeid,Animalia,Arthropoda,Malacostraca,Decapoda,Pasiphaeidae,Pasiphaea,Species,107678,NA,Species,,,,,,, -Pasiphaeidae,Pasiphaeidae,Pasiphaeid shrimp unid.,Animalia,Arthropoda,Malacostraca,Decapoda,Pasiphaeidae,NA,Family,106790,NA,Remove,,,,,,, -Patinopecten caurinus,Patinopecten caurinus,Weathervane scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Patinopecten,Species,393720,NA,Species,,,,,,, -Asterina miniata,Patiria miniata,Bat star,Animalia,Echinodermata,Asteroidea,Valvatida,Asterinidae,Asterina,Species,382131,NA,Species,,,,,,, -Pawsonaster parvus,Pawsonaster parvus,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Pawsonaster,Species,178151,NA,Species,,,,,,, -Pecten,Pecten,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Pecten,Genus,138323,NA,Remove,,,,,,, -Pectinidae,Pectinidae,Scallops,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,NA,Family,213,NA,Remove,,,,,,, -Pedicellaster,Pedicellaster,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Pedicellasteridae,Pedicellaster,Genus,123236,NA,Remove,,,,,,, -Pedicellaster sp.,Pedicellaster,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Pedicellasteridae,Pedicellaster,Genus,123236,NA,Remove,,,,,,, -Pedicellaster magister,Pedicellaster magister,Soft orange star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Pedicellasteridae,Pedicellaster,Species,255116,NA,Species,,,,,,, -Pelia mutica,Pelia mutica,Cryptic teardrop crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Pelia,Species,158440,NA,Species,,,,,,, -Peltodoris lentiginosa,Peltodoris lentiginosa,Mottled pale sea-lemon,Animalia,Mollusca,Gastropoda,Nudibranchia,Discodorididae,Peltodoris,Species,1481221,NA,Species,,,,,,, -Anisodoris nobilis,Peltodoris nobilis,Pacific sea-lemon,Animalia,Mollusca,Gastropoda,Nudibranchia,Discodorididae,Peltodoris,Species,594422,NA,Species,,,,,,, -Peltodoris nobilis,Peltodoris nobilis,Pacific sea-lemon,Animalia,Mollusca,Gastropoda,Nudibranchia,Discodorididae,Peltodoris,Species,594422,NA,Species,,,,,,, -Penaeidae,Penaeidae,Penaeid shrimps,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,NA,Family,106727,NA,Remove,,,,,,, -Penaeopsis,Penaeopsis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Penaeopsis,Genus,106821,NA,Remove,,,,,,, -Penaeopsis serrata,Penaeopsis serrata,Megalops shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Penaeopsis,Species,107111,NA,Species,,,,,,, -Penaeus,Penaeus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Penaeus,Genus,106822,NA,Remove,,,,,,, -Penaeus sp,Penaeus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Penaeus,Genus,106822,NA,Remove,,,,,,, -Farfantepenaeus aztecus,Penaeus aztecus,Brown shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Penaeus,Species,395176,NA,Species,,,,,,, -Penaeus aztecus,Penaeus aztecus,Brown shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Penaeus,Species,395176,NA,Species,,,,,,, -Farfantepenaeus duorarum,Penaeus duorarum,Pink shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Penaeus,Species,246391,NA,Species,,,,,,, -Penaeus duorarum,Penaeus duorarum,Pink shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Penaeus,Species,246391,NA,Species,,,,,,, -Penaeus monodon,Penaeus monodon,Giant tiger prawn,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Penaeus,Species,210378,NA,Species,,,,,,, -Litopenaeus setiferus,Penaeus setiferus,Northern white shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Penaeus,Species,762818,NA,Species,,,,,,, -Penaeus setiferus,Penaeus setiferus,Northern white shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Penaeus,Species,762818,NA,Species,,,,,,, -Litopenaeus vannamei,Penaeus vannamei,Whiteleg shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Litopenaeus,Species,377748,NA,Species,,,,,,, -Pennatula,Pennatula,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Pennatulidae,Pennatula,Genus,128495,NA,Remove,,,,,,, -Pennatula phosphorea,Pennatula phosphorea,Phosphorescent sea pen,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Pennatulidae,Pennatula,Species,128517,NA,Species,,,,,,, -Pennatulidae,Pennatulidae,Pennatulid sea pens,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Pennatulidae,NA,Family,128484,NA,Remove,,,,,,, -Pennatulacea,Pennatuloidea,Sea pens,Animalia,Cnidaria,Anthozoa,Pennatulacea,NA,NA,Order,1609360,NA,Remove,,,,,,, -Pennatuloidea,Pennatuloidea,Sea pens,Animalia,Cnidaria,Anthozoa,Pennatulacea,NA,NA,Order,1609360,NA,Remove,,,,,,, -Pentamera,Pentamera,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Phyllophoridae,Pentamera,Genus,123489,NA,Remove,,,,,,, -Pentamera sp.,Pentamera,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Phyllophoridae,Pentamera,Genus,123489,NA,Remove,,,,,,, -Pentamera lissoplaca,Pentamera lissoplaca,Crescent sea cucumber,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Phyllophoridae,Pentamera,Species,529598,NA,Species,,,,,,, -Pentamera pulcherrima,Pentamera pulcherrima,Splendid sea cucumber,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Phyllophoridae,Pentamera,Species,149908,NA,Species,,,,,,, -Pentamera sp. A (Clark 2006),Pentamera sp. A (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Peprilus burti,Peprilus burti,Gulf butterfish,Animalia,Chordata,Teleostei,Scombriformes,Stromateidae,Peprilus,Species,276560,3924,Species,,,,,,, -Peprilus alepidotus,Peprilus paru,Harvestfish,Animalia,Chordata,Teleostei,Scombriformes,Stromateidae,Peprilus,Species,159827,28143,Species,,,,,,, -Peprilus paru,Peprilus paru,Harvestfish,Animalia,Chordata,Teleostei,Scombriformes,Stromateidae,Peprilus,Species,159827,28143,Species,,,,,,, -Peprilus simillimus,Peprilus simillimus,Pacific pompano,Animalia,Chordata,Teleostei,Scombriformes,Stromateidae,Peprilus,Species,276563,493,Species,,,,,,, -Peprilus triacanthus,Peprilus triacanthus,American butterfish,Animalia,Chordata,Teleostei,Scombriformes,Stromateidae,Peprilus,Species,159828,492,Species,,,,,,, -Perciformes,Perciformes,NA,Animalia,Chordata,Teleostei,Perciformes,NA,NA,Order,11014,NA,Remove,,,,,,, -Percis japonicus,Percis japonica,Dragon poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Percis,Species,254389,23990,Species,,,,,,, -Percis japonica,Percis japonica,Dragon poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Percis,Species,254389,23990,Species,,,,,,, -Peribolaster biserialis,Peribolaster biserialis,Fuzzy star,Animalia,Echinodermata,Asteroidea,Velatida,Korethrasteridae,Peribolaster,Species,292746,NA,Species,,,,,,, -Periclimenes,Periclimenes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Palaemonidae,Periclimenes,Genus,107035,NA,Remove,,,,,,, -Periphylla,Periphylla,NA,Animalia,Cnidaria,Scyphozoa,Coronatae,Periphyllidae,Periphylla,Genus,135252,NA,Remove,,,,,,, -Periphylla sp.,Periphylla,NA,Animalia,Cnidaria,Scyphozoa,Coronatae,Periphyllidae,Periphylla,Genus,135252,NA,Remove,,,,,,, -Periphylla periphylla,Periphylla periphylla,Merchant cap,Animalia,Cnidaria,Scyphozoa,Coronatae,Periphyllidae,Periphylla,Species,135294,NA,Species,,,,,,, -Periploma fragile,Periploma fragile,Fragile spoonclam,Animalia,Mollusca,Bivalvia,NA,Periplomatidae,Periploma,Species,156939,NA,Species,,,,,,, -Peristedion,Peristedion,NA,Animalia,Chordata,Teleostei,Perciformes,Peristediidae,Peristedion,Genus,126165,NA,Remove,,,,,,, -Peristedion gracile,Peristedion gracile,Slender searobin,Animalia,Chordata,Teleostei,Perciformes,Peristediidae,Peristedion,Species,159548,4017,Species,,,,,,, -Peristedion greyae,Peristedion greyae,NA,Animalia,Chordata,Teleostei,Perciformes,Peristediidae,Peristedion,Species,159549,61103,Species,,,,,,, -Peristedion miniatum,Peristedion miniatum,Armored searobin,Animalia,Chordata,Teleostei,Perciformes,Peristediidae,Peristedion,Species,159550,4018,Species,,,,,,, -Persephona,Persephona,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Leucosiidae,Persephona,Genus,158441,NA,Remove,,,,,,, -Persephona crinita,Persephona crinita,Pink purse crab,Animalia,Arthropoda,Malacostraca,Decapoda,Leucosiidae,Persephona,Species,421935,NA,Species,,,,,,, -Persephona mediterranea,Persephona mediterranea,Mottled purse crab,Animalia,Arthropoda,Malacostraca,Decapoda,Leucosiidae,Persephona,Species,158443,NA,Species,,,,,,, -Solemya reidi,Petrasma pervernicosa,NA,Animalia,Mollusca,Bivalvia,Solemyida,Solemyidae,Solemya,Species,743493,NA,Species,,,,,,, -Petrochirus diogenes,Petrochirus diogenes,Giant hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Diogenidae,Petrochirus,Species,368346,NA,Species,,,,,,, -Petrolisthes,Petrolisthes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,Petrolisthes,Genus,206848,NA,Remove,,,,,,, -Petrolisthes armatus,Petrolisthes armatus,Green porcelain crab,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,Petrolisthes,Species,396707,NA,Species,,,,,,, -Petrolisthes galathinus,Petrolisthes galathinus,Banded porcelain crab,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,Petrolisthes,Species,421875,NA,Species,,,,,,, -Petromyzon marinus,Petromyzon marinus,Sea lamprey,Animalia,Chordata,Petromyzonti,Petromyzontiformes,Petromyzontidae,Petromyzon,Species,101174,2530,Species,,,,,,, -Petromyzontidae,Petromyzontidae,Lampreys,Animalia,Chordata,Petromyzonti,Petromyzontiformes,Petromyzontidae,NA,Family,101163,NA,Remove,,,,,,, -Phacellophora,Phacellophora,NA,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Phacellophoridae,Phacellophora,Genus,135266,NA,Remove,,,,,,, -Phacellophora sp.,Phacellophora,NA,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Phacellophoridae,Phacellophora,Genus,135266,NA,Remove,,,,,,, -Phacellophora camtschatica,Phacellophora camtschatica,Fried egg jellyfish,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,Phacellophoridae,Phacellophora,Species,135309,NA,Species,,,,,,, -Phaeophyceae,Phaeophyceae,NA,Chromista,Ochrophyta,Phaeophyceae,NA,NA,NA,Class,830,NA,Remove,,,,,,, -Phaeoptyx,Phaeoptyx,NA,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Phaeoptyx,Genus,270358,NA,Remove,,,,,,, -Phaeoptyx conklini,Phaeoptyx conklini,Freckled cardinalfish,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Phaeoptyx,Species,282226,3536,Species,,,,,,, -Phaeoptyx pigmentaria,Phaeoptyx pigmentaria,Dusky cardinalfish,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Phaeoptyx,Species,282227,3537,Species,,,,,,, -Phaeoptyx xenus,Phaeoptyx xenus,Sponge cardinalfish,Animalia,Chordata,Teleostei,Kurtiformes,Apogonidae,Phaeoptyx,Species,282228,3538,Species,,,,,,, -Phakellia,Phakellia,NA,Animalia,Porifera,Demospongiae,Bubarida,Bubaridae,Phakellia,Genus,131779,NA,Remove,,,,,,, -Phakellia sp.,Phakellia,NA,Animalia,Porifera,Demospongiae,Bubarida,Bubaridae,Phakellia,Genus,131779,NA,Remove,,,,,,, -Phallusia,Phallusia,NA,Animalia,Chordata,Ascidiacea,Phlebobranchia,Ascidiidae,Phallusia,Genus,103485,NA,Remove,,,,,,, -Phanerodon atripes,Phanerodon atripes,Sharpnose seaperch,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Embiotocidae,Phanerodon,Species,279409,3637,Species,,,,,,, -Phanerodon furcatus,Phanerodon furcatus,White seaperch,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Embiotocidae,Phanerodon,Species,240730,3638,Species,,,,,,, -Rhacochilus vacca,Phanerodon vacca,Pile perch,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Embiotocidae,Rhacochilus,Species,1577347,3640,Species,,,,,,, -Phascolosomatidae,Phascolosomatidae,NA,Animalia,Annelida,NA,Sipuncula,Phascolosomatidae,NA,Family,1645,NA,Remove,,,,,,, -Phidolopora pacifica,Phidolopora pacifica,Lattice work bryozoan,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Phidoloporidae,Phidolopora,Species,470149,NA,Species,,,,,,, -Philine bakeri,Philine bakeri,Baker paper-bubble,Animalia,Mollusca,Gastropoda,Cephalaspidea,Philinidae,Philine,Species,581406,NA,Species,,,,,,, -Phimochirus,Phimochirus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Phimochirus,Genus,366816,NA,Remove,,,,,,, -Phimochirus holthuisi,Phimochirus holthuisi,Red striped hermit,Animalia,Arthropoda,Malacostraca,Decapoda,Paguridae,Phimochirus,Species,366818,NA,Species,,,,,,, -Phocoena phocoena,Phocoena phocoena,Harbour porpoise,Animalia,Chordata,Mammalia,Cetartiodactyla,Phocoenidae,Phocoena,Species,137117,NA,Species,,,,,,, -Pholis gunnellus,Pholis gunnellus,Rock gunnel,Animalia,Chordata,Teleostei,Perciformes,Pholidae,Pholis,Species,126996,3804,Species,,,,,,, -Pholis laeta,Pholis laeta,Crescent gunnel,Animalia,Chordata,Teleostei,Perciformes,Pholidae,Pholis,Species,273689,3805,Species,,,,,,, -Phorbas,Phorbas,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Hymedesmiidae,Phorbas,Genus,131953,NA,Remove,,,,,,, -Phorbas sp.,Phorbas,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Hymedesmiidae,Phorbas,Genus,131953,NA,Remove,,,,,,, -Phorbas paucistylifer,Phorbas paucistylifer,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Hymedesmiidae,Phorbas,Species,169346,NA,Species,,,,,,, -Phoronida,Phoronida,Horseshoe worm,Animalia,Phoronida,NA,NA,NA,NA,Phylum,1789,NA,Remove,,,,,,, -Photonectes margarita,Photonectes margarita,NA,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,Photonectes,Species,127370,11790,Species,,,,,,, -Phoxichilidiidae,Phoxichilidiidae,NA,Animalia,Arthropoda,Pycnogonida,Pantopoda,Phoxichilidiidae,NA,Family,14469,NA,Remove,,,,,,, -Nassarius vibex,Phrontis vibex,Bruised nassa,Animalia,Mollusca,Gastropoda,Neogastropoda,Nassariidae,Nassarius,Species,877061,NA,Species,,,,,,, -Phtheirichthys lineatus,Phtheirichthys lineatus,Slender suckerfish,Animalia,Chordata,Teleostei,Carangiformes,Echeneidae,Phtheirichthys,Species,126849,3544,Species,,,,,,, -Urophycis chesteri,Phycis chesteri,Longfin hake,Animalia,Chordata,Teleostei,Gadiformes,Phycidae,Urophycis,Species,158988,1880,Species,,,,,,, -Phyllolithodes,Phyllolithodes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Phyllolithodes,Genus,550605,NA,Remove,,,,,,, -Phyllolithodes sp.,Phyllolithodes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Phyllolithodes,Genus,550605,NA,Remove,,,,,,, -Phyllolithodes papillosus,Phyllolithodes papillosus,Flatspine triangle crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Phyllolithodes,Species,550606,NA,Species,,,,,,, -Phyllonotus,Phyllonotus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Phyllonotus,Genus,403805,NA,Remove,,,,,,, -Chicoreus pomum,Phyllonotus pomum,Apple murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Phyllonotus,Species,419944,NA,Species,,,,,,, -Phyllonotum pomum,Phyllonotus pomum,Apple murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Phyllonotus,Species,419944,NA,Species,,,,,,, -Phyllonotus pomum,Phyllonotus pomum,Apple murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Phyllonotus,Species,419944,NA,Species,,,,,,, -Phyllorhiza punctata,Phyllorhiza punctata,Australian spotted jellyfish,Animalia,Cnidaria,Scyphozoa,Rhizostomeae,Mastigiidae,Phyllorhiza,Species,135298,NA,Species,,,,,,, -Physiculus,Physiculus,NA,Animalia,Chordata,Teleostei,Gadiformes,Moridae,Physiculus,Genus,125770,NA,Remove,,,,,,, -Physiculus fulvus,Physiculus fulvus,Hakeling,Animalia,Chordata,Teleostei,Gadiformes,Moridae,Physiculus,Species,158987,28217,Species,,,,,,, -Physiculus rastrelliger,Physiculus rastrelliger,Hundred fathom mora,Animalia,Chordata,Teleostei,Gadiformes,Moridae,Physiculus,Species,272510,11626,Species,,,,,,, -Pilumnus,Pilumnus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pilumnidae,Pilumnus,Genus,106941,NA,Remove,,,,,,, -Pilumnus dasypodus,Pilumnus dasypodus,Shortspined hairy crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pilumnidae,Pilumnus,Species,422095,NA,Species,,,,,,, -Pilumnus floridanus,Pilumnus floridanus,Plumed hairy crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pilumnidae,Pilumnus,Species,422097,NA,Species,,,,,,, -Pilumnus gracilipes,Pilumnus gracilipes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pilumnidae,Pilumnus,Species,442511,NA,Species,,,,,,, -Pilumnus pannosus,Pilumnus pannosus,Beaded hairy crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pilumnidae,Pilumnus,Species,422104,NA,Species,,,,,,, -Pilumnus sayi,Pilumnus sayi,Spineback hairy crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pilumnidae,Pilumnus,Species,422105,NA,Species,,,,,,, -Pinctada,Pinctada,NA,Animalia,Mollusca,Bivalvia,Ostreida,Margaritidae,Pinctada,Genus,138396,NA,Remove,,,,,,, -Pinctada imbricata,Pinctada imbricata,Atlantic pearl-oyster,Animalia,Mollusca,Bivalvia,Ostreida,Margaritidae,Pinctada,Species,207901,NA,Species,,,,,,, -Pinna carnea,Pinna carnea,Amber penshell,Animalia,Mollusca,Bivalvia,Ostreida,Pinnidae,Pinna,Species,420742,NA,Species,,,,,,, -Pinnaxodes floridensis,Pinnaxodes floridensis,Polkadotted pea crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pinnotheridae,Pinnaxodes,Species,422159,NA,Species,,,,,,, -Pinnidae,Pinnidae,NA,Animalia,Mollusca,Bivalvia,Ostreida,Pinnidae,NA,Family,1776,NA,Remove,,,,,,, -Pinnixa,Pinnixa,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pinnotheridae,Pinnixa,Genus,158444,NA,Remove,,,,,,, -Pinnixa lunzi,Pinnixa lunzi,Lunz pea crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pinnotheridae,Pinnixa,Species,158449,NA,Species,,,,,,, -Pinnotheridae,Pinnotheridae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pinnotheridae,NA,Family,106775,NA,Remove,,,,,,, -Pisaster,Pisaster,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Pisaster,Genus,240754,NA,Remove,,,,,,, -Pisaster sp.,Pisaster,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Pisaster,Genus,240754,NA,Remove,,,,,,, -Pisaster brevispinus,Pisaster brevispinus,Giant pink sea star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Pisaster,Species,240757,NA,Species,,,,,,, -Pisaster giganteus,Pisaster giganteus,Giant spined star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Pisaster,Species,240758,NA,Species,,,,,,, -Pisaster ochraceus,Pisaster ochraceus,Purple star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Pisaster,Species,240755,NA,Species,,,,,,, -Pitar,Pitar,NA,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Pitar,Genus,138644,NA,Remove,,,,,,, -Pitar albidus,Pitar albidus,NA,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Pitar,Species,420948,NA,Species,,,,,,, -Pitar cordatus,Pitarenus cordatus,Corded pitar,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Pitar,Species,420957,NA,Species,,,,,,, -Pitarenus cordatus,Pitarenus cordatus,Corded pitar,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Pitar,Species,420957,NA,Species,,,,,,, -Pitho,Pitho,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Mithracidae,Pitho,Genus,415820,NA,Remove,,,,,,, -Placetron wosnessenskii,Placetron wosnessenskii,Scaled crab,Animalia,Arthropoda,Malacostraca,Decapoda,Hapalogastridae,Placetron,Species,590118,NA,Species,,,,,,, -Placiphorella,Placiphorella,NA,Animalia,Mollusca,Polyplacophora,Chitonida,Mopaliidae,Placiphorella,Genus,138187,NA,Remove,,,,,,, -Placiphorella sp.,Placiphorella,NA,Animalia,Mollusca,Polyplacophora,Chitonida,Mopaliidae,Placiphorella,Genus,138187,NA,Remove,,,,,,, -Placiphorella pacifica,Placiphorella pacifica,NA,Animalia,Mollusca,Polyplacophora,Chitonida,Mopaliidae,Placiphorella,Species,386374,NA,Species,,,,,,, -Placiphorella rufa,Placiphorella rufa,Red veiled chiton,Animalia,Mollusca,Polyplacophora,Chitonida,Mopaliidae,Placiphorella,Species,386375,NA,Species,,,,,,, -Placopecten magellanicus,Placopecten magellanicus,Atlantic sea scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Placopecten,Species,156972,NA,Species,,,,,,, -Placopecten magellanicus clapper,Placopecten magellanicus clapper,Atlantic sea scallop,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Placopecten,Remove,156972,NA,Remove,,,,,,, -Plagusia depressa,Plagusia depressa,Tidal spray crab,Animalia,Arthropoda,Malacostraca,Decapoda,Plagusiidae,Plagusia,Species,107459,NA,Species,,,,,,, -Plakina atka,Plakina atka,Atka membrane sponge,Animalia,Porifera,Homoscleromorpha,Homosclerophorida,Plakinidae,Plakina,Species,195923,NA,Species,,,,,,, -Plakina tanaga,Plakina tanaga,White convoluted sponge,Animalia,Porifera,Homoscleromorpha,Homosclerophorida,Plakinidae,Plakina,Species,195924,NA,Species,,,,,,, -Planes minutus,Planes minutus,Gulfweed crab,Animalia,Arthropoda,Malacostraca,Decapoda,Grapsidae,Planes,Species,107462,NA,Species,,,,,,, -Platichthys stellatus,Platichthys stellatus,Starry flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Platichthys,Species,154781,4249,Species,,,,,,, -Platichthys stellatus X Pleuronectes quadrituberculatus hybrid,Platichthys stellatus X Pleuronectes quadrituberculatus hybrid,Hybrid starry flounder X Alaska plaice,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Platichthys,Species,154781,4249,Species,,,,,,, -Platybelone argalus,Platybelone argalus,Keeltail needlefish,Animalia,Chordata,Teleostei,Beloniformes,Belonidae,Platybelone,Species,126377,973,Species,,,,,,, -Platydoris angustipes,Platydoris angustipes,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Discodorididae,Platydoris,Species,420602,NA,Species,,,,,,, -Platyhelminthes,Platyhelminthes,Flatworms,Animalia,Platyhelminthes,NA,NA,NA,NA,Phylum,793,NA,Remove,,,,,,, -Platylambrus,Platylambrus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Platylambrus,Genus,205282,NA,Remove,,,,,,, -Parthenope granulata,Platylambrus granulatus,Bladetooth elbow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Platylambrus,Species,422028,NA,Species,,,,,,, -Parthenope punctata,Platylambrus granulatus,Bladetooth elbow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Platylambrus,Species,422028,NA,Species,,,,,,, -Platylambrus granulata,Platylambrus granulatus,Bladetooth elbow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Platylambrus,Species,422028,NA,Species,,,,,,, -Platylambrus granulatus,Platylambrus granulatus,Bladetooth elbow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Platylambrus,Species,422028,NA,Species,,,,,,, -Platylambrus serratus,Platylambrus serratus,Sawtooth elbow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Platylambrus,Species,422030,NA,Species,,,,,,, -Mursia gaudichaudii,Platymera gaudichaudii,Armed box crab,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Platymera,Species,440341,NA,Species,,,,,,, -Platymera gaudichaudii,Platymera gaudichaudii,Armed box crab,Animalia,Arthropoda,Malacostraca,Decapoda,Calappidae,Platymera,Species,440341,NA,Species,,,,,,, -Platytroctes apus,Platytroctes apus,Legless searsid,Animalia,Chordata,Teleostei,Alepocephaliformes,Platytroctidae,Platytroctes,Species,126746,11456,Species,,,,,,, -Platytroctidae,Platytroctidae,Tubeshoulders,Animalia,Chordata,Teleostei,Alepocephaliformes,Platytroctidae,NA,Family,125514,NA,Remove,,,,,,, -Plectobranchus evides,Plectobranchus evides,Bluebarred prickleback,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Plectobranchus,Species,282283,3793,Species,,,,,,, -Plectrypops retrospinis,Plectrypops retrospinis,Cardinal soldierfish,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Plectrypops,Species,277960,3253,Species,,,,,,, -Plectrypops retrospinus,Plectrypops retrospinis,Cardinal soldierfish,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Plectrypops,Species,277960,3253,Species,,,,,,, -Pleoticus robustus,Pleoticus robustus,Royal red shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Solenoceridae,Pleoticus,Species,158338,NA,Species,,,,,,, -Plesionika,Plesionika,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Plesionika,Genus,107046,NA,Remove,,,,,,, -Plesionika acanthonotus,Plesionika acanthonotus,Lesser striped shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Plesionika,Species,107654,NA,Species,,,,,,, -Plesionika edwardsii,Plesionika edwardsii,Soldier striped shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Plesionika,Species,107656,NA,Species,,,,,,, -Plesionika ensis,Plesionika ensis,Gladiator striped shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Plesionika,Species,107657,NA,Species,,,,,,, -Plesionika longicauda,Plesionika longicauda,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Plesionika,Species,240888,NA,Species,,,,,,, -Plesionika longipes,Plesionika longipes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pandalidae,Plesionika,Species,421803,NA,Species,,,,,,, -Pleurobrachiidae,Pleurobrachiidae,NA,Animalia,Ctenophora,Tentaculata,Cydippida,Pleurobrachiidae,NA,Family,106324,NA,Remove,,,,,,, -Pleurobranchaea,Pleurobranchaea,NA,Animalia,Mollusca,Gastropoda,Pleurobranchida,Pleurobranchaeidae,Pleurobranchaea,Genus,138363,NA,Remove,,,,,,, -Pleurobranchaea californica,Pleurobranchaea californica,NA,Animalia,Mollusca,Gastropoda,Pleurobranchida,Pleurobranchaeidae,Pleurobranchaea,Species,367819,NA,Species,,,,,,, -Pleurobranchus hedgpethi,Pleurobranchaea inconspicua,NA,Animalia,Mollusca,Gastropoda,Pleurobranchida,Pleurobranchidae,Pleurobranchus,Species,138364,NA,Species,,,,,,, -Pleurobranchaea inconspicua,Pleurobranchaea inconspicua,NA,Animalia,Mollusca,Gastropoda,Pleurobranchida,Pleurobranchidae,Pleurobranchus,Species,138364,NA,Species,,,,,,, -Pleurobranchaea hedgpethi,Pleurobranchaea inconspicua,NA,Animalia,Mollusca,Gastropoda,Pleurobranchida,Pleurobranchidae,Pleurobranchus,Species,138364,NA,Species,,,,,,, -Pleurobranchidae,Pleurobranchidae,NA,Animalia,Mollusca,Gastropoda,Pleurobranchida,Pleurobranchidae,NA,Family,1755,NA,Remove,,,,,,, -Pleurobranchus,Pleurobranchus,NA,Animalia,Mollusca,Gastropoda,Pleurobranchida,Pleurobranchidae,Pleurobranchus,Genus,138364,NA,Remove,,,,,,, -Pleurobranchus aerolatus,Pleurobranchus areolatus,Atlantic sidegill slug,Animalia,Mollusca,Gastropoda,Pleurobranchida,Pleurobranchidae,Pleurobranchus,Species,181218,NA,Species,,,,,,, -Pleurobranchus areolatus,Pleurobranchus areolatus,Atlantic sidegill slug,Animalia,Mollusca,Gastropoda,Pleurobranchida,Pleurobranchidae,Pleurobranchus,Species,181218,NA,Species,,,,,,, -Pleurogrammus monopterygius,Pleurogrammus monopterygius,Atka mackerel,Animalia,Chordata,Teleostei,Perciformes,Hexagrammidae,Pleurogrammus,Species,282289,4037,Species,,,,,,, -Pleuronectes quadrituberculatus,Pleuronectes quadrituberculatus,Alaska plaice,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Pleuronectes,Species,254564,4250,Species,,,,,,, -Pleuronectidae,Pleuronectidae,Righteye flounder unid.,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,NA,Family,125579,NA,Remove,,,,,,, -Pleuronectiformes larvae,Pleuronectiform larvae,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,NA,NA,Order,10331,NA,Remove,,,,,,, -Pleuronectiform,Pleuronectiformes,Flatfish,Animalia,Chordata,Teleostei,Pleuronectiformes,NA,NA,Order,10331,NA,Remove,,,,,,, -Pleuronectiformes,Pleuronectiformes,Flatfish,Animalia,Chordata,Teleostei,Pleuronectiformes,NA,NA,Order,10331,NA,Remove,,,,,,, -Pleuronichthys coenosus,Pleuronichthys coenosus,C o sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Pleuronichthys,Species,282290,4251,Species,,,,,,, -Pleuronichthys decurrens,Pleuronichthys decurrens,Curlfin sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Pleuronichthys,Species,282292,4252,Species,,,,,,, -Pleuronichthys ritteri,Pleuronichthys ritteri,Spotted turbot,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Pleuronichthys,Species,282294,4253,Species,,,,,,, -Pleuronichthys verticalis,Pleuronichthys verticalis,Hornyhead turbot,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Pleuronichthys,Species,282295,4254,Species,,,,,,, -Plexaura,Plexaura,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Plexauridae,Plexaura,Genus,267752,NA,Remove,,,,,,, -Plexauridae,Plexauridae,Plexaurid corals,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Plexauridae,NA,Family,125277,NA,Remove,,,,,,, -Plicatula gibbosa,Plicatula gibbosa,NA,Animalia,Mollusca,Bivalvia,Pectinida,Plicatulidae,Plicatula,Species,207848,NA,Species,,,,,,, -Plicifusus,Plicifusus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Plicifusus,Genus,254387,NA,Remove,,,,,,, -Plicifusus sp.,Plicifusus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Plicifusus,Genus,254387,NA,Remove,,,,,,, -Plicifusus kroyeri,Plicifusus kroyeri,Arctic whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Plicifusus,Species,491269,NA,Species,,,,,,, -Colus oceandromae,Plicifusus oceanodromae,Seahorse whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,491275,NA,Species,,,,,,, -Plicifusus oceanodromae,Plicifusus oceanodromae,Seahorse whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,491275,NA,Species,,,,,,, -Plicifusus incisus,Plicifusus olivaceus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Plicifusus,Species,596547,NA,Species,,,,,,, -Plicifusus olivaceus,Plicifusus olivaceus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Plicifusus,Species,596547,NA,Species,,,,,,, -Colus callorhinus,Plicifusus rodgersi,Strombiform whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,862576,NA,Species,,,,,,, -Plicifusus rodgersi,Plicifusus rodgersi,Strombiform whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,862576,NA,Species,,,,,,, -Plicifusus sp. A (Clark and McLean),Plicifusus sp. A (Clark and McLean),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Plinthaster dentatus,Plinthaster dentatus,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Goniasteridae,Plinthaster,Species,124080,NA,Species,,,,,,, -Plumarella,Plumarella,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Plumarella,Genus,177839,NA,Remove,,,,,,, -Plumarella sp.,Plumarella,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Plumarella,Genus,177839,NA,Remove,,,,,,, -Plumarella aleutiana,Plumarella aleutiana,Aleutian Plumarella,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Plumarella,Species,574236,NA,Species,,,,,,, -Plumarella echinata,Plumarella echinata,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Plumarella,Species,574239,NA,Species,,,,,,, -Plumarella hapala,Plumarella hapala,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Plumarella,Species,574235,NA,Species,,,,,,, -Plumarella nuttingi,Plumarella nuttingi,Loose-branched Plumarella,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Plumarella,Species,574238,NA,Species,,,,,,, -Plumarella robusta,Plumarella robusta,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Plumarella,Species,574240,NA,Species,,,,,,, -Plumarella sp. 1 (Bayer),Plumarella sp. 1 (Bayer),feathery Plumarella,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Plumarella sp. A,Plumarella sp. A,pale Plumarella,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Plumarella sp. B,Plumarella sp. B,pinnate Plumarella,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Plumarella sp. D,Plumarella sp. D,spiny Plumarella,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Plumarella superba,Plumarella superba,Bushy coral,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Plumarella,Species,574237,NA,Species,,,,,,, -Plumulariidae,Plumulariidae,Plumulariid hydroids,Animalia,Cnidaria,Hydrozoa,Leptothecata,Plumulariidae,NA,Family,1613,NA,Remove,,,,,,, -Podochela,Podochela,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Inachidae,Podochela,Genus,415843,NA,Remove,,,,,,, -Pododesmus,Pododesmus,NA,Animalia,Mollusca,Bivalvia,Pectinida,Anomiidae,Pododesmus,Genus,137653,NA,Remove,,,,,,, -Pododesmus sp.,Pododesmus,NA,Animalia,Mollusca,Bivalvia,Pectinida,Anomiidae,Pododesmus,Genus,137653,NA,Remove,,,,,,, -Pododesmus cepio,Pododesmus macrochisma,Green falsejingle,Animalia,Mollusca,Bivalvia,Pectinida,Anomiidae,Pododesmus,Species,758426,NA,Species,,,,,,, -Pododesmus macrochisma,Pododesmus macrochisma,Green falsejingle,Animalia,Mollusca,Bivalvia,Pectinida,Anomiidae,Pododesmus,Species,758426,NA,Species,,,,,,, -Pododesmus rudis,Pododesmus rudis,NA,Animalia,Mollusca,Bivalvia,Pectinida,Anomiidae,Pododesmus,Species,420776,NA,Species,,,,,,, -Podothecus,Podothecus,NA,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Podothecus,Genus,254386,NA,Remove,,,,,,, -Podothecus sp.,Podothecus,NA,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Podothecus,Genus,254386,NA,Remove,,,,,,, -Podothecus accipenserinus,Podothecus accipenserinus,Sturgeon poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Podothecus,Species,254501,4153,Species,,,,,,, -Podothecus veternus,Podothecus veternus,Veteran poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Podothecus,Species,254509,50370,Species,,,,,,, -Poecilopsetta beani,Poecilopsetta beanii,Deepwater dab,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Poecilopsetta,Species,275847,58866,Species,,,,,,, -Pogonias cromis,Pogonias cromis,Black drum,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Pogonias,Species,159333,425,Species,,,,,,, -Macrocoeloma septemspinosum,Pohleus septemspinosus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Macrocoeloma,Species,1436712,NA,Species,,,,,,, -Pohleus septemspinosus,Pohleus septemspinosus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Pohleus,Species,1436712,NA,Species,,,,,,, -Polinices,Polinices,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Polinices,Genus,147109,NA,Remove,,,,,,, -Pollachius virens,Pollachius virens,Pollock,Animalia,Chordata,Teleostei,Gadiformes,Gadidae,Pollachius,Species,126441,1343,Species,,,,,,, -Polycarpa,Polycarpa,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Styelidae,Polycarpa,Genus,103538,NA,Remove,,,,,,, -Polycarpa aurita,Polycarpa aurita,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Styelidae,Polycarpa,Species,251002,NA,Species,,,,,,, -Polycarpa spongiabilis,Polycarpa spongiabilis,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Styelidae,Polycarpa,Species,251069,NA,Species,,,,,,, -Polyceridae,Polyceridae,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Polyceridae,NA,Family,177,NA,Remove,,,,,,, -Polychaeta,Polychaeta,Bristle worms,Animalia,Annelida,Polychaeta,NA,NA,NA,Class,883,NA,Remove,,,,,,, -Polychaeta tubes,Polychaeta tubes,NA,NA,NA,NA,NA,NA,NA,Remove,NA,NA,Remove,,,,,,, -Polycheles,Polycheles,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Polychelidae,Polycheles,Genus,107056,NA,Remove,,,,,,, -Polycheles sp.,Polycheles,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Polychelidae,Polycheles,Genus,107056,NA,Remove,,,,,,, -Polycladida,Polycladida,Polyclad flatworm unid.,Animalia,Platyhelminthes,NA,Polycladida,NA,NA,Order,2853,NA,Remove,,,,,,, -Polyclinum planum,Polyclinum planum,Elephant ear tunicate,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polyclinidae,Polyclinum,Species,251110,NA,Species,,,,,,, -Polydactylus octonemus,Polydactylus octonemus,Atlantic threadfin,Animalia,Chordata,Teleostei,Carangaria incertae sedis,Polynemidae,Polydactylus,Species,159852,1110,Species,,,,,,, -Polydactylus virginicus,Polydactylus virginicus,Barbu,Animalia,Chordata,Teleostei,Carangaria incertae sedis,Polynemidae,Polydactylus,Species,159854,1112,Species,,,,,,, -Latirus infundibulum,Polygona infundibulum,Brown line latirus,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Latirus,Species,420047,NA,Species,,,,,,, -Polygona infundibulum,Polygona infundibulum,Brown line latirus,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Latirus,Species,420047,NA,Species,,,,,,, -Polyipnus clarus,Polyipnus clarus,Slope hatchetfish,Animalia,Chordata,Teleostei,Stomiiformes,Sternoptychidae,Polyipnus,Species,158840,47696,Species,,,,,,, -Polymastia,Polymastia,NA,Animalia,Porifera,Demospongiae,Polymastiida,Polymastiidae,Polymastia,Genus,132046,NA,Remove,,,,,,, -Polymastia sp.,Polymastia,NA,Animalia,Porifera,Demospongiae,Polymastiida,Polymastiidae,Polymastia,Genus,132046,NA,Remove,,,,,,, -Polymastia robusta,Polymastia boletiformis,Nipple sponge,Animalia,Porifera,Demospongiae,Polymastiida,Polymastiidae,Polymastia,Species,134194,NA,Species,,,,,,, -Polymastia boletiformis,Polymastia boletiformis,Nipple sponge,Animalia,Porifera,Demospongiae,Polymastiida,Polymastiidae,Polymastia,Species,134194,NA,Species,,,,,,, -Polymastia fluegeli,Polymastia fluegeli,Flugel nippled sponge,Animalia,Porifera,Demospongiae,Polymastiida,Polymastiidae,Polymastia,Species,195929,NA,Species,,,,,,, -Polymastia pachymastia,Polymastia pachymastia,Black orange spud sponge,Animalia,Porifera,Demospongiae,Polymastiida,Polymastiidae,Polymastia,Species,170652,NA,Species,,,,,,, -Polymastia pacifica,Polymastia pacifica,Aggregated nipple sponge,Animalia,Porifera,Demospongiae,Polymastiida,Polymastiidae,Polymastia,Species,170653,NA,Species,,,,,,, -Polymastia sp. A (Clark 2006),Polymastia sp. A (Clark 2006),prolific nipple sponge,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Polymastia sp. B (Clark 2006),Polymastia sp. B (Clark 2006),orange nipple ball sponge,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Polymastia sp. C (Clark 2006),Polymastia sp. C (Clark 2006),red nipple sponge,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Polymetme thaeocoryla,Polymetme thaeocoryla,NA,Animalia,Chordata,Teleostei,Stomiiformes,Phosichthyidae,Polymetme,Species,127301,57353,Species,,,,,,, -Polymixia lowei,Polymixia lowei,Beardfish,Animalia,Chordata,Teleostei,Polymixiiformes,Polymixiidae,Polymixia,Species,158923,3245,Species,,,,,,, -Polymixia nobilis,Polymixia nobilis,Stout beardfish,Animalia,Chordata,Teleostei,Polymixiiformes,Polymixiidae,Polymixia,Species,127163,7557,Species,,,,,,, -Polymyces cf montereyensis,Polymyces montereyensis,NA,Animalia,Cnidaria,Anthozoa,Scleractinia,Flabellidae,Polymyces,Species,290838,NA,Species,,,,,,, -Polynoidae,Polynoidae,Scaleworms,Animalia,Annelida,Polychaeta,Phyllodocida,Polynoidae,NA,Family,939,NA,Remove,,,,,,, -Polyonyx gibbesi,Polyonyx gibbesi,Eastern tube crab,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,Polyonyx,Species,158406,NA,Species,,,,,,, -Polyplacophora,Polyplacophora,Chitons,Animalia,Mollusca,Polyplacophora,NA,NA,NA,Class,55,NA,Remove,,,,,,, -Polystira,Polystira,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Turridae,Polystira,Genus,391298,NA,Remove,,,,,,, -Polystira albida,Polystira albida,White giant-turris,Animalia,Mollusca,Gastropoda,Neogastropoda,Turridae,Polystira,Species,420396,NA,Species,,,,,,, -Polystira tellea,Polystira tellea,Delicate giant-turris,Animalia,Mollusca,Gastropoda,Neogastropoda,Turridae,Polystira,Species,420398,NA,Species,,,,,,, -Pomacanthidae,Pomacanthidae,NA,Animalia,Chordata,Teleostei,Acanthuriformes,Pomacanthidae,NA,Family,151470,NA,Remove,,,,,,, -Pomacanthus arcuatus,Pomacanthus arcuatus,Gray angelfish,Animalia,Chordata,Teleostei,Acanthuriformes,Pomacanthidae,Pomacanthus,Species,159287,1117,Species,,,,,,, -Pomacanthus paru,Pomacanthus paru,French angelfish,Animalia,Chordata,Teleostei,Acanthuriformes,Pomacanthidae,Pomacanthus,Species,276025,1118,Species,,,,,,, -Pomacentridae,Pomacentridae,NA,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,NA,Family,125553,NA,Remove,,,,,,, -Pomatomus saltatrix,Pomatomus saltatrix,Bluefish,Animalia,Chordata,Teleostei,Scombriformes,Pomatomidae,Pomatomus,Species,151482,364,Species,,,,,,, -Pontinus longispinis,Pontinus longispinis,Longspine scorpionfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Pontinus,Species,159555,3931,Species,,,,,,, -Pontinus rathbuni,Pontinus rathbuni,Highfin scorpionfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Pontinus,Species,159556,3933,Species,,,,,,, -Pontophilus norvegicus,Pontophilus norvegicus,Norwegian shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Pontophilus,Species,107563,NA,Species,,,,,,, -Poraniopsis flexilis,Poraniopsis inflata,Spiny sea star,Animalia,Echinodermata,Asteroidea,Valvatida,Poraniidae,Poraniopsis,Species,381961,NA,Species,,,,,,, -Poraniopsis inflata,Poraniopsis inflata,Spiny sea star,Animalia,Echinodermata,Asteroidea,Valvatida,Poraniidae,Poraniopsis,Species,381961,NA,Species,,,,,,, -Porcellana,Porcellana,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,Porcellana,Genus,106838,NA,Remove,,,,,,, -Porcellana sayana,Porcellana sayana,Spotted porcelain crab,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,Porcellana,Species,421879,NA,Species,,,,,,, -Porcellana sigsbeiana,Porcellana sigsbeiana,Striped porcelain crab,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,Porcellana,Species,158042,NA,Species,,,,,,, -Porcellanidae,Porcellanidae,Porcelain crabs,Animalia,Arthropoda,Malacostraca,Decapoda,Porcellanidae,NA,Family,106734,NA,Remove,,,,,,, -Porella,Porella,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Bryocryptellidae,Porella,Genus,110835,NA,Remove,,,,,,, -Porella sp.,Porella,NA,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Bryocryptellidae,Porella,Genus,110835,NA,Remove,,,,,,, -Porella compressa,Porella compressa,Flattened bryozoan,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Bryocryptellidae,Porella,Species,111124,NA,Species,,,,,,, -Porichthys,Porichthys,NA,Animalia,Chordata,Teleostei,Batrachoidiformes,Batrachoididae,Porichthys,Genus,158783,NA,Remove,,,,,,, -Porichthys sp.,Porichthys,NA,Animalia,Chordata,Teleostei,Batrachoidiformes,Batrachoididae,Porichthys,Genus,158783,NA,Remove,,,,,,, -Porichthys myriaster,Porichthys myriaster,Specklefin midshipman,Animalia,Chordata,Teleostei,Batrachoidiformes,Batrachoididae,Porichthys,Species,275657,3070,Species,,,,,,, -Porichthys notatus,Porichthys notatus,Plainfin midshipman,Animalia,Chordata,Teleostei,Batrachoidiformes,Batrachoididae,Porichthys,Species,275658,3071,Species,,,,,,, -Porichthys plectrodon,Porichthys plectrodon,Atlantic midshipman,Animalia,Chordata,Teleostei,Batrachoidiformes,Batrachoididae,Porichthys,Species,158784,3072,Species,,,,,,, -Porifera,Porifera,Sponges,Animalia,Porifera,NA,NA,NA,NA,Phylum,558,NA,Remove,,,,,,, -Porifera (segregated 1),Porifera (segregated 1),NA,Animalia,Porifera,NA,NA,NA,NA,Phylum,558,NA,Remove,,,,,,, -Porifera (segregated 2),Porifera (segregated 2),NA,Animalia,Porifera,NA,NA,NA,NA,Phylum,558,NA,Remove,,,,,,, -Poriferball,Poriferball,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Poriferbarrel,Poriferbarrel,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Poriferencoth,Poriferencoth,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Poriferfinbra,Poriferfinbra,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Porifervastub,Porifervastub,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Poroclinus rothrocki,Poroclinus rothrocki,Whitebarred prickleback,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Poroclinus,Species,254385,3794,Species,,,,,,, -Porogadus,Porogadus,NA,Animalia,Chordata,Teleostei,Ophidiiformes,Ophidiidae,Porogadus,Genus,158774,NA,Remove,,,,,,, -Poromitra crassiceps,Poromitra crassiceps,crested bigscale,NA,NA,NA,NA,NA,NA,Species,127273,NA,Species,,,,,,, -Poromitra cristiceps,Poromitra cristiceps,NA,Animalia,Chordata,Teleostei,Beryciformes,Melamphaidae,Poromitra,Species,306617,65382,Species,,,,,,, -Poromitra curilensis,Poromitra curilensis,Alaskan crested bigscale,Animalia,Chordata,Teleostei,Beryciformes,Melamphaidae,Poromitra,Species,474945,65377,Species,,,,,,, -Portlandia,Portlandia,NA,Animalia,Mollusca,Bivalvia,Nuculanida,Yoldiidae,Portlandia,Genus,138671,NA,Remove,,,,,,, -Portlandia sp.,Portlandia,NA,Animalia,Mollusca,Bivalvia,Nuculanida,Yoldiidae,Portlandia,Genus,138671,NA,Remove,,,,,,, -Portunidae,Portunidae,Swimming crabs,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,NA,Family,106763,NA,Remove,,,,,,, -Portunus,Portunus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Portunus,Genus,106930,NA,Remove,,,,,,, -Portunus ordwayii,Portunus ordwayii,Redhair swimming crab,NA,NA,NA,NA,NA,NA,NotWrms,NA,NA,Species,,,,,,, -Portunus sayi,Portunus sayi,Sargassum swimming crab,Animalia,Arthropoda,Malacostraca,Decapoda,Portunidae,Portunus,Species,1061759,NA,Species,,,,,,, -Posterula sarsii,Posterula sarsii,NA,NA,NA,NA,NA,NA,NA,Species,470620,NA,Species,,,,,,, -Priacanthus arenatus,Priacanthus arenatus,Atlantic bigeye,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Priacanthidae,Priacanthus,Species,127005,1149,Species,,,,,,, -Priapulida,Priapulida,Priapulid worms,Animalia,Priapulida,NA,NA,NA,NA,Phylum,101063,NA,Remove,,,,,,, -Primavelans insculpta,Primavelans insculpta,NA,NA,NA,NA,NA,NA,NA,Species,472023,NA,Species,,,,,,, -Primnoa,Primnoa,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Primnoa,Genus,125321,NA,Remove,,,,,,, -Primnoa sp.,Primnoa,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Primnoa,Genus,125321,NA,Remove,,,,,,, -Primnoa pacifica,Primnoa pacifica,Red tree gorgonian coral,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Primnoa,Species,286539,NA,Species,,,,,,, -Primnoa willeyi,Primnoa pacifica var. willeyi,Red tree coral,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Primnoa,Species,409549,NA,Species,,,,,,, -Primnoa pacifica var. willeyi,Primnoa pacifica var. willeyi,Red tree coral,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Primnoa,Species,409549,NA,Species,,,,,,, -Primnoa resedaeformis,Primnoa resedaeformis,Red trees,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Primnoa,Species,125411,NA,Species,,,,,,, -Primnoa wingi,Primnoa wingi,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Primnoa,Species,286540,NA,Species,,,,,,, -Prionace glauca,Prionace glauca,Blue shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,Prionace,Species,105801,898,Species,,,,,,, -Prionotus,Prionotus,NA,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Genus,159569,NA,Remove,,,,,,, -Prionotus alatus,Prionotus alatus,Spiny searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,159570,4020,Species,,,,,,, -Prionotus carolinus,Prionotus carolinus,Northern searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,159571,1243,Species,,,,,,, -Prionotus evolans,Prionotus evolans,Striped searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,159572,1244,Species,,,,,,, -Prionotus longispinosus,Prionotus longispinosus,Bigeye searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,276282,4026,Species,,,,,,, -Prionotus martis,Prionotus martis,Gulf of mexico barred searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,276283,4021,Species,,,,,,, -Prionotus ophryas,Prionotus ophryas,Bandtail searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,159573,4022,Species,,,,,,, -Prionotus paralatus,Prionotus paralatus,Mexican searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,276287,4023,Species,,,,,,, -Prionotus punctatus,Prionotus punctatus,Bluewing searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,276288,1245,Species,,,,,,, -Prionotus roseus,Prionotus roseus,Bluespotted searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,159574,4024,Species,,,,,,, -Prionotus rubio,Prionotus rubio,Blackwing searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,276289,4025,Species,,,,,,, -Prionotus scitulus,Prionotus scitulus,Leopard searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,159575,4027,Species,,,,,,, -Prionotus stearnsi,Prionotus stearnsi,Shortwing searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,159576,4028,Species,,,,,,, -Prionotus stephanophrys,Prionotus stephanophrys,Lumptail searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,276291,4029,Species,,,,,,, -Prionotus tribulus,Prionotus tribulus,Bighead searobin,Animalia,Chordata,Teleostei,Perciformes,Triglidae,Prionotus,Species,159577,4030,Species,,,,,,, -Pristigenys alta,Pristigenys alta,Short bigeye,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Priacanthidae,Pristigenys,Species,159295,3518,Species,,,,,,, -Pristipomoides,Pristipomoides,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Lutjanidae,Pristipomoides,Species,159804,NA,Species,,,,,,, -Pristipomoides aquilonaris,Pristipomoides aquilonaris,Wenchman,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Lutjanidae,Pristipomoides,Species,159805,198,Species,,,,,,, -Procambarus clarkii,Procambarus clarkii,Red swamp crayfish,NA,NA,NA,NA,NA,NA,notMarine,NA,NA,Remove,,,,,,, -Processa,Processa,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Processidae,Processa,Genus,107054,NA,Remove,,,,,,, -Processa tenuipes,Processa guyanae,Thinfoot night shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Processidae,Processa,Species,421791,NA,Species,,,,,,, -Processa guyanae,Processa guyanae,Thinfoot night shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Processidae,Processa,Species,421791,NA,Species,,,,,,, -Processa profunda,Processa profunda,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Processidae,Processa,Species,421793,NA,Species,,,,,,, -Processidae,Processidae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Processidae,NA,Family,106791,NA,Remove,,,,,,, -Chaetodon aculeatus,Prognathodes aculeatus,Longsnout butterflyfish,Animalia,Chordata,Teleostei,Acanthuriformes,Chaetodontidae,Chaetodon,Species,273369,3600,Species,,,,,,, -Chaetodon aya,Prognathodes aya,Bank butterflyfish,Animalia,Chordata,Teleostei,Acanthuriformes,Chaetodontidae,Chaetodon,Species,273370,3601,Species,,,,,,, -Prognathodes aya,Prognathodes aya,Bank butterflyfish,Animalia,Chordata,Teleostei,Acanthuriformes,Chaetodontidae,Chaetodon,Species,273370,3601,Species,,,,,,, -Prognatholiparis ptychomandibularis,Prognatholiparis ptychomandibularis,Wrinkle jaw snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Prognatholiparis,Species,282359,58835,Species,,,,,,, -Prognichthys,Prognichthys,NA,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Prognichthys,Genus,205070,NA,Remove,,,,,,, -Prognichthys gibbifrons,Prognichthys gibbifrons,Bluntnose flyingfish,Animalia,Chordata,Teleostei,Beloniformes,Exocoetidae,Prognichthys,Species,277924,1038,Species,,,,,,, -Promethichthys prometheus,Promethichthys prometheus,Roudi escolar,Animalia,Chordata,Teleostei,Scombriformes,Gempylidae,Promethichthys,Species,126866,5008,Species,,,,,,, -Holanthias martinicensis,Pronotogrammus martinicensis,Roughtongue bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Pronotogrammus,Species,282365,3328,Species,,,,,,, -Pronotogrammus martinicensis,Pronotogrammus martinicensis,Roughtongue bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Pronotogrammus,Species,282365,3328,Species,,,,,,, -Pronucula tenuis,Pronucula tenuis,smooth nutclam,NA,NA,NA,NA,NA,NA,Species,607414,NA,Species,,,,,,, -Propebela nobilis,Propebela nobilis,Noble lora,Animalia,Mollusca,Gastropoda,Neogastropoda,Mangeliidae,Propebela,Species,160450,NA,Species,,,,,,, -Propeleda conceptionis,Propeleda conceptionis,NA,Animalia,Mollusca,Bivalvia,Nuculanida,Nuculanidae,Propeleda,Species,506444,NA,Species,,,,,,, -Protankyra grayi,Protankyra grayi,NA,Animalia,Echinodermata,Holothuroidea,Apodida,Synaptidae,Protankyra,Species,529096,NA,Species,,,,,,, -Protomyctophum,Protomyctophum,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Protomyctophum,Genus,125832,NA,Remove,,,,,,, -Protomyctophum sp.,Protomyctophum,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Protomyctophum,Genus,125832,NA,Remove,,,,,,, -Protomyctophum thompsoni,Protomyctophum thompsoni,Bigeye lanternfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Protomyctophum,Species,272732,22986,Species,,,,,,, -Protoptilum,Protoptilum,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Protoptilidae,Protoptilum,Genus,128498,NA,Remove,,,,,,, -Protoptilum sp.,Protoptilum,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Protoptilidae,Protoptilum,Genus,128498,NA,Remove,,,,,,, -Macoma brevifrons,Psammotreta brevifrons,Short macoma,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Species,606748,NA,Species,,,,,,, -Psammotreta brevifrons,Psammotreta brevifrons,Short macoma,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Macoma,Species,606748,NA,Species,,,,,,, -Psathyrometra fragilis,Psathyrometra fragilis,NA,Animalia,Echinodermata,Crinoidea,Comatulida,Zenometridae,Psathyrometra,Species,430552,NA,Species,,,,,,, -Psenes maculatus,Psenes maculatus,NA,Animalia,Chordata,Teleostei,Scombriformes,Nomeidae,Psenes,Genus,126992,NA,Remove,,,,,,, -Psenes pellucidus,Psenes pellucidus,Bluefin driftfish,Animalia,Chordata,Teleostei,Scombriformes,Nomeidae,Psenes,Species,126993,3927,Species,,,,,,, -Psettichthys melanostictus,Psettichthys melanostictus,Pacific sand sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Psettichthys,Species,282396,4255,Species,,,,,,, -Pseudarchaster,Pseudarchaster,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Pseudarchasteridae,Pseudarchaster,Genus,123304,NA,Remove,,,,,,, -Pseudarchaster sp.,Pseudarchaster,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Pseudarchasteridae,Pseudarchaster,Genus,123304,NA,Remove,,,,,,, -Pseudarchaster alascensis,Pseudarchaster alascensis,Aleutian scarlet star,Animalia,Echinodermata,Asteroidea,Paxillosida,Pseudarchasteridae,Pseudarchaster,Species,370831,NA,Species,,,,,,, -Pseudarchaster dissonus,Pseudarchaster dissonus,Giant brown pseudarchaster,Animalia,Echinodermata,Asteroidea,Paxillosida,Pseudarchasteridae,Pseudarchaster,Species,370836,NA,Species,,,,,,, -Pseudarchaster parelii,Pseudarchaster parelii,Northern scarlet star,Animalia,Echinodermata,Asteroidea,Paxillosida,Pseudarchasteridae,Pseudarchaster,Species,124085,NA,Species,,,,,,, -Pseudarchaster pusillus,Pseudarchaster pusillus,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Pseudarchasteridae,Pseudarchaster,Species,370848,NA,Species,,,,,,, -Pseudarchaster pussillus,Pseudarchaster pusillus,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Pseudarchasteridae,Pseudarchaster,Species,370848,NA,Species,,,,,,, -Bathylagus milleri,Pseudobathylagus milleri,Stout blacksmelt,Animalia,Chordata,Teleostei,Argentiniformes,Bathylagidae,Bathylagus,Species,282406,12541,Species,,,,,,, -Pseudobathylagus milleri,Pseudobathylagus milleri,Stout blacksmelt,Animalia,Chordata,Teleostei,Argentiniformes,Bathylagidae,Bathylagus,Species,282406,12541,Species,,,,,,, -Rhinobatos lentiginosus,Pseudobatos lentiginosus,Atlantic guitarfish,Animalia,Chordata,Elasmobranchii,Rhinopristiformes,Rhinobatidae,Rhinobatos,Species,1043479,2548,Species,,,,,,, -Pseudobatos lentiginosus,Pseudobatos lentiginosus,Atlantic guitarfish,Animalia,Chordata,Elasmobranchii,Rhinopristiformes,Rhinobatidae,Rhinobatos,Species,1043479,2548,Species,,,,,,, -Rhinobatos productus,Pseudobatos productus,Shovelnose guitarfish,Animalia,Chordata,Elasmobranchii,Rhinopristiformes,Rhinobatidae,Rhinobatos,Species,1043469,2549,Species,,,,,,, -Pseudoboletia maculata,Pseudoboletia maculata,NA,Animalia,Echinodermata,Echinoidea,Camarodonta,Toxopneustidae,Pseudoboletia,Species,214456,NA,Species,,,,,,, -Pseudochama,Pseudochama,NA,Animalia,Mollusca,Bivalvia,Venerida,Chamidae,Pseudochama,Genus,137776,NA,Remove,,,,,,, -Pseudochama radians,Pseudochama cristella,Atlantic jewelbox,Animalia,Mollusca,Bivalvia,Venerida,Chamidae,Pseudochama,Species,504796,NA,Species,,,,,,, -Pseudoliomesus ooides,Pseudoliomesus ooides,Nut whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Pseudoliomesus,Species,491320,NA,Species,,,,,,, -Pseudomedaeus agassizii,Pseudomedaeus agassizi,Rough rubble crab,Animalia,Arthropoda,Malacostraca,Decapoda,Xanthidae,Pseudomedaeus,Species,444171,NA,Species,,,,,,, -Pseudomedaeus agassizi,Pseudomedaeus agassizi,Rough rubble crab,Animalia,Arthropoda,Malacostraca,Decapoda,Xanthidae,Pseudomedaeus,Species,444171,NA,Species,,,,,,, -Lophopanopeus distinctus,Pseudomedaeus distinctus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Lophopanopeus,Species,422145,NA,Species,,,,,,, -Pseudomedaeus distinctus,Pseudomedaeus distinctus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Lophopanopeus,Species,422145,NA,Species,,,,,,, -Pseudomyrophis fugesae,Pseudomyrophis fugesae,Diminutive worm eel,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Pseudomyrophis,Species,282454,53860,Species,,,,,,, -Pseudomyrophis nimius,Pseudomyrophis nimius,NA,Animalia,Chordata,Teleostei,Anguilliformes,Ophichthidae,Pseudomyrophis,Species,282456,53859,Species,,,,,,, -Pseudopleuronectes americanus,Pseudopleuronectes americanus,Winter flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Pseudopleuronectes,Species,158885,524,Species,,,,,,, -Pseudoplexaura,Pseudoplexaura,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Plexauridae,Pseudoplexaura,Genus,267779,NA,Remove,,,,,,, -Pseudorhombila,Pseudorhombila,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Pseudorhombila,Genus,415897,NA,Remove,,,,,,, -Pseudorhombila quadridentata,Pseudorhombila quadridentata,Flecked squareback crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Pseudorhombila,Species,422116,NA,Species,,,,,,, -Pseudosquilla ciliata,Pseudosquilla ciliata,Ciliated mantis shrimp,Animalia,Arthropoda,Malacostraca,Stomatopoda,Pseudosquillidae,Pseudosquilla,Species,210232,NA,Species,,,,,,, -Pseudostichopus,Pseudostichopus,NA,Animalia,Echinodermata,Holothuroidea,Persiculida,Pseudostichopodidae,Pseudostichopus,Genus,123469,NA,Remove,,,,,,, -Pseudostichopus sp.,Pseudostichopus,NA,Animalia,Echinodermata,Holothuroidea,Persiculida,Pseudostichopodidae,Pseudostichopus,Genus,123469,NA,Remove,,,,,,, -Pseudostichopus mollis,Pseudostichopus mollis,Sandy sea cucumber,Animalia,Echinodermata,Holothuroidea,Persiculida,Pseudostichopodidae,Pseudostichopus,Species,152565,NA,Species,,,,,,, -Pseudosuberites montiniger,Pseudosuberites montiniger,Peachball sponge,Animalia,Porifera,Demospongiae,Suberitida,Suberitidae,Pseudosuberites,Species,134257,NA,Species,,,,,,, -Pseudupeneus maculatus,Pseudupeneus maculatus,Spotted goatfish,Animalia,Chordata,Teleostei,Mulliformes,Mullidae,Pseudupeneus,Species,159421,1094,Species,,,,,,, -Psolidae,Psolidae,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Psolidae,NA,Family,123189,NA,Remove,,,,,,, -Psolidium bullatum,Psolidium bullatum,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Psolidae,Psolidium,Species,529042,NA,Species,,,,,,, -Psolus,Psolus,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Psolidae,Psolus,Genus,146121,NA,Remove,,,,,,, -Psolus sp.,Psolus,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Psolidae,Psolus,Genus,146121,NA,Remove,,,,,,, -Psolus chitonoides,Psolus chitonoides,Slipper sea cucumber,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Psolidae,Psolus,Species,247772,NA,Species,,,,,,, -Psolus fabricii,Psolus fabricii,Scarlet psolus,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Psolidae,Psolus,Species,124703,NA,Species,,,,,,, -Psolus japonicus,Psolus japonicus,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Psolidae,Psolus,Species,254500,NA,Species,,,,,,, -Psolus phantapus,Psolus phantapus,Arctic armored cucumber,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Psolidae,Psolus,Species,124710,NA,Species,,,,,,, -Psolus sp. A (Clark 2006),Psolus sp. A (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Psolus squamatus,Psolus squamatus,White creeping pedal sea cucumber,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Psolidae,Psolus,Species,124713,NA,Species,,,,,,, -Psychrolutes,Psychrolutes,NA,Animalia,Chordata,Teleostei,Perciformes,Psychrolutidae,Psychrolutes,Genus,126169,NA,Remove,,,,,,, -Psychrolutes sp.,Psychrolutes,NA,Animalia,Chordata,Teleostei,Perciformes,Psychrolutidae,Psychrolutes,Genus,126169,NA,Remove,,,,,,, -Psychrolutes paradoxus,Psychrolutes paradoxus,Tadpole sculpin,Animalia,Chordata,Teleostei,Perciformes,Psychrolutidae,Psychrolutes,Species,254566,4135,Species,,,,,,, -Psychrolutes phrictus,Psychrolutes phrictus,Blob sculpin,Animalia,Chordata,Teleostei,Perciformes,Psychrolutidae,Psychrolutes,Species,274678,11732,Species,,,,,,, -Pteraster,Pteraster,Slime stars,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Genus,123335,NA,Remove,,,,,,, -Pteraster sp.,Pteraster,Slime stars,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Genus,123335,NA,Remove,,,,,,, -Pteraster coscinopeplus,Pteraster coscinopeplus,NA,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Species,369034,NA,Species,,,,,,, -Pteraster jordani,Pteraster jordani,Jordan's cushion star,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Species,369039,NA,Species,,,,,,, -Pteraster marssipus,Pteraster marsippus,Prickly cushion star,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Species,369041,NA,Species,,,,,,, -Pteraster marsippus,Pteraster marsippus,Prickly cushion star,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Species,369041,NA,Species,,,,,,, -Pteraster militaris,Pteraster militaris,Wrinkled sea star,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Species,124147,NA,Species,,,,,,, -Pteraster obscurus,Pteraster obscurus,Obscure cushion star,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Species,124149,NA,Species,,,,,,, -Pteraster octaster,Pteraster octaster,NA,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Species,369049,NA,Species,,,,,,, -Pteraster pulvillus,Pteraster pulvillus,Orange cushion star,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Species,124151,NA,Species,,,,,,, -Pteraster sp. A (Clark 1999),Pteraster sp. A (Clark 1999),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Pteraster sp. B (Clark 1997),Pteraster sp. B (Clark 1997),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Pteraster sp. cf. temnochiton (Clark 1999),Pteraster sp. cf. temnochiton (Clark 1999),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Pteraster sp. D (Clark),Pteraster sp. D (Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Pteraster sp. F (Clark),Pteraster sp. F (Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Pteraster temnochiton,Pteraster temnochiton,Rough cushion star,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Species,369052,NA,Species,,,,,,, -Pteraster tesselatus,Pteraster tesselatus,Tesselated slime star,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Species,369053,NA,Species,,,,,,, -Pteraster tesselatus arcuatus,Pteraster tesselatus arcuatus,NA,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,SubSpecies,369055,NA,SubSpecies,,,,,,, -Pteraster trigonodon,Pteraster trigonodon,NA,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Species,369058,NA,Species,,,,,,, -Pteraster willsi,Pteraster willsi,NA,Animalia,Echinodermata,Asteroidea,Velatida,Pterasteridae,Pteraster,Species,582010,NA,Species,,,,,,, -Ioglossus,Ptereleotris,NA,Animalia,Chordata,Teleostei,Gobiiformes,Microdesmidae,Ioglossus,Genus,204246,NA,Remove,,,,,,, -Ptereleotris,Ptereleotris,NA,Animalia,Chordata,Teleostei,Gobiiformes,Microdesmidae,Ioglossus,Genus,204246,NA,Remove,,,,,,, -Ioglossus calliurus,Ptereleotris calliura,Blue goby,Animalia,Chordata,Teleostei,Gobiiformes,Microdesmidae,Ioglossus,Species,277120,3881,Species,,,,,,, -Ptereleotris calliura,Ptereleotris calliura,Blue goby,Animalia,Chordata,Teleostei,Gobiiformes,Microdesmidae,Ioglossus,Species,277120,3881,Species,,,,,,, -Pteria colymbus,Pteria colymbus,Atlantic wing-oyster,Animalia,Mollusca,Bivalvia,Ostreida,Pteriidae,Pteria,Species,420735,NA,Species,,,,,,, -Pteriidae,Pteriidae,NA,Animalia,Mollusca,Bivalvia,Ostreida,Pteriidae,NA,Family,1775,NA,Remove,,,,,,, -Pterois,Pterois,NA,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Pterois,Genus,204051,NA,Remove,,,,,,, -Pterois volitans,Pterois volitans,Red lionfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Pterois,Species,159559,5195,Species,,,,,,, -Dasyatis violacea,Pteroplatytrygon violacea,Pelagic stingray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Dasyatidae,Dasyatis,Species,158540,2576,Species,,,,,,, -Ptilosarcus,Ptilosarcus,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Pennatulidae,Ptilosarcus,Genus,267795,NA,Remove,,,,,,, -Ptilosarcus sp.,Ptilosarcus,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Pennatulidae,Ptilosarcus,Genus,267795,NA,Remove,,,,,,, -Ptilosarcus gurneyi,Ptilosarcus gurneyi,Gurney's sea pen,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Pennatulidae,Ptilosarcus,Species,290947,NA,Species,,,,,,, -Pugettia,Pugettia,kelp crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Pugettia,Genus,240779,NA,Remove,,,,,,, -Pugettia sp.,Pugettia,kelp crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Pugettia,Genus,240779,NA,Remove,,,,,,, -Pugettia gracilis,Pugettia gracilis,Graceful kelp crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Pugettia,Species,441478,NA,Species,,,,,,, -Pugettia producta,Pugettia producta,Northern kelp crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Pugettia,Species,240780,NA,Species,,,,,,, -Pugettia richii,Pugettia richii,Cryptic kelp crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Pugettia,Species,441490,NA,Species,,,,,,, -Puncturella sp.,Puncturella,puncturella,NA,NA,NA,NA,NA,NA,Genus,138015,NA,Remove,,,,,,, -Cranopsis major,Puncturella major,Great puncturella,Animalia,Mollusca,Gastropoda,Lepetellida,Fissurellidae,Cranopsis,Species,714752,NA,Species,,,,,,, -Puncturella major,Puncturella major,Great puncturella,Animalia,Mollusca,Gastropoda,Lepetellida,Fissurellidae,Cranopsis,Species,714752,NA,Species,,,,,,, -Puncturella rothi,Puncturella rothi,NA,Animalia,Mollusca,Gastropoda,Lepetellida,Fissurellidae,Puncturella,Species,694616,NA,Species,,,,,,, -Pungitius pungitius,Pungitius pungitius,Ninespine stickleback,Animalia,Chordata,Teleostei,Perciformes,Gasterosteidae,Pungitius,Species,126507,3273,Species,,,,,,, -Purple striated anemone,Purple striated anemone,Purple striated anemone,NA,NA,NA,NA,NA,NA,Remove,NA,NA,Remove,,,,,,, -Trivia pediculus,Pusula pediculus,Coffeebean trivia,Animalia,Mollusca,Gastropoda,Littorinimorpha,Triviidae,Trivia,Species,419749,NA,Species,,,,,,, -Pusula pediculus,Pusula pediculus,Coffeebean trivia,Animalia,Mollusca,Gastropoda,Littorinimorpha,Triviidae,Trivia,Species,419749,NA,Species,,,,,,, -Puzanovia rubra,Puzanovia rubra,Coral eelpout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Puzanovia,Species,254380,23822,Species,,,,,,, -Pycnogonida,Pycnogonida,Sea spiders,Animalia,Arthropoda,Pycnogonida,NA,NA,NA,Class,1302,NA,Remove,,,,,,, -Pycnogonidae,Pycnogonidae,NA,Animalia,Arthropoda,Pycnogonida,Pantopoda,Pycnogonidae,NA,Genus,1567,NA,Remove,,,,,,, -Pycnogonum,Pycnogonum,NA,Animalia,Arthropoda,Pycnogonida,Pantopoda,Pycnogonidae,Pycnogonum,Genus,134595,NA,Remove,,,,,,, -Pycnogonum sp.,Pycnogonum,NA,Animalia,Arthropoda,Pycnogonida,Pantopoda,Pycnogonidae,Pycnogonum,Genus,134595,NA,Remove,,,,,,, -Pycnopodia helianthoides,Pycnopodia helianthoides,Sunflower sea star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Pycnopodia,Species,240764,NA,Species,,,,,,, -Pyromaia,Pyromaia,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Pyromaia,Genus,395035,NA,Remove,,,,,,, -Pyromaia arachna,Pyromaia arachna,Needlenose pear crab,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Pyromaia,Species,421969,NA,Species,,,,,,, -Pyromaia cuspidata,Pyromaia cuspidata,Dartnose pear crab,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Pyromaia,Species,421970,NA,Species,,,,,,, -Pyrosoma,Pyrosoma,NA,Animalia,Chordata,Thaliacea,Pyrosomatida,Pyrosomatidae,Pyrosoma,Genus,137224,NA,Remove,,,,,,, -Pyrosoma atlanticum,Pyrosoma atlanticum,NA,Animalia,Chordata,Thaliacea,Pyrosomatida,Pyrosomatidae,Pyrosoma,Species,137250,NA,Species,,,,,,, -Pyrulofusus,Pyrulofusus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Pyrulofusus,Genus,254377,NA,Remove,,,,,,, -Pyrulofusus sp.,Pyrulofusus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Pyrulofusus,Genus,254377,NA,Remove,,,,,,, -Pyrulofusus deformis,Pyrulofusus deformis,Warped whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Pyrulofusus,Species,254378,NA,Species,,,,,,, -Pyrulofusus dexius,Pyrulofusus dexius,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Pyrulofusus,Species,491408,NA,Species,,,,,,, -Pyrulofusus harpa,Pyrulofusus harpa,Left-hand whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Pyrulofusus,Species,491324,NA,Species,,,,,,, -Pyrulofusus melonis,Pyrulofusus melonis,Giant melon whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Pyrulofusus,Species,491325,NA,Species,,,,,,, -Pyrulofusus sp. eggs,Pyrulofusus sp. eggs,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Pyura haustor,Pyura haustor,Warty tunicate,Animalia,Chordata,Ascidiacea,Stolidobranchia,Pyuridae,Pyura,Species,251266,NA,Species,,,,,,, -Rachycentron canadum,Rachycentron canadum,Cobia,Animalia,Chordata,Teleostei,Carangiformes,Rachycentridae,Rachycentron,Species,127006,3542,Species,,,,,,, -Radulinus asprellus,Radulinus asprellus,Slim sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Radulinus,Species,282541,4136,Species,,,,,,, -Raja,Raja,Skates,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Genus,105766,NA,Remove,,,,,,, -Raja sp,Raja,Skates,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Genus,105766,NA,Remove,,,,,,, -Raja sp.,Raja,Skates,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Genus,105766,NA,Remove,,,,,,, -Rajidae,Rajidae,Skates,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,NA,Family,105711,NA,Remove,,,,,,, -Rajiformes,Rajiformes,NA,Animalia,Chordata,Elasmobranchii,Rajiformes,NA,NA,Order,10216,NA,Remove,,,,,,, -Rangianella,Rangia,NA,Animalia,Mollusca,Bivalvia,Venerida,Mactridae,Rangianella,Genus,156990,NA,Remove,,,,,,, -Rangia,Rangia,NA,Animalia,Mollusca,Bivalvia,Venerida,Mactridae,Rangia,Genus,156990,NA,Remove,,,,,,, -Ranilia,Ranilia,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Raninidae,Ranilia,Genus,206773,NA,Remove,,,,,,, -Ranilia muricata,Ranilia muricata,Muricate frog crab,Animalia,Arthropoda,Malacostraca,Decapoda,Raninidae,Ranilia,Species,421900,NA,Species,,,,,,, -Raninidae,Raninidae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Raninidae,NA,Family,106771,NA,Remove,,,,,,, -Raninoides,Raninoides,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Raninidae,Raninoides,Genus,204492,NA,Remove,,,,,,, -Raninoides loevis,Raninoides laevis,Furrowed frog crab,Animalia,Arthropoda,Malacostraca,Decapoda,Raninidae,Raninoides,Species,440246,NA,Species,,,,,,, -Raninoides laevis,Raninoides laevis,Furrowed frog crab,Animalia,Arthropoda,Malacostraca,Decapoda,Raninidae,Raninoides,Species,440246,NA,Species,,,,,,, -Raninoides louisianensis,Raninoides louisianensis,Gulf frog crab,Animalia,Arthropoda,Malacostraca,Decapoda,Raninidae,Raninoides,Species,421903,NA,Species,,,,,,, -Rastrinus scutiger,Rastrinus scutiger,Roughskin sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Rastrinus,Species,282552,50792,Species,,,,,,, -Rathbunaster californicus,Rathbunaster californicus,California sun star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Rathbunaster,Species,254844,NA,Species,,,,,,, -Rathbunella hypoplecta,Rathbunella hypoplecta,Stripefin ronquil,Animalia,Chordata,Teleostei,Perciformes,Bathymasteridae,Rathbunella,Species,282556,3694,Species,,,,,,, -Pinnixa occidentalis,Rathbunixa occidentalis,Western pea crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pinnotheridae,Pinnixa,Species,1424662,NA,Species,,,,,,, -Rathbunixa occidentalis,Rathbunixa occidentalis,Western pea crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pinnotheridae,Pinnixa,Species,1424662,NA,Species,,,,,,, -Raymanninus schmitti,Raymanninus schmitti,Sharpoar swimming crab,Animalia,Arthropoda,Malacostraca,Decapoda,Geryonidae,Raymanninus,Species,422050,NA,Species,,,,,,, -Red striated anemone,Red striated anemone,NA,NA,NA,NA,NA,NA,NA,Remove,NA,NA,Remove,,,,,,, -Regadrella okinoseana,Regadrella okinoseana,Lacy basket sponge,Animalia,Porifera,Hexactinellida,Lyssacinosida,Euplectellidae,Regadrella,Species,171875,NA,Species,,,,,,, -Reinhardtius hippoglossoides,Reinhardtius hippoglossoides,Greenland halibut,Animalia,Chordata,Teleostei,Pleuronectiformes,Pleuronectidae,Reinhardtius,Species,127144,516,Species,,,,,,, -Remora australis,Remora australis,Whalesucker,Animalia,Chordata,Teleostei,Carangiformes,Echeneidae,Remora,Species,126850,3545,Species,,,,,,, -Remora remora,Remora remora,Shark sucker,Animalia,Chordata,Teleostei,Carangiformes,Echeneidae,Remora,Species,126853,1751,Species,,,,,,, -Renilla,Renilla,Sea pansies,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Renillidae,Renilla,Genus,267800,NA,Remove,,,,,,, -Renilla muelleri,Renilla muelleri,Mueller's sea pansy,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Renillidae,Renilla,Species,290962,NA,Species,,,,,,, -Renilla mulleri,Renilla muelleri,Mueller's sea pansy,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Renillidae,Renilla,Species,290962,NA,Species,,,,,,, -Renilla reniformes,Renilla reniformis,Sea pansy,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Renillidae,Renilla,Species,290965,NA,Species,,,,,,, -Renilla reniformis,Renilla reniformis,Sea pansy,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Renillidae,Renilla,Species,290965,NA,Species,,,,,,, -Renillidae,Renillidae,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Renillidae,NA,Family,266953,NA,Remove,,,,,,, -Retifusus roseus,Retifusus roseus,Rosy whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Retimohniidae,Retifusus,Species,596553,NA,Species,,,,,,, -Colus virens,Retifusus virens,Green whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,580848,NA,Species,,,,,,, -Retifusus virens,Retifusus virens,Green whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Colidae,Colus,Species,580848,NA,Species,,,,,,, -Retiometra alascana,Retiometra alascana,Alaskan crinoid,Animalia,Echinodermata,Crinoidea,Comatulida,Antedonidae,Retiometra,Species,710763,NA,Species,,,,,,, -Reussia sp.,Reussia,NA,NA,NA,NA,NA,NA,NA,Genus,468543,NA,Remove,,,,,,, -Rhabdocalyptus sp.,Rhabdocalyptus,cloud sponge,NA,NA,NA,NA,NA,NA,Genus,NA,NA,Remove,,,,,,, -Rhabdus dalli,Rhabdus rectius,Dall tuskshell,Animalia,Mollusca,Scaphopoda,Dentaliida,Rhabdidae,Rhabdus,Species,344596,NA,Species,,,,,,, -Rhabdus rectius,Rhabdus rectius,Dall tuskshell,Animalia,Mollusca,Scaphopoda,Dentaliida,Rhabdidae,Rhabdus,Species,344596,NA,Species,,,,,,, -Rhacochilus toxotes,Rhacochilus toxotes,Rubberlip seaperch,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Embiotocidae,Rhacochilus,Species,282575,3639,Species,,,,,,, -Rhacostoma atlanticum,Rhacostoma atlanticum,NA,Animalia,Cnidaria,Hydrozoa,Leptothecata,Aequoreidae,Rhacostoma,Species,156967,NA,Species,,,,,,, -Rhamphocottus richardsoni,Rhamphocottus richardsonii,Grunt sculpin,Animalia,Chordata,Teleostei,Perciformes,Rhamphocottidae,Rhamphocottus,Species,282578,4139,Species,,,,,,, -Rhamphocottus richardsonii,Rhamphocottus richardsonii,Grunt sculpin,Animalia,Chordata,Teleostei,Perciformes,Rhamphocottidae,Rhamphocottus,Species,282578,4139,Species,,,,,,, -Rhamphostomella costata,Rhamphostomella costata,Ribbed bryozoan,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Umbonulidae,Rhamphostomella,Species,111140,NA,Species,,,,,,, -Rhinobatidae,Rhinobatidae,NA,Animalia,Chordata,Elasmobranchii,Rhinopristiformes,Rhinobatidae,NA,Family,105712,NA,Remove,,,,,,, -Rhinoliparis,Rhinoliparis,NA,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Rhinoliparis,Genus,270738,NA,Remove,,,,,,, -Rhinoliparis sp.,Rhinoliparis,NA,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Rhinoliparis,Genus,270738,NA,Remove,,,,,,, -Rhinoliparis attenuatus,Rhinoliparis attenuatus,Slim snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Rhinoliparis,Species,282584,25257,Species,,,,,,, -Rhinoliparis barbulifer,Rhinoliparis barbulifer,Longnose snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Rhinoliparis,Species,282585,50721,Species,,,,,,, -Rhinolithodes wosnessenskii,Rhinolithodes wosnessenskii,Rhinoceros crab,Animalia,Arthropoda,Malacostraca,Decapoda,Lithodidae,Rhinolithodes,Species,550610,NA,Species,,,,,,, -Rhinoptera,Rhinoptera,NA,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Myliobatidae,Rhinoptera,Genus,105759,NA,Remove,,,,,,, -Rhinoptera bonasus,Rhinoptera bonasus,Cownose ray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Myliobatidae,Rhinoptera,Species,158544,2584,Species,,,,,,, -Rhinoptera brasiliensis,Rhinoptera brasiliensis,Brazilian cownose ray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Myliobatidae,Rhinoptera,Species,271495,14148,Species,,,,,,, -Rhithropanopeus harrisii,Rhithropanopeus harrisii,Harris mud crab,Animalia,Arthropoda,Malacostraca,Decapoda,Panopeidae,Rhithropanopeus,Species,107414,NA,Species,,,,,,, -Rhizoprionodon terraenovae,Rhizoprionodon terraenovae,Atlantic sharpnose shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Carcharhinidae,Rhizoprionodon,Species,158510,905,Species,,,,,,, -Rhodomelaceae,Rhodomelaceae,NA,Plantae,Rhodophyta,Florideophyceae,Ceramiales,Rhodomelaceae,NA,Family,143674,NA,Remove,,,,,,, -Rhodophyceae,Rhodophyta,NA,Plantae,Rhodophyta,Rhodophyceae,NA,NA,NA,Class,852,NA,Remove,,,,,,, -Rhomboplites aurorubens,Rhomboplites aurorubens,Vermilion snapper,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Lutjanidae,Rhomboplites,Species,159807,213,Species,,,,,,, -Rhopilema verrilli,Rhopilema verrilli,Mushroom cap jellyfish,Animalia,Cnidaria,Scyphozoa,Rhizostomeae,Rhizostomatidae,Rhopilema,Species,158198,NA,Species,,,,,,, -Rhynchoconger,Rhynchoconger,NA,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Rhynchoconger,Genus,158570,NA,Remove,,,,,,, -Hildebrandia flava,Rhynchoconger flavus,Yellow conger,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Rhynchoconger,Species,158571,2628,Species,,,,,,, -Rhynchoconger flavus,Rhynchoconger flavus,Yellow conger,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Rhynchoconger,Species,158571,2628,Species,,,,,,, -Hildebrandia gracilior,Rhynchoconger gracilior,Whiptail conger,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Rhynchoconger,Species,158572,2629,Species,,,,,,, -Rhynchoconger gracilior,Rhynchoconger gracilior,Whiptail conger,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Rhynchoconger,Species,158572,2629,Species,,,,,,, -Rhynchoconger guppyi,Rhynchoconger guppyi,NA,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Rhynchoconger,Species,275425,47178,Species,,,,,,, -Rhynocrangon alata,Rhynocrangon alata,Saddleback shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Rhynocrangon,Species,515669,NA,Species,,,,,,, -Rhynocrangon sharpi,Rhynocrangon sharpi,Spiked shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Rhynocrangon,Species,515671,NA,Species,,,,,,, -Rimapenaeus,Rimapenaeus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Rimapenaeus,Genus,158339,NA,Remove,,,,,,, -Rimapenaeus constrictus,Rimapenaeus constrictus,Roughneck shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Rimapenaeus,Species,158340,NA,Species,,,,,,, -Risor ruber,Risor ruber,Tusked goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Risor,Species,282620,3898,Species,,,,,,, -Rocinela angustata,Rocinela angustata,Sea cockroach,Animalia,Arthropoda,Malacostraca,Isopoda,Aegidae,Rocinela,Species,256455,NA,Species,,,,,,, -Cancer antennarius,Romaleon antennarium,Pacific rock crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Cancer,Species,106876,NA,Species,,,,,,, -Cancer branneri,Romaleon branneri,Furrowed rock crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Romaleon,Species,440398,NA,Species,,,,,,, -Romaleon branneri,Romaleon branneri,Furrowed rock crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cancridae,Romaleon,Species,440398,NA,Species,,,,,,, -Rondeletiidae,Rondeletiidae,Redmouth whalefishes,Animalia,Chordata,Teleostei,Beryciformes,Rondeletiidae,NA,Family,125463,NA,Remove,,,,,,, -Ronquilus jordani,Ronquilus jordani,Northern ronquil,Animalia,Chordata,Teleostei,Perciformes,Bathymasteridae,Ronquilus,Species,282629,3695,Species,,,,,,, -Rossellinae,Rossellidae,Sea spunge,Animalia,Porifera,Hexactinellida,Lyssacinosida,Rossellidae,NA,SubFamily,131694,NA,Remove,,,,,,, -Rossia bullisi,Rossia bullisi,Bully bobtailsquid,Animalia,Mollusca,Cephalopoda,Sepiida,Sepiolidae,Rossia,Species,342194,NA,Species,,,,,,, -Rossia pacifica,Rossia pacifica,Eastern pacific bobtail,Animalia,Mollusca,Cephalopoda,Sepiida,Sepiolidae,Rossia,Species,346432,NA,Species,,,,,,, -Rossia pacifica eggs,Rossia pacifica eggs,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Rossia,Rossia spp.,Benthic bobtail squid,Chromista,Bacillariophyta,Bacillariophyceae,Naviculales,Sellaphoraceae,Rossia,Genus,602300,NA,Remove,,,,,,, -Raja eglanteria,Rostroraja eglanteria,Clearnose skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Species,1460141,1252,Species,,,,,,, -Rostroraja eglanteria,Rostroraja eglanteria,Clearnose skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Species,1460141,1252,Species,,,,,,, -Raja texana,Rostroraja texana,Roundel skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Species,1670925,NA,Species,,,,,,, -Rostroraja texana,Rostroraja texana,Roundel skate,Animalia,Chordata,Elasmobranchii,Rajiformes,Rajidae,Raja,Species,1670925,NA,Species,,,,,,, -Rouleina attrita,Rouleina attrita,Softskin smooth-head,Animalia,Chordata,Teleostei,Alepocephaliformes,Alepocephalidae,Rouleina,Species,126709,6964,Species,,,,,,, -Rypticus arenatus,Rypticus bistrispinus,Freckled soapfish,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Rypticus,Species,275958,3353,Species,,,,,,, -Rypticus bistrispinus,Rypticus bistrispinus,Freckled soapfish,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Rypticus,Species,275958,3353,Species,,,,,,, -Rypticus maculatus,Rypticus maculatus,Whitespotted soapfish,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Rypticus,Species,159235,3354,Species,,,,,,, -Rypticus saponaceus,Rypticus saponaceus,Greater soapfish,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Rypticus,Species,275963,1056,Species,,,,,,, -Rypticus subbifrenatus,Rypticus subbifrenatus,Spotted soapfish,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Rypticus,Species,275964,3355,Species,,,,,,, -Sabellidae,Sabellidae,Fanworms,Animalia,Annelida,Polychaeta,Sabellida,Sabellidae,NA,Family,985,NA,Remove,,,,,,, -Sabinella troglodytes,Sabinella troglodytes,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Eulimidae,Sabinella,Species,419856,NA,Species,,,,,,, -Saccopharyngidae,Saccopharyngidae,NA,Animalia,Chordata,Teleostei,Saccopharyngiformes,Saccopharyngidae,NA,Family,125586,NA,Remove,,,,,,, -Saccopharynx,Saccopharynx,NA,Animalia,Chordata,Teleostei,Saccopharyngiformes,Saccopharyngidae,Saccopharynx,Genus,126138,NA,Remove,,,,,,, -Sagamichthys abei,Sagamichthys abei,Shining tubeshoulder,Animalia,Chordata,Teleostei,Alepocephaliformes,Platytroctidae,Sagamichthys,Species,234630,5198,Species,,,,,,, -Zoroaster evermanni,Sagenaster evermanni,Evermann's star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Zoroasteridae,Zoroaster,Species,254775,NA,Species,,,,,,, -Sagenaster evermanni,Sagenaster evermanni,Evermann's star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Zoroasteridae,Zoroaster,Species,254775,NA,Species,,,,,,, -Salmo salar,Salmo salar,Atlantic salmon,Animalia,Chordata,Teleostei,Salmoniformes,Salmonidae,Salmo,Species,127186,236,Species,,,,,,, -Salmonidae,Salmonidae,Salmon and trouts unid.,Animalia,Chordata,Teleostei,Salmoniformes,Salmonidae,NA,Family,125587,NA,Remove,,,,,,, -Salpa,Salpa,NA,Animalia,Chordata,Thaliacea,Salpida,Salpidae,Salpa,Genus,137233,NA,Remove,,,,,,, -Salpidae,Salpidae,NA,Animalia,Chordata,Thaliacea,Salpida,Salpidae,NA,Family,137217,NA,Remove,,,,,,, -Salvelinus malma,Salvelinus malma,Dolly varden,Animalia,Chordata,Teleostei,Salmoniformes,Salmonidae,Salvelinus,Species,254570,2691,Species,,,,,,, -Sarda orientalis,Sarda orientalis,Striped bonito,Animalia,Chordata,Teleostei,Scombriformes,Scombridae,Sarda,Species,219713,114,Species,,,,,,, -Sarda sarda,Sarda sarda,Atlantic bonito,Animalia,Chordata,Teleostei,Scombriformes,Scombridae,Sarda,Species,127021,115,Species,,,,,,, -Sardinella,Sardinella,NA,Animalia,Chordata,Teleostei,Clupeiformes,Dorosomatidae,Sardinella,Genus,125721,NA,Remove,,,,,,, -Sardinella aurita,Sardinella aurita,Spanish sardine,Animalia,Chordata,Teleostei,Clupeiformes,Dorosomatidae,Sardinella,Species,126422,1043,Species,,,,,,, -Sardinella brasiliensis,Sardinella brasiliensis,Brazilian sardinella,Animalia,Chordata,Teleostei,Clupeiformes,Dorosomatidae,Sardinella,Species,300551,1505,Species,,,,,,, -Sardinops sagax,Sardinops sagax,South american pilchard,Animalia,Chordata,Teleostei,Clupeiformes,Alosidae,Sardinops,Species,217452,1477,Species,,,,,,, -Sargassaceae,Sargassaceae,NA,Chromista,Ochrophyta,Phaeophyceae,Fucales,Sargassaceae,NA,Family,143725,NA,Remove,,,,,,, -Sargassum,Sargassum,NA,Chromista,Ochrophyta,Phaeophyceae,Fucales,Sargassaceae,Sargassum,Genus,144132,NA,Remove,,,,,,, -Sargocentron,Sargocentron,NA,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Sargocentron,Genus,125704,NA,Remove,,,,,,, -Holocentrus bullisi,Sargocentron bullisi,Deepwater squirrelfish,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Holocentrus,Species,272206,3247,Species,,,,,,, -Sargocentron bullisi,Sargocentron bullisi,Deepwater squirrelfish,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Holocentrus,Species,272206,3247,Species,,,,,,, -Sargocentron coruscum,Sargocentron coruscum,Reef squirrelfish,Animalia,Chordata,Teleostei,Holocentriformes,Holocentridae,Sargocentron,Species,272207,3248,Species,,,,,,, -Leptagonus frenatus,Sarritor frenatus,Sawback poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Leptagonus,Species,254374,4170,Species,,,,,,, -Sarritor frenatus,Sarritor frenatus,Sawback poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Leptagonus,Species,254374,4170,Species,,,,,,, -Leptagonus leptorhynchus,Sarritor leptorhynchus,Longnose poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Leptagonus,Species,254376,4171,Species,,,,,,, -Sarritor leptorhynchus,Sarritor leptorhynchus,Longnose poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Leptagonus,Species,254376,4171,Species,,,,,,, -Sasakiopus salebrosus,Sasakiopus salebrosus,Rough octopus,Animalia,Mollusca,Cephalopoda,Octopoda,Enteroctopodidae,Sasakiopus,Species,534138,NA,Species,,,,,,, -Saurenchelys cognita,Saurenchelys cognita,Longface eel,Animalia,Chordata,Teleostei,Anguilliformes,Nettastomatidae,Saurenchelys,Species,158592,58722,Species,,,,,,, -Saurida,Saurida,NA,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,Saurida,Genus,125685,NA,Remove,,,,,,, -Saurida brasiliensis,Saurida brasiliensis,Largescale lizardfish,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,Saurida,Species,158756,2716,Species,,,,,,, -Saurida caribbaea,Saurida caribbaea,Smallscale lizardfish,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,Saurida,Species,158757,2717,Species,,,,,,, -Saurida normani,Saurida normani,Shortjaw lizardfish,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,Saurida,Species,272117,2718,Species,,,,,,, -Saxidomus gigantea,Saxidomus gigantea,Washington butterclam,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Saxidomus,Species,546014,NA,Species,,,,,,, -Saxidomus nuttalli,Saxidomus nuttalli,California butterclam,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,Saxidomus,Species,367778,NA,Species,,,,,,, -Scabrotrophon,Scabrotrophon,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Scabrotrophon,Genus,147145,NA,Remove,,,,,,, -Scabrotrophon sp.,Scabrotrophon,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Scabrotrophon,Genus,147145,NA,Remove,,,,,,, -Scabrotrophon scitulus,Scabrotrophon scitulus,spiny trophon,NA,NA,NA,NA,NA,NA,Species,1332407,NA,Species,,,,,,, -Boreotrophon stuarti,Scabrotrophon stuarti,Winged trophon,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Boreotrophon,Species,1329504,NA,Species,,,,,,, -Nipponotrophon stuarti,Scabrotrophon stuarti,Winged trophon,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Nipponotrophon,Species,1329504,NA,Species,,,,,,, -Scabrotrophon stuarti,Scabrotrophon stuarti,Winged trophon,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Nipponotrophon,Species,1329504,NA,Species,,,,,,, -Scalpellidae,Scalpellidae,NA,Animalia,Arthropoda,Thecostraca,Scalpellomorpha,Scalpellidae,NA,Family,106055,NA,Remove,,,,,,, -Scalpellum,Scalpellum,NA,Animalia,Arthropoda,Thecostraca,Scalpellomorpha,Scalpellidae,Scalpellum,Genus,106115,NA,Remove,,,,,,, -Scalpellum sp.,Scalpellum,NA,Animalia,Arthropoda,Thecostraca,Scalpellomorpha,Scalpellidae,Scalpellum,Genus,106115,NA,Remove,,,,,,, -Scaphella,Scaphella,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutidae,Scaphella,Genus,382285,NA,Remove,,,,,,, -Scaphella dohrni,Scaphella dohrni,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutidae,Scaphella,Species,606573,NA,Species,,,,,,, -Scaphella dubia,Scaphella dubia,Dubious volute,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutidae,Scaphella,Species,719754,NA,Species,,,,,,, -Scaphella junonia,Scaphella junonia,Junonia,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutidae,Scaphella,Species,527749,NA,Species,,,,,,, -Scaridae,Scaridae,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Scaridae,NA,Family,125557,NA,Remove,,,,,,, -Scarus iseri,Scarus iseri,Striped parrotfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Scaridae,Scarus,Species,276052,NA,Species,,,,,,, -Scarus taeniopterus,Scarus taeniopterus,Princess parrotfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Scaridae,Scarus,Species,276062,1156,Species,,,,,,, -Scelidotoma bella,Scelidotoma bella,Elegant emarginula,Animalia,Mollusca,Gastropoda,Lepetellida,Fissurellidae,Scelidotoma,Species,701693,NA,Species,,,,,,, -Hexactinosida,Sceptrulophora,Sponge,Animalia,Porifera,Hexactinellida,Hexactinosida,NA,NA,Order,605841,NA,Remove,,,,,,, -Schizaster,Schizaster,NA,Animalia,Echinodermata,Echinoidea,Spatangoida,Schizasteridae,Schizaster,Genus,123428,NA,Remove,,,,,,, -Schizaster orbignyanus,Schizaster orbignyanus,NA,Animalia,Echinodermata,Echinoidea,Spatangoida,Schizasteridae,Schizaster,Species,422521,NA,Species,,,,,,, -Schizoporaellidae,Schizoporaellidae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Schultzea beta,Schultzea beta,School bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Schultzea,Species,282691,3340,Species,,,,,,, -Sciaenidae,Sciaenidae,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,NA,Family,125558,NA,Remove,,,,,,, -Sciaenops ocellatus,Sciaenops ocellatus,Red drum,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Sciaenops,Species,159335,1191,Species,,,,,,, -Scleracis,Scleracis,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Scleracidae,Scleracis,Genus,267830,NA,Remove,,,,,,, -Madreporaria,Scleractinia,Hard corals,Animalia,Cnidaria,Anthozoa,Scleractinia,NA,NA,Order,1363,NA,Remove,,,,,,, -Scleractinia,Scleractinia,Hard corals,Animalia,Cnidaria,Anthozoa,Scleractinia,NA,NA,Order,1363,NA,Remove,,,,,,, -Calcaxonia,Scleralcyonacea,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,NA,NA,SubOrder,1609355,NA,Remove,,,,,,, -Sclerasterias heteropaes,Sclerasterias heteropaes,Banded sea star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Sclerasterias,Species,378795,NA,Species,,,,,,, -Sclerocrangon,Sclerocrangon,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Sclerocrangon,Genus,107013,NA,Remove,,,,,,, -Sclerocrangon sp.,Sclerocrangon,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Sclerocrangon,Genus,107013,NA,Remove,,,,,,, -Sclerocrangon boreas,Sclerocrangon boreas,Sculptured shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Crangonidae,Sclerocrangon,Species,107568,NA,Species,,,,,,, -Scomber,Scomber,NA,Animalia,Chordata,Teleostei,Scombriformes,Scombridae,Scomber,Genus,126063,NA,Remove,,,,,,, -Scomber colias,Scomber colias,Atlantic chub mackerel,Animalia,Chordata,Teleostei,Scombriformes,Scombridae,Scomber,Species,151174,54736,Species,,,,,,, -Scomber japonicus,Scomber japonicus,Chub mackerel,Animalia,Chordata,Teleostei,Scombriformes,Scombridae,Scomber,Species,127022,117,Species,,,,,,, -Scomber scombrus,Scomber scombrus,Atlantic mackerel,Animalia,Chordata,Teleostei,Scombriformes,Scombridae,Scomber,Species,127023,118,Species,,,,,,, -Scomberesocidae,Scomberesocidae,Sauries,Animalia,Chordata,Teleostei,Beloniformes,Scomberesocidae,NA,Family,125454,NA,Remove,,,,,,, -Scomberesox saurus,Scomberesox saurus,Atlantic saury,Animalia,Chordata,Teleostei,Beloniformes,Scomberesocidae,Scomberesox,Species,126392,1084,Species,,,,,,, -Scomberomorus,Scomberomorus,NA,Animalia,Chordata,Teleostei,Scombriformes,Scombridae,Scomberomorus,Genus,126064,NA,Remove,,,,,,, -Scomberomorus cavalla,Scomberomorus cavalla,King mackerel,Animalia,Chordata,Teleostei,Scombriformes,Scombridae,Scomberomorus,Species,159340,120,Species,,,,,,, -Scomberomorus maculatus,Scomberomorus maculatus,Spanish mackerel,Animalia,Chordata,Teleostei,Scombriformes,Scombridae,Scomberomorus,Species,159342,126,Species,,,,,,, -Scomberomorus regalis,Scomberomorus regalis,Cero,Animalia,Chordata,Teleostei,Scombriformes,Scombridae,Scomberomorus,Species,273819,134,Species,,,,,,, -Scombridae,Scombridae,"Mackerels, tuna, bonitos",Animalia,Chordata,Teleostei,Scombriformes,Scombridae,NA,Family,125559,NA,Remove,,,,,,, -Sconsia,Sconsia,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cassidae,Sconsia,Genus,415965,NA,Remove,,,,,,, -Sconsia striata,Sconsia grayi,Royal bonnet,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cassidae,Sconsia,Species,533413,NA,Species,,,,,,, -Sconsia grayi,Sconsia grayi,Royal bonnet,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cassidae,Sconsia,Species,533413,NA,Species,,,,,,, -Scopelarchidae,Scopelarchidae,Pearleyes,Animalia,Chordata,Teleostei,Aulopiformes,Scopelarchidae,NA,Family,125448,NA,Remove,,,,,,, -Scopelengys tristis,Scopelengys tristis,Pacific blackchin,Animalia,Chordata,Teleostei,Myctophiformes,Neoscopelidae,Scopelengys,Species,126636,5119,Species,,,,,,, -Scopelosaurus,Scopelosaurus,NA,Animalia,Chordata,Teleostei,Aulopiformes,Notosudidae,Scopelosaurus,Genus,125672,NA,Remove,,,,,,, -Scopelosaurus sp.,Scopelosaurus,NA,Animalia,Chordata,Teleostei,Aulopiformes,Notosudidae,Scopelosaurus,Genus,125672,NA,Remove,,,,,,, -Scopelosaurus adleri,Scopelosaurus adleri,Adler waryfish,Animalia,Chordata,Teleostei,Aulopiformes,Notosudidae,Scopelosaurus,Species,254552,60268,Species,,,,,,, -Scopelosaurus harryi,Scopelosaurus harryi,Scaly paperbone,Animalia,Chordata,Teleostei,Aulopiformes,Notosudidae,Scopelosaurus,Species,272082,11600,Species,,,,,,, -Scophthalmus aquosus,Scophthalmus aquosus,Windowpane flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Scophthalmidae,Scophthalmus,Species,158907,530,Species,,,,,,, -Micropanope nuttingii,Scopolius nuttingi,Beaded mud crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Scopolius,Species,881728,NA,Species,,,,,,, -Scorpaena,Scorpaena,NA,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Scorpaena,Genus,126171,NA,Remove,,,,,,, -Scorpaena agassizi,Scorpaena agassizii,Longfin scorpionfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Scorpaena,Species,159560,3934,Species,,,,,,, -Scorpaena agassizii,Scorpaena agassizii,Longfin scorpionfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Scorpaena,Species,159560,3934,Species,,,,,,, -Scorpaena brachyptera,Scorpaena brachyptera,Shortfin scorpionfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Scorpaena,Species,274701,3937,Species,,,,,,, -Scorpaena brasiliensis,Scorpaena brasiliensis,Barbfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Scorpaena,Species,159562,3938,Species,,,,,,, -Scorpaena calcarata,Scorpaena calcarata,Smoothhead scorpionfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Scorpaena,Species,159563,3939,Species,,,,,,, -Scorpaena dispar,Scorpaena dispar,Hunchback scorpionfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Scorpaena,Species,274706,3940,Species,,,,,,, -Scorpaena grandicornis,Scorpaena grandicornis,Plumed scorpionfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Scorpaena,Species,274711,NA,Species,,,,,,, -Scorpaena guttata,Scorpaena guttata,California scorpionfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Scorpaena,Species,274713,3943,Species,,,,,,, -Scorpaena inermis,Scorpaena inermis,Mushroom scorpionfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Scorpaena,Species,274717,3944,Species,,,,,,, -Scorpaena plumieri,Scorpaena plumieri,Spotted scorpionfish,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,Scorpaena,Species,159564,1201,Species,,,,,,, -Scorpaenichthys marmoratus,Scorpaenichthys marmoratus,Cabezon,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Scorpaenichthys,Species,282726,4140,Species,,,,,,, -Scorpaenidae,Scorpaenidae,Scorpionfishes rockfishes,Animalia,Chordata,Teleostei,Perciformes,Scorpaenidae,NA,Family,125595,NA,Remove,,,,,,, -Scotoplanes,Scotoplanes,Sea pigs,Animalia,Echinodermata,Holothuroidea,Elasipodida,Elpidiidae,Scotoplanes,Genus,123520,NA,Remove,,,,,,, -Scotoplanes sp.,Scotoplanes,Sea pigs,Animalia,Echinodermata,Holothuroidea,Elasipodida,Elpidiidae,Scotoplanes,Genus,123520,NA,Remove,,,,,,, -Scotoplanes theeli,Scotoplanes theeli,NA,NA,NA,NA,NA,NA,NA,Species,530223,NA,Species,,,,,,, -Scutellidae,Scutellidae,NA,Animalia,Echinodermata,Echinoidea,Echinolampadacea,Scutellidae,NA,Family,196179,NA,Remove,,,,,,, -Scyliorhinidae,Scyliorhinidae,NA,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Scyliorhinidae,NA,Family,105693,NA,Remove,,,,,,, -Scyliorhinus retifer,Scyliorhinus retifer,Chain catshark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Scyliorhinidae,Scyliorhinus,Species,158516,853,Species,,,,,,, -Scyllaridae,Scyllaridae,Shovel nosed lobsters,Animalia,Arthropoda,Malacostraca,Decapoda,Scyllaridae,NA,Family,106795,NA,Remove,,,,,,, -Scyllarides,Scyllarides,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Scyllaridae,Scyllarides,Genus,107061,NA,Remove,,,,,,, -Scyllarides aequinoctialis,Scyllarides aequinoctialis,Spanish slipper lobster,Animalia,Arthropoda,Malacostraca,Decapoda,Scyllaridae,Scyllarides,Species,382909,NA,Species,,,,,,, -Scyllarides nodifer,Scyllarides nodifer,Ridged slipper lobster,Animalia,Arthropoda,Malacostraca,Decapoda,Scyllaridae,Scyllarides,Species,382914,NA,Species,,,,,,, -Scyllarus,Scyllarus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Scyllaridae,Scyllarus,Genus,107062,NA,Remove,,,,,,, -Scyllarus americanus,Scyllarus americanus,American slipper lobster,Animalia,Arthropoda,Malacostraca,Decapoda,Scyllaridae,Scyllarus,Species,382968,NA,Species,,,,,,, -Scyllarus chacei,Scyllarus chacei,Chace slipper lobster,Animalia,Arthropoda,Malacostraca,Decapoda,Scyllaridae,Scyllarus,Species,382969,NA,Species,,,,,,, -Scyllarus depressus,Scyllarus depressus,Scaled slipper lobster,Animalia,Arthropoda,Malacostraca,Decapoda,Scyllaridae,Scyllarus,Species,158377,NA,Species,,,,,,, -Scyphozoa,Scyphozoa,Jellyfishes,Animalia,Cnidaria,Scyphozoa,NA,NA,NA,Class,135220,NA,Remove,,,,,,, -Scyra acutifrons,Scyra acutifrons,Sharpnose crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Scyra,Species,441698,NA,Species,,,,,,, -Sebastes,Sebastes,Rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Genus,126175,NA,Remove,,,,,,, -Sebastes (=sebastomus),Sebastes,Rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Genus,126175,NA,Remove,,,,,,, -Sebastes sebastes (mystinus / diaconus),Sebastes,Rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Genus,126175,NA,Remove,,,,,,, -Sebastes sp.,Sebastes,Rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Genus,126175,NA,Remove,,,,,,, -Sebastes (=sebastomus) sp.,Sebastes,NA,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Genus,126175,NA,Remove,,,,,,, -Sebastes aleutianus,Sebastes aleutianus,Rougheye rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274771,3949,Species,,,,,,, -Sebastes alutus,Sebastes alutus,Pacific ocean perch,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,254573,504,Species,,,,,,, -Sebastes atrovirens,Sebastes atrovirens,Kelp rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274772,3950,Species,,,,,,, -Sebastes auriculatus,Sebastes auriculatus,Brown rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274773,3951,Species,,,,,,, -Sebastes aurora,Sebastes aurora,Aurora rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274774,3952,Species,,,,,,, -Sebastes babcocki,Sebastes babcocki,Redbanded rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274775,3953,Species,,,,,,, -Sebastes borealis,Sebastes borealis,Shortraker rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274777,3954,Species,,,,,,, -Sebastes brevispinis,Sebastes brevispinis,Silvergray rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274778,3955,Species,,,,,,, -Sebastes carnatus,Sebastes carnatus,Gopher rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274779,3956,Species,,,,,,, -Sebastes caurinus,Sebastes caurinus,Copper rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274780,3957,Species,,,,,,, -Sebastes chlorostictus,Sebastes chlorostictus,Greenspotted rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274781,3958,Species,,,,,,, -Sebastes ciliatus,Sebastes ciliatus,dark rockfish,NA,NA,NA,NA,NA,NA,Species,274782,NA,Species,,,,,,, -Sebastes constellatus,Sebastes constellatus,Starry rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274783,3961,Species,,,,,,, -Sebastes crameri,Sebastes crameri,Darkblotched rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274785,3962,Species,,,,,,, -Sebastes dalli,Sebastes dallii,Calico rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274786,3963,Species,,,,,,, -Sebastes diaconus,Sebastes diaconus,Deacon rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,1384909,68589,Species,,,,,,, -Sebastes diploproa,Sebastes diploproa,Splitnose rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274787,3964,Species,,,,,,, -Sebastes elongatus,Sebastes elongatus,Greenstriped rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274788,3965,Species,,,,,,, -Sebastes emphaeus,Sebastes emphaeus,Puget sound rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274789,3966,Species,,,,,,, -Sebastes ensifer,Sebastes ensifer,Swordspine rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274790,3967,Species,,,,,,, -Sebastes entomelas,Sebastes entomelas,Widow rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274791,502,Species,,,,,,, -Sebastes eos,Sebastes eos,Pink rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274792,3968,Species,,,,,,, -Sebastes fasciatus,Sebastes fasciatus,Acadian redfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,127252,3969,Species,,,,,,, -Sebastes flavidus,Sebastes flavidus,Yellowtail rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274795,503,Species,,,,,,, -Sebastes gilli,Sebastes gilli,Bronzespotted rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274796,3970,Species,,,,,,, -Sebastes goodei,Sebastes goodei,Chilipepper rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274798,3971,Species,,,,,,, -Sebastes helvomaculatus,Sebastes helvomaculatus,Rosethorn rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274799,3972,Species,,,,,,, -Sebastes hopkinsi,Sebastes hopkinsi,Squarespot rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274800,3973,Species,,,,,,, -Sebastes jordani,Sebastes jordani,Shortbelly rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274806,3974,Species,,,,,,, -Sebastes lentiginosus,Sebastes lentiginosus,Freckled rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274811,3975,Species,,,,,,, -Sebastes levis,Sebastes levis,Cowcod,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274812,3976,Species,,,,,,, -Sebastes macdonaldi,Sebastes macdonaldi,Mexican rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274814,3977,Species,,,,,,, -Sebastes maliger,Sebastes maliger,Quillback rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274815,3978,Species,,,,,,, -Sebastes melanops,Sebastes melanops,Black rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274817,3979,Species,,,,,,, -Sebastes melanostictus,Sebastes melanostictus,Blackspotted rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,1015496,67247,Species,,,,,,, -Sebastes (aleutianus / melanostictus),Sebastes melanostictus and S. aleutianus,Blackspotted and rougheye rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,126175,NA,Species,,,,,,, -Sebastes melanostictus and s. aleutianus,Sebastes melanostictus and S. aleutianus,Blackspotted and rougheye rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,126175,NA,Species,,,,,,, -Sebastes sp. (aleutianus / melanostictus),Sebastes melanostictus and S. aleutianus,Blackspotted and rougheye rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,126175,NA,Species,,,,,,, -Sebastes melanostomus,Sebastes melanostomus,Blackgill rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274819,3981,Species,,,,,,, -Sebastes miniatus,Sebastes miniatus,Vermilion rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274820,3982,Species,,,,,,, -Sebastes (miniatus / crocotulus),Sebastes miniatus and S. crocotulus,Vermillion and sunset rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,126175,NA,Species,,,,,,, -Sebastes sp. (miniatus / crocotulus),Sebastes miniatus and S. crocotulus,Vermillion and sunset rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,126175,NA,Species,,,,,,, -Sebastes (miniatus / pinniger),Sebastes miniatus and S. pinniger,Vermillion and canary rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,126175,NA,Species,,,,,,, -Sebastes sp. (miniatus / pinniger),Sebastes miniatus and S. pinniger,Vermillion and canary rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,126175,NA,Species,,,,,,, -Sebastes moseri,Sebastes moseri,Whitespeckled rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274822,54379,Species,,,,,,, -Sebastes mystinus,Sebastes mystinus,Blue rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274823,3983,Species,,,,,,, -Sebastes sebastes sp. (mystinus / diaconus),Sebastes mystinus and S. diaconus,Blue and Deacon rockfish,NA,NA,NA,NA,NA,NA,Species,NA,Species,Species,,,,,,, -Sebastes nigrocinctus,Sebastes nigrocinctus,Tiger rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274825,3985,Species,,,,,,, -Sebastes ovalis,Sebastes ovalis,Speckled rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274830,3986,Species,,,,,,, -Sebastes paucispinis,Sebastes paucispinis,Bocaccio,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274833,3987,Species,,,,,,, -Sebastes phillipsi,Sebastes phillipsi,Chameleon rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274835,3988,Species,,,,,,, -Sebastes pinniger,Sebastes pinniger,Canary rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274836,3989,Species,,,,,,, -Sebastes polyspinis,Sebastes polyspinis,Northern rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274837,3990,Species,,,,,,, -Sebastes proriger,Sebastes proriger,Redstripe rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274838,3991,Species,,,,,,, -Sebastes rastrelliger,Sebastes rastrelliger,Grass rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274839,3992,Species,,,,,,, -Sebastes reedi,Sebastes reedi,Yellowmouth rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274840,3993,Species,,,,,,, -Sebastes rosaceus,Sebastes rosaceus,Rosy rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274841,3994,Species,,,,,,, -Sebastes rosenblatti,Sebastes rosenblatti,Greenblotched rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274842,3995,Species,,,,,,, -Sebastes ruberrimus,Sebastes ruberrimus,Yelloweye rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274844,3996,Species,,,,,,, -Sebastes rubrivinctus,Sebastes rubrivinctus,Flag rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274845,3997,Species,,,,,,, -Sebastes rufus,Sebastes rufus,Bank rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274847,3999,Species,,,,,,, -Sebastes saxicola,Sebastes saxicola,Stripetail rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274848,4000,Species,,,,,,, -Sebastes semicinctus,Sebastes semicinctus,Halfbanded rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274851,4001,Species,,,,,,, -Sebastes serranoides,Sebastes serranoides,Olive rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274852,4002,Species,,,,,,, -Sebastes serriceps,Sebastes serriceps,Treefish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274853,4003,Species,,,,,,, -Sebastes simulator,Sebastes simulator,Pinkrose rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274854,4004,Species,,,,,,, -Sebastes umbrosus,Sebastes umbrosus,Honeycomb rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274862,4005,Species,,,,,,, -Sebastes variabilis,Sebastes variabilis,dusky rockfish,NA,NA,NA,NA,NA,NA,Species,398442,NA,Species,,,,,,, -Sebastes variabilis and s. ciliatus,Sebastes variabilis and S. ciliatus,Dusky and dark rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,398442,63583,Species,,,,,,, -Sebastes variegatus,Sebastes variegatus,Harlequin rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274863,4006,Species,,,,,,, -Sebastes wilsoni,Sebastes wilsoni,Pygmy rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274868,4007,Species,,,,,,, -Sebastes zacentrus,Sebastes zacentrus,Sharpchin rockfish,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastes,Species,274869,4008,Species,,,,,,, -Sebastolobus,Sebastolobus,NA,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastolobus,Genus,270859,NA,Remove,,,,,,, -Sebastolobus sp.,Sebastolobus,NA,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastolobus,Genus,270859,NA,Remove,,,,,,, -Sebastolobus alascanus,Sebastolobus alascanus,Shortspine thornyhead,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastolobus,Species,282740,4009,Species,,,,,,, -Sebastolobus altivelis,Sebastolobus altivelis,Longspine thornyhead,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastolobus,Species,282741,4010,Species,,,,,,, -Sebastolobus macrochir,Sebastolobus macrochir,Broadbanded thornyhead,Animalia,Chordata,Teleostei,Perciformes,Sebastidae,Sebastolobus,Species,282742,11704,Species,,,,,,, -Selachii,Selachii,NA,Animalia,Chordata,Elasmobranchii,NA,NA,NA,InfraClass,368408,NA,Remove,,,,,,, -Selachii sharks,Selachii sharks,NA,Animalia,Chordata,Elasmobranchii,NA,NA,NA,InfraClass,368408,NA,Remove,,,,,,, -Selachimorpha,Selachimorpha,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Selar crumenophthalmus,Selar crumenophthalmus,Bigeye scad,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Selar,Species,159646,387,Species,,,,,,, -Selene,Selene,NA,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Selene,Genus,125943,NA,Remove,,,,,,, -Selene setapinnis,Selene setapinnis,Atlantic moonfish,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Selene,Species,159647,378,Species,,,,,,, -Selene vomer,Selene vomer,Lookdown,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Selene,Species,159649,1004,Species,,,,,,, -Semaeostomae,Semaeostomae,Jellyfish,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Semaeostomeae,Semaeostomeae,NA,Animalia,Cnidaria,Scyphozoa,Semaeostomeae,NA,NA,Genus,135225,NA,Remove,,,,,,, -Phalium granulatum,Semicassis granulata,Scotch bonnet,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cassidae,Phalium,Species,419784,NA,Species,,,,,,, -Semicassis granulata,Semicassis granulata,Scotch bonnet,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cassidae,Phalium,Species,419784,NA,Species,,,,,,, -Semicossyphus pulcher,Semicossyphus pulcher,California sheephead,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Semicossyphus,Species,282753,3671,Species,,,,,,, -Semirossia,Semirossia,NA,Animalia,Mollusca,Cephalopoda,Sepiida,Sepiolidae,Semirossia,Genus,157035,NA,Remove,,,,,,, -Semirossia equalis,Semirossia equalis,Greater bobtail squid,Animalia,Mollusca,Cephalopoda,Sepiida,Sepiolidae,Semirossia,Species,342232,NA,Species,,,,,,, -Semirossia tenera,Semirossia tenera,Lesser shining bobtail,Animalia,Mollusca,Cephalopoda,Sepiida,Sepiolidae,Semirossia,Species,157036,NA,Species,,,,,,, -Semisuberites cribrosa,Semisuberites cribrosa,Vase sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Esperiopsidae,Semisuberites,Species,168379,NA,Species,,,,,,, -Tellina listeri,Senegona senegambiensis,Speckled tellin,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Tellina,Species,849069,NA,Species,,,,,,, -Sepiolidae,Sepiolidae,NA,Animalia,Mollusca,Cephalopoda,Sepiida,Sepiolidae,NA,Family,11725,NA,Remove,,,,,,, -Septa occidentalis,Septa occidentalis,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Cymatiidae,Septa,Species,476588,NA,Species,,,,,,, -Sergestes,Sergestes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Sergestidae,Sergestes,Genus,106829,NA,Remove,,,,,,, -Sergestes sp.,Sergestes,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Sergestidae,Sergestes,Genus,106829,NA,Remove,,,,,,, -Sergestidae,Sergestidae,Sergestid shrimps,Animalia,Arthropoda,Malacostraca,Decapoda,Sergestidae,NA,Family,106731,NA,Remove,,,,,,, -Seriola,Seriola,NA,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Seriola,Genus,125944,NA,Remove,,,,,,, -Seriola dumerili,Seriola dumerili,Greater amberjack,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Seriola,Species,126816,1005,Species,,,,,,, -Seriola fasciata,Seriola fasciata,Lesser amberjack,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Seriola,Species,126817,1006,Species,,,,,,, -Seriola rivoliana,Seriola rivoliana,Longfin yellowtail,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Seriola,Species,126818,1007,Species,,,,,,, -Seriola zonata,Seriola zonata,Banded rudderfish,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Seriola,Species,159650,1008,Species,,,,,,, -Seriphus politus,Seriphus politus,Queen croaker,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Seriphus,Species,282761,3589,Species,,,,,,, -Serpula,Serpula,NA,Animalia,Annelida,Polychaeta,Sabellida,Serpulidae,Serpula,Genus,129580,NA,Remove,,,,,,, -Serpula sp.,Serpula,NA,Animalia,Annelida,Polychaeta,Sabellida,Serpulidae,Serpula,Genus,129580,NA,Remove,,,,,,, -Serpula columbiana,Serpula columbiana,Red trumpet calcareous tubeworm,Animalia,Annelida,Polychaeta,Sabellida,Serpulidae,Serpula,Species,338088,NA,Species,,,,,,, -Serpula vermicularis,Serpula vermicularis,Serpulid worm,Animalia,Annelida,Polychaeta,Sabellida,Serpulidae,Serpula,Species,131051,NA,Species,,,,,,, -Serpulidae,Serpulidae,Calcareous tubeworms,Animalia,Annelida,Polychaeta,Sabellida,Serpulidae,NA,Family,988,NA,Remove,,,,,,, -Serraniculus pumilio,Serraniculus pumilio,Pygmy sea bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Serraniculus,Species,282762,3341,Species,,,,,,, -Serranidae,Serranidae,Seabasses (groupers and fairy basslets),Animalia,Chordata,Teleostei,Perciformes,Serranidae,NA,Family,125561,NA,Remove,,,,,,, -Serranus,Serranus,NA,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Serranus,Genus,126070,NA,Remove,,,,,,, -Serranus annularis,Serranus annularis,Orangeback bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Serranus,Species,273890,3342,Species,,,,,,, -Serranus atrobranchus,Serranus atrobranchus,Blackear bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Serranus,Species,273891,3343,Species,,,,,,, -Serranus notospilus,Serranus notospilus,Saddle bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Serranus,Species,273901,3346,Species,,,,,,, -Serranus phoebe,Serranus phoebe,Tattler,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Serranus,Species,273903,3347,Species,,,,,,, -Serranus subligarius,Serranus subligarius,Belted sandfish,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Serranus,Species,159236,3348,Species,,,,,,, -Serranus tortugarum,Serranus tortugarum,Chalk bass,Animalia,Chordata,Teleostei,Perciformes,Serranidae,Serranus,Species,273910,3351,Species,,,,,,, -Flustra serrulata,Serratiflustra serrulata,Leafy bryozoan,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Flustridae,Flustra,Species,465722,NA,Species,,,,,,, -Serratiflustra serrulata,Serratiflustra serrulata,Leafy bryozoan,Animalia,Bryozoa,Gymnolaemata,Cheilostomatida,Flustridae,Flustra,Species,465722,NA,Species,,,,,,, -Serripes,Serripes,NA,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Serripes,Genus,137741,NA,Remove,,,,,,, -Serripes sp.,Serripes,NA,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Serripes,Genus,137741,NA,Remove,,,,,,, -Serripes groenlandicus,Serripes groenlandicus,Greenland cockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Serripes,Species,582749,NA,Species,,,,,,, -Serripes laperousii,Serripes laperousii,Broad smoothcockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Serripes,Species,582750,NA,Species,,,,,,, -Serripes notabilis,Serripes notabilis,Oblique smoothcockle,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Serripes,Species,582751,NA,Species,,,,,,, -Serrivomer,Serrivomer,NA,Animalia,Chordata,Teleostei,Anguilliformes,Serrivomeridae,Serrivomer,Genus,125650,NA,Remove,,,,,,, -Serrivomer jesperseni,Serrivomer jesperseni,Crossthroat sawpalate,Animalia,Chordata,Teleostei,Anguilliformes,Serrivomeridae,Serrivomer,Species,272002,24468,Species,,,,,,, -Serrivomer sector,Serrivomer sector,Sawtooth eel,Animalia,Chordata,Teleostei,Anguilliformes,Serrivomeridae,Serrivomer,Species,272005,11483,Species,,,,,,, -Serrivomeridae,Serrivomeridae,NA,Animalia,Chordata,Teleostei,Anguilliformes,Serrivomeridae,NA,Family,125435,NA,Remove,,,,,,, -Sertulariidae,Sertulariidae,Sertulariid hydroid,Animalia,Cnidaria,Hydrozoa,Leptothecata,Sertulariidae,NA,Family,1614,NA,Remove,,,,,,, -Sesarma,Sesarma,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Sesarmidae,Sesarma,Genus,158457,NA,Remove,,,,,,, -Sicyonia,Sicyonia,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Sicyoniidae,Sicyonia,Genus,106824,NA,Remove,,,,,,, -Sicyonia brevirostris,Sicyonia brevirostris,Brown rock shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Sicyoniidae,Sicyonia,Species,158342,NA,Species,,,,,,, -Sicyonia burkenroadi,Sicyonia burkenroadi,Spiny rock shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Sicyoniidae,Sicyonia,Species,377625,NA,Species,,,,,,, -Sicyonia dorsalis,Sicyonia dorsalis,Lesser rock shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Sicyoniidae,Sicyonia,Species,377631,NA,Species,,,,,,, -Sicyonia ingentis,Sicyonia ingentis,Ridgeback rock shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Sicyoniidae,Sicyonia,Species,377635,NA,Species,,,,,,, -Sicyonia laevigata,Sicyonia laevigata,Notched tidal rock shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Sicyoniidae,Sicyonia,Species,377637,NA,Species,,,,,,, -Sicyonia parri,Sicyonia parri,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Sicyoniidae,Sicyonia,Species,377647,NA,Species,,,,,,, -Sicyonia penicillata,Sicyonia penicillata,Target rock shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Sicyoniidae,Sicyonia,Species,377649,NA,Species,,,,,,, -Sicyonia stimpsoni,Sicyonia stimpsoni,Eyespot rock shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Sicyoniidae,Sicyonia,Species,377652,NA,Species,,,,,,, -Sicyonia typica,Sicyonia typica,Kinglet rock shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Sicyoniidae,Sicyonia,Species,377654,NA,Species,,,,,,, -Sicyonis,Sicyonis,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Sicyonidae,Sicyonis,Genus,100715,NA,Remove,,,,,,, -Sicyonis sp. A (Clark 2006),Sicyonis sp. A (Clark 2006),orange actinistolid,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Gonostoma elongatum,Sigmops elongatus,Elongated bristlemouth fish,Animalia,Chordata,Teleostei,Stomiiformes,Gonostomatidae,Gonostoma,Species,221512,7383,Species,,,,,,, -Sigmops gracilis,Sigmops gracilis,Slender fangjaw,Animalia,Chordata,Teleostei,Stomiiformes,Gonostomatidae,Sigmops,Species,279336,22719,Species,,,,,,, -Siliqua,Siliqua,NA,Animalia,Mollusca,Bivalvia,Adapedonta,Pharidae,Siliqua,Genus,159997,NA,Remove,,,,,,, -Siliqua sp.,Siliqua,NA,Animalia,Mollusca,Bivalvia,Adapedonta,Pharidae,Siliqua,Genus,159997,NA,Remove,,,,,,, -Siliqua alta,Siliqua alta,Alaska razor,Animalia,Mollusca,Bivalvia,Adapedonta,Pharidae,Siliqua,Species,413689,NA,Species,,,,,,, -Siliqua patula,Siliqua patula,Pacific razor,Animalia,Mollusca,Bivalvia,Adapedonta,Pharidae,Siliqua,Species,536684,NA,Species,,,,,,, -Simenchelys parasiticus,Simenchelys parasitica,Snubnosed eel,Animalia,Chordata,Teleostei,Anguilliformes,Synaphobranchidae,Simenchelys,Species,126327,9102,Species,,,,,,, -Busycon contrarum,Sinistrofulgur contrarium,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Sinistrofulgur,Species,1522862,NA,Species,,,,,,, -Sinistrofulgur contrarium,Sinistrofulgur contrarium,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Sinistrofulgur,Species,1522862,NA,Species,,,,,,, -Busycon perversum,Sinistrofulgur perversum,Perverse whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862937,NA,Species,,,,,,, -Sinistrofulgur perversum,Sinistrofulgur perversum,Perverse whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862937,NA,Species,,,,,,, -Busycon pulleyi,Sinistrofulgur pulleyi,Prickly whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862936,NA,Species,,,,,,, -Sinistrofulgur pulleyi,Sinistrofulgur pulleyi,Prickly whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862936,NA,Species,,,,,,, -Busycon sinistrum,Sinistrofulgur sinistrum,Lightning whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862934,NA,Species,,,,,,, -Sinistrofulgur sinistrum,Sinistrofulgur sinistrum,Lightning whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Busyconidae,Busycon,Species,862934,NA,Species,,,,,,, -Sinum,Sinum,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Sinum,Genus,138244,NA,Remove,,,,,,, -Sinum maculatum,Sinum maculatum,Brown baby ear,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Sinum,Species,419768,NA,Species,,,,,,, -Sinum perspectivum,Sinum perspectivum,White baby ear,Animalia,Mollusca,Gastropoda,Littorinimorpha,Naticidae,Sinum,Species,160053,NA,Species,,,,,,, -Siphonariidae,Siphonariidae,False limpets,Animalia,Mollusca,Gastropoda,Siphonariida,Siphonariidae,NA,Family,23118,NA,Remove,,,,,,, -Sipuncula,Sipuncula,Peanut worms,Animalia,Annelida,NA,Sipuncula,NA,NA,Order,1268,NA,Remove,,,,,,, -Sipunculidae,Sipunculidae,NA,Animalia,Annelida,NA,Sipuncula,Sipunculidae,NA,Family,1648,NA,Remove,,,,,,, -Sipunculus nudus,Sipunculus (Sipunculus) nudus,NA,Animalia,Annelida,NA,Sipuncula,Sipunculidae,Sipunculus,Species,136084,NA,Species,,,,,,, -Siratus beauii,Siratus beauii,Beau's murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Siratus,Species,405262,NA,Species,,,,,,, -Solariella,Solariella,NA,Animalia,Mollusca,Gastropoda,Trochida,Solariellidae,Solariella,Genus,138597,NA,Remove,,,,,,, -Solariella sp.,Solariella,NA,Animalia,Mollusca,Gastropoda,Trochida,Solariellidae,Solariella,Genus,138597,NA,Remove,,,,,,, -Solariella obscura,Solariella obscura,Obscure solarelle,Animalia,Mollusca,Gastropoda,Trochida,Solariellidae,Solariella,Species,141840,NA,Species,,,,,,, -Solaster,Solaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Solaster,Genus,123338,NA,Remove,,,,,,, -Solaster sp.,Solaster,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Solaster,Genus,123338,NA,Remove,,,,,,, -Solaster dawsoni,Solaster dawsoni,Morning sun star,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Solaster,Species,292720,NA,Species,,,,,,, -Solaster arcticus,Solaster dawsoni arcticus,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Solaster,Species,123338,NA,Species,,,,,,, -Solaster dawsoni arcticus,Solaster dawsoni arcticus,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Solaster,Species,123338,NA,Species,,,,,,, -Solaster endeca,Solaster endeca,Northern sun star,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Solaster,Species,124160,NA,Species,,,,,,, -Solaster exiguus,Solaster exiguus,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Solaster,Species,292721,NA,Species,,,,,,, -Solaster hexactis,Solaster hexactis,NA,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Solaster,Species,582008,NA,Species,,,,,,, -Solaster hypothrissus,Solaster hypothrissus,White sun star,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Solaster,Species,292723,NA,Species,,,,,,, -Solaster paxillatus,Solaster paxillatus,Orange sunstar,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Solaster,Species,292727,NA,Species,,,,,,, -Solaster sp. A (Clark 1997),Solaster sp. A (Clark 1997),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Solaster sp. D (Clark),Solaster sp. D (Clark),serpent sun star,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Solaster sp. E (Clark),Solaster sp. E (Clark),Kessler sun star,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Solaster sp. F (Clark),Solaster sp. F (Clark),Fisher sun star,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Solaster sp. G (Clark),Solaster sp. G (Clark),ocher sun star,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Solaster spectabilis,Solaster spectabilis,Beautiful sun star,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Solaster,Species,582009,NA,Species,,,,,,, -Solaster stimpsoni,Solaster stimpsoni,Stimpson's sun star,Animalia,Echinodermata,Asteroidea,Valvatida,Solasteridae,Solaster,Species,292729,NA,Species,,,,,,, -Solecurtus cumingianus,Solecurtus cumingianus,Corrugate solecurtus,Animalia,Mollusca,Bivalvia,Cardiida,Solecurtidae,Solecurtus,Species,420918,NA,Species,,,,,,, -Solemya,Solemya,NA,Animalia,Mollusca,Bivalvia,Solemyida,Solemyidae,Solemya,Genus,138514,NA,Remove,,,,,,, -Solenastrea,Solenastrea,NA,Animalia,Cnidaria,Hexacorallia,Scleractinia,Scleractinia incertae sedis,Solenastrea,Genus,267842,NA,Remove,,,,,,, -Solenastrea hyades,Solenastrea hyades,Knobby star coral,Animalia,Cnidaria,Anthozoa,Scleractinia,Scleractinia incertae sedis,Solenastrea,Species,291055,NA,Species,,,,,,, -Solengaster,Solengaster,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Solengaster sp.,Solengaster sp.,NA,NA,NA,NA,NA,NA,NA,Genus,NA,NA,Remove,,,,,,, -Solenocera,Solenocera,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Solenoceridae,Solenocera,Genus,106826,NA,Remove,,,,,,, -Solenocera acuminata,Solenocera acuminata,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Solenoceridae,Solenocera,Species,377657,NA,Species,,,,,,, -Solenocera atlantidis,Solenocera atlantidis,Dwarf humpback shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Solenoceridae,Solenocera,Species,377660,NA,Species,,,,,,, -Solenocera necopina,Solenocera necopina,Deepwater humpback shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Solenoceridae,Solenocera,Species,377672,NA,Species,,,,,,, -Solenocera vioscai,Solenocera vioscai,Humpback shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Solenoceridae,Solenocera,Species,377677,NA,Species,,,,,,, -Solenoceridae,Solenoceridae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Solenoceridae,NA,Family,106729,NA,Remove,,,,,,, -Solenolambrus tenellus,Solenolambrus tenellus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Solenolambrus,Species,422032,NA,Species,,,,,,, -Cantharus cancellarius,Solenosteira cancellaria,Cancellate cantharus,Animalia,Mollusca,Gastropoda,Neogastropoda,Pisaniidae,Cantharus,Species,419981,NA,Species,,,,,,, -Solenosteira cancellaria,Solenosteira cancellaria,Cancellate cantharus,Animalia,Mollusca,Gastropoda,Neogastropoda,Pisaniidae,Cantharus,Species,419981,NA,Species,,,,,,, -Somniosus pacificus,Somniosus pacificus,Pacific sleeper shark,Animalia,Chordata,Elasmobranchii,Squaliformes,Somniosidae,Somniosus,Species,271654,2544,Species,,,,,,, -Sparidae,Sparidae,Porgies,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,NA,Family,125564,NA,Remove,,,,,,, -Sparisoma atromarium,Sparisoma atomarium,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Scaridae,Sparisoma,Species,273771,3675,Species,,,,,,, -Sparisoma atomarium,Sparisoma atomarium,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Scaridae,Sparisoma,Species,273771,3675,Species,,,,,,, -Sparisoma aurofrenatum,Sparisoma aurofrenatum,Redband parrotfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Scaridae,Sparisoma,Species,273772,1158,Species,,,,,,, -Sparisoma chrysopterum,Sparisoma chrysopterum,Redtail parrotfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Scaridae,Sparisoma,Species,273774,1159,Species,,,,,,, -Spatangidae,Spatangidae,NA,Animalia,Echinodermata,Echinoidea,Spatangoida,Spatangidae,NA,Family,123177,NA,Remove,,,,,,, -Spatangoida,Spatangoida,NA,Animalia,Echinodermata,Echinoidea,Spatangoida,NA,NA,Order,123106,NA,Remove,,,,,,, -Spatangus californicus,Spatangus californicus,California heart urchin,Animalia,Echinodermata,Echinoidea,Spatangoida,Spatangidae,Spatangus,Species,513547,NA,Species,,,,,,, -Spathochlamys benedicti,Spathochlamys benedicti,NA,Animalia,Mollusca,Bivalvia,Pectinida,Pectinidae,Spathochlamys,Species,393788,NA,Species,,,,,,, -Spengleria rostrata,Spengleria rostrata,Rostrate gastrochaenid,Animalia,Mollusca,Bivalvia,Gastrochaenida,Gastrochaenidae,Spengleria,Species,420987,NA,Species,,,,,,, -Speocarcinus,Speocarcinus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Speocarcinus,Genus,415995,NA,Remove,,,,,,, -Speocarcinus carolinensis,Speocarcinus carolinensis,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Speocarcinus,Species,422107,NA,Species,,,,,,, -Speocarcinus lobatus,Speocarcinus lobatus,Gulf squareback crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Speocarcinus,Species,422108,NA,Species,,,,,,, -Speciospongia vesparia,Spheciospongia vesparium,Loggerhead sponge,Animalia,Porifera,Demospongiae,Clionaida,Clionaidae,Spheciospongia,Species,170566,NA,Species,,,,,,, -Sphenia fragilis,Sphenia fragilis,NA,Animalia,Mollusca,Bivalvia,Myida,Myidae,Sphenia,Species,420973,NA,Species,,,,,,, -Sphoeroides,Sphoeroides,NA,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Sphoeroides,Genus,126241,NA,Remove,,,,,,, -Sphoeroides dorsalis,Sphoeroides dorsalis,Marbled puffer,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Sphoeroides,Species,275274,4294,Species,,,,,,, -Sphoeroides maculatus,Sphoeroides maculatus,Northern puffer,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Sphoeroides,Species,158934,1181,Species,,,,,,, -Sphoeroides nephelus,Sphoeroides nephelus,Southern puffer,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Sphoeroides,Species,275280,1240,Species,,,,,,, -Sphoeroides pachygaster,Sphoeroides pachygaster,Blunthead puffer,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Sphoeroides,Species,127417,4296,Species,,,,,,, -Sphoeroides parvus,Sphoeroides parvus,Least puffer,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Sphoeroides,Species,275282,4297,Species,,,,,,, -Sphoeroides spengleri,Sphoeroides spengleri,Bandtail puffer,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Sphoeroides,Species,158935,1241,Species,,,,,,, -Sphoeroides testudineus,Sphoeroides testudineus,Checkered puffer,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,Sphoeroides,Species,158936,1242,Species,,,,,,, -Sphyraena,Sphyraena,NA,Animalia,Chordata,Teleostei,Carangaria incertae sedis,Sphyraenidae,Sphyraena,Genus,126084,NA,Remove,,,,,,, -Sphyraena sp,Sphyraena,NA,Animalia,Chordata,Teleostei,Carangaria incertae sedis,Sphyraenidae,Sphyraena,Genus,126084,NA,Remove,,,,,,, -Sphyraena argentea,Sphyraena argentea,Pacific barracuda,Animalia,Chordata,Teleostei,Carangaria incertae sedis,Sphyraenidae,Sphyraena,Species,273978,3678,Species,,,,,,, -Sphyraena barracuda,Sphyraena barracuda,Great barracuda,Animalia,Chordata,Teleostei,Carangaria incertae sedis,Sphyraenidae,Sphyraena,Species,345843,1235,Species,,,,,,, -Sphyraena borealis,Sphyraena borealis,Northern sennet,Animalia,Chordata,Teleostei,Carangaria incertae sedis,Sphyraenidae,Sphyraena,Species,159813,3679,Species,,,,,,, -Sphyraena guachancho,Sphyraena guachancho,Guachanche barracuda,Animalia,Chordata,Teleostei,Carangaria incertae sedis,Sphyraenidae,Sphyraena,Species,159814,1236,Species,,,,,,, -Sphyraena picudilla,Sphyraena picudilla,Southern sennet,Animalia,Chordata,Teleostei,Carangaria incertae sedis,Sphyraenidae,Sphyraena,Species,273984,1237,Species,,,,,,, -Sphyraenidae,Sphyraenidae,NA,Animalia,Chordata,Teleostei,Carangaria incertae sedis,Sphyraenidae,NA,Family,125565,NA,Remove,,,,,,, -Sphyrna lewini,Sphyrna lewini,Scalloped hammerhead,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Sphyrnidae,Sphyrna,Species,105816,912,Species,,,,,,, -Sphyrna mokarran,Sphyrna mokarran,Great hammerhead,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Sphyrnidae,Sphyrna,Species,105817,914,Species,,,,,,, -Sphyrna tiburo,Sphyrna tiburo,Bonnethead,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Sphyrnidae,Sphyrna,Species,158517,915,Species,,,,,,, -Sphyrna zygaena,Sphyrna zygaena,Smooth hammerhead,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Sphyrnidae,Sphyrna,Species,105819,917,Species,,,,,,, -Parthenope fraterculus,Spinolambrus fraterculus,Rough elbow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Parthenope,Species,442338,NA,Species,,,,,,, -Spinolambrus fraterculus,Spinolambrus fraterculus,Rough elbow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Parthenope,Species,442338,NA,Species,,,,,,, -Parthenope pourtalesii,Spinolambrus pourtalesii,Spinous elbow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Parthenope,Species,442342,NA,Species,,,,,,, -Spinolambrus pourtalesii,Spinolambrus pourtalesii,Spinous elbow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Parthenopidae,Parthenope,Species,442342,NA,Species,,,,,,, -Spinther,Spinther,NA,Animalia,Annelida,Polychaeta,NA,Spintheridae,Spinther,Genus,129604,NA,Remove,,,,,,, -Spinther sp. A (Clark 2006),Spinther sp. A (Clark 2006),pink sponge worm,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Spirinchus starksi,Spirinchus starksi,Night smelt,Animalia,Chordata,Teleostei,Osmeriformes,Osmeridae,Spirinchus,Species,282843,2697,Species,,,,,,, -Spirinchus thaleichthys,Spirinchus thaleichthys,Longfin smelt,Animalia,Chordata,Teleostei,Osmeriformes,Osmeridae,Spirinchus,Species,282844,2698,Species,,,,,,, -Spirontocaris,Spirontocaris,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Spirontocaris,Genus,106994,NA,Remove,,,,,,, -Spirontocaris sp.,Spirontocaris,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Spirontocaris,Genus,106994,NA,Remove,,,,,,, -Spirontocaris arcuata,Spirontocaris arcuata,Rathbun blade shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Spirontocaris,Species,254485,NA,Species,,,,,,, -Spirontocaris lamellicornis,Spirontocaris lamellicornis,Dana's blade shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Spirontocaris,Species,515332,NA,Species,,,,,,, -Spirontocaris liljeborgii,Spirontocaris liljeborgii,Friendly blade shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Spirontocaris,Species,107531,NA,Species,,,,,,, -Spirontocaris phippsii,Spirontocaris phippsii,Punctuate blade shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Thoridae,Spirontocaris,Species,107532,NA,Species,,,,,,, -Spisula solidissima,Spisula solidissima,Atlantic surfclam,Animalia,Mollusca,Bivalvia,Venerida,Mactridae,Spisula,Species,156996,NA,Species,,,,,,, -Spondylus,Spondylus,NA,Animalia,Mollusca,Bivalvia,Pectinida,Spondylidae,Spondylus,Genus,138518,NA,Remove,,,,,,, -Spondylus americanus,Spondylus americanus,Atlantic thorny oyster,Animalia,Mollusca,Bivalvia,Pectinida,Spondylidae,Spondylus,Species,420772,NA,Species,,,,,,, -Spondylus ictericus,Spondylus tenuis,Digitate thorny oyster,Animalia,Mollusca,Bivalvia,Pectinida,Spondylidae,Spondylus,Species,506972,NA,Species,,,,,,, -Spondylus tenuis,Spondylus tenuis,Digitate thorny oyster,Animalia,Mollusca,Bivalvia,Pectinida,Spondylidae,Spondylus,Species,506972,NA,Species,,,,,,, -Spongiidae,Spongiidae,NA,Animalia,Porifera,Demospongiae,Dictyoceratida,Spongiidae,NA,Family,131626,NA,Remove,,,,,,, -Squalidae,Squalidae,NA,Animalia,Chordata,Elasmobranchii,Squaliformes,Squalidae,NA,Family,105716,NA,Remove,,,,,,, -Squalus acanthias,Squalus acanthias,Spiny dogfish,Animalia,Chordata,Elasmobranchii,Squaliformes,Squalidae,Squalus,Species,105923,139,Species,,,,,,, -Squalus suckleyi,Squalus suckleyi,Pacific spiny dogfish,Animalia,Chordata,Elasmobranchii,Squaliformes,Squalidae,Squalus,Species,299224,65869,Species,,,,,,, -Squatina californica,Squatina californica,Pacific angelshark,Animalia,Chordata,Elasmobranchii,Squatiniformes,Squatinidae,Squatina,Species,271667,729,Species,,,,,,, -Squatina dumeril,Squatina dumeril,Sand devil,Animalia,Chordata,Elasmobranchii,Squatiniformes,Squatinidae,Squatina,Species,158525,731,Species,,,,,,, -Squatinidae,Squatinidae,Angel sharks,Animalia,Chordata,Elasmobranchii,Squatiniformes,Squatinidae,NA,Family,105717,NA,Remove,,,,,,, -Squilla,Squilla,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,Squilla,Genus,136113,NA,Remove,,,,,,, -Squilla brasiliensis,Squilla brasiliensis,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,Squilla,Species,409342,NA,Species,,,,,,, -Squilla chydaea,Squilla chydaea,Offshore mantis shrimp,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,Squilla,Species,409345,NA,Species,,,,,,, -Squilla deceptrix,Squilla deceptrix,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,Squilla,Species,409346,NA,Species,,,,,,, -Squilla edentata,Squilla edentata,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,Squilla,Species,409348,NA,Species,,,,,,, -Squilla empusa,Squilla empusa,Mantis shrimp,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,Squilla,Species,158466,NA,Species,,,,,,, -Squilla grenadensis,Squilla grenadensis,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,Squilla,Species,409349,NA,Species,,,,,,, -Squilla lijdingi,Squilla lijdingi,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,Squilla,Species,409352,NA,Species,,,,,,, -Squilla rugosa,Squilla rugosa,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,Squilla,Species,409357,NA,Species,,,,,,, -Squillidae,Squillidae,NA,Animalia,Arthropoda,Malacostraca,Stomatopoda,Squillidae,NA,Family,136093,NA,Remove,,,,,,, -Stachyptilum superbum,Stachyptilum superbum,Exquisite sea pen,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Stachyptilidae,Stachyptilum,Species,291109,NA,Species,,,,,,, -Starksia ocellata,Starksia ocellata,Checkered blenny,Animalia,Chordata,Teleostei,Blenniiformes,Labrisomidae,Starksia,Species,159670,3750,Species,,,,,,, -Staurocalyptus sp.,Staurocalyptus,NA,NA,NA,NA,NA,NA,NA,Genus,NA,NA,Remove,,,,,,, -Staurostoma mertensii,Staurostoma mertensii,Whitecross jellyfish,Animalia,Cnidaria,Hydrozoa,Leptothecata,Laodiceidae,Staurostoma,Species,594013,NA,Species,,,,,,, -Pomacentrus fuscus,Stegastes fuscus,Brazilian damsel,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Pomacentrus,Species,276669,3650,Species,,,,,,, -Stegastes fuscus,Stegastes fuscus,Brazilian damsel,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Pomacentrus,Species,276669,3650,Species,,,,,,, -Pomacentrus leucostictus,Stegastes leucostictus,Beaugregory,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Pomacentrus,Species,159291,3651,Species,,,,,,, -Stegastes leucostictus,Stegastes leucostictus,Beaugregory,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Pomacentrus,Species,159291,3651,Species,,,,,,, -Pomacentrus partitus,Stegastes partitus,Bicolor damselfish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Pomacentrus,Species,276677,3652,Species,,,,,,, -Stegastes partitus,Stegastes partitus,Bicolor damselfish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Pomacentrus,Species,276677,3652,Species,,,,,,, -Pomacentrus planifrons,Stegastes planifrons,Threespot damselfish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Pomacentrus,Species,276679,3653,Species,,,,,,, -Stegastes planifrons,Stegastes planifrons,Threespot damselfish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Pomacentrus,Species,276679,3653,Species,,,,,,, -Pomacentrus variabilis,Stegastes variabilis,Cocoa damselfish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Pomacentrus,Species,276688,3654,Species,,,,,,, -Stegastes variabilis,Stegastes variabilis,Cocoa damselfish,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Pomacentridae,Pomacentrus,Species,276688,3654,Species,,,,,,, -Stegocephalus inflatus,Stegocephalus inflatus,Smooth northern amphipod,Animalia,Arthropoda,Malacostraca,Amphipoda,Stegocephalidae,Stegocephalus,Species,103105,NA,Species,,,,,,, -Stegophiura nodosa,Stegophiura nodosa,NA,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiopyrgidae,Stegophiura,Species,124943,NA,Species,,,,,,, -Stegophiura ponderosa,Stegophiura ponderosa,NA,Animalia,Echinodermata,Ophiuroidea,Ophiurida,Ophiopyrgidae,Stegophiura,Species,244369,NA,Species,,,,,,, -Steindachneria argentea,Steindachneria argentea,Luminous hake,Animalia,Chordata,Teleostei,Gadiformes,Merlucciidae,Steindachneria,Species,282877,1829,Species,,,,,,, -Stelletta,Stelletta,stone sponge,Animalia,Porifera,Demospongiae,Tetractinellida,Ancorinidae,Stelletta,Genus,131994,NA,Remove,,,,,,, -Stelletta sp.,Stelletta,stone sponge,Animalia,Porifera,Demospongiae,Tetractinellida,Ancorinidae,Stelletta,Genus,131994,NA,Remove,,,,,,, -Stellifer lanceolatus,Stellifer lanceolatus,Star drum,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Stellifer,Species,159337,1193,Species,,,,,,, -Stelodoryx oxeata,Stelodoryx oxeata,Scapula sponge,Animalia,Porifera,Demospongiae,Poecilosclerida,Myxillidae,Stelodoryx,Species,233108,NA,Species,,,,,,, -Stenobrachius,Stenobrachius,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Stenobrachius,Genus,254362,NA,Remove,,,,,,, -Stenobrachius sp.,Stenobrachius,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Stenobrachius,Genus,254362,NA,Remove,,,,,,, -Stenobrachius leucopsarus,Stenobrachius leucopsarus,Northern lampfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Stenobrachius,Species,254363,2737,Species,,,,,,, -Stenobrachius nannochir,Stenobrachius nannochir,Garnet lanternfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Stenobrachius,Species,254364,17406,Species,,,,,,, -Stenocionops,Stenocionops,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Stenocionops,Genus,416012,NA,Remove,,,,,,, -Stenocionops coelata,Stenocionops coelatus,Furcate spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Stenocionops,Species,442134,NA,Species,,,,,,, -Stenocionops furcatus coelatus,Stenocionops coelatus,Furcate spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Stenocionops,Species,442134,NA,Species,,,,,,, -Stenocionops coelatus,Stenocionops coelatus,Furcate spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Stenocionops,Species,442134,NA,Species,,,,,,, -Stenocionops furcata,Stenocionops furcatus,Furcate spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Stenocionops,Species,421998,NA,Species,,,,,,, -Stenocionops furcatus,Stenocionops furcatus,Furcate spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Stenocionops,Species,421998,NA,Species,,,,,,, -Stenocionops spinimana,Stenocionops spinimanus,Prickly spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Stenocionops,Species,421999,NA,Species,,,,,,, -Stenocionops spinimanus,Stenocionops spinimanus,Prickly spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Stenocionops,Species,421999,NA,Species,,,,,,, -Stenocionops spinosissima,Stenocionops spinosissimus,Tenspine spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Stenocionops,Species,422000,NA,Species,,,,,,, -Stenocionops spinosissimus,Stenocionops spinosissimus,Tenspine spider crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Stenocionops,Species,422000,NA,Species,,,,,,, -Stenopus,Stenopus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Stenopodidae,Stenopus,Genus,107066,NA,Remove,,,,,,, -Stenopus hispidus,Stenopus hispidus,Banded coral shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Stenopodidae,Stenopus,Species,210370,NA,Species,,,,,,, -Stenopus scutellatus,Stenopus scutellatus,Yellowbanded coral shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Stenopodidae,Stenopus,Species,421664,NA,Species,,,,,,, -Stenorhynchus,Stenorhynchus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Stenorhynchus,Genus,106914,NA,Remove,,,,,,, -Stenorhynchus seticornis,Stenorhynchus seticornis,Yellowline arrow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Stenorhynchus,Species,421957,NA,Species,,,,,,, -Stenorhynchus yangi,Stenorhynchus yangi,Red arrow crab,Animalia,Arthropoda,Malacostraca,Decapoda,Inachoididae,Stenorhynchus,Species,421958,NA,Species,,,,,,, -Stenothoidae,Stenothoidae,NA,Animalia,Arthropoda,Malacostraca,Amphipoda,Stenothoidae,NA,Family,101409,NA,Remove,,,,,,, -Stenotomus,Stenotomus,Porgies,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Stenotomus,Genus,159809,NA,Remove,,,,,,, -Stenotomus caprinus,Stenotomus caprinus,Longspine porgy,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Stenotomus,Species,159810,1234,Species,,,,,,, -Stenotomus chrysops,Stenotomus chrysops,Scup,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sparidae,Stenotomus,Species,159811,452,Species,,,,,,, -Stephanasterias albula,Stephanasterias albula,Odd rayed star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Stephanasterias,Species,123808,NA,Species,,,,,,, -Stephanolepis,Stephanolepis,NA,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Stephanolepis,Genus,126236,NA,Remove,,,,,,, -Monacanthus hispidus,Stephanolepis hispida,Planehead filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Stephanolepis,Species,307126,4281,Species,,,,,,, -Stephanolepis hispida,Stephanolepis hispida,Planehead filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Stephanolepis,Species,307126,4281,Species,,,,,,, -Monacanthus setifer,Stephanolepis setifer,Pygmy filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Stephanolepis,Species,159500,1195,Species,,,,,,, -Stephanolepis setifer,Stephanolepis setifer,Pygmy filefish,Animalia,Chordata,Teleostei,Tetraodontiformes,Monacanthidae,Stephanolepis,Species,159500,1195,Species,,,,,,, -Stereolepis gigas,Stereolepis gigas,Black pacific jewfish,Animalia,Chordata,Teleostei,Acropomatiformes,Stereolepididae,Stereolepis,Species,282884,NA,Species,,,,,,, -Polycheles sculptus,Stereomastis sculpta,Flatback blind lobster,Animalia,Arthropoda,Malacostraca,Decapoda,Polychelidae,Polycheles,Species,107700,NA,Species,,,,,,, -Sternoptychidae,Sternoptychidae,Hatchetfish unid.,Animalia,Chordata,Teleostei,Stomiiformes,Sternoptychidae,NA,Family,125603,NA,Remove,,,,,,, -Sternoptyx,Sternoptyx,NA,Animalia,Chordata,Teleostei,Stomiiformes,Sternoptychidae,Sternoptyx,Genus,126199,NA,Remove,,,,,,, -Sternoptyx diaphana,Sternoptyx diaphana,Diaphanous hatchet fish,Animalia,Chordata,Teleostei,Stomiiformes,Sternoptychidae,Sternoptyx,Species,127314,7389,Species,,,,,,, -Stichaeidae,Stichaeidae,Pricklebacks,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,NA,Family,125566,NA,Remove,,,,,,, -Stichaeus punctatus,Stichaeus punctatus,Arctic shanny,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Stichaeus,Species,159819,3795,Species,,,,,,, -Stichopathes,Stichopathes,NA,Animalia,Cnidaria,Hexacorallia,Antipatharia,Antipathidae,Stichopathes,Genus,103308,NA,Remove,,,,,,, -Cirrhipathes leutkeni,Stichopathes luetkeni,Black wire coral,Animalia,Cnidaria,Anthozoa,Antipatharia,Antipathidae,Cirrhipathes,Species,1287835,NA,Species,,,,,,, -Stichopathes lutkeni,Stichopathes luetkeni,Black wire coral,Animalia,Cnidaria,Anthozoa,Antipatharia,Antipathidae,Cirrhipathes,Species,1287835,NA,Species,,,,,,, -Stichopathes luetkeni,Stichopathes luetkeni,Black wire coral,Animalia,Cnidaria,Anthozoa,Antipatharia,Antipathidae,Cirrhipathes,Species,1287835,NA,Species,,,,,,, -Stichopodidae,Stichopodidae,NA,Animalia,Echinodermata,Holothuroidea,Synallactida,Stichopodidae,NA,Family,123184,NA,Remove,,,,,,, -Stichopus,Stichopus,NA,Animalia,Echinodermata,Holothuroidea,Synallactida,Stichopodidae,Stichopus,Genus,123459,NA,Remove,,,,,,, -Histioteuthis dofleini,Stigmatoteuthis dofleini,North pacific flowervase jewel squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Histioteuthidae,Stigmatoteuthis,Species,410402,NA,Species,,,,,,, -Stigmatoteuthis dofleini,Stigmatoteuthis dofleini,North pacific flowervase jewel squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Histioteuthidae,Stigmatoteuthis,Species,410402,NA,Species,,,,,,, -Histioteuthis hoylei,Stigmatoteuthis hoylei,South pacific flowervase jewel squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Histioteuthidae,Histioteuthis,Species,410403,NA,Species,,,,,,, -Stigmatoteuthis hoylei,Stigmatoteuthis hoylei,South pacific flowervase jewel squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Histioteuthidae,Histioteuthis,Species,410403,NA,Species,,,,,,, -Stoloteuthis leucoptera,Stoloteuthis leucoptera,Butterfly bob tail,Animalia,Mollusca,Cephalopoda,Sepiida,Sepiolidae,Stoloteuthis,Species,157037,NA,Species,,,,,,, -Stomatopoda,Stomatopoda,Mantis shrimp,Animalia,Arthropoda,Malacostraca,Stomatopoda,NA,NA,Order,14355,NA,Remove,,,,,,, -Stomias atriventer,Stomias atriventer,Black-belly dragonfish,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,Stomias,Species,275178,5155,Species,,,,,,, -Stomias boa,Stomias boa,Boa dragonfish,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,Stomias,Species,127374,1806,Species,,,,,,, -Stomiidae,Stomiidae,NA,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,NA,Family,125604,NA,Remove,,,,,,, -Stomiiformes,Stomiiformes,NA,Animalia,Chordata,Teleostei,Stomiiformes,NA,NA,Order,10306,NA,Remove,,,,,,, -Stomolophus meleagris,Stomolophus meleagris,Cannonball jellyfish,Animalia,Cnidaria,Scyphozoa,Rhizostomeae,Stomolophidae,Stomolophus,Species,291140,NA,Species,,,,,,, -Stomozoa gigantea,Stomozoa gigantea,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Stomozoidae,Stomozoa,Species,488025,NA,Species,,,,,,, -Stomphia,Stomphia,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,Stomphia,Genus,100716,NA,Remove,,,,,,, -Stomphia sp.,Stomphia,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,Stomphia,Genus,100716,NA,Remove,,,,,,, -Stomphia coccinea,Stomphia coccinea,Swimming anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,Stomphia,Species,100854,NA,Species,,,,,,, -Stomphia didemon,Stomphia didemon,Cowardly anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Actinostolidae,Stomphia,Species,283473,NA,Species,,,,,,, -Stramonita canaliculata,Stramonita canaliculata,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Stramonita,Species,397112,NA,Species,,,,,,, -Stramonita haemastoma,Stramonita haemastoma,Red mouthed rock shell,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Stramonita,Species,140417,NA,Species,,,,,,, -Thais haemastoma,Stramonita haemastoma,Red mouthed rock shell,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Stramonita,Species,140417,NA,Species,,,,,,, -Stromateidae,Stromateidae,NA,Animalia,Chordata,Teleostei,Scombriformes,Stromateidae,NA,Family,125567,NA,Remove,,,,,,, -Strombus alatus,Strombus alatus,Florida fighting conch,Animalia,Mollusca,Gastropoda,Littorinimorpha,Strombidae,Strombus,Species,419694,NA,Species,,,,,,, -Allocentrotus,Strongylocentrotus,NA,Animalia,Echinodermata,Echinoidea,Camarodonta,Strongylocentrotidae,Strongylocentrotus,Genus,123390,NA,Remove,,,,,,, -Strongylocentrotus,Strongylocentrotus,NA,Animalia,Echinodermata,Echinoidea,Camarodonta,Strongylocentrotidae,Strongylocentrotus,Genus,123390,NA,Remove,,,,,,, -Strongylocentrotus sp.,Strongylocentrotus,NA,Animalia,Echinodermata,Echinoidea,Camarodonta,Strongylocentrotidae,Strongylocentrotus,Genus,123390,NA,Remove,,,,,,, -Allocentrotus sp.,Strongylocentrotus,NA,Animalia,Echinodermata,Echinoidea,Camarodonta,Strongylocentrotidae,Strongylocentrotus,Genus,123390,NA,Remove,,,,,,, -Strongylocentrotus droebachiensis,Strongylocentrotus droebachiensis,Green sea urchin,Animalia,Echinodermata,Echinoidea,Camarodonta,Strongylocentrotidae,Strongylocentrotus,Species,124321,NA,Species,,,,,,, -Allocentrotus fragilis,Strongylocentrotus fragilis,Fragile sea urchin,Animalia,Echinodermata,Echinoidea,Camarodonta,Strongylocentrotidae,Strongylocentrotus,Species,569742,NA,Species,,,,,,, -Strongylocentrotus cf. fragilis,Strongylocentrotus fragilis,Fragile sea urchin,Animalia,Echinodermata,Echinoidea,Camarodonta,Strongylocentrotidae,Strongylocentrotus,Species,569742,NA,Species,,,,,,, -Strongylocentrotus fragilis,Strongylocentrotus fragilis,Fragile sea urchin,Animalia,Echinodermata,Echinoidea,Camarodonta,Strongylocentrotidae,Strongylocentrotus,Species,569742,NA,Species,,,,,,, -Strongylocentrotus pallidus,Strongylocentrotus pallidus,Pale urchin,Animalia,Echinodermata,Echinoidea,Camarodonta,Strongylocentrotidae,Strongylocentrotus,Species,124324,NA,Species,,,,,,, -Strongylocentrotus polyacanthus,Strongylocentrotus polyacanthus,NA,Animalia,Echinodermata,Echinoidea,Camarodonta,Strongylocentrotidae,Strongylocentrotus,Species,423782,NA,Species,,,,,,, -Strongylocentrotus purpuratus,Strongylocentrotus purpuratus,Purple urchin,Animalia,Echinodermata,Echinoidea,Camarodonta,Strongylocentrotidae,Strongylocentrotus,Species,240747,NA,Species,,,,,,, -Strongylocentrotus sp. A,Strongylocentrotus sp. A,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Strongylocentrotus sp. B,Strongylocentrotus sp. B,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Strongylura,Strongylura,Needlefishes,Animalia,Chordata,Teleostei,Beloniformes,Belonidae,Strongylura,Genus,159253,NA,Remove,,,,,,, -Strongylura marina,Strongylura marina,Atlantic needlefish,Animalia,Chordata,Teleostei,Beloniformes,Belonidae,Strongylura,Species,159256,974,Species,,,,,,, -Styela,Styela,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Styelidae,Styela,Genus,103543,NA,Remove,,,,,,, -Styela sp.,Styela,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Styelidae,Styela,Genus,103543,NA,Remove,,,,,,, -Styela plicata,Styela plicata,Pleated sea squirt,Animalia,Chordata,Ascidiacea,Stolidobranchia,Styelidae,Styela,Species,103936,NA,Species,,,,,,, -Styela rustica,Styela rustica,Sea potato,Animalia,Chordata,Ascidiacea,Stolidobranchia,Styelidae,Styela,Species,103937,NA,Species,,,,,,, -Styela sp. A (Clark 2006),Styela sp. A (Clark 2006),Aleutian long-stalked tunicate,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Styela sp. B (Clark 2006),Styela sp. B (Clark 2006),hexagonal tunicate,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Styelidae,Styelidae,NA,Animalia,Chordata,Ascidiacea,Stolidobranchia,Styelidae,NA,Family,103450,NA,Remove,,,,,,, -Stylaster,Stylaster,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Genus,117246,NA,Remove,,,,,,, -Stylaster sp.,Stylaster,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Genus,117246,NA,Remove,,,,,,, -Stylaster alaskanus,Stylaster alaskanus,Alaskan hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,285846,NA,Species,,,,,,, -Stylaster cancellatus,Stylaster alaskanus,Alaskan hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,285846,NA,Species,,,,,,, -Stylaster brochi,Stylaster brochi,Rough orange hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,285858,NA,Species,,,,,,, -Stylaster campylecus,Stylaster campylecus,White branching hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,346433,NA,Species,,,,,,, -Stylaster moseleyana,Stylaster campylecus,White branching hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,346433,NA,Species,,,,,,, -Stylaster polyorchis,Stylaster campylecus,White branching hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,346433,NA,Species,,,,,,, -Stylaster crassiseptum,Stylaster crassiseptum,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,592254,NA,Species,,,,,,, -Stylaster elassotomus,Stylaster elassotomus,Smooth tube hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,285874,NA,Species,,,,,,, -Stylaster parageus,Stylaster parageus,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,592250,NA,Species,,,,,,, -Stylaster repandus,Stylaster repandus,Undulate hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,592243,NA,Species,,,,,,, -Stylaster stejnegeri,Stylaster stejnegeri,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,285910,NA,Species,,,,,,, -Stylaster trachystomus,Stylaster trachystomus,NA,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,592249,NA,Species,,,,,,, -Stylaster venustus,Stylaster venustus,Fuchsia lace hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,285914,NA,Species,,,,,,, -Stylaster verrilli,Stylaster verrillii,Pink branching lace hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,285915,NA,Species,,,,,,, -Stylaster verrillii,Stylaster verrillii,Pink branching lace hydrocoral,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,Stylaster,Species,285915,NA,Species,,,,,,, -Stylasterias,Stylasterias,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Stylasterias,Genus,146049,NA,Remove,,,,,,, -Stylasterias sp.,Stylasterias,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Stylasterias,Genus,146049,NA,Remove,,,,,,, -Stylasterias forreri,Stylasterias forreri,Velcro star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Asteriidae,Stylasterias,Species,255062,NA,Species,,,,,,, -Stylasteridae,Stylasteridae,Lace corals,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,NA,Family,22805,NA,Remove,,,,,,, -Stylasterina,Stylasteridae,Lace corals,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Stylasteridae,NA,Family,22805,NA,Remove,,,,,,, -Stylatula,Stylatula,slender seawhips,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Virgulariidae,Stylatula,Genus,128502,NA,Remove,,,,,,, -Stylatula sp.,Stylatula,slender seawhips,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Virgulariidae,Stylatula,Genus,128502,NA,Remove,,,,,,, -Stylatula antillarum,Stylatula antillarum,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Virgulariidae,Stylatula,Species,286690,NA,Species,,,,,,, -Stylatula gracile,Stylatula gracilis,Roughstem seawhip,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Virgulariidae,Stylatula,Species,1393629,NA,Species,,,,,,, -Stylatula gracilis,Stylatula gracilis,Roughstem seawhip,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Virgulariidae,Stylatula,Species,1393629,NA,Species,,,,,,, -Stylissa,Stylissa,NA,Animalia,Porifera,Demospongiae,Scopalinida,Scopalinidae,Stylissa,Genus,131781,NA,Remove,,,,,,, -Stylocidaris affinis,Stylocidaris affinis,Pencil urchin,Animalia,Echinodermata,Echinoidea,Cidaroida,Cidaridae,Stylocidaris,Species,124268,NA,Species,,,,,,, -Stylocordyla,Stylocordyla,lollypop sponge,Animalia,Porifera,Demospongiae,Suberitida,Stylocordylidae,Stylocordyla,Genus,132063,NA,Remove,,,,,,, -Stylocordyla sp.,Stylocordyla,lollypop sponge,Animalia,Porifera,Demospongiae,Suberitida,Stylocordylidae,Stylocordyla,Genus,132063,NA,Remove,,,,,,, -Stylocordyla borealis,Stylocordyla borealis,Boreal horny sponge,Animalia,Porifera,Demospongiae,Suberitida,Stylocordylidae,Stylocordyla,Species,134240,NA,Species,,,,,,, -Stylocordyla eous,Stylocordyla borealis eous,NA,Animalia,Porifera,Demospongiae,Suberitida,Stylocordylidae,Stylocordyla,subSpecies,170722,NA,subSpecies,,,,,,, -Stylocordyla borealis eous,Stylocordyla borealis eous,NA,Animalia,Porifera,Demospongiae,Suberitida,Stylocordylidae,Stylocordyla,subSpecies,170722,NA,subSpecies,,,,,,, -Suberites,Suberites,NA,Animalia,Porifera,Demospongiae,Suberitida,Suberitidae,Suberites,Genus,132072,NA,Remove,,,,,,, -Suberites sp.,Suberites,NA,Animalia,Porifera,Demospongiae,Suberitida,Suberitidae,Suberites,Genus,132072,NA,Remove,,,,,,, -Suberites domuncula,Suberites domuncula,Sea orange,Animalia,Porifera,Demospongiae,Suberitida,Suberitidae,Suberites,Species,134282,NA,Species,,,,,,, -Suberites ficus,Suberites ficus,Fig sponge,Animalia,Porifera,Demospongiae,Suberitida,Suberitidae,Suberites,Species,134285,NA,Species,,,,,,, -Suberites montalbidus,Suberites montalbidus,Stinky sponge,Animalia,Porifera,Demospongiae,Suberitida,Suberitidae,Suberites,Species,134297,NA,Species,,,,,,, -Suberites montiniger,Suberites montiniger,peach sponge,NA,NA,NA,NA,NA,NA,Species,134298,NA,Species,,,,,,, -Suberites sp. A (Clark 2006),Suberites sp. A (Clark 2006),wax sponge,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Sulcosinus taphrius,Sulcosinus taphrium,Sulcated whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Sulcosinus,Species,833966,NA,Species,,,,,,, -Sulcosinus taphrium,Sulcosinus taphrium,Sulcated whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Sulcosinus,Species,833966,NA,Species,,,,,,, -Swiftia,Swiftia,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Plexauridae,Swiftia,Genus,125314,NA,Remove,,,,,,, -Swiftia sp.,Swiftia,NA,Animalia,Cnidaria,Anthozoa,Malacalcyonacea,Plexauridae,Swiftia,Genus,125314,NA,Remove,,,,,,, -Syacium,Syacium,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Syacium,Genus,158875,NA,Remove,,,,,,, -Syacium gunteri,Syacium gunteri,Shoal flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Syacium,Species,275839,4231,Species,,,,,,, -Syacium micrurum,Syacium micrurum,Channel flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Syacium,Species,158877,4232,Species,,,,,,, -Syacium papillosum,Syacium papillosum,Dusky flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Syacium,Species,158878,4233,Species,,,,,,, -Sycon compactum,Sycon compactum,Betrothed calcareous sponge,Animalia,Porifera,Calcarea,Leucosolenida,Syconidae,Sycon,Species,164569,NA,Species,,,,,,, -Symbolophorus californiensis,Symbolophorus californiensis,Bigfin lanternfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Symbolophorus,Species,272733,5351,Species,,,,,,, -Symethis variolosa,Symethis variolosa,Eroded frog crab,Animalia,Arthropoda,Malacostraca,Decapoda,Raninidae,Symethis,Species,421904,NA,Species,,,,,,, -Symphurus,Symphurus,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Genus,126113,NA,Remove,,,,,,, -Symphurus sp,Symphurus,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Genus,126113,NA,Remove,,,,,,, -Symphurus atricauda,Symphurus atricauda,California tonguefish,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Species,305635,4262,Species,,,,,,, -Symphurus civitatum,Symphurus civitatum,Offshore tonguefish,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Species,305637,4263,Species,,,,,,, -Symphurus civitatus,Symphurus civitatum,Offshore tonguefish,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Species,305637,4263,Species,,,,,,, -Symphurus civitatium,Symphurus civitatum,Offshore tonguefish,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Species,305637,4263,Species,,,,,,, -Symphurus diomedianus,Symphurus diomedeanus,Spottedfin tonguefish,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Species,159358,1018,Species,,,,,,, -Symphurus diomedeanus,Symphurus diomedeanus,Spottedfin tonguefish,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Species,159358,1018,Species,,,,,,, -Symphurus marginatus,Symphurus marginatus,Margined tonguefish,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Species,159359,47499,Species,,,,,,, -Symphurus minor,Symphurus minor,Largescale tonguefish,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Species,159360,4264,Species,,,,,,, -Symphurus parvus,Symphurus parvus,Pygmy tonguefish,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Species,159362,4266,Species,,,,,,, -Symphurus pelicanus,Symphurus pelicanus,Longtail tonguefish,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Species,274267,4267,Species,,,,,,, -Symphurus plagiusa,Symphurus plagiusa,Blackcheek tonguefish,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Species,159363,1019,Species,,,,,,, -Symphurus pusillus,Symphurus pusillus,Northern tonguefish,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Species,159364,4269,Species,,,,,,, -Symphurus urospilus,Symphurus urospilus,Spottail tonguefish,Animalia,Chordata,Teleostei,Pleuronectiformes,Cynoglossidae,Symphurus,Species,274281,4270,Species,,,,,,, -Synagrops,Synagrops,NA,Animalia,Chordata,Teleostei,Acropomatiformes,Acropomatidae,Synagrops,Genus,159583,NA,Remove,,,,,,, -Synagrops bella,Synagrops bellus,Blackmouth bass,Animalia,Chordata,Teleostei,Acropomatiformes,Acropomatidae,Synagrops,Species,159584,3311,Species,,,,,,, -Synagrops bellus,Synagrops bellus,Blackmouth bass,Animalia,Chordata,Teleostei,Acropomatiformes,Acropomatidae,Synagrops,Species,159584,3311,Species,,,,,,, -Synallactes,Synallactes,NA,Animalia,Echinodermata,Holothuroidea,Synallactida,Synallactidae,Synallactes,Genus,123471,NA,Remove,,,,,,, -Synallactes sp.,Synallactes,NA,Animalia,Echinodermata,Holothuroidea,Synallactida,Synallactidae,Synallactes,Genus,123471,NA,Remove,,,,,,, -Synallactes challengeri,Synallactes challengeri,Challenger cucumber,Animalia,Echinodermata,Holothuroidea,Synallactida,Synallactidae,Synallactes,Species,529678,NA,Species,,,,,,, -Synallactes sp. A (Clark 2006),Synallactes sp. A (Clark 2006),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Synallactidae,Synallactidae,NA,Animalia,Echinodermata,Holothuroidea,Synallactida,Synallactidae,NA,Family,123185,NA,Remove,,,,,,, -Synalpheus,Synalpheus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Synalpheus,Genus,106982,NA,Remove,,,,,,, -Synalpheus fritzmuelleri,Synalpheus fritzmuelleri,Speckled snapping shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Synalpheus,Species,240870,NA,Species,,,,,,, -Synalpheus hemphilli,Synalpheus hemphilli,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Synalpheus,Species,421759,NA,Species,,,,,,, -Synalpheus longicarpus,Synalpheus longicarpus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Synalpheus,Species,421761,NA,Species,,,,,,, -Synalpheus minus,Synalpheus minus,Minor snapping shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Synalpheus,Species,421763,NA,Species,,,,,,, -Synalpheus townsendi,Synalpheus townsendi,Townsend snapping shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Alpheidae,Synalpheus,Species,421771,NA,Species,,,,,,, -Foetorepus goodenbeani,Synchiropus goodenbeani,Palefin dragonet,Animalia,Chordata,Teleostei,Callionymiformes,Callionymidae,Foetorepus,Species,712846,54437,Species,,,,,,, -Synchiropus goodenbeani,Synchiropus goodenbeani,Palefin dragonet,Animalia,Chordata,Teleostei,Callionymiformes,Callionymidae,Foetorepus,Species,712846,54437,Species,,,,,,, -Syngnathidae,Syngnathidae,Pipefishes and seahorses,Animalia,Chordata,Teleostei,Syngnathiformes,Syngnathidae,NA,Family,125606,NA,Remove,,,,,,, -Syngnathus,Syngnathus,NA,Animalia,Chordata,Teleostei,Syngnathiformes,Syngnathidae,Syngnathus,Genus,126227,NA,Remove,,,,,,, -Syngnathus floridae,Syngnathus floridae,Dusky pipefish,Animalia,Chordata,Teleostei,Syngnathiformes,Syngnathidae,Syngnathus,Species,159450,3300,Species,,,,,,, -Syngnathus fuscus,Syngnathus fuscus,Northern pipefish,Animalia,Chordata,Teleostei,Syngnathiformes,Syngnathidae,Syngnathus,Species,159451,3301,Species,,,,,,, -Syngnathus louisianae,Syngnathus louisianae,Chain pipefish,Animalia,Chordata,Teleostei,Syngnathiformes,Syngnathidae,Syngnathus,Species,159453,3304,Species,,,,,,, -Syngnathus pelagicus,Syngnathus pelagicus,Broadnosed pipefish,Animalia,Chordata,Teleostei,Syngnathiformes,Syngnathidae,Syngnathus,Species,367332,3305,Species,,,,,,, -Syngnathus springeri,Syngnathus springeri,Bull pipefish,Animalia,Chordata,Teleostei,Syngnathiformes,Syngnathidae,Syngnathus,Species,159454,3307,Species,,,,,,, -Synodontidae,Synodontidae,NA,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,NA,Family,125449,NA,Remove,,,,,,, -Synodus,Synodus,NA,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,Synodus,Genus,125686,NA,Remove,,,,,,, -Synodus foetens,Synodus foetens,Inshore lizardfish,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,Synodus,Species,158758,2719,Species,,,,,,, -Synodus intermedius,Synodus intermedius,Sand diver,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,Synodus,Species,158759,2720,Species,,,,,,, -Synodus lucioceps,Synodus lucioceps,California lizardfish,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,Synodus,Species,272132,2721,Species,,,,,,, -Synodus macrostigmus,Synodus macrostigmus,Largespot lizardfish,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,Synodus,Species,835034,68040,Species,,,,,,, -Synodus poeyi,Synodus poeyi,Offshore lizardfish,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,Synodus,Species,158760,2722,Species,,,,,,, -Synodus synodus,Synodus synodus,Diamond lizardfish,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,Synodus,Species,126373,2723,Species,,,,,,, -Synoicum,Synoicum,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polyclinidae,Synoicum,Genus,103479,NA,Remove,,,,,,, -Synoicum sp.,Synoicum,sea blob,Animalia,Chordata,Ascidiacea,Aplousobranchia,Polyclinidae,Synoicum,Genus,103479,NA,Remove,,,,,,, -Syphonota geographica,Syphonota geographica,NA,Animalia,Mollusca,Gastropoda,Aplysiida,Aplysiidae,Syphonota,Species,370566,NA,Species,,,,,,, -Systellaspis braueri,Systellaspis braueri,Quale spinytail,NA,NA,NA,NA,NA,NA,Species,107603,NA,Species,,,,,,, -Tachyrhynchus,Tachyrhynchus,NA,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Turritellidae,Tachyrhynchus,Genus,138614,NA,Remove,,,,,,, -Tachyrhynchus sp.,Tachyrhynchus,NA,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Turritellidae,Tachyrhynchus,Genus,138614,NA,Remove,,,,,,, -Tachyrhynchus erosus,Tachyrhynchus erosus,Eroded turretsnail,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Turritellidae,Tachyrhynchus,Species,196391,NA,Species,,,,,,, -Tactostoma macropus,Tactostoma macropus,Longfin dragonfish,Animalia,Chordata,Teleostei,Stomiiformes,Stomiidae,Tactostoma,Species,282922,2713,Species,,,,,,, -Tagelus,Tagelus,NA,Animalia,Mollusca,Bivalvia,Cardiida,Solecurtidae,Tagelus,Genus,156997,NA,Remove,,,,,,, -Talismania bifurcata,Talismania bifurcata,Threadfin slickhead,Animalia,Chordata,Teleostei,Alepocephaliformes,Alepocephalidae,Talismania,Species,272884,24576,Species,,,,,,, -Tamoya haplonema,Tamoya haplonema,NA,Animalia,Cnidaria,Cubozoa,Carybdeida,Tamoyidae,Tamoya,Species,288081,NA,Species,,,,,,, -Taningia danae,Taningia danae,Dana octopus squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Octopoteuthidae,Taningia,Species,140609,NA,Species,,,,,,, -Belonella borealis,Taonius borealis,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Cranchiidae,Belonella,Species,410406,NA,Species,,,,,,, -Taonius borealis,Taonius borealis,NA,Animalia,Mollusca,Cephalopoda,Oegopsida,Cranchiidae,Belonella,Species,410406,NA,Species,,,,,,, -Taonius pavo,Taonius pavo,Peacock cranch squid,Animalia,Mollusca,Cephalopoda,Oegopsida,Cranchiidae,Taonius,Species,139428,NA,Species,,,,,,, -Tarletonbeania,Tarletonbeania,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Tarletonbeania,Genus,271040,NA,Remove,,,,,,, -Tarletonbeania sp.,Tarletonbeania,NA,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Tarletonbeania,Genus,271040,NA,Remove,,,,,,, -Tarletonbeania crenularis,Tarletonbeania crenularis,Blue lanternfish,Animalia,Chordata,Teleostei,Myctophiformes,Myctophidae,Tarletonbeania,Species,282927,2738,Species,,,,,,, -Tarsaster alaskanus,Tarsaster alaskanus,Alaskan star,Animalia,Echinodermata,Asteroidea,Forcipulatida,Pedicellasteridae,Tarsaster,Species,255123,NA,Species,,,,,,, -Tautoga onitis,Tautoga onitis,Tautog,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Tautoga,Species,158830,458,Species,,,,,,, -Tautogolabrus adspersus,Tautogolabrus adspersus,Cunner,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Tautogolabrus,Species,159785,3672,Species,,,,,,, -Tedania sp.,Tedania,NA,NA,NA,NA,NA,NA,NA,Genus,NA,NA,Remove,,,,,,, -Tedania,Tedania (Tedania),NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Tedaniidae,Tedania,Genus,169545,NA,Remove,,,,,,, -Tedania dirhaphis,Tedania (Tedania) dirhaphis,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Tedaniidae,Tedania,Species,169558,NA,Species,,,,,,, -Tedania kagalaskai,Tedania (Tedania) kagalaskai,NA,Animalia,Porifera,Demospongiae,Poecilosclerida,Tedaniidae,Tedania,Species,225434,NA,Species,,,,,,, -Tegula pulligo,Tegula pulligo,Dusky tegula,Animalia,Mollusca,Gastropoda,Trochida,Tegulidae,Tegula,Species,534194,NA,Species,,,,,,, -Tellina,Tellina,NA,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Tellina,Genus,138533,NA,Remove,,,,,,, -Tellina sp.,Tellina,NA,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Tellina,Genus,138533,NA,Remove,,,,,,, -Tellina nuculoides,Tellina nuculoides,Salmon tellin,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Tellina,Species,582784,NA,Species,,,,,,, -Tellinella listeri,Tellinella listeri,NA,Animalia,Mollusca,Bivalvia,Cardiida,Tellinidae,Tellinella,Species,420901,NA,Species,,,,,,, -Telmessus cheiragonus,Telmessus cheiragonus,Helmet crab,Animalia,Arthropoda,Malacostraca,Decapoda,Cheiragonidae,Telmessus,Species,254360,NA,Species,,,,,,, -Careproctus candidus,Temnocora candida,Bigeye snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,282939,51554,Species,,,,,,, -Temnocora candida,Temnocora candida,Bigeye snailfish,Animalia,Chordata,Teleostei,Perciformes,Liparidae,Careproctus,Species,282939,51554,Species,,,,,,, -Tenagodus squamatus,Tenagodus squamatus,Slit wormsnail,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Siliquariidae,Tenagodus,Species,419540,NA,Species,,,,,,, -Tentorium semisuberites,Tentorium semisuberites,Pavilion horny sponge,Animalia,Porifera,Demospongiae,Polymastiida,Polymastiidae,Tentorium,Species,134224,NA,Species,,,,,,, -Terebellidae,Terebellidae,NA,Animalia,Annelida,Polychaeta,Terebellida,Terebellidae,NA,Family,982,NA,Remove,,,,,,, -Terebratalia transversa,Terebratalia transversa,Common lamp shell,Animalia,Brachiopoda,Rhynchonellata,Terebratulida,Terebrataliidae,Terebratalia,Species,235615,NA,Species,,,,,,, -Terebratellacea,Terebratellacea,Brachiopod,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Terebratulina,Terebratulina,NA,Animalia,Brachiopoda,Rhynchonellata,Terebratulida,Cancellothyrididae,Terebratulina,Genus,104040,NA,Remove,,,,,,, -Terebratulina sp.,Terebratulina,NA,Animalia,Brachiopoda,Rhynchonellata,Terebratulida,Cancellothyrididae,Terebratulina,Genus,104040,NA,Remove,,,,,,, -Terebratulina unguicula,Terebratulina unguicula,Snake's head lamp shell,Animalia,Brachiopoda,Rhynchonellata,Terebratulida,Cancellothyrididae,Terebratulina,Species,235529,NA,Species,,,,,,, -Teredinidae,Teredinidae,Shipworms,Animalia,Mollusca,Bivalvia,Myida,Teredinidae,NA,Family,253,NA,Remove,,,,,,, -Tethya,Tethya,ball sponge,Animalia,Porifera,Demospongiae,Tethyida,Tethyidae,Tethya,Genus,132077,NA,Remove,,,,,,, -Tethya sp.,Tethya,ball sponge,Animalia,Porifera,Demospongiae,Tethyida,Tethyidae,Tethya,Genus,132077,NA,Remove,,,,,,, -Tethyaster,Tethyaster,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Tethyaster,Genus,123257,NA,Remove,,,,,,, -Tethyaster grandis,Tethyaster grandis,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Tethyaster,Species,178717,NA,Species,,,,,,, -Tethyaster vestitus,Tethyaster vestitus,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Tethyaster,Species,178718,NA,Species,,,,,,, -Tethyaster vestitus vestitus,Tethyaster vestitus vestitus,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Tethyaster,Species,178719,NA,Species,,,,,,, -Donatiidae,Tethyidae,NA,Animalia,Porifera,Demospongiae,Tethyida,Donatiidae,NA,Family,131677,NA,Remove,,,,,,, -Tetragonuridae,Tetragonuridae,Squaretails,Animalia,Chordata,Teleostei,Scombriformes,Tetragonuridae,NA,Family,125569,NA,Remove,,,,,,, -Tetragonurus cuvieri,Tetragonurus cuvieri,Smalleye squaretail,Animalia,Chordata,Teleostei,Scombriformes,Tetragonuridae,Tetragonurus,Species,127080,1772,Species,,,,,,, -Tetraodontidae,Tetraodontidae,Puffers,Animalia,Chordata,Teleostei,Tetraodontiformes,Tetraodontidae,NA,Family,125612,NA,Remove,,,,,,, -Tetraxanthus,Tetraxanthus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Tetraxanthus,Genus,416059,NA,Remove,,,,,,, -Tetraxanthus rathbunae,Tetraxanthus rathbunae,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Tetraxanthus,Species,422119,NA,Species,,,,,,, -Torpedo californica,Tetronarce californica,Pacific electric ray,Animalia,Chordata,Elasmobranchii,Torpediniformes,Torpedinidae,Torpedo,Species,845703,2552,Species,,,,,,, -Torpedo nobiliana,Tetronarce nobiliana,Electric ray,Animalia,Chordata,Elasmobranchii,Torpediniformes,Torpedinidae,Torpedo,Species,321911,2553,Species,,,,,,, -Tetronarce nobiliana,Tetronarce nobiliana,Electric ray,Animalia,Chordata,Elasmobranchii,Torpediniformes,Torpedinidae,Torpedo,Species,321911,2553,Species,,,,,,, -Teuthida,Teuthida,NA,Animalia,Mollusca,Cephalopoda,Teuthida,NA,NA,Order,11716,NA,Remove,,,,,,, -Thaleichthys pacificus,Thaleichthys pacificus,Eulachon,Animalia,Chordata,Teleostei,Osmeriformes,Osmeridae,Thaleichthys,Species,282959,256,Species,,,,,,, -Thaliacea,Thaliacea,Salp unid.,Animalia,Chordata,Thaliacea,NA,NA,NA,Class,22626,NA,Remove,,,,,,, -Thetys vagina,Thetys vagina,Virgin salpa,Animalia,Chordata,Thaliacea,Salpida,Salpidae,Thetys,Species,137281,NA,Species,,,,,,, -Thoracica,Thoracica,True barnacles,Animalia,Arthropoda,Thecostraca,NA,NA,NA,InfraClass,1107,NA,Remove,,,,,,, -Amphilaphis,Thouarella,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Thouarella,Genus,125323,NA,Remove,,,,,,, -Thouarella,Thouarella,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Thouarella,Genus,125323,NA,Remove,,,,,,, -Thouarella sp.,Thouarella,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Thouarella,Genus,125323,NA,Remove,,,,,,, -Thouarella cristata,Thouarella cristata,Bottlebrush coral,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Primnoidae,Thouarella,Species,574232,NA,Species,,,,,,, -Thouarella sp. 1 (Bayer et al.),Thouarella sp. 1 (Bayer et al.),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Thouarella sp. 2 (Bayer et al.),Thouarella sp. 2 (Bayer et al.),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Thrissacanthias penicillatus,Thrissacanthias penicillatus,NA,Animalia,Echinodermata,Asteroidea,Paxillosida,Astropectinidae,Thrissacanthias,Species,292833,NA,Species,,,,,,, -Thunnus alalunga,Thunnus alalunga,Albacore,Animalia,Chordata,Teleostei,Scombriformes,Scombridae,Thunnus,Species,127026,142,Species,,,,,,, -Thyonella,Thyonella,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,Thyonella,Genus,158533,NA,Remove,,,,,,, -Thyonella gemmata,Thyonella gemmata,Green sea cucumber,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,Thyonella,Species,158534,NA,Species,,,,,,, -Thyonella pervicax,Thyonella pervicax,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,Thyonella,Species,422527,NA,Species,,,,,,, -Thyonidium,Thyonidium,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,Thyonidium,Genus,123503,NA,Remove,,,,,,, -Thyonidium sp.,Thyonidium,NA,Animalia,Echinodermata,Holothuroidea,Dendrochirotida,Cucumariidae,Thyonidium,Genus,123503,NA,Remove,,,,,,, -Thyriscus anoplus,Thyriscus anoplus,Sponge sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Thyriscus,Species,282971,51486,Species,,,,,,, -Gobiosoma macrodon,Tigrigobius macrodon,Tiger goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobiosoma,Species,1016103,3875,Species,,,,,,, -Elacatinus macrodon,Tigrigobius macrodon,Tiger goby,Animalia,Chordata,Teleostei,Gobiiformes,Gobiidae,Gobiosoma,Species,1016103,3875,Species,,,,,,, -Titanideum frauenfeldii,Titanideum frauenfeldii,Brilliant sea fingers,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Spongiodermidae,Titanideum,Species,291226,NA,Species,,,,,,, -Tochuina gigantea,Tochuina gigantea,Giant orange tochui,Animalia,Mollusca,Gastropoda,Nudibranchia,Tritoniidae,Tochuina,Species,572093,NA,Species,,,,,,, -Tonicella,Tonicella,NA,Animalia,Mollusca,Polyplacophora,Chitonida,Tonicellidae,Tonicella,Genus,138090,NA,Remove,,,,,,, -Tonicella sp.,Tonicella,NA,Animalia,Mollusca,Polyplacophora,Chitonida,Tonicellidae,Tonicella,Genus,138090,NA,Remove,,,,,,, -Tonicella insignis,Tonicella insignis,White line chiton,Animalia,Mollusca,Polyplacophora,Chitonida,Tonicellidae,Tonicella,Species,386440,NA,Species,,,,,,, -Tonna galea,Tonna galea,Giant tun,Animalia,Mollusca,Gastropoda,Littorinimorpha,Tonnidae,Tonna,Species,141687,NA,Species,,,,,,, -Tonna maculosa,Tonna pennata,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Tonnidae,Tonna,Species,410165,NA,Species,,,,,,, -Torellivelutina ammonia,Torellivelutina ammonia,Rams-horn snail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Torellivelutina,Species,580681,NA,Species,,,,,,, -Torpedinidae,Torpedinidae,Electric rays,Animalia,Chordata,Elasmobranchii,Torpediniformes,Torpedinidae,NA,Family,105718,NA,Remove,,,,,,, -Tozeuma serratum,Tozeuma serratum,Serrate arrow shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Hippolytidae,Tozeuma,Species,158376,NA,Species,,,,,,, -Trachinocephalus,Trachinocephalus,NA,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,Trachinocephalus,Genus,158883,NA,Remove,,,,,,, -Trachinocephalus myops,Trachinocephalus myops,Snakefish,Animalia,Chordata,Teleostei,Aulopiformes,Synodontidae,Trachinocephalus,Species,158884,2724,Species,,,,,,, -Trachinotus carolinus,Trachinotus carolinus,Florida pompano,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Trachinotus,Species,159652,380,Species,,,,,,, -Trachinotus falcatus,Trachinotus falcatus,Permit,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Trachinotus,Species,367285,1010,Species,,,,,,, -Trachipteridae,Trachipteridae,Ribbonfishes,Animalia,Chordata,Teleostei,Lampriformes,Trachipteridae,NA,Family,125483,NA,Remove,,,,,,, -Trachipterus altivelis,Trachipterus altivelis,King of-the-salmon,Animalia,Chordata,Teleostei,Lampriformes,Trachipteridae,Trachipterus,Species,272531,3264,Species,,,,,,, -Trachurus lathami,Trachurus lathami,Rough scad,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Trachurus,Species,159655,369,Species,,,,,,, -Trachurus symmetricus,Trachurus symmetricus,Jack mackerel,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Trachurus,Species,273305,368,Species,,,,,,, -Trachycardium,Trachycardium,NA,Animalia,Mollusca,Bivalvia,Cardiida,Cardiidae,Trachycardium,Genus,203976,NA,Remove,,,,,,, -Trachycaris rugosa,Trachycaris rugosa,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Hippolytidae,Trachycaris,Species,421786,NA,Species,,,,,,, -Trachypeneus,Trachypeneus,Trachypeneid shrimps,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Trapezioplax tridentata,Trapezioplax tridentata,Spined broadface crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pseudorhombilidae,Trapezioplax,Species,422066,NA,Species,,,,,,, -Travisia pupa,Travisia pupa,Pupa utility worm,Animalia,Annelida,Polychaeta,NA,Travisiidae,Travisia,Species,254764,NA,Species,,,,,,, -Tremoctopus violaceus,Tremoctopus violaceus,Banket octopods,Animalia,Mollusca,Cephalopoda,Octopoda,Tremoctopodidae,Temoctopus,Species,141694,NA,Species,,,,,,, -Tresus capax,Tresus capax,Fat gaper,Animalia,Mollusca,Bivalvia,Venerida,Mactridae,Tresus,Species,367776,NA,Species,,,,,,, -Tretocidaris bartletti,Tretocidaris bartletti,NA,Animalia,Echinodermata,Echinoidea,Cidaroida,Cidaridae,Tretocidaris,Species,422484,NA,Species,,,,,,, -Triakidae,Triakidae,NA,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Triakidae,NA,Family,105695,NA,Remove,,,,,,, -Triakis semifasciata,Triakis semifasciata,Leopard shark,Animalia,Chordata,Elasmobranchii,Carcharhiniformes,Triakidae,Triakis,Species,279060,2543,Species,,,,,,, -Trichiuridae,Trichiuridae,NA,Animalia,Chordata,Teleostei,Scombriformes,Trichiuridae,NA,Family,125571,NA,Remove,,,,,,, -Trichiurus lepturus,Trichiurus lepturus,Atlantic cutlassfish,Animalia,Chordata,Teleostei,Scombriformes,Trichiuridae,Trichiurus,Species,127089,1288,Species,,,,,,, -Trichocottus brashnikovi,Trichocottus brashnikovi,Hairhead sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Trichocottus,Species,254355,61288,Species,,,,,,, -Trichodon trichodon,Trichodon trichodon,Pacific sandfish,Animalia,Chordata,Teleostei,Perciformes,Trichodontidae,Trichodon,Species,283043,3682,Species,,,,,,, -Trichopsetta,Trichopsetta,NA,Animalia,Chordata,Teleostei,Pleuronectiformes,Bothidae,Trichopsetta,Genus,159214,NA,Remove,,,,,,, -Trichopsetta ventralis,Trichopsetta ventralis,Sash flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Bothidae,Trichopsetta,Species,159217,4234,Species,,,,,,, -Trichotropis bicarinata,Trichotropis bicarinata,Two keel hairysnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Capulidae,Trichotropis,Species,160421,NA,Species,,,,,,, -Trididemnum opacum,Trididemnum opacum,Purple-gray ascidian,Animalia,Chordata,Ascidiacea,Aplousobranchia,Didemnidae,Trididemnum,Species,251518,NA,Species,,,,,,, -Trididemnum savignii,Trididemnum savignii,NA,Animalia,Chordata,Ascidiacea,Aplousobranchia,Didemnidae,Trididemnum,Species,251534,NA,Species,,,,,,, -Triglidae,Triglidae,NA,Animalia,Chordata,Teleostei,Perciformes,Triglidae,NA,Family,125598,NA,Remove,,,,,,, -Triglops,Triglops,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Triglops,Genus,126154,NA,Remove,,,,,,, -Triglops sp.,Triglops,NA,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Triglops,Genus,126154,NA,Remove,,,,,,, -Triglops forficata,Triglops forficatus,Scissortail sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Triglops,Species,254530,4144,Species,,,,,,, -Triglops forficatus,Triglops forficatus,Scissortail sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Triglops,Species,254530,4144,Species,,,,,,, -Triglops macellus,Triglops macellus,Roughspine sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Triglops,Species,274399,4145,Species,,,,,,, -Triglops metopias,Triglops metopias,Alaskan sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Triglops,Species,274400,11734,Species,,,,,,, -Triglops murrayi,Triglops murrayi,Moustache sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Triglops,Species,127205,4146,Species,,,,,,, -Triglops pingeli,Triglops pingelii,Ribbed sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Triglops,Species,127207,4148,Species,,,,,,, -Triglops pingelii,Triglops pingelii,Ribbed sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Triglops,Species,127207,4148,Species,,,,,,, -Triglops scepticus,Triglops scepticus,Spectacled sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Triglops,Species,254531,4149,Species,,,,,,, -Triglops xenostethus,Triglops xenostethus,Scaly breasted sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Triglops,Species,274401,11883,Species,,,,,,, -Trinectes inscriptus,Trinectes inscriptus,Scrawled sole,Animalia,Chordata,Teleostei,Pleuronectiformes,Achiridae,Trinectes,Species,276000,4259,Species,,,,,,, -Trinectes maculatus,Trinectes maculatus,Hogchoker,Animalia,Chordata,Teleostei,Pleuronectiformes,Achiridae,Trinectes,Species,159271,4260,Species,,,,,,, -Triopha catalinae,Triopha catalinae,Sea clown triopha,Animalia,Mollusca,Gastropoda,Nudibranchia,Polyceridae,Triopha,Species,531258,NA,Species,,,,,,, -Pleuroploca gigantea,Triplofusus giganteus,Florida horse conch,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Pleuroploca,Species,420051,NA,Species,,,,,,, -Fasciolaria papillosa,Triplofusus giganteus,Florida horse conch,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Triplofusus,Species,420051,NA,Species,,,,,,, -Triplofusus giganteus,Triplofusus giganteus,Florida horse conch,Animalia,Mollusca,Gastropoda,Neogastropoda,Fasciolariidae,Triplofusus,Species,420051,NA,Species,,,,,,, -Tripoplax abyssicola,Tripoplax abyssicola,Bering chiton,Animalia,Mollusca,Polyplacophora,Chitonida,Ischnochitonidae,Tripoplax,Species,386093,NA,Species,,,,,,, -Tripoplax beringiana,Tripoplax beringiana,Deepsea chiton,Animalia,Mollusca,Polyplacophora,Chitonida,Ischnochitonidae,Tripoplax,Species,386100,NA,Species,,,,,,, -Tripoplax trifida,Tripoplax trifida,Three rib chiton,Animalia,Mollusca,Polyplacophora,Chitonida,Ischnochitonidae,Tripoplax,Species,386109,NA,Species,,,,,,, -Tritonia,Tritonia,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Tritoniidae,Tritonia,Genus,138580,NA,Remove,,,,,,, -Tritonia sp.,Tritonia,NA,Animalia,Mollusca,Gastropoda,Nudibranchia,Tritoniidae,Tritonia,Genus,138580,NA,Remove,,,,,,, -Tritonia festiva,Tritonia festiva,Diamondback tritonia,Animalia,Mollusca,Gastropoda,Nudibranchia,Tritoniidae,Tritonia,Species,549413,NA,Species,,,,,,, -Tochuina tetraquetra,Tritonia tetraquetra,Large orange peel nudibranch,Animalia,Mollusca,Gastropoda,Nudibranchia,Tritoniidae,Tochuina,Species,851422,NA,Species,,,,,,, -Tritonia diomedea,Tritonia tetraquetra,Large orange peel nudibranch,Animalia,Mollusca,Gastropoda,Nudibranchia,Tritoniidae,Tritonia,Species,851422,NA,Species,,,,,,, -Tritonia tetraquetra,Tritonia tetraquetra,Large orange peel nudibranch,Animalia,Mollusca,Gastropoda,Nudibranchia,Tritoniidae,Tritonia,Species,851422,NA,Species,,,,,,, -Trochidae,Trochidae,Top shells,Animalia,Mollusca,Gastropoda,Trochida,Trochidae,NA,Family,443,NA,Remove,,,,,,, -Trochus,Trochus,NA,Animalia,Mollusca,Gastropoda,Trochida,Trochidae,Trochus,Genus,138598,NA,Remove,,,,,,, -Pinnixa chaetopterana,Tubicolixa chaetopterana,Tube pea crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pinnotheridae,Pinnixa,Species,1424673,NA,Species,,,,,,, -Tubulanus,Tubulanus,NA,Animalia,Nemertea,Palaeonemertea,Tubulaniformes,Tubulanidae,Tubulanus,Genus,122388,NA,Remove,,,,,,, -Tubulanus polymorphus,Tubulanus polymorphus,Orange ribbon worm,Animalia,Nemertea,Palaeonemertea,Tubulaniformes,Tubulanidae,Tubulanus,Species,122637,NA,Species,,,,,,, -Tubulanus sp. A (Clark 2006),Tubulanus sp. A (Clark 2006),red ribbon worm,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Tubulipora,Tubulipora,NA,Animalia,Bryozoa,Stenolaemata,Cyclostomatida,Tubuliporidae,Tubulipora,Genus,111054,NA,Remove,,,,,,, -Tubulipora sp.,Tubulipora,NA,Animalia,Bryozoa,Stenolaemata,Cyclostomatida,Tubuliporidae,Tubulipora,Genus,111054,NA,Remove,,,,,,, -Pinnotheres maculatus,Tumidotheres maculatus,Squatter pea crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pinnotheridae,Pinnotheres,Species,158460,NA,Species,,,,,,, -Tumidotheres maculatus,Tumidotheres maculatus,Squatter pea crab,Animalia,Arthropoda,Malacostraca,Decapoda,Pinnotheridae,Pinnotheres,Species,158460,NA,Species,,,,,,, -Tunicata,Tunicata,Sea squirts,Animalia,Chordata,NA,NA,NA,NA,Subphylum,146420,NA,Remove,,,,,,, -Turbellaria,Turbellaria,NA,Animalia,Platyhelminthes,Turbellaria,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Turbinidae,Turbinidae,NA,Animalia,Mollusca,Gastropoda,Trochida,Turbinidae,NA,Family,503,NA,Remove,,,,,,, -Turbo,Turbo,NA,Animalia,Mollusca,Gastropoda,Trochida,Turbinidae,Turbo,Genus,151576,NA,Remove,,,,,,, -Turbo castaneus,Turbo castanea,NA,Animalia,Mollusca,Gastropoda,Trochida,Turbinidae,Turbo,Species,528089,NA,Species,,,,,,, -Turbo castanea,Turbo castanea,NA,Animalia,Mollusca,Gastropoda,Trochida,Turbinidae,Turbo,Species,528089,NA,Species,,,,,,, -Turris,Turris,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Turridae,Turris,Genus,153926,NA,Remove,,,,,,, -Turritella acropora,Turritella acropora,Boring turretsnail,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Turritellidae,Turritella,Species,419541,NA,Species,,,,,,, -Turritella exoleta,Turritella exoleta,Eastern turretsnail,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Turritellidae,Turritella,Species,419542,NA,Species,,,,,,, -Tyche,Tyche,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Tyche,Genus,416115,NA,Remove,,,,,,, -Tyche emarginata,Tyche emarginata,Fourhorn crab,Animalia,Arthropoda,Malacostraca,Decapoda,Epialtidae,Tyche,Species,422022,NA,Species,,,,,,, -Tylosurus acus,Tylosurus acus,Agujon needlefish,Animalia,Chordata,Teleostei,Beloniformes,Belonidae,Tylosurus,Species,126378,976,Species,,,,,,, -Tylosurus crocodilus,Tylosurus crocodilus,Hound needlefish,Animalia,Chordata,Teleostei,Beloniformes,Belonidae,Tylosurus,Species,159259,977,Species,,,,,,, -Ulvaria subbifurcata,Ulvaria subbifurcata,Radiated shanny,Animalia,Chordata,Teleostei,Perciformes,Stichaeidae,Ulvaria,Species,159821,3796,Species,,,,,,, -Umbellula,Umbellula,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Umbellulidae,Umbellula,Genus,128499,NA,Remove,,,,,,, -Umbellula sp.,Umbellula,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Umbellulidae,Umbellula,Genus,128499,NA,Remove,,,,,,, -Umbellulidae,Umbellulidae,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Umbellulidae,NA,Family,128486,NA,Remove,,,,,,, -Umbraculum,Umbraculum,NA,Animalia,Mollusca,Gastropoda,Umbraculida,Umbraculidae,Umbraculum,Genus,138620,NA,Remove,,,,,,, -Umbraculum plicatulum,Umbraculum umbraculum,NA,Animalia,Mollusca,Gastropoda,Umbraculida,Umbraculidae,Umbraculum,Species,141879,NA,Species,,,,,,, -Umbraculum umbraculum,Umbraculum umbraculum,NA,Animalia,Mollusca,Gastropoda,Umbraculida,Umbraculidae,Umbraculum,Species,141879,NA,Species,,,,,,, -Umbrina coroides,Umbrina coroides,Sand drum,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Sciaenidae,Umbrina,Species,159338,1199,Species,,,,,,, -Unidentified fish,Unidentified fish,NA,NA,NA,NA,NA,NA,NA,Remove,NA,NA,Remove,,,,,,, -Unidentified specimen,Unidentified specimen,NA,NA,NA,NA,NA,NA,NA,Remove,NA,NA,Remove,,,,,,, -Unionidae,Unionidae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Upeneus parvus,Upeneus parvus,Dwarf goatfish,Animalia,Chordata,Teleostei,Mulliformes,Mullidae,Upeneus,Species,159422,1095,Species,,,,,,, -Upogebia affinis,Upogebia affinis,Coastal mud shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Upogebiidae,Upogebia,Species,158389,NA,Species,,,,,,, -Upogebia pugettensis,Upogebia pugettensis,Blue mud shrimp,Animalia,Arthropoda,Malacostraca,Decapoda,Upogebiidae,Upogebia,Species,367757,NA,Species,,,,,,, -Uranoscopidae,Uranoscopidae,NA,Animalia,Chordata,Teleostei,Perciformes,Uranoscopidae,NA,Family,125573,NA,Remove,,,,,,, -Uraspis secunda,Uraspis secunda,Cottonmouth jack,Animalia,Chordata,Teleostei,Carangiformes,Carangidae,Uraspis,Species,159658,1012,Species,,,,,,, -Urobatis,Urobatis,NA,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Urotrygonidae,Urobatis,Genus,271193,NA,Remove,,,,,,, -Urolophus jamaicencis,Urobatis jamaicensis,Yellow stingray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Urolophidae,Urolophus,Species,283086,2581,Species,,,,,,, -Urobatis jamaicensis,Urobatis jamaicensis,Yellow stingray,Animalia,Chordata,Elasmobranchii,Myliobatiformes,Urolophidae,Urolophus,Species,283086,2581,Species,,,,,,, -Uroconger,Uroconger,NA,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Uroconger,Genus,158573,NA,Remove,,,,,,, -Uroconger syringinus,Uroconger syringinus,Threadtail conger,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Uroconger,Species,158574,2632,Species,,,,,,, -Urophycis,Urophycis,NA,Animalia,Chordata,Teleostei,Gadiformes,Phycidae,Urophycis,Genus,125774,NA,Remove,,,,,,, -Urophycis sp,Urophycis,NA,Animalia,Chordata,Teleostei,Gadiformes,Phycidae,Urophycis,Genus,125774,NA,Remove,,,,,,, -Urophycis n sp cf earllii,Urophycis,NA,Animalia,Chordata,Teleostei,Gadiformes,Phycidae,Urophycis,Genus,125774,NA,Remove,,,,,,, -Urophycis chuss,Urophycis chuss,Red hake,Animalia,Chordata,Teleostei,Gadiformes,Phycidae,Urophycis,Species,126503,312,Species,,,,,,, -Urophycis cirratus,Urophycis cirrata,Gulf hake,Animalia,Chordata,Teleostei,Gadiformes,Phycidae,Urophycis,Species,272520,1884,Species,,,,,,, -Urophycis cirrata,Urophycis cirrata,Gulf hake,Animalia,Chordata,Teleostei,Gadiformes,Phycidae,Urophycis,Species,272520,1884,Species,,,,,,, -Urophycis earlli,Urophycis earllii,Carolina hake,Animalia,Chordata,Teleostei,Gadiformes,Phycidae,Urophycis,Species,158989,1885,Species,,,,,,, -Urophycis earllii,Urophycis earllii,Carolina hake,Animalia,Chordata,Teleostei,Gadiformes,Phycidae,Urophycis,Species,158989,1885,Species,,,,,,, -Urophycis floridana,Urophycis floridana,Southern hake,Animalia,Chordata,Teleostei,Gadiformes,Phycidae,Urophycis,Species,158990,1882,Species,,,,,,, -Urophycis floridanus,Urophycis floridana,Southern hake,Animalia,Chordata,Teleostei,Gadiformes,Phycidae,Urophycis,Species,158990,1882,Species,,,,,,, -Urophycis regia,Urophycis regia,Spotted hake,Animalia,Chordata,Teleostei,Gadiformes,Phycidae,Urophycis,Species,158991,1883,Species,,,,,,, -Urophycis tenuis,Urophycis tenuis,White hake,Animalia,Chordata,Teleostei,Gadiformes,Phycidae,Urophycis,Species,126504,313,Species,,,,,,, -Urosalpinx cinerea,Urosalpinx cinerea,Atlantic oyster drill,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Urosalpinx,Species,140429,NA,Species,,,,,,, -Urticina,Urticina,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actiniidae,Urticina,Genus,100706,NA,Remove,,,,,,, -Urticina sp.,Urticina,NA,Animalia,Cnidaria,Anthozoa,Actiniaria,Actiniidae,Urticina,Genus,100706,NA,Remove,,,,,,, -Urticina columbiana,Urticina columbiana,Crusty red anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Actiniidae,Urticina,Species,283440,NA,Species,,,,,,, -Urticina coriacea,Urticina coriacea,Leathery anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Actiniidae,Urticina,Species,283441,NA,Species,,,,,,, -Urticina crassicornis,Urticina crassicornis,Mottled anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Actiniidae,Urticina,Species,100832,NA,Species,,,,,,, -Urticina lofotensis,Urticina eques,Spotted red anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Actiniidae,Urticina,Species,100833,NA,Species,,,,,,, -Urticina eques,Urticina eques,Spotted red anemone,Animalia,Cnidaria,Anthozoa,Actiniaria,Actiniidae,Urticina,Species,100833,NA,Species,,,,,,, -Urticina piscivora,Urticina piscivora,Fisheating anemone,Animalia,Cnidaria,Hexacorallia,Actiniaria,Actiniidae,Urticina,Species,283445,NA,Species,,,,,,, -Vampyroteuthis infernalis,Vampyroteuthis infernalis,Vampire squid,Animalia,Mollusca,Cephalopoda,Vampyromorpha,Vampyroteuthidae,Vampyroteuthis,Species,141887,NA,Species,,,,,,, -Varicorbula,Varicorbula,NA,Animalia,Mollusca,Bivalvia,Myida,Corbulidae,Varicorbula,Genus,378491,NA,Remove,,,,,,, -Vase sponge,Vase sponge,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Velella velella,Velella velella,By the-wind sailor,Animalia,Cnidaria,Hydrozoa,Anthoathecata,Porpitidae,Velella,Species,117832,NA,Species,,,,,,, -Velutina,Velutina,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Velutina,Genus,138631,NA,Remove,,,,,,, -Velutina sp.,Velutina,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Velutina,Genus,138631,NA,Remove,,,,,,, -Velutina plicatilis,Velutina plicatilis,Oblique lamellaria,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Velutina,Species,141902,NA,Species,,,,,,, -Velutina rubra,Velutina plicatilis,Oblique lamellaria,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Velutina,Species,141902,NA,Species,,,,,,, -Velutina velutina,Velutina velutina,Smooth lamellaria,Animalia,Mollusca,Gastropoda,Littorinimorpha,Velutinidae,Velutina,Species,141905,NA,Species,,,,,,, -Venefica,Venefica,NA,Animalia,Chordata,Teleostei,Anguilliformes,Nettastomatidae,Venefica,Genus,125643,NA,Remove,,,,,,, -Venefica tentaculata,Venefica tentaculata,NA,Animalia,Chordata,Teleostei,Anguilliformes,Nettastomatidae,Venefica,Species,271922,22599,Species,,,,,,, -Veneridae,Veneridae,NA,Animalia,Mollusca,Bivalvia,Venerida,Veneridae,NA,Family,243,NA,Remove,,,,,,, -Vermicularia,Vermicularia,NA,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Turritellidae,Vermicularia,Genus,160073,NA,Remove,,,,,,, -Vermicularia knorri,Vermicularia knorrii,Florida wormsnail,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Turritellidae,Vermicularia,Species,419546,NA,Species,,,,,,, -Vermicularia knorrii,Vermicularia lumbricalis,NA,Animalia,Mollusca,Gastropoda,Caenogastropoda incertae sedis,Turritellidae,Vermicularia,Species,709461,NA,Species,,,,,,, -Vermicularia spirata,Vermicularia spirata,West indian wormsnail,Animalia,Mollusca,Gastropoda,[unassigned] Caenogastropoda,Turritellidae,Vermicularia,Species,160074,NA,Species,,,,,,, -Vesicomya pacifica,Vesicomya pacifica,NA,Animalia,Mollusca,Bivalvia,Venerida,Vesicomyidae,Vesicomya,Species,464378,NA,Species,,,,,,, -Vesicomyidae,Vesicomyidae,NA,Animalia,Mollusca,Bivalvia,Venerida,Vesicomyidae,NA,Family,23140,NA,Remove,,,,,,, -Crenella seminuda,Vilasina seminuda,Partly sculptured crenella,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Vilasina,Species,506194,NA,Species,,,,,,, -Vilasina seminuda,Vilasina seminuda,Partly sculptured crenella,Animalia,Mollusca,Bivalvia,Mytilida,Mytilidae,Vilasina,Species,506194,NA,Species,,,,,,, -Vinciguerria sp,Vinciguerria,NA,Animalia,Chordata,Teleostei,Stomiiformes,Phosichthyidae,Vinciguerria,Genus,126194,NA,Remove,,,,,,, -Virgularia,Virgularia,smoothstem seawhip,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Virgulariidae,Virgularia,Genus,128503,NA,Remove,,,,,,, -Virgularia sp.,Virgularia,smoothstem seawhip,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Virgulariidae,Virgularia,Genus,128503,NA,Remove,,,,,,, -Virgulariidae,Virgulariidae,NA,Animalia,Cnidaria,Anthozoa,Scleralcyonacea,Virgulariidae,NA,Family,128488,NA,Remove,,,,,,, -Murex cabritti,Vokesimurex cabritii,Cabrit murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Murex,Species,405198,NA,Species,,,,,,, -Vokesimurex cabritii,Vokesimurex cabritii,Cabrit murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Murex,Species,405198,NA,Species,,,,,,, -Murex donmoorei,Vokesimurex donmoorei,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Vokesimurex,Species,405205,NA,Species,,,,,,, -Vokesimurex donmoorei,Vokesimurex donmoorei,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Vokesimurex,Species,405205,NA,Species,,,,,,, -Murex bellegladeensis,Vokesimurex sallasi,Belleglade murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Murex,Species,405229,NA,Species,,,,,,, -Vokesimurex bellegladeensis,Vokesimurex sallasi,Belleglade murex,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Murex,Species,405229,NA,Species,,,,,,, -Murex tyroni,Vokesimurex tryoni,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Murex,Species,138196,NA,Species,,,,,,, -Vokesimurex tryoni,Vokesimurex tryoni,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Murex,Species,138196,NA,Species,,,,,,, -Volutomitra,Volutomitra,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutomitridae,Volutomitra,Genus,138662,NA,Remove,,,,,,, -Volutomitra sp.,Volutomitra,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutomitridae,Volutomitra,Genus,138662,NA,Remove,,,,,,, -Volutomitra alaskana,Volutomitra groenlandica,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutomitridae,Volutomitra,Species,141968,NA,Species,,,,,,, -Volutomitra groenlandica,Volutomitra groenlandica,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Volutomitridae,Volutomitra,Species,141968,NA,Species,,,,,,, -Volutomitra sp. A (Clark and McLean),Volutomitra sp. A (Clark and McLean),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Volutopsius,Volutopsius,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Volutopsius,Genus,137715,NA,Remove,,,,,,, -Volutopsius sp.,Volutopsius,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Volutopsius,Genus,137715,NA,Remove,,,,,,, -Volutopsius castanea,Volutopsius castaneus,Volute whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Volutopsius,Species,254481,NA,Species,,,,,,, -Volutopsius castaneus,Volutopsius castaneus,Volute whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Volutopsius,Species,254481,NA,Species,,,,,,, -Volutopsius fragilis,Volutopsius fragilis,Fragile whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Volutopsius,Species,491385,NA,Species,,,,,,, -Volutopsius middendorffi,Volutopsius middendorffi,Tulip whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Volutopsius,Species,491386,NA,Species,,,,,,, -Volutopsius pallidus,Volutopsius pallidus,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Volutopsius,Species,491387,NA,Species,,,,,,, -Volutopsius regularis,Volutopsius regularis,Regular whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Volutopsius,Species,491388,NA,Species,,,,,,, -Volutopsius simplex,Volutopsius simplex,Volute whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Volutopsius,Species,510379,NA,Species,,,,,,, -Volutopsius sp. A (McLean and Clark),Volutopsius sp. A (McLean and Clark),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Volutopsius sp. C (Clark and McLean),Volutopsius sp. C (Clark and McLean),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Volutopsius sp. D (Clark and McLean),Volutopsius sp. D (Clark and McLean),NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Volutopsius sp. eggs,Volutopsius sp. eggs,NA,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Volutopsius stefanssoni,Volutopsius stefanssoni,Shouldered whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Volutopsius,Species,510380,NA,Species,,,,,,, -Volutopsius trophonius,Volutopsius trophonius,Frilled whelk,Animalia,Mollusca,Gastropoda,Neogastropoda,Buccinidae,Volutopsius,Species,491389,NA,Species,,,,,,, -Vulcanella,Vulcanella,NA,Chromista,Bacillariophyta,Bacillariophyceae,NA,NA,Vulcanella,Genus,602186,NA,Remove,,,,,,, -Vulcanella sp.,Vulcanella,NA,Chromista,Bacillariophyta,Bacillariophyceae,NA,NA,Vulcanella,Genus,602186,NA,Remove,,,,,,, -Vulcanella sp. 1,Vulcanella sp. 1,fuzzy cratered sponge,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Boreotrophon elegantulus,Warenia elegantula,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Boreotrophon,Species,1329549,NA,Species,,,,,,, -Warenia elegantula,Warenia elegantula,NA,Animalia,Mollusca,Gastropoda,Neogastropoda,Muricidae,Boreotrophon,Species,1329549,NA,Species,,,,,,, -Weberella bursa,Weberella bursa,Pale mammilated sponge,Animalia,Porifera,Demospongiae,Polymastiida,Polymastiidae,Weberella,Species,134232,NA,Species,,,,,,, -White claypipe sponge,White claypipe sponge,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Xanthidae,Xanthidae,Mud crabs,Animalia,Arthropoda,Malacostraca,Decapoda,Xanthidae,NA,Family,106769,NA,Remove,,,,,,, -Xanthoidea,Xanthoidea,NA,Animalia,Arthropoda,Malacostraca,Decapoda,NA,NA,SuperFamily,106703,NA,Remove,,,,,,, -Xeneretmus latifrons,Xeneretmus latifrons,Blacktip poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Xeneretmus,Species,283171,4173,Species,,,,,,, -Xeneretmus leiops,Xeneretmus leiops,Smooth eye poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Xeneretmus,Species,283172,4174,Species,,,,,,, -Xeneretmus triacanthus,Xeneretmus triacanthus,Bluespotted poacher,Animalia,Chordata,Teleostei,Perciformes,Agonidae,Xeneretmus,Species,283174,4176,Species,,,,,,, -Gnathagnus egregius,Xenocephalus egregius,Freckled stargazer,Animalia,Chordata,Teleostei,Perciformes,Uranoscopidae,Xenocephalus,Species,394993,3705,Species,,,,,,, -Xenocephalus egregius,Xenocephalus egregius,Freckled stargazer,Animalia,Chordata,Teleostei,Perciformes,Uranoscopidae,Xenocephalus,Species,394993,3705,Species,,,,,,, -Xenolepidichthys dalgleishi,Xenolepidichthys dalgleishi,Spotted tinselfish,Animalia,Chordata,Teleostei,Zeiformes,Grammicolepididae,Xenolepidichthys,Species,159432,3257,Species,,,,,,, -Xenomystax bidentatus,Xenomystax bidentatus,NA,Animalia,Chordata,Teleostei,Anguilliformes,Congridae,Xenomystax,Species,283190,NA,Species,,,,,,, -Xenophora,Xenophora,NA,Animalia,Mollusca,Gastropoda,Littorinimorpha,Xenophoridae,Xenophora,Genus,138664,NA,Remove,,,,,,, -Tugurium caribaeum,Xenophora caribaea,Caribbean carriersnail,NA,NA,Gastropoda,Littorinimorpha,Xenophoridae,NA,NotWrms,NA,NA,Species,,,,,,, -Xenophora conchyliophora,Xenophora conchyliophora,American carriersnail,Animalia,Mollusca,Gastropoda,Littorinimorpha,Xenophoridae,Xenophora,Species,743840,NA,Species,,,,,,, -Xiphias gladius,Xiphias gladius,Swordfish,Animalia,Chordata,Teleostei,Carangiformes,Xiphiidae,Xiphias,Species,127094,226,Species,,,,,,, -Xiphopenaeus,Xiphopenaeus,NA,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Xiphopenaeus,Genus,377401,NA,Remove,,,,,,, -Xiphopenaeus kroyeri,Xiphopenaeus kroyeri,Atlantic seabob,Animalia,Arthropoda,Malacostraca,Decapoda,Penaeidae,Xiphopenaeus,Species,377690,NA,Species,,,,,,, -Xyrichtys,Xyrichtys,NA,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Xyrichtys,Genus,126025,NA,Remove,,,,,,, -Hemipteronotus martinicensis,Xyrichtys martinicensis,Rosy razorfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Hemipteronotus,Species,273602,3668,Species,,,,,,, -Xyrichtys martinicensis,Xyrichtys martinicensis,Rosy razorfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Hemipteronotus,Species,273602,3668,Species,,,,,,, -Hemipteronotus novacula,Xyrichtys novacula,Pearly razorfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Xyrichtys,Species,126971,4581,Species,,,,,,, -Xyrichtys novacula,Xyrichtys novacula,Pearly razorfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Xyrichtys,Species,126971,4581,Species,,,,,,, -Hemipteronotus splendens,Xyrichtys splendens,Green razorfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Hemipteronotus,Species,273608,3669,Species,,,,,,, -Xyrichtys splendens,Xyrichtys splendens,Green razorfish,Animalia,Chordata,Teleostei,Eupercaria incertae sedis,Labridae,Hemipteronotus,Species,273608,3669,Species,,,,,,, -Xystreurys liolepis,Xystreurys liolepis,Fantail flounder,Animalia,Chordata,Teleostei,Pleuronectiformes,Paralichthyidae,Xystreurys,Species,283199,4235,Species,,,,,,, -Yellow bowl sponge,Yellow bowl sponge,NA,NA,NA,NA,NA,NA,NA,Remove,NA,NA,Remove,,,,,,, -Yoldia,Yoldia,NA,Animalia,Mollusca,Bivalvia,Nuculanida,Yoldiidae,Yoldia,Genus,138672,NA,Remove,,,,,,, -Yoldia sp.,Yoldia,NA,Animalia,Mollusca,Bivalvia,Nuculanida,Yoldiidae,Yoldia,Genus,138672,NA,Remove,,,,,,, -Yoldia seminuda,Yoldia aeolica,Oblique lined yoldia,Animalia,Mollusca,Bivalvia,Nuculanida,Yoldiidae,Yoldia,Species,867964,NA,Species,,,,,,, -Yoldia aeolica,Yoldia aeolica,Oblique lined yoldia,Animalia,Mollusca,Bivalvia,Nuculanida,Yoldiidae,Yoldia,Species,867964,NA,Species,,,,,,, -Yoldia hyperborea,Yoldia hyperborea,Northern yoldia,Animalia,Mollusca,Bivalvia,Nuculanida,Yoldiidae,Yoldia,Species,141989,NA,Species,,,,,,, -Yoldia myalis,Yoldia myalis,Oval yoldia,Animalia,Mollusca,Bivalvia,Nuculanida,Yoldiidae,Yoldia,Species,157006,NA,Species,,,,,,, -Yoldiella,Yoldiella,NA,Animalia,Mollusca,Bivalvia,Nuculanida,Yoldiidae,Yoldiella,Genus,138673,NA,Remove,,,,,,, -Nucula tenuis,Yoldiella philippiana,Smooth nutclam,Animalia,Mollusca,Bivalvia,Nuculida,Nuculidae,Nucula,Species,142005,NA,Species,,,,,,, -Zalembius rosaceus,Zalembius rosaceus,Pink seaperch,Animalia,Chordata,Teleostei,Ovalentaria incertae sedis,Embiotocidae,Zalembius,Species,283202,3641,Species,,,,,,, -Zalieutes mcgintyi,Zalieutes mcgintyi,Tricorn batfish,Animalia,Chordata,Teleostei,Lophiiformes,Ogcocephalidae,Zalieutes,Species,283204,3097,Species,,,,,,, -Scymnodon squamulosus,Zameus squamulosus,Velvet dogfish,Animalia,Chordata,Elasmobranchii,Squaliformes,Somniosidae,Scymnodon,Species,283206,701,Species,,,,,,, -Zaniolepidinae,Zaniolepidinae,NA,Animalia,Chordata,Teleostei,Perciformes,Hexagrammidae,NA,SubFamily,267138,NA,Remove,,,,,,, -Zaniolepis frenata,Zaniolepis frenata,Shortspine combfish,Animalia,Chordata,Teleostei,Perciformes,Hexagrammidae,Zaniolepis,Species,283208,4038,Species,,,,,,, -Zaniolepis latipinnis,Zaniolepis latipinnis,Longspine combfish,Animalia,Chordata,Teleostei,Perciformes,Hexagrammidae,Zaniolepis,Species,283209,4039,Species,,,,,,, -Zaprora silenus,Zaprora silenus,Prowfish,Animalia,Chordata,Teleostei,Perciformes,Zaproridae,Zaprora,Species,254353,3819,Species,,,,,,, -Zapteryx exasperata,Zapteryx exasperata,Banded guitarfish,Animalia,Chordata,Elasmobranchii,Rhinopristiformes,Rhinobatidae,Zapteryx,Species,283213,2550,Species,,,,,,, -Zenopsis conchifera,Zenopsis conchifer,Silvery john dory,Animalia,Chordata,Teleostei,Zeiformes,Zeidae,Zenopsis,Species,127426,336,Species,,,,,,, -Zenopsis ocellatus,Zenopsis conchifer,Silvery john dory,Animalia,Chordata,Teleostei,Zeiformes,Zeidae,Zenopsis,Species,127426,336,Species,,,,,,, -Zesticelus profundorum,Zesticelus profundorum,Flabby sculpin,Animalia,Chordata,Teleostei,Perciformes,Cottidae,Zesticelus,Species,283218,11735,Species,,,,,,, -Zoanthidae,Zoanthidae,NA,Animalia,Cnidaria,Anthozoa,Zoantharia,Zoanthidae,NA,Family,100690,NA,Remove,,,,,,, -Zoanthidae sp. A,Zoanthidae sp. A,hot dog zoanthid,NA,NA,NA,NA,NA,NA,Species,NA,NA,Species,,,,,,, -Zoanthus,Zoanthus,NA,Animalia,Cnidaria,Anthozoa,Zoantharia,Zoanthidae,Zoanthus,Genus,206284,NA,Remove,,,,,,, -Zoanthus sp.,Zoanthus,NA,Animalia,Cnidaria,Anthozoa,Zoantharia,Zoanthidae,Zoanthus,Genus,206284,NA,Remove,,,,,,, -Macrozoarces americanus,Zoarces americanus,Ocean pout,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,Macrozoarces,Species,159267,480,Species,,,,,,, -Zoarcidae,Zoarcidae,Eelpouts,Animalia,Chordata,Teleostei,Perciformes,Zoarcidae,NA,Family,125575,NA,Remove,,,,,,, -Zoobotriidae,Zoobotriidae,NA,NA,NA,NA,NA,NA,NA,HigherOrder,NA,NA,Remove,,,,,,, -Zoroaster,Zoroaster,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Zoroasteridae,Zoroaster,Genus,123237,NA,Remove,,,,,,, -Zoroaster ophiurus,Zoroaster ophiurus,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Zoroasteridae,Zoroaster,Species,254837,NA,Species,,,,,,, -Zoroasteridae,Zoroasteridae,NA,Animalia,Echinodermata,Asteroidea,Forcipulatida,Zoroasteridae,NA,Family,123125,NA,Remove,,,,,,, diff --git a/gitignore_old b/gitignore_old deleted file mode 100644 index d7d02d5..0000000 --- a/gitignore_old +++ /dev/null @@ -1,31 +0,0 @@ -.Rproj.user -.Rhistory -.RData -.Ruserdata - -# ignore everything -* - -# but don't ignore files ending with slash = directories -!*/ - -# Except the following: -!.gitignore -!.gitattributes -!README.md -!Metadata.md -!Metadata.doc -!DisMAP Presentation June 21, 2022.docx -!data_processing_rcode/* -# and don't ignore files ending with ".php" -# !*.py - -# R Code -# !Data Processing - Rcode/* - -# And except the following Python scripts - -# Create DisMAP Datasets -!ArcGIS Analysis - Python/Create DisMAP Biomass Datasets.py -!ArcGIS Analysis - Python/Create DisMAP Datasets Latest.py -!ArcGIS Analysis - Python/Create DisMAP Biomass Datasets 20230401.py diff --git a/update_python_files.py b/update_python_files.py new file mode 100644 index 0000000..081dcaf --- /dev/null +++ b/update_python_files.py @@ -0,0 +1,51 @@ +import os + + +# Function to add a comment and a newline at the end of a Python file +def add_comment_and_newline(file_path, comment): + with open(file_path, "a") as file: + file.write(f"\n# {comment}\n") + + +# Function to search and replace blocks or lines of code in a Python file +def search_and_replace(file_path, search_text, replace_text): + with open(file_path, "r") as file: + content = file.read() + + updated_content = content.replace(search_text, replace_text) + + with open(file_path, "w") as file: + file.write(updated_content) + + +# Function to process all Python files in a directory +def process_python_files(directory, comment, replacements): + for root, _, files in os.walk(directory): + for file in files: + if file.endswith(".py"): + file_path = os.path.join(root, file) + print(f"Processing: {file_path}") + + # Add comment and newline + add_comment_and_newline(file_path, comment) + + # Perform search and replace + for search_text, replace_text in replacements.items(): + search_and_replace(file_path, search_text, replace_text) + + +if __name__ == "__main__": + # Directory containing Python files + directory = "c:\\Users\\john.f.kennedy\\Documents\\ArcGIS\\Projects\\DisMAP" + + # Comment to add at the end of each file + comment = "This is an autogenerated comment." + + # Dictionary of search and replace pairs + replacements = { + "replace_text_1": "replace_text_1", + "replace_text_2": "replace_text_2", + } + + process_python_files(directory, comment, replacements) +# This is an autogenerated comment.