Exemplo n.º 1
0
                            elif Pysakointi == "4":
                                Break = str(int(float(Break) - 0.16))
                    #----------------------------------------------------------------------------------------

                #Tehdään ServiceAreaLayer:
                if float(Break) <= 0.0:
                    if infoCheck == False:
                        teksti = "Break arvo: " + Break + ". Palvelualueen raja-arvoksi muodoistui <= 0 minuuttia! Ei laskettu palvelualuetta."
                        msg(teksti)
                        infoCheck = True
                else:

                    #Tehdään ServiceAreaLayer:
                    arcpy.MakeServiceAreaLayer_na(
                        NetworkData, BreakName, Impedanssi, Suunta, Break,
                        Details, Overlap, RinDisk, Lines, "OVERLAP",
                        "NO_SPLIT", "", Accumulation, "ALLOW_DEAD_ENDS_ONLY",
                        "", Trim, TrimCut, "")

                    #Lisätään yksitellen kohteet Facilityiksi:
                    facility = temp + "\\" + facility + ".shp"
                    desc = arcpy.Describe(facility)
                    arcpy.AddLocations_na(BreakName, "Facilities", facility,
                                          "", "1000 Meters", "", "",
                                          "MATCH_TO_CLOSEST", "CLEAR",
                                          "NO_SNAP", "5 Meters", "EXCLUDE", "")

                    #Suoritetaan laskenta:
                    arcpy.Solve_na(BreakName)

                    #Lisätään kartalle:
##create points at the intersections of streams and patch edges for use in distance calculation
patchPointTemp = os.path.join(outDir, "patchPointTemp.shp")
arcpy.Intersect_analysis([streams, patches],
                         patchPointTemp,
                         output_type="POINT")

##explode multipoint objects
patchPoints = os.path.join(outDir, "patchPoints.shp")
arcpy.MultipartToSinglepart_management(patchPointTemp, patchPoints)

arcpy.AddMessage("Starting Distance Measurements Between Patches...")

##make new service area analysis
distThreshMeters = float(distThresh) * 1000
arcpy.MakeServiceAreaLayer_na(streamNetwork,
                              "ServiceArea",
                              "Length",
                              default_break_values=distThreshMeters)

##Process: Add Locations, using PatchID (Feat_ID) as name
arcpy.AddMessage("Adding Points to Network Dataset...")
arcpy.AddLocations_na("ServiceArea",
                      "Facilities",
                      patchPoints,
                      "Name Feat_ID #",
                      append="CLEAR")

##Solve
arcpy.AddMessage("Solving Network Analysis (longest step)...")
arcpy.Solve_na("ServiceArea", "SKIP", "TERMINATE", "")

##save polygons
Exemplo n.º 3
0
if(a>b): 
    errorFlag = True
    arcpy.AddError("Lower radius is greater than upper radius")
    
if errorFlag:
    arcpy.AddError("Error, Halting")
    sys.exit(1)

   
    
#smoothing
arcpy.SetProgressor("step","Running Analysis",int(a),int(b+d),int(d))
for breakValue in range(a,b+d,d):
    arcpy.SetProgressorLabel("Creating Network")
    arcpy.MakeServiceAreaLayer_na(nd_streets,"SA", option_measureField,"TRAVEL_FROM",breakValue,"SIMPLE_POLYS","MERGE","RINGS","NO_LINES","#","#","#","#","ALLOW_UTURNS","#","#","#","#")
    arcpy.AddLocations_na("SA", "Facilities", "Input", "","")
    arcpy.SetProgressorLabel("Solving Network")
    arcpy.Solve_na("SA")
    arcpy.SetProgressorLabel("Smoothing Ring")
    extentValue = (arcpy.Describe("Polygons").extent.Xmax - arcpy.Describe("Polygons").extent.Xmin)/8+(arcpy.Describe("Polygons").extent.Ymax - arcpy.Describe("Polygons").extent.Ymin)/8
    arcpy.SmoothPolygon_cartography("Polygons","Smooth","PAEK",str(extentValue*smoothFactor), False )
    if breakValue == a: #This condition is the first ring to export, so it has unique
        arcpy.PolygonToLine_management("Smooth", v_output)
        arcpy.AddField_management(v_output,option_measureField,"LONG")
        arcpy.CalculateField_management(v_output,option_measureField, breakValue)
    else:
        arcpy.PolygonToLine_management("Smooth", "SmoothLines")
        arcpy.AddField_management("SmoothLines",option_measureField,"LONG")
        arcpy.CalculateField_management("SmoothLines",option_measureField, breakValue)
        arcpy.Append_management("SmoothLines",v_output)
Exemplo n.º 4
0
# Local variables:
StreetCenterlines_NetworkDataset_nd = "Z:\\AdvancedGIS\\FinalProject\\Data1\\StreetCenterlines_NetworkDataset.nd"
Service_Area = "ServiceArea"
Service_Area_with_Destinations = Service_Area
Solved_Service_Area = Service_Area_with_Destinations
Solve_Succeeded = "true"
Parcels_shp = "Z:\\AdvancedGIS\\FinalProject\\Data1\\Parcels.shp"
Polygons = Solved_Service_Area
SAPolygons_Layer = "SAPolygons_Layer"
AllWalkableParcels_shp = "Z:\\AdvancedGIS\\FinalProject\\Data1\\AllWalkableParcels.shp"
WalkableParcels_shp = "Z:\\AdvancedGIS\\FinalProject\\Data1\\WalkableParcels.shp"

# Process: Make Service Area Layer
arcpy.MakeServiceAreaLayer_na(
    StreetCenterlines_NetworkDataset_nd, "ServiceArea", "Length",
    "TRAVEL_FROM", Default_Break_Values, "SIMPLE_POLYS", "NO_MERGE", "RINGS",
    "NO_LINES", "OVERLAP", "NO_SPLIT", "", "", "ALLOW_UTURNS", "Oneway",
    "TRIM_POLYS", "100 Meters", "NO_LINES_SOURCE_FIELDS", "NO_HIERARCHY", "")

# Process: Add Locations
arcpy.AddLocations_na(
    Service_Area, Select_Layer_Type, Destinations_Layer, "Name Address #",
    "5000 Meters", "",
    "Hennepin_County_Street_Centerlines SHAPE;StreetCenterlines_NetworkDataset_Junctions NONE",
    "MATCH_TO_CLOSEST", "APPEND", "NO_SNAP", "5 Meters", "INCLUDE",
    "Hennepin_County_Street_Centerlines #;StreetCenterlines_NetworkDataset_Junctions #"
)

# Process: Solve
arcpy.Solve_na(Service_Area_with_Destinations, "SKIP", "TERMINATE", "", "")
Exemplo n.º 5
0
def service_area_use_meters(net,
                            rdv,
                            distance,
                            loc,
                            out,
                            OVERLAP=True,
                            ONEWAY=None):
    """
    Execute service area tool using metric distances
    """

    from glass.mng.gen import copy_feat

    if arcpy.CheckExtension("Network") == "Available":
        arcpy.CheckOutExtension("Network")

    else:
        raise ValueError('Network analyst extension is not avaiable')

    network_name = str(os.path.basename(net))
    JUNCTIONS = network_name + '_Junctions'

    oneway = "" if not ONEWAY else "Oneway"

    INTERVALS = str(distance) if type(distance) == int or \
        type(distance) == float else distance if \
        type(distance) == str or type(distance) == unicode \
        else ' '.join([str(int(x)) for x in distance]) if \
        type(distance) == list else None

    if not INTERVALS: raise ValueError(('distance format is not valid'))

    arcpy.MakeServiceAreaLayer_na(
        in_network_dataset=net,
        out_network_analysis_layer="servArea",
        impedance_attribute="Length",
        travel_from_to="TRAVEL_FROM",
        default_break_values=INTERVALS,
        polygon_type="DETAILED_POLYS",
        merge="NO_MERGE" if OVERLAP else "NO_OVERLAP",
        nesting_type="RINGS",
        line_type="NO_LINES",
        overlap="OVERLAP" if OVERLAP else "NON_OVERLAP",
        split="NO_SPLIT",
        excluded_source_name="",
        accumulate_attribute_name="",
        UTurn_policy="NO_UTURNS",
        restriction_attribute_name=oneway,
        polygon_trim="TRIM_POLYS",
        poly_trim_value="250 Meters",
        lines_source_fields="NO_LINES_SOURCE_FIELDS",
        hierarchy="NO_HIERARCHY",
        time_of_day="")

    # Add locations to the service area layer
    arcpy.AddLocations_na(
        "servArea", "Facilities", loc, "", "5000 Meters", "",
        "{_rdv} SHAPE;{j} NONE".format(_rdv=str(rdv), j=str(JUNCTIONS)),
        "MATCH_TO_CLOSEST", "APPEND", "NO_SNAP", "5 Meters", "INCLUDE",
        "{_rdv} #;{j} #".format(_rdv=str(rdv), j=str(JUNCTIONS)))
    # Solve
    arcpy.Solve_na("servArea", "SKIP", "TERMINATE", "")
    # Export to a shapefile
    save_servArea = copy_feat("servArea\\Polygons", out, gisApi='arcpy')

    return save_servArea
Exemplo n.º 6
0
arcpy.env.workspace = "CURRENT"

# global variables
temp = "temp"
outlayer, unused = os.path.split(net_set)
fin_layer = outlayer + "/"+unused+"_"+dist+".lyr" # No longer needed but kept for my own purposes

# functions
try:
    # Begin Progressor bar...
    arcpy.SetProgressor("step","Beginning Build...", 0, 4, 1)
    # Make sure Network Extension is present, will return explained error if extension is not available
    arcpy.CheckOutExtension("Network")
    
    # Create a Service Area Layer
    arcpy.MakeServiceAreaLayer_na(net_set, temp, "Length", "TRAVEL_FROM", dist, "SIMPLE_POLYS", "NO_MERGE")
    arcpy.SetProgressorLabel("Adding Locations...")
    arcpy.SetProgressorPosition(1)
    # Add Locations to Network Layer for Buffers
    arcpy.AddLocations_na(temp, "Facilities", points, "", "")
    arcpy.SetProgressorLabel("Solving...")
    arcpy.SetProgressorPosition(2)
    # Create buffers based on line distance from specified points
    arcpy.Solve_na(temp)
    arcpy.SetProgressorLabel("Creating Layer...")
    arcpy.SetProgressorPosition(3)
    # check to see if the output file already exists, WILL DELETE ANY PRE-EXISTING FILE WITH THE SAME NAME!!
    if arcpy.Exists(outfile):
        arcpy.Delete_management(outfile)
    # Save layer file
    arcpy.SaveToLayerFile_management(temp, outfile, "RELATIVE")