Skip to main content
32 votes

Transforming Shapely Polygon and MultiPolygon objects

If you're using pyproj2, it's much easier to use a Transformer. Here's an example: import pyproj from shapely.ops import transform project = pyproj.Transformer.from_proj( pyproj.Proj(init='epsg:...
Nick ODell's user avatar
20 votes

Converting projected coordinates to lat/lon using Python

When using pyproj, note the differences from various releases in how it is used to transform data. Here are a few examples using new/old capabilities based on the question: Using pyproj >= 2.2.0 ...
Mike T's user avatar
  • 42.7k
18 votes

UserWarning when trying to get centroid from a polygon GeoPandas

Round-trip the data through a flat projection, ideally one which preserves area, such as Equal Area Cylindrical ('+proj=cea'): df1.to_crs('+proj=cea').centroid.to_crs(df1.crs) This projects the ...
Michael Delgado's user avatar
16 votes

Vertical Datum transformation using Pyproj

The accepted answer has a couple of flaws I'd like to address. First, the objection to the use of NAD83 is misplaced. It is true that NAD83 is a horizontal datum, but the setup in the question uses ...
asynchron's user avatar
  • 161
13 votes
Accepted

Convert GPS coordinates into 3-dimensional cartesian coordinates (x,y,z)

To do 3D transformations, you need 3D CRS: EPSG:4326 (2D) -> EPSG:4979 (3D) <Geographic 3D CRS: EPSG:4979> Name: WGS 84 Axis Info [ellipsoidal]: - Lat[north]: Geodetic latitude (degree) - ...
snowman2's user avatar
  • 7,647
11 votes
Accepted

Different origins of UTM projection

Both coordinates are the same. As you are in the Southern Hemisphere a False Northing (of +10000000m) is usually applied to eliminate the negatives. The utm package applies the false Northing by ...
nickves's user avatar
  • 11.7k
11 votes
Accepted

Constant future warnings with new pyproj

The +init=epsg:xxxx syntax (or in form of a {'init': 'epsg:xxx'}) is being deprecated in PROJ / pyproj (see here. You are indeed not using it directly, but, the previous releases of GeoPandas (<= 0....
joris's user avatar
  • 3,993
11 votes

I am getting the wrong result for north coordinate

It might be related to the proj string you specified. Use CRS instead of the proj string. from pyproj import Proj, CRS #converting lat/long - UTM lat = -22.818009494 long = -47.059235202 crs = CRS....
Kadir Şahbaz's user avatar
10 votes
Accepted

Use pyproj new projection initialization method when setting a CRS in GeoPandas

'<authority>:<code>' in the error means that you need just to use crs='EPSG:4326' instead of crs={'epsg:4326'}.
Noura's user avatar
  • 3,437
9 votes
Accepted

Using Rioxarray / QGIS Projection

Upon inspecting the dataset, I realized that the units of the data are in radians. import xarray import rioxarray from pyproj import CRS xds = xarray.open_dataset("OR_ABI-L2-LSTF-...
snowman2's user avatar
  • 7,647
9 votes
Accepted

UserWarning when trying to get centroid from a polygon GeoPandas

I am no expert on geopandas, but to me the warning only tells you that you should use a crs with coordinates in meters, Probably because the function calculating the centroid doesn't support ...
Kalak's user avatar
  • 4,154
8 votes

Converting projected coordinates to lat/lon using pyproj fails

If you examine the answer of afalciano in Converting projected coordinates to lat/lon using Python? 1) you define the two projections # original projection p = pyproj.Proj("+proj=stere +lat_0=90 +...
gene's user avatar
  • 55.8k
8 votes

Converting WGS84 to ECEF in Python?

Here is a test(seems both methods work with same precision): import math import pyproj coords = [ (37.4001100556, -79.1539111111, 208.38), (37.3996955278, -79.153841, 208.48), (37....
mrgloom's user avatar
  • 621
8 votes
Accepted

Explaining pyproj to_epsg min_confidence parameter?

This is a great question and I will do my best to answer. To begin, the init style syntax is deprecated (https://pyproj4.github.io/pyproj/stable/gotchas.html#init-auth-auth-code-should-be-replaced-...
snowman2's user avatar
  • 7,647
8 votes

I am getting the wrong result for north coordinate

The issue is the stray comma and unnecessary latitude band K. With the proj string, +zone= must be a value between 1-60, so just use 23 without a comma: myProj = Proj("+proj=utm +zone=23 +south +...
Mike T's user avatar
  • 42.7k
7 votes

Converting projected coordinates to lat/lon using Python

Tried the code suggested by Marcel Wilson and it is faster: from pyproj import Proj, transform import time import pyproj # Test 1 - 0.0006158 s start=time.time() inProj = Proj(init='epsg:3857') ...
user1174460's user avatar
7 votes

Change shapefile coordinate system using Python

Here's some handy code from the Python GDAL/OGR cookbook that will reproject a shapefile. from osgeo import ogr, osr import os in_epsg = 5514 out_epsg = 4326 in_shp = '/path/to/input.shp' out_shp = '/...
onakua's user avatar
  • 700
7 votes
Accepted

Converting EPSG:2263 to WGS84 using Python Pyproj

Look Converting EPSG:2284 to EPSG:4326 with pyproj (and many others...). Pyproj expects degrees (lon, lat) or meters (x,y) as units but the unit of Projection: 2263 isUNIT["US survey foot"..., ...
gene's user avatar
  • 55.8k
7 votes

Converting large data with lat and long into X and Y?

UPDATE: After thinking about it, the most efficient method for you to transform the coordinates is probably to not use apply but to use the column array. from pyproj import Proj pp = Proj(proj='utm',...
snowman2's user avatar
  • 7,647
7 votes
Accepted

What is the correct way to assign GeoPandas a CRS from Rasterio?

You should try to preserve the WKT form if possible. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems It all depends on the version of geopandas. ...
snowman2's user avatar
  • 7,647
7 votes
Accepted

Transformation from CRS EPSG:3857 to ESRI:54009

Your output CRS is not defined by EPSG but by ESRI. EPSG:54009 does not exist. For ESRI:54009 use ImportFromESRI https://gdal.org/python/osgeo.osr.SpatialReference-class.html#ImportFromESRI. EDIT User ...
user30184's user avatar
  • 71.7k
6 votes

Change shapefile coordinate system using Python

Here is even more concise option using geopandas library: import geopandas data = geopandas.read_file(path+file_in) # change CRS to epsg 4326 data = data.to_crs(epsg=4326) # write shp file data....
bnd's user avatar
  • 69
6 votes

Setting CRS to ESRI:102001 using GeoPandas

The +init= syntax is deprecated. So all you need is the ESRI:102001 part. See: https://pyproj4.github.io/pyproj/stable/gotchas.html#init-auth-auth-code-should-be-replaced-with-auth-auth-code inputGDF....
snowman2's user avatar
  • 7,647
6 votes

Use pyproj new projection initialization method when setting a CRS in GeoPandas

As too often, I continue cobbling around with my code after having posted my question, and I figure it out: Short Do not pass a dictionary but a string as a CRS! Explanation I.e, in concrete ...
swiss_knight's user avatar
  • 11.4k
6 votes
Accepted

Setting CRS of point using shapely

Shapely geometries are unaware of their CRS. Using pyproj to transform them only changes the values of the coordinates without leaving any trace of the final CRS in the resulting geometries. ...
Jeremiah England's user avatar
6 votes
Accepted

Why is this plot rotated in QGIS?

Either EPSG::27700, British National Grid, or EPSG::26918, NAD 83 / UTM zone 18 North is incorrect. I'm guessing the later one. If the data's in the UK, not only is the UTM zone wildly out of the area ...
mkennedy's user avatar
  • 19.5k
5 votes
Accepted

Converting projected coordinates to lat/lon using pyproj fails

Thanks for the comments. However, I figured out that the problem was related to a missed call of meshgrid. By doing this I was able to run my code and generate the right lon/lat arrays. x=np.array(...
Droid's user avatar
  • 231
5 votes

What is the difference between a datum and an ellipsoid?

In this case, there is not difference. The function is assuming that the ellipsoid (and thus, the datum) is earth-centered, earth-fixed. That is, centered at the earth's center of mass. Many older ...
mkennedy's user avatar
  • 19.5k
5 votes

geopandas can't import

Had the same problem and ended with installing python3 with anaconda, and then installed geopandas with conda install -c conda-forge geopandas conda-forge is community curated packaging for python ...
MikolajM's user avatar
  • 151
5 votes

Convert GPS coordinates to Web Mercator EPSG:3857 using python/pyproj

With the latest version of pyproj, the recommended way is from pyproj import Transformer # See other answer about the always_xy=True parameter TRAN_4326_TO_3857 = Transformer.from_crs("EPSG:4326&...
Jacopofar's user avatar
  • 151

Only top scored, non community-wiki answers of a minimum length are eligible