Skip to main content

Generates random coordinates and much more

Project description

randcoor BETA

A basic Python library to generate random geographical coordinates with additional features

Installation

This module can quickly be installed with pip

pip install randcoor

Usage

Geographical coordinates are represented by a tuple with two decimal values (Example: (-73.1657655614035, 32.52677878350798))

Functions that can generate random coordinates:

  • randCoor(): Generates random coordinates
  • randCoorByDist(position, distanceMax, distanceMin=0): Generates random coordinates by distance
  • randCoorByRule(rule, limit=None, showError=False): Generates random coordinates by checking if they follow the function rule
  • randCoorByArea(minCoor, maxCoor): Generates random coordinates that are between the coordinates of two points

Other functions:

  • calcDist(*coordinates): Calculates the distance between points
  • roundCoor(coor, ndigits=0): Round the two coordinates of a position
  • decimalToDMS(coor): Converts decimal notation to DMS notation
  • DMSToDecimal(coor): Converts DMS notation to decimal notation

If you need more information about these functions, you can use the help function

Examples

from randcoor import *
coor = randCoor()
print(coor)
# (0.5682138386708715, 7.332646594327713)
print(roundCoor(coor))
# (1.0, 7.0)
print(decimalToDMS(coor))
# ((0, 34, 5), (7, 19, 57))
randCoorByDist((0,0), 10, 5)
# (0.0795066131324715, -0.02793806206797174)
randCoorByArea((20,20),(50,50))
# (32.66256834620321, 44.82375046671473)
randCoorByArea((20,50),(50,20))
# (24.12540072542634, 169.03115180655362)
L = [randCoorByRule(lambda x, y: x>y) for x in range(3)]
print(L)
# [(71.83324744299622, -27.090322185441806), (-31.870493778872586, -167.80562795747355), (17.87985263208857, -162.7185532945298)]
calcDist(L)
# 20565.48275832477

Changelog

0.3.0

  • decimalToDMS() and DMSToDecimal() added
  • The help function on randcoor itself works properly now

0.2.0

  • randCoorByArea() added
  • Small changes for the case when longitude = -180

0.1.1

  • Small error in randCoor() fixed
  • roundCoor() added

0.1.0

  • First release

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

randcoor-0.3.0.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

randcoor-0.3.0-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

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