Skip to main content

Transform pixel coordinates to tile coordinates

Project description

coords-transformer

coords-transformer is a library to transform pixel coordinate to latitude and longitude, and vise versa.

Installing

Install and update using pip:

pip install coords-transformer

Examples

Examples of transforming pixel coordinate to latitude and longitude, and vise versa

from coords_transformer.coords_calculation import *

# Get x pixel coordinate from longitude considering zoom level
convert_lng_zoom_to_x(141.242035, 17)

# Get y pixel coordinate from longitude considering zoom level
convert_lat_zoom_to_y(45.178506, 17)

# Get longitude from x pixel coordinate considering zoom level
convert_x_zoom_to_lng(29941927, 17)

# Get latitude from y pixel coordinate considering zoom level
convert_y_zoom_to_lat(12046802, 17)

A example of designated filename format

This has idx, longitude, latitude of center point, pixel size and zoom level.

0_long130dot51051050424576-lati33dot25308662907951-size512-zoom17.jpg

A example of getting a point object with pixel coordinates, longitude and latitude from pixel coordinate within an image.

from coords_transformer.point.factory import create_from_lat_lng_zoom
from coords_transformer.point.service import create_point_from_image_pixel_coords
from coords_transformer.filename.factory import create_from_filename

# Create a Filename object from filename.
filename = "0_long130dot51051050424576-lati33dot25308662907951-size512-zoom17.jpg"
path = "image/"
create_from_filename(filename, path)
# return value -> FileName(lng=130.51051050424576, lat=33.25308662907951, idx=0, size=512, path='image/', zoom=17)

# Create a Point object from latitude, longitude and zoom level.
# This Point obejct should be created from longitude and latitude of an image center point
create_from_lat_lng_zoom(filename_obj.lat, filename_obj.lng)
# return value -> Point(lng=130.51051050424576, lat=33.25308662907951, x=28941677, y=13487547)

# Pass x and y pixel coordinate within an image, center_point, image pixel size and zoom level
# Then you can get a Point object
create_point_from_image_pixel_coords(5, 10, center_point, filename_obj.size, filename_obj.zoom)
# return value -> Point(lng=130.5078148841858, lat=33.25529597095926, x=28941426, y=13487301)

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

coords_transformer-0.0.4.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file coords_transformer-0.0.4.tar.gz.

File metadata

  • Download URL: coords_transformer-0.0.4.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.4.2 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.0

File hashes

Hashes for coords_transformer-0.0.4.tar.gz
Algorithm Hash digest
SHA256 db8e38f6e12f8fe2776ebf6cffc6bd1b2b4807dc46e3e1903d9e99fd7b5cab32
MD5 4c7ebfbf0a3320177a415b9f9886884c
BLAKE2b-256 0548057da53b2da2817ae19a1abaa84257711b0c00775f00914dd437b5dd6a50

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