I'm trying to get to the bottom of the following (weird) problem. When applying pyproj.Transformer transformation to a certain polygon, it fails the first time with (inf,inf) throughout. Second and all subsequent calls to the same work just fine!

I saw similar issues with inf which had to do with inappropriate CRS (out of bounds), but this is not the case here.

The question was originally prompted by geopandas' to_crs() failing occasionally; similar question by someone else here.


import shapely, shapely.geometry, shapely.speedups, shapely.ops, pyproj
print('Shapely version:',shapely.__version__)
print('Shapely speedups enabled:',shapely.speedups.enabled)
#shapely.speedups.disable() # makes no difference
print('Pyproj version:',pyproj.__version__)
print('PROJ version:',pyproj.proj_version_str)

xy = [(532303, 181814), (532190, 181854), (532192, 181861), (532199, 181863), 
      (532195, 181874), (532183, 181870), (532163, 181864), (532162, 181868), 
      (532309, 181915), (532294, 181828), (532306, 181820)] #, (532303, 181814)]
geom = shapely.geometry.Polygon(xy)
OSGB1936 = pyproj.CRS('EPSG:27700')
WGS84 = pyproj.CRS('EPSG:4326')

proj = pyproj.Transformer.from_crs(OSGB1936, WGS84, always_xy=True)
func = proj.transform

# First call fails with inf, all subsequent calls are OK:
for ii in range(3):
    tp = shapely.ops.transform(func, geom)


Shapely version: 1.7.1
Shapely speedups enabled: True
Pyproj version: 2.6.1.post1
PROJ version: 7.1.0
(inf, inf)
(-0.0929010345368997, 51.519248856167074)
(-0.0929010345368997, 51.519248856167074)

  • 1
    Did you install with conda? It could be that you are using PROJ_NETWORK.
    – snowman2
    Sep 8, 2020 at 17:04
  • @snowman2: good point, thanks. Yes, installed with conda (from conda-forge channel). Will try setting PROJ_NETWORK to OFF and report back.
    – Vitaliy
    Sep 8, 2020 at 17:10
  • @snowman2 That seems to solve the problem. Even though the proj.ini has network = on commented out, the PROJ_NETWORK is set to ON. Setting it to off explicitly works: i.e., os.environ['PROJ_NETWORK'] = 'OFF'.
    – Vitaliy
    Sep 8, 2020 at 17:35

1 Answer 1


@snowman2 's comment fixes the problem; viz.: explicitly setting

import os
os.environ['PROJ_NETWORK'] = 'OFF'

in the preamble resolves the issue. Thanks!

Also verified that the original problem is solved (i.e., geopandas' to_crs() works fine with or without pygeos)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.