зеркало из https://github.com/microsoft/torchgeo.git
7d1ff80649
* 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 |
||
---|---|---|
.. | ||
advance | ||
bigearthnet | ||
cbf | ||
cdl | ||
chesapeake | ||
cowc_counting | ||
cowc_detection | ||
cyclone | ||
etci2021 | ||
eurosat | ||
gid15 | ||
landcoverai | ||
landsat8 | ||
levircd | ||
naip | ||
patternnet | ||
ref_african_crops_kenya_02 | ||
resisc45 | ||
sen12ms | ||
sentinel2 | ||
so2sat | ||
spacenet | ||
ts_cashew_benin | ||
ucmerced | ||
vhr10 | ||
visionclassificationdataset | ||
zuericrop | ||
README.md |
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()