## *GeoPatch* is a package for generating patches from remote sensing data [](https://pypi.org/project/GeoPatch/) [](https://pepy.tech/project/geopatch) [](https://github.com/Hejarshahabi/GeoPatch) [](https://www.linkedin.com/in/hejarshahabi/) [](https://twitter.com/hejarshahabi)
*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.
<img src="https://github.com/Hejarshahabi/GeoPatch/blob/main/Patch_logo.jpg?raw=true?raw=true" width="880" height="325">
## Quick tutorial on how to use GeoPatch
### 1- Installation :
```bash
pip install GeoPatch
```
### 2- Calling the Package:
```bash
from GeoPatch import TrainPatch
```
### 3- Feeding data
for image and label variables both string and array
can be passed and the function automatically process and read dataset.
```bash
patch= TrainPatch( 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
```bash
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.
```bash
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 labelled data.
```bash
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 vertically and horizontally flip patches, respectively, and rotation is used to rotate patches in 90,180 and 270 degree.
```bash
patch.save_numpy(folder_name="npy", only_label=False, return_stacked=False, save_stack=False, V_flip=True, H_flip=True, Rotation=True)
#to return numpy patches as a stack file:
patch, label= patch.save_numpy(folder_name="npy", only_label=False, return_stacked=True, save_stack=False, V_flip=True, H_flip=True, Rotation=True)
```
### 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.
```bash
patch.visualize(folder_name='npy',patches_to_show=2,band_num=1,
fig_size=(10, 20),dpi=96)
```
### 9- Generating Prediction Patch
Using the following line of codes prediction patches can be generated.
```bash
from GeoPatch import PredictionPatch
Prediction= PredictionPatch( image="xxx/test_image.tif", patch_size=128, stride=128, channel_first=True)
Prediction.data_dimension()
Prediction.patch_info()
```
### 10- Saving Prediction Patches
Using the following line of code prediction patches can be saved as GeoTIF format in the provided folder.
```bash
Prediction.save_Geotif('folder_name')
Raw data
{
"_id": null,
"home_page": "https://github.com/Hejarshahabi",
"name": "GeoPatch",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "Machine Learning,Remote Sensing,Deep Learning",
"author": "Hejar Shahabi",
"author_email": "hejarshahabi@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/4c/06/fe90b557aa81afabce251ba338ed65fad4c8ec2561b7345fb578ff5da1a1/GeoPatch-1.1.1.tar.gz",
"platform": null,
"description": "\n\n## *GeoPatch* is a package for generating patches from remote sensing data [](https://pypi.org/project/GeoPatch/) [](https://pepy.tech/project/geopatch) [](https://github.com/Hejarshahabi/GeoPatch) [](https://www.linkedin.com/in/hejarshahabi/) [](https://twitter.com/hejarshahabi)\n\n \n \n\n*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.\n\nUsing this package user is able to feed satellite imagery and corresponding label data and exports patches in both Geotiff and Numpy array.\n\n \n\nAny feedback from users is welcome and you can write to me at hejarshahabi@gmail.com in case of any contribution or suggestion.\n\n \n\n<img src=\"https://github.com/Hejarshahabi/GeoPatch/blob/main/Patch_logo.jpg?raw=true?raw=true\" width=\"880\" height=\"325\">\n\n \n\n## Quick tutorial on how to use GeoPatch\n\n \n\n### 1- Installation :\n\n```bash\n\npip install GeoPatch\n\n```\n\n### 2- Calling the Package:\n\n```bash\n\nfrom GeoPatch import TrainPatch\n\n```\n\n### 3- Feeding data\n\nfor image and label variables both string and array\n\ncan be passed and the function automatically process and read dataset.\n\n```bash\n\npatch= TrainPatch( image=\"xxx/image.tif\", label=\"xxx/label.tif\",\n\npatch_size=128, stride=64, channel_first=True)\n\n```\n\n### 4- Input data specifications\n\nUsing follwoing code the the shape and size of data can be displayed\n\n```bash\n\npatch.data_dimension()\n\n```\n\n### 5- Patch details\n\nTo display the number of orginal image patches can be generated based on given patch size and stride values.\n\n```bash\n\npatch.patch_info()\n\n```\n\n### 6- Saving image patch as a Geotiff file\n\nTo 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 labelled data.\n\n```bash\n\npatch.save_Geotif(folder_name=\"tif\", only_label=True)\n\n```\n\n### 7- Saving image patch as a Numpy array\n\nUsing this function image patches will be generated in Numpy format with data augmentation options. V_flip and H_flip are used to vertically and horizontally flip patches, respectively, and rotation is used to rotate patches in 90,180 and 270 degree.\n\n```bash\n\npatch.save_numpy(folder_name=\"npy\", only_label=False, return_stacked=False, save_stack=False, V_flip=True, H_flip=True, Rotation=True)\n\n#to return numpy patches as a stack file:\n\npatch, label= patch.save_numpy(folder_name=\"npy\", only_label=False, return_stacked=True, save_stack=False, V_flip=True, H_flip=True, Rotation=True)\n\n```\n\n### 8- Patch visualization\n\nPatches with their corresponding labels can be displayed using this line of code.\n\nIn \"*folder_name*\" the exact name of the folder that patches are located in should be passed.\n\n```bash\n\npatch.visualize(folder_name='npy',patches_to_show=2,band_num=1,\n\nfig_size=(10, 20),dpi=96)\n\n```\n### 9- Generating Prediction Patch \n\nUsing the following line of codes prediction patches can be generated.\n\n\n```bash\n\nfrom GeoPatch import PredictionPatch\nPrediction= PredictionPatch( image=\"xxx/test_image.tif\", patch_size=128, stride=128, channel_first=True)\nPrediction.data_dimension()\nPrediction.patch_info()\n```\n### 10- Saving Prediction Patches\n\nUsing the following line of code prediction patches can be saved as GeoTIF format in the provided folder. \n\n\n```bash\nPrediction.save_Geotif('folder_name')\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "GeoPatch is a package for generating patches from remote sensing data",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://github.com/Hejarshahabi"
},
"split_keywords": [
"machine learning",
"remote sensing",
"deep learning"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0d61ebf707252298745c52422d39fb005f9f5255968a9c1de9bcaf564cf0b9b2",
"md5": "c9d5a7efbeb7552b90b1664c1ee5b17d",
"sha256": "84bad857337cfa3bdfe1566ec73131d03ef4c796bf1bcfb7c5a287f6cf91b4bf"
},
"downloads": -1,
"filename": "GeoPatch-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c9d5a7efbeb7552b90b1664c1ee5b17d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 22454537,
"upload_time": "2023-11-22T22:18:20",
"upload_time_iso_8601": "2023-11-22T22:18:20.485459Z",
"url": "https://files.pythonhosted.org/packages/0d/61/ebf707252298745c52422d39fb005f9f5255968a9c1de9bcaf564cf0b9b2/GeoPatch-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4c06fe90b557aa81afabce251ba338ed65fad4c8ec2561b7345fb578ff5da1a1",
"md5": "9a680f4df84d9c11f8ce820dc4cac7ca",
"sha256": "5243717b659d77a554a46805a75b27bc751a48bccaccb5e56cecb6f5704b3a73"
},
"downloads": -1,
"filename": "GeoPatch-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "9a680f4df84d9c11f8ce820dc4cac7ca",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 22455341,
"upload_time": "2023-11-22T22:18:31",
"upload_time_iso_8601": "2023-11-22T22:18:31.879696Z",
"url": "https://files.pythonhosted.org/packages/4c/06/fe90b557aa81afabce251ba338ed65fad4c8ec2561b7345fb578ff5da1a1/GeoPatch-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-22 22:18:31",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "geopatch"
}