def loadAreaSourceFromSHP(filename_in,
                          mmax_data,
                          background_layer,
                          filename_out=None,
                          layer2file=False,
                          ui_mode=True):
    """Load area source layer from Shapefile, independent of QGis UI."""

    temp_area_source_layer = QgsVectorLayer(filename_in, "Area Sources", "ogr")

    # PostGIS SRID 4326 is allocated for WGS84
    crs = QgsCoordinateReferenceSystem(
        4326, QgsCoordinateReferenceSystem.PostgisCrsId)

    layer = utils.shp2memory(temp_area_source_layer, "Area Sources")
    layer.setCrs(crs)

    # check if all features are okay
    _checkAreaSourceLayer(layer, ui_mode=ui_mode)

    # assign Mmax from Meletti data set
    assignMmaxfromMelettiDataset(layer, mmax_data)

    # assign attributes from background zones
    assignAttributesFromBackgroundZones(layer,
                                        background_layer,
                                        MCDIST_ATTRIBUTES,
                                        ui_mode=ui_mode)

    # write memory layer to disk (as a Shapefile)
    if layer2file is True:
        utils.writeLayerToShapefile(layer, filename_out, crs, ui_mode=ui_mode)

    return layer
def loadAreaSourceFromSHP(filename_in, mmax_data, background_layer, 
    filename_out=None, layer2file=False, ui_mode=True):
    """Load area source layer from Shapefile, independent of QGis UI."""
    
    temp_area_source_layer = QgsVectorLayer(filename_in, "Area Sources", "ogr")

    # PostGIS SRID 4326 is allocated for WGS84
    crs = QgsCoordinateReferenceSystem(4326, 
        QgsCoordinateReferenceSystem.PostgisCrsId)

    layer = utils.shp2memory(temp_area_source_layer, "Area Sources")
    layer.setCrs(crs) 

    # check if all features are okay
    _checkAreaSourceLayer(layer, ui_mode=ui_mode)

    # assign Mmax from Meletti data set
    assignMmaxfromMelettiDataset(layer, mmax_data)
    
    # assign attributes from background zones
    assignAttributesFromBackgroundZones(layer, background_layer, 
        MCDIST_ATTRIBUTES, ui_mode=ui_mode)

    # write memory layer to disk (as a Shapefile)
    if layer2file is True:
        utils.writeLayerToShapefile(layer, filename_out, crs, ui_mode=ui_mode)
        
    return layer
Esempio n. 3
0
def loadFaultSourceFromSHP(filename_in, filename_out=None, layer2file=False):
    """Load fault source layer from Shapefile, independent of QGis UI."""

    temp_fault_source_layer = QgsVectorLayer(filename_in, "Fault Sources",
                                             "ogr")

    # PostGIS SRID 4326 is allocated for WGS84
    crs = QgsCoordinateReferenceSystem(
        4326, QgsCoordinateReferenceSystem.PostgisCrsId)

    layer = utils.shp2memory(temp_fault_source_layer, "Fault Sources")
    layer.setCrs(crs)

    # write memory layer to disk (as a Shapefile)
    if layer2file is True:
        utils.writeLayerToShapefile(layer, filename_out, crs)

    return layer
def loadFaultSourceFromSHP(filename_in, filename_out=None, layer2file=False):
    """Load fault source layer from Shapefile, independent of QGis UI."""
    
    temp_fault_source_layer = QgsVectorLayer(filename_in, "Fault Sources", 
        "ogr")

    # PostGIS SRID 4326 is allocated for WGS84
    crs = QgsCoordinateReferenceSystem(4326, 
        QgsCoordinateReferenceSystem.PostgisCrsId)

    layer = utils.shp2memory(temp_fault_source_layer, "Fault Sources")
    layer.setCrs(crs) 
    
    # write memory layer to disk (as a Shapefile)
    if layer2file is True:
        utils.writeLayerToShapefile(layer, filename_out, crs)
    
    return layer