def check_projection(proj4string): if not isinstance(proj4string, str): return False if proj4string[0] == '"' and proj4string[len(proj4string) - 1] == '"': proj4string = proj4string[1:len(proj4string) - 1] if "epsg:" in proj4string[:5]: proj4string = "".join(["+init=", proj4string]) try: pyproj_Proj(proj4string) outSpRef = SpatialReference() ret_val = outSpRef.ImportFromProj4(proj4string) if not ret_val == 0: return False return proj4string except: return False
def check_projection(proj4string): """Check if a proj4string is valid.""" if not isinstance(proj4string, str): return False if proj4string[0] == '"' and proj4string[len(proj4string) - 1] == '"': proj4string = proj4string[1:len(proj4string) - 1] if "epsg:" in proj4string[:5]: proj4string = "".join(["+init=", proj4string]) try: pyproj_Proj(proj4string) outSpRef = SpatialReference() ret_val = outSpRef.ImportFromProj4(proj4string) if not ret_val == 0: return False return proj4string except: return False
def reproj_layer(geojson, output_crs, input_crs="epsg:4326"): reproj = partial(pyproj_transform, pyproj_Proj(init=input_crs), pyproj_Proj(output_crs)) for feature in geojson["features"]: feature["geometry"] = mapping( transform(reproj, shape(feature["geometry"])))