Compare commits

..

No commits in common. "40697118309c25990560aa057ba94dd8d8415475" and "93fe12312bbb2885843eb3085da28fa5e8cbdc65" have entirely different histories.

2 changed files with 1 additions and 102 deletions

View File

@ -1,77 +1,2 @@
--- # RegionIdentifier
**Project Name:** RegionIdentifier
**Git Repository:** [https://git.nickhepler.cloud/nick/RegionIdentifier.git](https://git.nickhepler.cloud/nick/RegionIdentifier.git)
---
## RegionIdentifier
### Overview
The `RegionIdentifier` project is a Python function that helps identify an economic region based on the county name provided as input. It is particularly useful in geospatial analyses where counties are used to categorize regions within a specific area, like New York State. The function takes the name of a county and returns the corresponding economic region based on a predefined list of counties associated with each region.
This project is designed for use with **ArcGIS Pro**, where it can be incorporated into field calculations for geographic information systems (GIS) tasks. The function uses a dictionary to map counties to their respective regions, and based on the county input, it identifies the region the county belongs to.
---
### Function: `get_region_by_county`
The function `get_region_by_county(county_name)` takes a string representing the name of a county and returns the corresponding economic region. The function performs case-insensitive comparisons to ensure robustness against different input formats.
#### Arguments:
- `county_name` (str): The name of the county to be checked.
#### Returns:
- A string representing the region name, such as "Western New York" or "Capital District".
- If the county does not belong to any predefined region, the function returns "County not found in any region."
---
### Example Usage
```python
# Example usage of the get_region_by_county function
county = "Monroe"
region = get_region_by_county(county)
print(f"The county {county} belongs to the {region} region.")
```
**Output:**
```
The county Monroe belongs to the Finger Lakes region.
```
---
### Regions and Counties Mapping
The following regions and their corresponding counties are predefined in the function:
- **Western New York**: Niagara, Erie, Chautauqua, Cattaraugus
- **Finger Lakes**: Orleans, Genesee, Wyoming, Monroe, Livingston, Wayne, Ontario, Yates, Seneca
- **Southern Tier**: Steuben, Schuyler, Chemung, Tompkins, Tioga, Chenango, Broome, Delaware
- **Central New York**: Cortland, Cayuga, Onondaga, Oswego, Madison
- **North Country**: St. Lawrence, Lewis, Jefferson, Hamilton, Essex, Clinton, Franklin
- **Mohawk Valley**: Oneida, Herkimer, Fulton, Montgomery, Otsego, Schoharie
- **Capital District**: Albany, Columbia, Greene, Warren, Washington, Saratoga, Schenectady, Rensselaer
- **Hudson Valley**: Sullivan, Ulster, Dutchess, Orange, Putnam, Rockland, Westchester
- **New York City**: New York, Bronx, Queens, Kings, Richmond
- **Long Island**: Nassau, Suffolk
---
### Installation
1. Clone this repository to your local machine:
```bash
git clone https://git.nickhepler.cloud/nick/RegionIdentifier.git
```
2. Ensure that Python is installed on your system (Python 3.x recommended).
3. The function `get_region_by_county` does not have external dependencies but is designed to be used within ArcGIS Pro's Python environment for field calculations.
---
### License
This project is licensed under the GPL License - see the [LICENSE](LICENSE) file for details.

View File

@ -1,26 +0,0 @@
def get_region_by_county(county_name):
# Define the dictionary of regions and their associated counties/boroughs
regions = {
"Western New York": ["Niagara", "Erie", "Chautauqua", "Cattaraugus"],
"Finger Lakes": ["Orleans", "Genesee", "Wyoming", "Monroe", "Livingston", "Wayne", "Ontario", "Yates", "Seneca"],
"Southern Tier": ["Steuben", "Schuyler", "Chemung", "Tompkins", "Tioga", "Chenango", "Broome", "Delaware"],
"Central New York": ["Cortland", "Cayuga", "Onondaga", "Oswego", "Madison"],
"North Country": ["Saint Lawrence", "St Lawrence", "St. Lawrence", "Lewis", "Jefferson", "Hamilton", "Essex", "Clinton", "Franklin"],
"Mohawk Valley": ["Oneida", "Herkimer", "Fulton", "Montgomery", "Otsego", "Schoharie"],
"Capital District": ["Albany", "Columbia", "Greene", "Warren", "Washington", "Saratoga", "Schenectady", "Rensselaer"],
"Hudson Valley": ["Sullivan", "Ulster", "Dutchess", "Orange", "Putnam", "Rockland", "Westchester"],
"New York City": ["New York", "Manhattan", "Bronx", "Queens", "Kings", "Brooklyn", "Richmond", "Staten Island"],
"Long Island": ["Nassau", "Suffolk"]
}
# Trim any leading/trailing whitespace and convert to lowercase
county_name = county_name.strip().lower()
# Loop through the regions and check if the county is in any region's list
for region, counties in regions.items():
# Compare the county_name in lowercase with each county (also in lowercase)
if county_name in [county.lower() for county in counties]:
return region
# Return a message if the county is not found
return "Error"