Skip to main content

Utility for image and math related operation in GIS

Project description

py-gis-utility

A GIS utility library which contains some regularly required math and image operations.

Downloads

Installation

pip install py-gis-utility

Requirements

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

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

Animation

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

Buy Me a Coffee at ko-fi.com

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

py-gis-utility-0.2.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

py_gis_utility-0.2.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file py-gis-utility-0.2.0.tar.gz.

File metadata

  • Download URL: py-gis-utility-0.2.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for py-gis-utility-0.2.0.tar.gz
Algorithm Hash digest
SHA256 13c7a158bf26f1bbc1123ff446e36ad363d2af06bca79b1fd4351beb033bacf1
MD5 1bd3e0476adbd6c6c649ec8fca1efc43
BLAKE2b-256 fd965bc424b4fdc2a9996b3b5249adea3c725f7be2aaa148248c6203b9e569d7

See more details on using hashes here.

File details

Details for the file py_gis_utility-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: py_gis_utility-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for py_gis_utility-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9b7eb8902a6383a9913a6cd629566502f7657840fbe9c71c889e1d74d41af2b
MD5 fe97a1b1570f10cb20c811f3e7811e84
BLAKE2b-256 7b66091cb9284a99ff6223888120b455a49c46c2a66e0b6914ba53e67dd6817a

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