def getRasterProj4(raster): print("Getting projection information for %s" % raster) """ Function returns the projection of the input raster in proj4""" fac = gdal.Open(raster) ras_proj = fac.GetProjection() spatialRef = osr.SpatialReference() osr.UseExceptions() # Apparently osr has difficulties identifying albers projections prjText = ras_proj.replace('"Albers"', '"Albers_Conic_Equal_Area"') spatialRef.ImportFromWkt(prjText) ras_proj_proj4 = spatialRef.ExportToProj4() return ras_proj_proj4
@author: %(Faizan Anwar, IWS Uni-Stuttgart)s """ from __future__ import unicode_literals import time import timeit import os from multiprocessing import Process, Queue import ogr import osr import numpy as np import pandas as pd import netCDF4 as nc ogr.UseExceptions() osr.UseExceptions() def extract_grid_ppt(sub_date_list, in_net_cdf, in_cat_shp, sub_out_cat_data_df, other_args, ppt_que): ''' Extract precipitation from a given list of netCDf files The catchments shapefile can have one more catchment polygons. Change names of variables and values inside the function, (not everything is specified through the arguments). ''' cat_vec = ogr.Open(in_cat_shp) lyr = cat_vec.GetLayer(0) spt_ref = lyr.GetSpatialRef() trgt = osr.SpatialReference()