30
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:...
19
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
...
16
votes
Accepted
Convert GPS coordinates to Web Mercator EPSG:3857 using python/pyproj
from pyproj import Proj, transform
print(transform(Proj(init='epsg:4326'), Proj(init='epsg:3857'), -0.1285907, 51.50809)) # longitude first, latitude second.
# output (meters east of 0, meters north ...
15
votes
Accepted
How to get appropriate CRS for a position specified in lat/lon coordinates?
You can calculate the UTM zone of each town center from the longitude, starting at zone 1 from -180°E to -174°E. zone=ROUND((183+longitude)/6;0) should calculate that in one step.
The EPSG code is ...
13
votes
Converting projected coordinates to lat/lon using Python
afalciano has the right answer but wanted to include a variant usage of pyproj.
It does require you know the proj4 string and is a tiny bit faster.
import pyproj
p = pyproj.Proj("+proj=merc +lon_0=0 ...
13
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 ...
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)
- ...
12
votes
Accepted
Converting shapefile from projected coordinates using pyproj and fiona
At the first question, 'epsg:32054' code has feet units. For this reason, it is necessary to use 'preserve_units=True' as parameter in inProj = Proj(init='epsg:32054') line. Now, next code works well:
...
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 ...
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....
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....
10
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 ...
9
votes
Accepted
Installing PyProj into ArcPy
For that, you must know the real Python world and the modern way to install modules.
1) The pyproj module needs the compilation of many C libraries and Windows has no compiler by default as in Linux ...
9
votes
Converting EPSG:2284 to EPSG:4326 with pyproj
Simply use (Converting elevations into correct units with pyproj?, Proj4 String for NAD83(2011) / Louisiana South (ftUS), ...)
preserve_units=True (as you say, pyproj assumes that your coordinates ...
9
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'}.
8
votes
Python pyproj converting from wgs84 to Israel Grid IG 05/12 EPSG:6991
The proj4 library has an error identifying the difference between Israel TM Grid 2039 and IG 05/12 6991. Survey if Israel made a horrendous error and updated 2039 to include the new 7 parameter ...
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....
8
votes
Why does Pyproj fail converting lon lat alt to ECEF?
Probably because in
lon, lat, alt = 49.74761271, -113.2179781, 0
a lat of -113.2179781 is outside the valid bounds of -90 to 90.
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 +...
8
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 ...
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 +...
7
votes
Accepted
Difference in destination location between pyproj and geopy
It looks like you've done everything correctly. You can evaluate the errors from each method by performing the inverse calculations to find the distance given the origin and destination coordinates, ...
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')
...
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 = '/...
7
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-...
7
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-...
6
votes
Accepted
How to tranform MODIS tiles into lat/long?
Projection of this kind of files is sinusoidal. For this one:
ftp://ladsweb.nascom.nasa.gov/allData/6/MOD13Q1/2016/129/MOD13Q1.A2016129.h07v06.006.2016147112419.hdf
the next code can access to ...
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....
6
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"..., ...
6
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',...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
pyproj × 287python × 169
coordinate-system × 143
proj × 56
geopandas × 25
shapely × 24
wgs84 × 19
epsg × 16
utm × 16
gdal × 14
coordinates × 13
latitude-longitude × 12
qgis × 10
convert × 9
python-3 × 9
shapefile × 6
fiona × 6
vertical-transformation × 6
geometry × 5
rasterio × 5
ellipsoid × 5
rioxarray × 5
netcdf × 4
well-known-text × 4
postgis × 3