https://github.com/fuzailpalnak/py-gis-utility
A GIS utility library which contains some regularly required math and image operations.
https://github.com/fuzailpalnak/py-gis-utility
geographical-information-system geopandas georeferenced-data gis gis-data gis-utils shapefile
Last synced: 7 months ago
JSON representation
A GIS utility library which contains some regularly required math and image operations.
- Host: GitHub
- URL: https://github.com/fuzailpalnak/py-gis-utility
- Owner: fuzailpalnak
- License: mit
- Created: 2021-03-20T09:34:46.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-07-26T12:52:12.000Z (about 2 years ago)
- Last Synced: 2025-02-16T00:24:50.424Z (8 months ago)
- Topics: geographical-information-system, geopandas, georeferenced-data, gis, gis-data, gis-utils, shapefile
- Language: Python
- Homepage:
- Size: 70.3 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# py-gis-utility
A GIS utility library which contains some regularly required math and image operations.
[](https://pepy.tech/project/py-gis-utility)
## Installation
pip install py-gis-utility
## Requirements- *_Geopandas - [installation](https://anaconda.org/conda-forge/geopandas)_*
- *_Rasterio - [installation](https://anaconda.org/conda-forge/rasterio)_*
- *_GDAL - [installation](https://anaconda.org/conda-forge/gdal)_*
- *_Fiona - [installation](https://anaconda.org/conda-forge/fiona)_*
- *_Shapely - [installation](https://anaconda.org/conda-forge/shapely)_*## Math Operations
1. Get perpendicular point with reference to start and end point of the segment
2. Get perpendicular distance from point to line_segment
3. Given a Point find a new point at an given 'angle' with given 'distance'
4. Calculate a new point on the line segment given the distance from the start
5. Euclidean computation## Image Operations
### Save Multi Band Imagery
```python
import numpy as np
from affine import Affine
from py_gis_utility.image_func import save_16bit_multi_band, save_8bit_multi_bandimage = np.zeros((512, 512, 6))
transform = Affine(1.0, 0.0, 3422098.682455578,
0.0, -1.0, 5289611.291479621)# Save 8bit
save_8bit_multi_band(image, transform, 26910, r"8bit.tiff")# Save 16bit
save_16bit_multi_band(image, transform, 26910, r"16bit.tiff")```
### Generate bitmap from shape file

```python
from py_gis_utility.helper import (
read_data_frame,
save_image_with_geo_transform,
)
from py_gis_utility.image_func import shape_geometry_to_bitmap_from_data_frame_generatordata_frame = read_data_frame(r"path_to_geometry_file")
bitmap_gen = shape_geometry_to_bitmap_from_data_frame_generator(data_frame, (50, 50), (1, 1),
allow_output_to_overlap=True)for i, bitmap in enumerate(bitmap_gen):
save_image_with_geo_transform(f"{i}.tiff", bitmap.array, bitmap.transform)
```### Generate shape geometry from geo reference bitmap
```python
from py_gis_utility.helper import (read_image_with_geo_transform,
)
from py_gis_utility.image_func import image_obj_to_coordinates_generator, image_obj_to_shape_generatorimg_obj = read_image_with_geo_transform(r"path_to_geo_referenced_file")
# output in format {'geometry': , 'properties': {'id': 255.0, 'crs': CRS.from_epsg(4326)}}
shape_gen = image_obj_to_shape_generator(img_obj)
for g in shape_gen:
print(g)# output in format {'geometry': {'type': 'Polygon', 'coordinates': [[(621000.0, 3349500.0), .... ,(621000.0, 3349489.5)]]}, 'properties': {'id': 255.0, 'crs': CRS.from_epsg(4326)}}
co_ord_gen = image_obj_to_coordinates_generator(img_obj)
for g in co_ord_gen:
print(g)
```## Support Me