py-gis-utility
A GIS utility library which contains some regularly required math and image operations.
Installation
pip install py-gis-utility
Requirements
- Geopandas - installation
- Rasterio - installation
- GDAL 2.4.4 - installation
- Fiona - installation
- Shapely - installation
Math Operations
- Get perpendicular point with reference to start and end point of the segment
- Get perpendicular distance from point to line_segment
- Given a Point find a new point at an given 'angle' with given 'distance'
- Calculate a new point on the line segment given the distance from the start
- Euclidean computation
Image Operations
Save Multi Band Imagery
import numpy as np
from affine import Affine
from py_gis_utility.image_func import save_16bit_multi_band, save_8bit_multi_band
image = 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
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_generator
data_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
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_generator
img_obj = read_image_with_geo_transform(r"path_to_geo_referenced_file")
# output in format {'geometry': <shapely.geometry.polygon.Polygon object at 0x0000022009E5EC08>, '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
Metadata
Release files for py-gis-utility 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py-gis-utility-0.2.2.tar.gz | 12.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_gis_utility-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.1 kB
Release files / py-gis-utility-0.2.2.tar.gz
| Download URL | py-gis-utility-0.2.2.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d68d5e83cf6910c8af20a5a441299414ba529573cdef26cef17d3c2d3c3ba0c6
|
|
BLAKE2b-256 checksum How to use checksums |
14cf15ef3369b2bc7e9253d60aca856e5bb7f69076d826c1741c9633a6c5b0cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / py_gis_utility-0.2.2-py3-none-any.whl
| Download URL | py_gis_utility-0.2.2-py3-none-any.whl |
|---|---|
| Size | 13.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e20097e20af2d2faf0f58769b945f1b4e05fd83451dc21abea8deecaeec43366
|
|
BLAKE2b-256 checksum How to use checksums |
06778b83f62ee38e90b9f292b5c553d30c8c2cc851e63a90455a303d061d3a58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|