0

I have on geoseries that I would like to project to equal area conic of lambret. However my code doesn't work.

What is wrong with it?

#piece of g_source {GeoSeries}: 
156     POINT (-40.44880502028832 -11.46367489031081)
316     POINT (-39.41085010955187 -14.377529459967)
597     POINT (-41.38150747600145 -12.50530265608625)
611     POINT (-40.83168841504723 -9.831649257327703)
655     POINT (-38.65003368469574 -10.58169711296605)
762     POINT (-41.65309648409965 -13.84055043883477)
803     POINT (-40.16682973721372 -13.8128259068363)
895     POINT (-40.32563763661891 -11.44304599350725)
955     POINT (-42.83093325758571 -14.58912682266423)
1044    POINT (-44.19089700267293 -10.92335966009432)
1090    POINT (-42.48081539796195 -13.53028686200761)
1098    POINT (-42.5018315288937 -11.14269666158528)
1110    POINT (-40.58867787879641 -10.05547817406703)
1112    POINT (-42.68838715258138 -14.65174718137191)
1185    POINT (-43.50920272535527 -11.5860204677622)
1254    POINT (-40.48677193204426 -12.40027031089884)
1285    POINT (-42.15471265231525 -13.8609924490699)
1310    POINT (-43.01429033526334 -13.23693183675715)
1327    POINT (-41.07969455240436 -12.57893027527855)
1354    POINT (-40.4935550707856 -12.79451069316572)
1358    POINT (-45.59765266096689 -12.17602089331463)
1365    POINT (-39.12818338990706 -16.31180811000418)
1417    POINT (-41.8006242904709 -14.3024884040351)
1459    POINT (-38.87533320706946 -12.27064395995037)
1480     POINT (-41.7334747357795 -11.27345848882953)
1521    POINT (-40.54234022136743 -13.49153493325051)
1522    POINT (-43.26469993111385 -11.71467214706978)
Name: source, dtype: object

crs_source = {'init': 'epsg: 4674'}
crs_target = {'init': 'epsg: 102033'}

g_source = gpd.GeoSeries(data['source'].map(shapely.wkt.loads))
g_source.crs = crs_source
g_source.to_crs(crs_target)
0

GeoPandas uses pyproj for the projections (requirements) and pyproj does not know the crs EPSG:102033 (does not exist) nor the ESRI:102033 South_America_Albers_Equal_Area_Conic (look at GIS SE: Projected coordinate system for South America)

But you can use the Proj4 string of the ESRI:102033 projection

With pyproj

from pyproj import Proj, transform
from shapely.wkt import loads
point = loads("POINT (-40.44880502028832 -11.46367489031081)")
from pyproj import Proj, transform
inProj  = Proj('+init=EPSG:4674')
outProj = Proj('+proj=aea +lat_1=-5 +lat_2=-42 +lat_0=-32 +lon_0=-60 +x_0=0 +y_0=0 +ellps=aust_SA +units=m +no_defs')
print transform(inProj,outProj,point.x, point.y)
(2068758.2788049988, 2248230.944751877)

Therefore, with GeoPandas

import geopandas as gpd
g_source = gpd.GeoSeries(point)
crs_source = ('+init=EPSG:4674')
crs_target = ('+proj=aea +lat_1=-5 +lat_2=-42 +lat_0=-32 +lon_0=-60 +x_0=0 +y_0=0 +ellps=aust_SA +units=m +no_defs')
g_source.crs = crs_source
g_source
0    POINT (-40.44880502028832 -11.46367489031081)
dtype: object
g_source.to_crs(crs_target)
0    POINT (2068758.278804999 2248230.944751877)
dtype: object
  • Your explanation is perfect. However I don't know why your suggestion haven't worked in my Geoseries. When I run the code it return me this error {RuntimeError}b'projection not named'. – Diogo Caribé Apr 24 '17 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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