Package: guessproj
guessprojis a Python script that calculates unknown parameters
of cartographic projection or coordinate system from coordinates
of identical points in some known coordinate system and in unknown one.
You should know projection type, though.
The script can also determine parameters of transformation between two datums.The script usespyprojandscipyinternally.
The method of least squares is used, so the more points you have,
the better accuracy will be achieved.Supported Python versionsPython 2.6+ and 3.3+ are supported. The script is written in pure Python
itself but depends on some packages that are not.InstallationThe best way to installguessprojis usingpip:pip install guessprojBe aware thatguessprojhas some binary dependencies that you need
to install before trying to installguessproj.
These areGDALandPROJ.4.
If you are a GIS specialist you probably already have these libraries.
You also need Python bindings for them (GDAL bindingsandpyproj)
as well asNumPyandSciPypackages.
Thepiptool will try to install these packages automatically
but on most systems you’ll need to install them in a platform-specific way.Note that GDAL is an optional dependency but may become required in future
versions ofguessproj.Instead of usingpip, you can download the source archive,
unpack it and runpython setup.py installin the unpacked directory. You needsetuptoolsto do this.Also, you can useguessprojwithout installation. Just download
the fileguessproj.pyand run it like any Python script:python guessproj.py --helpYou still need dependencies to be installed, of course.Input data formatThe input data for the script is a text file that contains lines
of space separated values, each line representing a point.Input data format for 2D points is as follows:x1 y1 x2 y2 point nameInput data format for 3D points is as follows:x1 y1 z1 x2 y2 z2 point namePoint name may contain spaces but should not start with a number.
If the line starts with#, it will be ignored.The coordinates in known coordinate system go first, followed by coordinates
in unknown one. 3D points are mostly useful if there exists
a datum transformation between coordinate systems.Obviously, the number of point coordinate values must be not less
than the number of unknown parameters to determine.Both decimal format and degrees, minutes and seconds format
(XXXdXX'XX.XXX") are supported for coordinate values.
You can use comma as well as period to separate fractional part.Command line  syntaxCommand line syntax used to run the script is similar to that ofcs2csutility which comes withPROJ.4library. You should specify parameters
of known coordinate system inPROJ.4format (referred as projstring here),
known and unknown parameters of the unknown system, and a path to input file.
Exact parameters of various coordinate systems you can find
inPROJ.4 documentation.The unknown parameters are specified among all others in the projstring,
the only difference is using~symbol instead of=. The numeric value
that follows the~symbol is an initial approximation of the parameter value.
For+towgs84parameter, you can specify~before any (or all) of comma-separated
values. The combination=~is the same as~.Example:guessproj +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +to \
  +proj=tmerc +ellps=krass +lat_0=0 +lon_0~44 +x_0=300000 +y_0~-4.7e6 \
  +towgs84=23.57,-140.95,-79.8,0,0.35,0.79,-0.22 points.txtAll that goes before+toargument is a projstring for the known system
(if omitted, WGS84 longitude/latitude is used by default). All the rest
parameters starting with+are the projstring for the unknown system,
where initial approximations of the unknown parameters are marked with~.
In this example, parameters+lon_0and+y_0are unknown. The last argument
is a name of input text file containing point coordinates.The script can evaluate numeric parameters only, so you should specify
at least+projand+ellps. It’s worth mentioning, also, that some
parameters have the same (or nearly the same) effect, so it’s a bad idea,
for example, to specify both+lat_0and+y_0as unknown
for Transverse Mercator projection. The system of equations will be
ill-determined in that case.OptionsAny additional program options (which are not part of projstring syntax)
start with-or--.Option-hor--helpprints a short command line reference and exits
the program.Option--encoding=ENCODING_NAMEspecifies the encoding of input file
(--encoding=utf-8by default).Option--projor--proj4forces output of resulting projstring only,
suppressing table of residual errors.Option--wktforces output of projection parameters in OGC WKT format
(GDAL Python bindings required).Option--esriforces output of projection parameters in Esri WKT format
(experimental, GDAL Python bindings required).Option--prettyforces pretty WKT formatting when used with--wktor--esri.OutputThe default output of the program is a projstring in which approximated values
of parameters are replaced with the exact values found by the script,
and a list of residual errors for each point. Other forms of output
can be specified using program options.If GDAL bindings are installed, the projstring will be formatted
so as to be represented in a normalized form.TestingTo run unit tests with Python 2.7 or 3.3+, execute in source directory:python -m unittest discover testIn Python 2.6, you should install unittest2 package and use:PYTHONPATH=. unit2 discover testYou can also run scripts fromtest/directory directly.