pycrs/load.py
def from_file(filepath):
    """
    Returns the crs object from a file, with the format determined from the filename extension.

    Arguments:

    - *filepath*: filepath to be loaded, including extension. 
    """
    if filepath.endswith(".prj"):
        string = open(filepath, "r").read()
        return parse.from_unknown_wkt(string)
    
    elif filepath.endswith((".geojson",".json")):
        raw = open(filepath).read()
        geoj = json.loads(raw)
        if "crs" in geoj:
            crsinfo = geoj["crs"]
            
            if crsinfo["type"] == "name":
                string = crsinfo["properties"]["name"]
                return parse.from_unknown_text(string)
                
            elif crsinfo["type"] == "link":
                url = crsinfo["properties"]["name"]
                type = crsinfo["properties"].get("type")
                return from_url(url, format=type)
                
            else: raise FormatError("Invalid GeoJSON crs type: must be either 'name' or 'link'")

        else:
            # assume default wgs84 as per the spec
            return parse.from_epsg_code("4326")
def from_file(filepath):
    if filepath.endswith(".prj"):
        string = open(filepath, "r").read()
        return parse.from_unknown_wkt(string)
    
    elif filepath.endswith((".geojson",".json")):
        raw = open(filepath).read()
        geoj = json.loads(raw)
        if "crs" in geoj:
            crsinfo = geoj["crs"]
            
            if crsinfo["type"] == "name":
                string = crsinfo["properties"]["name"]
                return parse.from_unknown_text(string)
                
            elif crsinfo["type"] == "link":
                url = crsinfo["properties"]["name"]
                type = crsinfo["properties"].get("type")
                return from_url(url, format=type)
                
            else: raise FormatError("Invalid GeoJSON crs type: must be either 'name' or 'link'")

        else:
            # assume default wgs84 as per the spec
            return parse.from_epsg_code("4326")
def from_file ( filepath ) : if filepath . endswith ( ".prj" ) : string = open ( filepath , "r" ) . read ( ) return parse . from_unknown_wkt ( string ) elif filepath . endswith ( ( ".geojson" , ".json" ) ) : raw = open ( filepath ) . read ( ) geoj = json . loads ( raw ) if "crs" in geoj : crsinfo = geoj [ "crs" ] if crsinfo [ "type" ] == "name" : string = crsinfo [ "properties" ] [ "name" ] return parse . from_unknown_text ( string ) elif crsinfo [ "type" ] == "link" : url = crsinfo [ "properties" ] [ "name" ] type = crsinfo [ "properties" ] . get ( "type" ) return from_url ( url , format = type ) else : raise FormatError ( "Invalid GeoJSON crs type: must be either 'name' or 'link'" ) else : # assume default wgs84 as per the spec return parse . from_epsg_code ( "4326" )
Returns the crs object from a file, with the format determined from the filename extension.

    Arguments:

    - *filepath*: filepath to be loaded, including extension.
Returns the crs object from a file with the format determined from the filename extension .