question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting `accuracy` parameter in the `pyproj.Transformer` class

See original GitHub issue

This is a question about how to set the accuracy parameter in the Transformer class.

I have UK Northing/Easting (EPSG:27700) data held in the variable DATA and would like to project this to WGS 84 (EPSG:4326) to a given level of accuracy using pyproj as set out in the following code snippet:

from pyproj import Transformer, CRS
from shapely.ops import transform
transformer = Transformer.from_crs(DATA.crs, CRS.from_epsg(4326), always_xy=True)

From the API I understand that the Transformer accuracy parameter is in metres and defaults to -1.0. If I wanted to set this accuracy to an arbitrary distance, say, 0.5m, how do I do this?

My naïve attempts to set the value as below fail with a can't set attribute error:

-1.0
>>> transformer.accuracy = 0.5
Traceback (most recent call last):
  AttributeError: can't set attribute
>>> transformer['accuracy'] = 0.5
Traceback (most recent call last):
  AttributeError: can't set attribute

I have looked and couldn’t see answer in the usual places.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
snowman2commented, Jun 14, 2020

The accuracy is just for information. So, no behavior change.

numpy can help with the decimal precision: https://numpy.org/devdocs/reference/generated/numpy.around.html#numpy.around

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transformer - pyproj 3.4.1 documentation - GitHub Pages
The Transformer class is for facilitating re-using transforms without needing ... New in version 3.1.0: authority, accuracy, allow_ballpark ... Parameters:.
Read more >
Transformer — pyproj 3.1.0 documentation - GitHub Pages
The pyproj.Transformer has the capabilities of performing 2D, 3D, and 4D (time) transformations. It can do anything that the PROJ command line programs...
Read more >
Source code for pyproj.transformer - GitHub Pages
From PROJ docs:: The operations are sorted with the most relevant ones first: by descending area (intersection of the transformation area with the...
Read more >
Transformer — pyproj 2.4.0 documentation - GitHub Pages
The Transformer class is for facilitating re-using transforms without needing to re-create them. The goal is to make repeated transforms faster.
Read more >
Proj - pyproj 3.4.1 documentation - GitHub Pages
A Proj class instance is initialized with proj map projection control parameter key/value pairs. The key/value pairs can either be passed in a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found