def deleteLayers(self):
     '''
     @param: self
     @brief: Elimina las capas de los dataframes
     :return: None
     '''
     [
         mapping.RemoveLayer(df, l) for df in self.dataframes
         for l in mapping.ListLayers(self.mxd, '', df)
     ]
Exemplo n.º 2
0
                # update and insert layer
                main_df = mp.ListDataFrames(mxd)[1]
                main_lyrs = mp.ListLayers(mxd, "", main_df)

                for lyr in main_lyrs:
                    lyr_name = lyr.name

                    if "Sea" in lyr_name:
                        lyr.transparency = 0
                    elif "Contours" in lyr_name:
                        print "Updating %s" % lyr_name
                        mp.UpdateLayer(main_df, lyr, ref_lyr)
                    elif "Bathymetry" in lyr_name:
                        print "Removing %s" % lyr_name
                        mp.RemoveLayer(main_df, lyr)
                    else:
                        pass
                        #print 'no'

                #save mapdoc
                mxd.save()

                #export map
                map_name = os.path.join(out_dir, mdoc_name)
                print "Exporting %s" % mapdoc
                mp.ExportToPNG(mxd, map_name, resolution=250)

                print '\n'
                del mxd, lyr
                count += 1
Exemplo n.º 3
0
FeatureClassToFeatureClass_conversion(r"Database Connections\CANP.sde\NM3.NM_NLT_CRND_CRND_SDO", STAGEDB, "CRND" )
TableToTable_conversion(r'Database Connections\CANP.sde\KDOT.MV_MAP_EXTRACT', STAGEDB, "Map_Extract")
TableToTable_conversion(r'Database Connections\CANP.sde\NM3.NM_ELEMENTS_ALL', STAGEDB, "ELEMENTS_ALL")
TableToTable_conversion(r'Database Connections\CANP.sde\NM3.NM_MEMBERS_ALL', STAGEDB, "MEMBERS_ALL") #Members takes a long time to copy


#To copy the SECT layer it must be joined to preserve RSE_HE_ID
MakeFeatureLayer_management(r"Database Connections\CANP.sde\NM3.NM3_NET_MAP_SECT_TABLE", "NM_SECT" )
MakeTableView_management(STAGEDB+r"\Elements_ALL", "ELEMENTS")
AddJoin_management("NM_SECT", "RSE_HE_ID", "ELEMENTS", "NE_ID", "KEEP_COMMON")
FeatureClassToFeatureClass_conversion("NM_SECT", STAGEDB, "SECT" )

#Remove the CANP Prod layers
for df in mapping.ListDataFrames(mxd):
    for lyr in mapping.ListLayers(mxd, "", df):
        mapping.RemoveLayer(df, lyr)
RefreshActiveView()

#Start the processing to rebuild layers
MakeFeatureLayer_management(STAGEDB+r"\SRND", "SRND")
SRNDelem = "NE_NT_TYPE = 'SRND' AND NE_VERSION_NO in ('EB', 'NB')"
MakeTableView_management(STAGEDB+r"\ELEMENTS_ALL", "SRND_ELEM", SRNDelem)
AddJoin_management("SRND", "NE_ID", "SRND_ELEM", "NE_ID", "KEEP_COMMON")

#Create the vertices for calibration points
FeatureVerticesToPoints_management("SRND", STAGEDB+"/Calibration_Points_SRND","ALL")
AddXY_management("GIS_CANSYS.DBO.Calibration_Points_SRND")
'''
LocateFeaturesAlongRoutes_lr(ws+"\\"+tempgdb+"/Calibration_Points",ws+"\\"+tempgdb+"/SRND","NE_UNIQUE","0.001 Feet",ws+"\\"+tempgdb+"/CP_SRND","STATE_MILE POINT SR_MEAS","ALL","DISTANCE","ZERO","FIELDS","M_DIRECTON")
AddJoin_management("SECT","RSE_HE_ID","Elements","NE_ID","KEEP_COMMON")
Exemplo n.º 4
0
                                                  styleItem,
                                                  show_feature_count=True)
##                                    if item.name == str(Cfc):
##                                       legend.removeItem(item)
##                                    if item.name == str(Officialfc) or item.name == str(RMSHDfc):
##                                        legend.updateItem(item, show_feature_count = True)

#Refresh TOC and ActiveView
                            arcpy.RefreshActiveView()
                            arcpy.RefreshTOC()

                            map.ExportToPDF(
                                mxd, r"C:/gc_work/evl/Outputs/" + floodmodel +
                                "_" + name + ".pdf")

                            map.RemoveLayer(df, InputBuildingLayer_temp)
                            map.RemoveLayer(df, InputRMSHDFishnetLayer_temp)
                            map.RemoveLayer(df, InputOfficialFishnetLayer_temp)
                            map.RemoveLayer(df, InputCityLayer_temp)
                            map.RemoveLayer(df, BuildingLayer)
                            map.RemoveLayer(df, RMSHDFishnetLayer)
                            map.RemoveLayer(df, OfficialFishnetLayer)
                            map.RemoveLayer(df, CityLayer)

                            ##                    mxd.save()

                            del InputBuildingLayer_temp, InputRMSHDFishnetLayer_temp, InputOfficialFishnetLayer_temp, InputCityLayer_temp
                            del BuildingLayer, RMSHDFishnetLayer, OfficialFishnetLayer, CityLayer
                    del Cfc
                del RMSHDfc
            del Officialfc
rasDir2 = "F:\\NFIE_SI_2016\\groupProject\\postprocessOutput\\rasters\\composites\\"
outlyrDir = "F:\\NFIE_SI_2016\\groupProject\\postprocessOutput\\rasters\\layers\\"

# Source layers that will be used for symbology reference
fldext_srcLyr = mp.Layer(outlyrDir + "fldext_source_stretch.lyr")
wd_srcLyr = mp.Layer(outlyrDir + "wd_source_stretch.lyr")
fv_srcLyr = mp.Layer(outlyrDir + "fv_source_stretch.lyr")
crit_srcLyr = mp.Layer(outlyrDir + "crit_source_stretch.lyr")

spatialRef = arcpy.SpatialReference(
    3857)  # 3857 is code for WGS_1984_Web_Mecator (auxiliary sphere)

# Remove all current possible layers in the MXD
for df in mp.ListDataFrames(mxd):
    for lyr in mp.ListLayers(mxd, "*", df):
        mp.RemoveLayer(df, lyr)

# Set up raster list
dirList2 = os.listdir(rasDir2)

# List the files found in dirList with their full pathname
rasList2 = [
    rasDir2 + filename for filename in dirList2 if filename.endswith(".tif")
]

# Set up loop for adding raster layers to MXD
for ras in rasList2:
    rasName2 = os.path.basename(ras[:-4])
    if "Per" in rasName2:
        outLyr = outlyrDir + rasName2 + ".lyr"
        tmpLyr = outlyrDir + rasName2
Exemplo n.º 6
0
                                                  show_feature_count=True)

                        BuildingLayer.name = "Open Street map building"
                        FishnetLayer.name = "Number of flooded buildings"
                        InputBuildingLayer_temp.name = "Open Street map building"
                        InputFishnetLayer_temp.name = "Number of flooded buildings"

                        #Refresh TOC and ActiveView
                        arcpy.RefreshActiveView()
                        arcpy.RefreshTOC()

                        map.ExportToPDF(
                            mxd, r"C:/gc_work/evl/Outputs/" + floodmodel +
                            "_" + name + ".pdf")

                        map.RemoveLayer(df, InputBuildingLayer_temp)
                        map.RemoveLayer(df, InputFishnetLayer_temp)
                        map.RemoveLayer(df, InputCityLayer_temp)
                        map.RemoveLayer(df, BuildingLayer)
                        map.RemoveLayer(df, FishnetLayer)
                        map.RemoveLayer(df, CityLayer)

                        #mxd.save()
                        del InputBuildingLayer_temp, InputFishnetLayer_temp, BuildingLayer, FishnetLayer, CityLayer, InputCityLayer_temp
                    del Cfc
                del Ffc
            del Bfc
        del mxd
    else:
        print("GDB Does not exists")
        arcpy.AddMessage("GDB Does not exists")