Skip to main content

ProjPicker (projection picker) allows the user to select all projections whose extent completely contains given points, polylines, polygons, and bounding boxes. The goal is to make it easy and visual to select a desired projection by location.

Project description

ProjPicker

PyPI version Documentation Status

ProjPicker (projection picker) allows the user to select all projections whose extent completely contains given points, polylines, polygons, and bounding boxes. The goal is to make it easy and visual to select a desired projection by location. This project was motivated by a GRASS GIS feature request. It is a work in progress; join discussions. See also the command-line and API documentation.

image

Branches

main

The single Python script projpicker.py provides the CLI and API for ProjPicker.

rtree-oop

The rtree-oop branch utilizes the rtree module in an object-oriented programming (OOP) way. This branch supports point intersection. The rtree spatial indexing may not be able to handle reversed west and east longitudinal boundaries that cross the antimeridian.

Requirements

Tested with PROJ 7.2.1 in Python 3.7.2

Requires the PROJ database (e.g., /usr/share/proj/proj.db) only for recreating the provided projpicker.db, if you want, and the following standard modules:

Installation

pip3 install projpicker

# or if you're not a root
pip3 install --user projpicker

# to install development versions
pip3 install --pre projpicker

# or if you're not a root
pip3 install --pre --user projpicker

Command-line usage

usage: projpicker [-h] [-v] [-c] [-O | -a] [-d PROJPICKER_DB] [-P PROJ_DB]
                  [-g {point,poly,bbox}] [-p] [-q {and,or,all}]
                  [-f {plain,json,pretty}] [-n] [-s SEPARATOR] [-i INPUT]
                  [-o OUTPUT]
                  [geometry [geometry ...]]

ProjPicker finds coordinate reference systems (CRSs) whose bounding box
contains given geometries; visit https://github.com/HuidaeCho/projpicker for
more details

positional arguments:
  geometry              query geometry in latitude,longitude (point or poly)
                        or south,north,west,east (bbox); each point or bbox is
                        a separate argument and multiple polys are separated
                        by any non-coordinate argument such as a comma

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         print version (0.1.4.dev2) and copyright, and exit
  -c, --create          create ProjPicker database
  -O, --overwrite       overwrite output files; applies to both projpicker.db
                        and query output file
  -a, --append          append to output file if any; applies only to query
                        output file
  -d PROJPICKER_DB, --projpicker-db PROJPICKER_DB
                        projpicker database path (default: ./projpicker.db);
                        use PROJPICKER_DB environment variable to skip this
                        option
  -P PROJ_DB, --proj-db PROJ_DB
                        proj database path (default: /usr/share/proj/proj.db);
                        use PROJ_DB or PROJ_LIB (PROJ_LIB/proj.db) environment
                        variables to skip this option
  -g {point,poly,bbox}, --geometry-type {point,poly,bbox}
                        geometry type (default: point)
  -p, --print-geometries
                        print parsed geometries in a list form for input
                        validation and exit
  -q {and,or,all}, --query-mode {and,or,all}
                        query mode for multiple points (default: and); use all
                        to ignore query geometries and list all bboxes
  -f {plain,json,pretty}, --format {plain,json,pretty}
                        output format (default: plain)
  -n, --no-header       do not print header for plain output format
  -s SEPARATOR, --separator SEPARATOR
                        separator for plain output format (default: comma)
  -i INPUT, --input INPUT
                        input geometry file path (default: stdin); use - for
                        stdin; appended to geometries from arguments unless it
                        is stdin with no incoming data
  -o OUTPUT, --output OUTPUT
                        output bbox file path (default: stdout); use - for
                        stdout

Creating the ProjPicker database

This step is optional because projpicker.db generated from PROJ 7.2.1 is shipped with the module by default. Run this step only when you want to recreate this database from your version of PROJ.

From the shell,

projpicker -c

From Python,

import projpicker as ppik
ppik.create_projpicker_db()

Supported coordinate formats

The following geometry file points.txt contains 11 identical points:

################################
# decimal degrees and separators
################################
34.2348,-83.8677		# comma
34.2348		-83.8677	# whitespace

####################################################
# degree, minute, and second symbols
# degree: ° (U+00B0, °, alt+0 in xterm), o, d
# minute: ' (U+0027, '), ′ (U+2032, ′), m
# second: " (U+0022, "), ″ (U+2033, ″),
#	  '' (U+0027 U+0027, ' '), s
####################################################
34.2348°	-83.8677°	# without minutes, seconds, and [SNWE]
34°14.088'	-83°52.062'	# without seconds and [SNWE]
34°14'5.28"	-83°52'3.72"	# without [SNWE]
34.2348°N	83.8677°W	# without minutes and seconds
34°14.088'N	83°52.062'W	# without seconds
34°14'5.28"N	83°52'3.72"W	# full
34°14′5.28″N	83°52′3.72″W	# full using U+2032 and U+2033
34o14'5.28''N	83o52'3.72''W	# full using o' and ''
34d14m5.28sN	83d52m3.72sW	# full using dms

Running projpicker -p -i points.txt will generate:

[[34.2348, -83.8677],
 [34.2348, -83.8677],
 [34.2348, -83.8677],
 [34.2348, -83.8677],
 [34.2348, -83.8677],
 [34.2348, -83.8677],
 [34.2348, -83.8677],
 [34.2348, -83.8677],
 [34.2348, -83.8677],
 [34.2348, -83.8677],
 [34.2348, -83.8677]]

Querying points

From the shell,

# read latitude and longitude separated by a comma or whitespaces from
# arguments
projpicker 34.2348,-83.8677 "33.7490  84.3880W"

# read latitude and longitude from stdin
projpicker <<EOT
# query points
34.2348		83°52'3.72"W	# UNG Gainesville Campus
33°44'56.4"	-84.3880	# Atlanta
EOT

From Python,

import projpicker as ppik
bbox = ppik.listify_bbox(ppik.query_points([[34.2348, -83.8677],
                                            [33.7490, -84.3880]]))

Querying polylines or polygons

From the shell,

# read latitude,longitude from arguments
projpicker -g poly -- -10,0 10,0 10,10 10,0 , 10,20 30,40

# read latitude,longitude from stdin
projpicker -g poly <<EOT
# poly 1
# south-west corner
10S,0
10,0	# north-west corner
	# this comment-only line doesn't start a new poly
# north-east corner
10	10
# north-west corner
10	0
poly 2	# "poly 2" is neither a comment nor a point, so we start a new poly
10	20
30	40
EOT

From Python,

import projpicker as ppik
bbox = ppik.listify_bbox(ppik.query_polys([[[-10, 0], [10, 0],
                                            [10, 10], [10, 0]],
                                           [[10, 20], [30, 40]]]))

Querying bounding boxes

From the shell,

# read south,north,west,east from arguments
projpicker -g bbox 0,0,10,10 20,20,50,50

# read south,north,west,east from stdin
projpicker -g bbox <<EOT
# region 1
0	0	10	10

# region 2
20	20	50	50
EOT

From Python,

import projpicker as ppik
bbox = ppik.listify_bbox(ppik.query_bboxes([[0, 0, 10, 10], [20, 20, 50, 50]]))

TODO

  1. GUI
    • ArcGIS Pro Toolbox for ArcGIS users including IESA students? Will be easier to implement because ArcGIS Pro provides nice pencil tools and mapping functionalities. We'll be able to see almost immediate returns.
    • Web (client-only)
    • Desktop
  2. Missing projection information? Let's find it using coordinates in latitude and longitude.
  3. CRS hints
    • Crowdsourcing agency and product information?

Versioning

N(.N)*[{a|b|rc}N][.postN][.devN]

Sponsor

This project is kindly funded by the Institute for Environmental and Spatial Analysis (IESA) at the University of North Georgia (UNG).

License

Copyright (C) 2021 Huidae Cho and Owen Smith

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

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

projpicker-0.1.4.dev2.tar.gz (431.0 kB view details)

Uploaded Source

Built Distribution

projpicker-0.1.4.dev2-py3-none-any.whl (432.0 kB view details)

Uploaded Python 3

File details

Details for the file projpicker-0.1.4.dev2.tar.gz.

File metadata

  • Download URL: projpicker-0.1.4.dev2.tar.gz
  • Upload date:
  • Size: 431.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.2

File hashes

Hashes for projpicker-0.1.4.dev2.tar.gz
Algorithm Hash digest
SHA256 e76878419923edb6d320730ae6aaf32f8ca6c9c9eac8fc683a09481f50403387
MD5 c73b9374d8b22e42edf5f5b17cfde472
BLAKE2b-256 d16322355828a0d552641ec89e512c645162681d9063789679c50292de2f037b

See more details on using hashes here.

File details

Details for the file projpicker-0.1.4.dev2-py3-none-any.whl.

File metadata

  • Download URL: projpicker-0.1.4.dev2-py3-none-any.whl
  • Upload date:
  • Size: 432.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.2

File hashes

Hashes for projpicker-0.1.4.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 a0f640b21099607ecac418d36165b75ab2c1885424b5700cb743ecaa69905a23
MD5 1ffa85eed07e9ca1de54f5e26511127d
BLAKE2b-256 076bf3da56d000e2bf9066a9d7b1455cb63a1ea14902ee60cf1824e8b9de4072

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page