Skip to main content

GeoPatch is a package for generating patches from remote sensing data

Project description

GeoPatch is a package for generating patches from remote sensing data PyPI version Downloads Github

GeoPatch enables the user to read, process and export GeoTIFFs in various patch sizes. The module is built on the Rasterio library but is much more convenient when it comes to reading and exporting GeoTIFs patches for training deep learning models. Using this package user is able to feed satellite imagery and corresponding label data and exports patches in both Geotiff and Numpy array.

Any feedback from users is welcome and you can write to me at hejarshahabi@gmail.com in case of any contribution or suggestion.

Quick tutorial on how to use GeoPatch

1- Installation :

pip install GeoPatch

2- Calling the Package:

from GeoPatch import Generator

3- Feeding data

for image and label variables both string and array can be passed and the function automatically process and read dataset.

patch= Generator( image="xxx/image.tif", label="xxx/label.tif",
       patch_size=128, stride=64, channel_first=True)

4- Input data specifications

Using follwoing code the the shape and size of data can be displayed

patch.data_dimension()

5- Patch details

To display the number of orginal image patches can be generated based on given patch size and stride values.

patch.patch_info()

6- Saving image patch as a Geotiff file

To save image patches as Geotiff files in the current working directory with the given "folder_name", and if "only_label" pass as True, only patches will be save that has labeled data.

patch.save_Geotif(folder_name="tif", only_label=True)

7- Saving image patch as a Numpy array

Using this function image patches will be generated in Numpy format with data augmentation options. V_flip and H_flip are used to flip patches vertical and horizontal, respectively. Rotation is also used to apply roations such as 90,180 and 270 degree and patches.

patch.save_numpy(folder_name="npy", only_label=True, return_stacked=True, save_stack=True, V_flip=True, H_flip=True, Rotation=True)
#to return numpy patches as a stack file:
patch, label= patch.save_numpy

8- Patch visualization

Patches with their corresponding labels can be displayed using this line of code. In "folder_name" the exact name of the folder that patches are located in should be passed.

patch.visualize(folder_name='npy',patches_to_show=2,band_num=1,
fig_size=(10, 20),dpi=96)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

GeoPatch-1.0.2.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

GeoPatch-1.0.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file GeoPatch-1.0.2.tar.gz.

File metadata

  • Download URL: GeoPatch-1.0.2.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for GeoPatch-1.0.2.tar.gz
Algorithm Hash digest
SHA256 7fe5fdff362d4ec723ca1364ae681c1bcd2315070381242bc59aaf0abc9c49f7
MD5 c1bfa3f84d20d01ab3c9e139a6c23cb7
BLAKE2b-256 e6484380239b2d2f74b50cf47305d95073f40c7615cbe7e692cf1b487ca8f008

See more details on using hashes here.

File details

Details for the file GeoPatch-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: GeoPatch-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for GeoPatch-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8623a88e44b4e6757ecd0ca7150d412385ce3e9ac1183488cd7514feaa8c5005
MD5 007072124922a8f24555b97d46ab0b6b
BLAKE2b-256 df6f39616f296f591fdf467097652b740dbf5f0dada731066d8756bd06572f5d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page