Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ Before installing this project, ensure you have the following requirements:

### Clone the Repository

Clone the project using the `dev` branch (this branch contains the latest development features):
Clone the project using the default `master` branch:

```bash
git clone -b dev https://github.com/your-username/coastline-extraction.git
cd coastline-extraction
git clone https://github.com/fwitmer/CoastlineExtraction.git
cd CoastlineExtraction
```

> ⚠️ Note: The repository currently contains only the `master` branch. Earlier versions of this README referenced a non-existent `dev` branch and an incorrect repository URL (`coastlineExtraction.git`), which caused cloning to fail for new users.

---

### Environment Setup
Expand Down Expand Up @@ -124,20 +126,22 @@ shapefile_path = get_shapefile_path(config, 0) # First shapefile

## Contributing

### Working with the Dev Branch
### Contribution Workflow

This project currently uses the `master` branch as the primary development branch.

This project uses the `dev` branch for active development. When contributing:
When contributing:

1. **Fork the repository on GitHub**

2. **Clone your fork using the `dev` branch**:
2. **Clone your fork**:

```bash
git clone -b dev https://github.com/your-username/coastline-extraction.git
cd coastline-extraction
git clone https://github.com/your-username/CoastlineExtraction.git
cd CoastlineExtraction
```

3. **Create a feature branch from `dev`**:
3. **Create a feature branch from `master`**:

```bash
git checkout -b feature/your-feature-name
Expand Down
15 changes: 9 additions & 6 deletions data_preprocessing/create_masks.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# import libraries
import rasterio as rio
from rasterio import mask
from rasterio.plot import show
from rasterio.mask import mask
from rasterio.plot import show
from rasterio.io import MemoryFile

import shapely
from shapely.geometry import Polygon, shape, box # added box
from shapely.geometry import Polygon, shape, box
import geopandas as gpd

import sys
import os

from matplotlib import pyplot as plt
import numpy as np
import cv2
Expand Down Expand Up @@ -78,8 +81,8 @@ def get_ndwi_label(image_path, points_path, ksize=100, blurring=True, out_dir="r

np.seterr(divide='ignore', invalid='ignore')

ndwi = (green - nir) / (green + nir) # NDWI equation
ndwi[np.isnan(ndwi)] = 0 # Sets any NaN values in the NDWI array to 0. (Dividing by zero => NaN pixels)
ndwi = (green - nir) / (green + nir + 1e-8) # NDWI equation
# ndwi[np.isnan(ndwi)] = 0 # Sets any NaN values in the NDWI array to 0. (Dividing by zero => NaN pixels)
ndwi_profile = src_raster.profile # Copies the image profile (metadata).

# Apply Gaussian blur
Expand Down Expand Up @@ -152,7 +155,7 @@ def get_ndwi_label(image_path, points_path, ksize=100, blurring=True, out_dir="r
if buffer.intersects(raster_bounds_geom):
out_image, out_transform = mask(dataset, shapes=[buffer], nodata=-1, crop=False)
out_image = out_image[0]
out_image = (out_image * 127) + 128
out_image = ((out_image + 1) * 127.5).astype(np.uint8)
out_image = out_image.astype(np.uint8)

out_image_clipped, out_transform_clipped = mask(dataset, shapes=[buffer], nodata=-1, crop=True)
Expand Down