torchgeo/tests/data
isaac 7d1ff80649
Add BigEarthNet dataset (#197)
* add bigearthnet dataset

* add dummy data for bigearthnet tests

* add bigearthnet unit tests

* updated bigearthnet dataset and tests with s1 imagery

* add bigearthnet to docs

* mypy fixes

* updated docstrings
2021-10-17 11:19:57 -05:00
..
advance Add ADVANCE dataset (#133) 2021-09-19 23:00:56 +00:00
bigearthnet Add BigEarthNet dataset (#197) 2021-10-17 11:19:57 -05:00
cbf Remove real data from CBF tests 2021-08-31 10:52:24 -07:00
cdl Add colormap to CDL test files 2021-07-21 09:37:28 -05:00
chesapeake ChesapeakeCVPR: fix non-existing dir support, add unit tests (#195) 2021-10-12 22:20:45 -07:00
cowc_counting Monkeypatch download_url to get 100% coverage 2021-06-21 17:01:10 +00:00
cowc_detection Monkeypatch download_url to get 100% coverage 2021-06-21 17:01:10 +00:00
cyclone Pytorch lightning based training framework (#42) 2021-07-17 16:57:18 -07:00
etci2021 Add ETCI2021 Dataset (#119) 2021-09-11 20:05:38 -05:00
eurosat Added EuroSat dataset (#167) 2021-09-27 20:13:17 -05:00
gid15 added dummy sample test data 2021-09-10 14:49:19 -05:00
landcoverai Flake8 fixes 2021-08-31 13:25:05 -05:00
landsat8 Various fixes to GeoDataset 2021-08-10 10:06:00 -05:00
levircd replaced dataset samples with dummy data 2021-09-05 14:58:18 -05:00
naip Add NAIP dataset 2021-08-02 12:33:47 -07:00
patternnet added sample data for tests 2021-09-07 21:51:53 -05:00
ref_african_crops_kenya_02 Add unit tests for CV4AKenyaCropType dataset 2021-06-24 17:20:23 +00:00
resisc45 Add RESISC45 Dataset (#126) 2021-09-12 10:50:15 -05:00
sen12ms Add tests for SEN12MS task 2021-07-21 12:23:35 -05:00
sentinel2 Various fixes to GeoDataset 2021-08-10 10:06:00 -05:00
so2sat Dependencies, tests, cleaning up 2021-07-07 17:03:23 -05:00
spacenet Spacenet 4 (#185) 2021-10-12 15:39:49 -05:00
ts_cashew_benin Add unit tests 2021-06-24 10:48:41 -05:00
ucmerced Added the UC Merced dataset (#169) 2021-09-27 20:14:02 -05:00
vhr10 Add VHR-10 Dataset tests 2021-06-22 15:20:31 +00:00
visionclassificationdataset Add VisionClassificationDataset (#171) 2021-09-27 20:55:50 -05:00
zuericrop Add ZueriCrop dataset (#147) 2021-09-19 23:25:09 +00:00
README.md Set src properties (#156) 2021-09-21 13:54:40 -05:00

README.md

This directory contains fake data used to test torchgeo. Depending on the type of dataset, fake data can be created in multiple ways:

GeoDataset

GeoDataset data can be created like so. We first open an existing data example and use it to copy the driver/CRS/transform to the fake data.

Raster data

import os

import numpy as np
import rasterio

ROOT = "data/landsat8"
FILENAME = "LC08_L2SP_023032_20210622_20210629_02_T1_SR_B1.TIF"

src = rasterio.open(os.path.join(ROOT, FILENAME))
Z = np.arange(4, dtype=src.read().dtype).reshape(2, 2)
dst = rasterio.open(FILENAME, "w", driver=src.driver, height=Z.shape[0], width=Z.shape[1], count=src.count, dtype=Z.dtype, crs=src.crs, transform=src.transform)
for i in range(1, dst.count + 1):
    dst.write(Z, i)

Optionally, if the dataset has a colormap, this can be copied like so:

cmap = src.colormap(1)
dst.write_colormap(1, cmap)

Vector data

import os
from collections import OrderedDict

import fiona

ROOT = "data/cbf"
FILENAME = "Ontario.geojson"

src = fiona.open(os.path.join(ROOT, FILENAME))
src.meta["schema"]["properties"] = OrderedDict()
dst = fiona.open(FILENAME, "w", **src.meta)
rec = {"type": "Feature", "id": "0", "properties": OrderedDict(), "geometry": {"type": "Polygon", "coordinates": [[(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)]]}}
dst.write(rec)

VisionDataset

VisionDataset data can be created like so.

RGB images

from PIL import Image

img = Image.new("RGB", (1, 1))
img.save("01.png")

Grayscale images

from PIL import Image

img = Image.new("L", (1, 1))
img.save("02.jpg")

Audio wav files

import numpy as np
from scipy.io import wavfile

audio = np.random.randn(1).astype(np.float32)
wavfile.write("01.wav", rate=22050, data=audio)

HDF5 datasets

import h5py
import numpy as np

f = h5py.File("data.hdf5", "w")

num_classes = 10
images = np.random.randint(low=0, high=255, size=(1, 1, 3)).astype(np.uint8)
masks = np.random.randint(low=0, high=num_classes, size=(1, 1)).astype(np.uint8)
f.create_dataset("images", data=images)
f.create_dataset("masks", data=masks)
f.close()