Skip to content

Commit

Permalink
Add WRI data
Browse files Browse the repository at this point in the history
  • Loading branch information
bw4sz committed Oct 3, 2024
1 parent 438d284 commit 08fcf6a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
46 changes: 46 additions & 0 deletions data_prep/WRI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import pandas as pd
from deepforest import utilities
from PIL import Image

# Define the root directory
root_dir = "/orange/ewhite/DeepForest/WRI/WRI-labels-opensource"

# Initialize an empty list to store dataframes
dataframes = []

# Iterate through each file in the directory
for filename in os.listdir(root_dir):
if filename.endswith(".txt"):
file_path = os.path.join(root_dir, filename)

# Load the text file into a dataframe
df = pd.read_csv(file_path, delim_whitespace=True, header=None, names=["index", "x", "y", "width", "height"])

# Load the corresponding image to get its shape
image_path = os.path.join(root_dir, os.path.splitext(filename)[0] + ".png")
image = Image.open(image_path)
original_width, original_height = image.size

# Apply the coordinate transformation to each row
df["xmin"] = (df["x"] * original_width).astype(int)
df["ymin"] = (df["y"] * original_height).astype(int)
df["xmax"] = (df["xmin"] + df["width"] * original_width).astype(int)
df["ymax"] = (df["ymin"] + df["height"] * original_height).astype(int)

# Add the image_path column
df["image_path"] = image_path

# Append the dataframe to the list
df = utilities.read_file(df, root_dir)
dataframes.append(df)

# Concatenate all dataframes
annotations_df = pd.concat(dataframes, ignore_index=True)

# Add the 'label' and 'source' columns
annotations_df["label"] = "Tree"
annotations_df["source"] = "World Resources Institute"

# Save the concatenated dataframe to annotations.csv
annotations_df.to_csv(os.path.join(root_dir, "annotations.csv"), index=False)
1 change: 1 addition & 0 deletions data_prep/collect_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"/orange/ewhite/DeepForest/Velasquez_urban_trees/tree_canopies/nueva_carpeta/annotations.csv",
'/orange/ewhite/DeepForest/individual_urban_tree_crown_detection/annotations.csv',
'/orange/ewhite/DeepForest/Radogoshi_Sweden/annotations.csv',
"/orange/ewhite/DeepForest/WRI/WRI-labels-opensource/annotations.csv",
'/orange/ewhite/DeepForest/ReForestTree/images/train.csv']

TreePoints = [
Expand Down
6 changes: 6 additions & 0 deletions docs/datasets.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ ISPRS Journal of Photogrammetry and Remote Sensing, Volume 206, 2023

**Location:** Mato Grosso do Sul, Brazil

### World Resources Institute

NAIP Imagery from across the United States

![sample_image](public/World_Resources_Institute.png)

## Points

### Amirkolaee et al. 2023
Expand Down
Binary file added docs/public/World_Resources_Institute.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/public/reiersen_et_2022.jpg
Binary file not shown.

0 comments on commit 08fcf6a

Please sign in to comment.