Project shape file to a custom projection that does not exist in EPSG

272
0
09-11-2023 04:32 PM
SaraAV
by
New Contributor

Hello!

I am facing issues with projections when I try to match custom projections with EPSG projections from ArcMap.

I have a xarray.Dataset in python with the following coordinate system: 

'+proj=lcc +units=m +a=6370000.0 +b=6370000.0 +lat_1=30.0 +lat_2=60.0 +lat_0=40.0 +lon_0=-97.0 +x_0=0 +y_0=0 +k_0=1.0 +nadgrids=@null +wktext +no_defs'

When I try to get in python the equivalence of that projection to EPSG there is not equivalence. What I know it is that the closest projection in ArcMap to that one is North_America_Lambert_Conformal_Conic.

I need to extract the data of that xarray.Dataset to the boundary of a basin that I have in North_America_Lambert_Conformal_Conic.

I have extracted a subset of the xarray.Dataset to a raster and this is how it looks. As you can see there are watersheds inside the great lakes. Both raster and shapefile are not in the same coordinate system

SaraAV_0-1694474711619.png

I try to put the shape file into the same custom coordinate system of the xarray.Dataset with the following code in python, but with no success.

 

proj4_string = '+proj=lcc +units=m +a=6370000.0 +b=6370000.0 +lat_1=30.0 +lat_2=60.0 +lat_0=40.0 +lon_0=-97.0 +x_0=0 +y_0=0 +k_0=1.0 +nadgrids=@null +wktext +no_defs'

target_crs = pyproj.CRS.from_proj4(proj4_string)

shapefile_path = 'basins_Lambert_conformal_conic.shp'

basins = gpd.read_file(shapefile_path)

projected_basin = basins.to_crs(target_crs)

snow=ldasout['QSNOW'] #ldasout is the xarray.Dataset 

snow=snow.rio.write_crs(target_crs)

snow1=snow.rio.clip(projected_basin.iloc[[5]].geometry)

When I run the last line of code I got the following error. Any idea about how to solve it?

ERROR 1: PROJ: internal_proj_identify: Transformation cannot be formatted as WKT1 TOWGS84 parameters

 

Any idea how can i get the shape file into the custom projection of the xarray?

 

Thanks!

0 Kudos
0 Replies