POST
|
And only using version 3.14 . When I switch to version 3.13, the attribute field name doesn't show up. At least this has been a learning experience, I've never really used the Inspector before. Maybe I just need to learn to create my own Legend from scratch without using the widget. That will probably satisfy the control freak in me Thanks for your suggestions!
... View more
10-09-2015
04:50 PM
|
0
|
0
|
1155
|
POST
|
Upon closer inspection, you did put ServiceLabel the first time. I was trying LayerLabel for whatever reason. So, I tried ServiceLabel in place of LayerLabel. It did remove the title from the legend (August 2015, Average Temperature (°F) ), but the field name (Temp) was still there...
... View more
10-09-2015
03:17 PM
|
0
|
2
|
1155
|
POST
|
This was interesting. So, I added this line to the <style> section of my htm file: .esriLegendLayerLabel{display:none !important; } However, the field name was still showing in the legend. But, then I switched the version of the API I was referencing... I changed from 3.14 back to 3.13. And that seemed to do the trick, the field name was not showing any more. Unfortunately, I was purposely using 3.14 because can easily round/pad the decimal numbers for polygon labels in my feature layer... So for now at least, I guess we'll just have to decide which is more important to us.
... View more
10-09-2015
01:51 PM
|
0
|
5
|
1155
|
POST
|
OK, FIrefox has an inspector as well. I haven't used it much, but now's a good time to start, right! Here's the link to our ENSO Comparison Tool.
... View more
10-09-2015
01:35 PM
|
0
|
0
|
1155
|
POST
|
This is similar to a question in another recent post of mine – but since this is dealing with generating maps using a print service, I figure it warranted a separate post. I have a map that’s showing a feature layer. The feature layer has been symbolized in the code using a class breaks renderer. I’ve also set up custom map templates and a custom print service, to have control over the details of how an exported map will look. There are two things that I’m having trouble figuring out: 1 - In the exported map, the name of the feature class (also the layer name in the service) shows up in the legend… I don’t want that there. Interestingly, it does not show up in the Legend Dijit. Just in an exported image. 2 - I’d like to know if there is a way to force the legend to display multiple columns, since I have a portrait layout and only 3 or 4 classes will fit in one column before the legend goes off the page. Is there a setting somewhere in the renderer that I can use? Do I set that up in the custom mxd? It is saved with no layers in it, so I'm not sure how any settings I make there would carry through to when it's used with the print service.
... View more
10-09-2015
11:09 AM
|
2
|
19
|
11118
|
POST
|
I’m sure I’m just one line of code away from getting this to work just right! In my code, I have a feature layer that is being symbolized with a class breaks renderer. I also have a Legend (Dijit?). The Title, color swatches and class labels are all showing up OK. However, the legend is also showing what attribute field the renderer is using. I’m guessing that I just need to add a line and use CSS (esriLegendServiceLabel?) to get this to go away, but I just can’t quite figure out what to put. Here’s a screenshot. I circled the field name that I want not to display in light blue.
... View more
10-09-2015
10:48 AM
|
0
|
11
|
4403
|
POST
|
Aha! That was it! The labels round/pad correctly now. Thanks for digging into this with me!
... View more
10-01-2015
01:06 PM
|
0
|
0
|
1576
|
POST
|
Hm, I edited my code to match, but that still didn't do it. The label symbol looks different though. It must be something else in my code that's messing it up. There's a lot more going on in addition to the label changes - changing symbology, text, etc. I figured out how to share on JS Bin (which I didn't even know about until I saw the examples that Kelly Hutchins posted-thanks!) and put the whole thing here: JS Bin - Collaborative JavaScript Debugging
... View more
10-01-2015
12:34 PM
|
0
|
2
|
1576
|
POST
|
Well, I got LabelClass to work, so I've partially succeeded. However, setting the fieldInfos>format>places doesn't seem to be doing the trick for me. Here's the code I implemented. The variables flayer, field and labelCDvSymbol are defined earlier in my code. var labelsCDs = new LabelClass({labelExpressionInfo: {"value": "{"+field+"}"}, minScale: 10000000});
labelsCDs.fieldInfos = [{"fieldName": field, "format": {"places": 1}}];
labelsCDs.symbol = labelCDvSymbol;
console.log(labelsCDs);
fLayer.setLabelingInfo([labelsCDs]); The labels show the correct field and font/symbol, but they're still just not rounded/padded to the tenth. I can see in the console that the fieldInfos>format>places has been set to 1.
... View more
10-01-2015
11:39 AM
|
0
|
4
|
1576
|
POST
|
Ah, I see - use LabelClass instead of LabelLayer. I think I may have initially blown off LabelClass since the documentation seems to be for ArcGISDynamicMapServiceLayer instead of FeatureLayer. The example is very helpful, I got LabelClass to work with the FeatureLayer in my web map pretty quickly. Thanks! Not sure if it's possible to mark two answers as correct in the forums (since Tim's suggestion worked as well)... But I'm definitely marking this as helpful.
... View more
10-01-2015
08:50 AM
|
0
|
0
|
2054
|
POST
|
I have a web map with a FeatureLayer (polygons). I’m using a LabelLayer to label the polygons with a double-type field. My values in the field go to the hundredth, but some don’t. (example image below) I want to show all labels with values to the tenth, which means some will have to be rounded, and others will have to be padded on the right with “.0” I know how to do this in ArcMap - go to the layer’s attribute table, go to the field’s numeric properties, set how many decimal places to show, also check the ‘Pad with zeros’ box. How do I accomplish this with my web map? I can’t find a decimal places setting in the documentation for LabelLayer... Is there a round/pad function I can use in the textExpression of the addFeatureLayer method? Or is there a way to set field display properties in the map service?
... View more
09-25-2015
08:35 AM
|
0
|
10
|
5129
|
POST
|
You know what, that did the trick. Maybe not the most elegant solution, I'm still open to other ideas, but right now this works so I'm running with it. Just had to add a few lines of code around my addFeatureLayer line that I'd posted above. map.removeLayer(lLayer);
lLayer = new LabelLayer('layerlabel','STATIC');
lLayer.minScale = 10000000;
lLayer.addFeatureLayer(fLayer, labelRenderer, ("{" + field + "}"));
map.addLayer(lLayer);
... View more
09-24-2015
12:07 PM
|
1
|
1
|
2054
|
POST
|
So – I have a web map that I’ve made from scratch using the ArcGIS API for Javascript. In this web map I have multiple feature layers (all polygons) that have multiple numeric fields. Users have the ability to choose what they want to see (in essence, choosing a feature layer and field combination) using dropdowns and radio buttons. I have figured out how to change the symbology and labels of the polygons shown at any given time. My problem is with the Label Layer. The way I have my code written, every time the user changes an option, a new feature layer is added to the Label Layer. While this ensures that the correct labels are shown, after about a dozen option changes, performance really takes a hit and the view in the web map is glacially slow to update. Is there a way to just change the field (of the Feature Layer) that the Label Layer is showing without having to add a new feature layer to the Label Layer each time? I’ve poked around in the documentation for LabelLayer but haven’t found what I’m looking for. I feel like I’m just missing something obvious here. Here is the one line that adds the feature layer (the variables lLayer, fLayer, labelRenderer, and field are all calculated before here). If I comment out this line, everything runs great, but there are no labels. lLayer.addFeatureLayer(fLayer, labelRenderer, ("{" + field + "}"));
... View more
09-24-2015
10:06 AM
|
0
|
10
|
5680
|
POST
|
I also find that the ExportToPNG() line appears to be where my script fails. One difference that I see between our scripts is that I only use one mxd for exporting. I have at least figured out that only certain map sets fail, so at this point I have gotten my script to run all the way through without crashing... but I now it only makes half of the maps that it used to. I wonder if this is related to Python 2.7, since everything was fine with ArcGIS 10.0 and Python 2.6. I tried to shave my code down (I omitted the data creation / geoprocessing portion of the script since it works fine every time), but it is still kinda long for a forum post. Well, here it is: import string, os, sys, datetime, shutil, arcpy, urllib, gc
# Set Folder
Folder = r'C:\Users\username\VegetationImpactProgram'
print Folder
#Other variables...
FGDB = Folder + '\\freeze\\stations.gdb'
FGDBras = Folder + '\\freeze\\rasters.gdb'
FGDBgddras = Folder + '\\freeze\\gddrasters.gdb'
mapsfolder = Folder + '\\maps\\freeze\\stationdata'
themxd = Folder + '\\mxd_templates\\freeze_stationdata.mxd'
dpi = 100
# Lists
cwa010 = ('SEW', 'OTX', 'PQR', 'PDT', 'MFR', 'BOI')
cwa020 = ('EKA', 'STO', 'REV', 'LKN')
cwa030 = ('HNX', 'LOX', 'SGX', 'VEF', 'MTR')
cwa040 = ('MSO', 'TFX', 'PIH', 'GGW', 'BYZ', 'RIW', 'CYS')
cwa050 = ('SLC', 'GJT', 'BOU', 'PUB')
cwa060 = ('PSR', 'FGZ', 'TWC', 'ABQ', 'EPZ')
cwa070 = ('BIS', 'FGF', 'UNR', 'ABR', 'FSD')
cwa080 = ('LBF', 'GID', 'GLD', 'DDC', 'TOP', 'ICT', 'OAX')
cwa090 = ('AMA', 'LUB', 'OUN', 'TSA')
cwa100 = ('MAF', 'SJT', 'FWD', 'EWX', 'HGX', 'CRP', 'BRO')
cwa110 = ('DLH', 'MPX', 'ARX')
cwa120 = ('DVN', 'LOT', 'ILX', 'DMX')
cwa130 = ('EAX', 'SGF', 'LSX', 'PAH')
cwa140 = ('LZK', 'SHV', 'LCH', 'MEG', 'JAN', 'LIX')
cwa150 = ('MQT', 'GRB', 'MKX', 'APX', 'GRR', 'DTX')
cwa160 = ('CLE', 'ILN', 'RLX', 'IWX', 'IND')
cwa170 = ('LMK', 'OHX', 'JKL', 'MRX')
cwa180 = ('FFC', 'HUN', 'BMX', 'MOB')
cwa190 = ('CAR', 'GYX', 'BTV', 'ALY', 'BOX', 'OKX')
cwa200 = ('BUF', 'BGM', 'CTP', 'PHI', 'PBZ')
cwa210 = ('LWX', 'RNK', 'AKQ')
cwa220 = ('RAH', 'MHX', 'ILM', 'GSP', 'CAE', 'CHS')
cwa230 = ('TAE', 'JAX', 'MLB', 'TBW', 'MFL', 'KEY')
cwaall = cwa010 + cwa020 + cwa030 + cwa040 + cwa050 + cwa060 + cwa070 + cwa080 + cwa090 + cwa100 + cwa110 + \
cwa120 + cwa130 + cwa140 + cwa150 + cwa160 + cwa170 + cwa180 + cwa190 + cwa200 + cwa210 + cwa220 + cwa230
areas = (['010',cwa010,'-117.0',0.1,10000,0],['020',cwa020,'-118.0',0.25,10000,25000],['030',cwa030,'-112.0',0.1,10000,0], \
['040',cwa040,'-108.0',0.1,0,0],['050',cwa050,'-107.0',0.15,0,0],['060',cwa060,'-110.0',0.2,0,0], \
['070',cwa070,'-100.0',0.1,0,0],['080',cwa080,'-100.0',0.1,0,0],['090',cwa090,'-99.0',0.2,0,0], \
['100',cwa100,'-100.0',0.1,0,0],['110',cwa110,'-95.0',0.15,0,10000],['120',cwa120,'-91.0',0.15,0,0], \
['130',cwa130,'-92.0',0.25,0,0],['140',cwa140,'-92.0',0.1,10000,0],['150',cwa150,'-88.0',0.1,0,0], \
['160',cwa160,'-86.0',0.1,20000,-10000],['170',cwa170,'-88.0',0.2,-70000,0],['180',cwa180,'-88.0',0.1,10000,0], \
['190',cwa190,'-78.0',0.05,-70000,0],['200',cwa200,'-80.0',0.05,-20000,0],['210',cwa210,'-81.0',0.2,-50000,0], \
['220',cwa220,'-83.0',0.2,0,0],['230',cwa230,'-86.0',0.1,-10000,15000],['US',cwaall,'-100.0',-0.19,-150000,-50000])
types = ['pt', 'py']
temps = ['32', '28']
varis = ['dtf', 'date', 'days', 'dblw']
gdd_temps = ['mg', '42', '45', '50', '54']
mapsets = ['pt_sus','pt_lmin','py_lmin','pt_mmin','py_mmin']
# Start to Calculate the list of maps to make
for vari in varis:
for temp in temps:
for type in types:
mapsets.append(type + '_' + vari + '_' + temp)
# Set today's date and time
today = datetime.datetime.today()
todaydate = today.strftime('%m%d')
thisyear = today.strftime('%Y')
thismonth = today.strftime('%m')
if thismonth == '1' or thismonth == '2' or thismonth == '01' or thismonth == '02':
marfirst = datetime.datetime((int(thisyear)-1), 3, 1)
else:
marfirst = datetime.datetime((int(thisyear)), 3, 1)
date = today.strftime('%Y%m%d')
# Figure out what month this is (to choose symbology)
thismonthabv = today.strftime('%b')
# Figure out which end dates to use for GDD (based on today's date)
gdd_dates = []
for temp in temps:
gdd_dates.append('lt' + temp)
# Calculate the rest of the mapset list
for temp in gdd_temps:
for date in gdd_dates:
for typ in types:
mapsets.append(typ + '_gd_' + temp + '_' + date) # add all GDD to mapsets
print 'mapsets:', len(mapsets), mapsets
# # The next portions of the script include gathering and reading input data sources,
# # creating point, polygon and raster data, and calculating these string variables:
# == datadate, titledate, frzpoints_lyr, frzpoints_name, frzpoints_full_name, thiessens ==
# Make all the maps!
gc.enable()
try:
# set mxd
mxd = arcpy.mapping.MapDocument(themxd)
# make up layer variables for the layers in the mxd
dataframe = arcpy.mapping.ListDataFrames(mxd, 'Layers')[0]
cwaareaslyr = arcpy.mapping.ListLayers(mxd, 'CWA_areas', dataframe)[0]
cwaslyr = arcpy.mapping.ListLayers(mxd, 'CWA_bndy', dataframe)[0]
stateslyr = arcpy.mapping.ListLayers(mxd, 'States', dataframe)[0]
statesloreslyr = arcpy.mapping.ListLayers(mxd, 'States_lores', dataframe)[0]
countieslyr = arcpy.mapping.ListLayers(mxd, 'US_Counties', dataframe)[0]
countiesloreslyr = arcpy.mapping.ListLayers(mxd, 'US_Counties_lores', dataframe)[0]
masklyr = arcpy.mapping.ListLayers(mxd, 'States_mask', dataframe)[0]
# Set variables for legends/legend images
legendpt = arcpy.mapping.ListLayoutElements(mxd, 'LEGEND_ELEMENT', 'PntLegend')[0]
legendpy = arcpy.mapping.ListLayoutElements(mxd, 'LEGEND_ELEMENT', 'RasLegend')[0]
legendptMar = arcpy.mapping.ListLayoutElements(mxd, 'PICTURE_ELEMENT', 'frz_legend_pt_date_Mar')[0]
legendpyMar = arcpy.mapping.ListLayoutElements(mxd, 'PICTURE_ELEMENT', 'frz_legend_py_date_Mar')[0]
legendptApr = arcpy.mapping.ListLayoutElements(mxd, 'PICTURE_ELEMENT', 'frz_legend_pt_date_Apr')[0]
legendpyApr = arcpy.mapping.ListLayoutElements(mxd, 'PICTURE_ELEMENT', 'frz_legend_py_date_Apr')[0]
legendptMay = arcpy.mapping.ListLayoutElements(mxd, 'PICTURE_ELEMENT', 'frz_legend_pt_date_May')[0]
legendpyMay = arcpy.mapping.ListLayoutElements(mxd, 'PICTURE_ELEMENT', 'frz_legend_py_date_May')[0]
legends = [legendpt, legendpy, legendptMar, legendpyMar, legendptApr, legendpyApr, legendptMay, legendpyMay]
# clear out def queries off the bat
cwaareaslyr.definitionQuery = ''
cwaslyr.definitionQuery = ''
stateslyr.definitionQuery = ''
statesloreslyr.definitionQuery = ''
countieslyr.definitionQuery = ''
countiesloreslyr.definitionQuery = ''
masklyr.definitionQuery = ''
for mapset in mapsets:
print 'mapset = ' + mapset
temp = mapset[-2:]
# figure out layer names for this mapset
if mapset[3:5] <> 'gd':
layernmpt = 'pt' + mapset[2:]
if len(mapset) == 6:
layernmras = 'sus_ras'
if len(mapset) == 7:
layernmras = mapset[3:] + '_ras'
if len(mapset) == 9:
layernmras = 'dtf_ras'
if len(mapset) == 10:
layernmras = mapset[3:-3] + '_ras'
else:
if mapset[6:8] <> 'mg':
layernmpt = 'pt_gd' + mapset[6:8] + '_' + temp
layernmras = 'gdd_ras'
elif mapset[6:8] == 'mg':
layernmpt = 'pt_mgdd_' + temp
layernmras = 'mgdd_ras'
if mapset[3:-3] == 'date':
layernmpt = layernmpt + '_' + thismonthabv
layernmras = layernmras + '_' + thismonthabv
# make up layer variables for data layers
try:
ptthislyr = arcpy.mapping.ListLayers(mxd, layernmpt, dataframe)[0]
ptthislyr.definitionQuery = "\"ST\" <> 'ON' AND \"ST\" IS NOT NULL"
except:
layernmpt = 'pt_blank'
ptthislyr = arcpy.mapping.ListLayers(mxd, layernmpt, dataframe)[0]
try:
rasthislyr = arcpy.mapping.ListLayers(mxd, layernmras, dataframe)[0]
except:
layernmras = 'blank_ras'
rasthislyr = arcpy.mapping.ListLayers(mxd, layernmras, dataframe)[0]
# set data source for this mapset (use if statements if making points maps in addition to poly maps)
if mapset[:2] == 'pt':
ptthislyr.replaceDataSource (FGDB, 'FILEGDB_WORKSPACE', frzpoints_name, False)
if mapset[:2] == 'py':
if mapset[3:5] <> 'gd':
if len(mapset) == 7:
datanm = 'l' + mapset[4:]
else:
datanm = mapset[3:-3] + mapset[-2:]
else:
datanm = 'gd' + mapset[6:8] + mapset[-4:]
if mapset[3:5] == 'gd':
thisras = FGDBgddras + '\\' + datanm
if arcpy.Exists(thisras):
rasthislyr.replaceDataSource (FGDBgddras, 'FILEGDB_WORKSPACE', datanm, False)
else:
layernmras = 'blank_ras'
rasthislyr = arcpy.mapping.ListLayers(mxd, layernmras, dataframe)[0]
else:
thisras = FGDBras + '\\' + datanm
if arcpy.Exists(thisras):
rasthislyr.replaceDataSource (FGDBras, 'FILEGDB_WORKSPACE', datanm, False)
else:
layernmras = 'blank_ras'
rasthislyr = arcpy.mapping.ListLayers(mxd, layernmras, dataframe)[0]
# set visibility for data layers and mask layer
for lyr in arcpy.mapping.ListLayers(mxd):
lyr.visible = False
if mapset[:2] == 'pt':
ptthislyr.visible = True
rasthislyr.visible = False
masklyr.visible = False
elif mapset[:2] == 'py':
ptthislyr.visible = True
rasthislyr.visible = True
masklyr.visible = True
for reg in areas:
area = reg[0]
# area-specific variables
cm = reg[2]
scaleadj = reg[3]
xadj = reg[4]
yadj = reg[5]
# set visibility of basemap layers
if area <> 'US':
cwaareaslyr.visible = False
cwaslyr.visible = True
stateslyr.visible = True
countieslyr.visible = True
statesloreslyr.visible = False
countiesloreslyr.visible = False
else:
cwaareaslyr.visible = False
cwaslyr.visible = False
stateslyr.visible = False
countieslyr.visible = False
statesloreslyr.visible = True
countiesloreslyr.visible = False
if mapset[:2] == 'py':
ptthislyr.visible = False
# def query for cwas in area
defq = ''
for regst in reg[1]:
defq = defq + " OR \"CWA\" = '" + regst + "'"
defq = defq[4:]
# Adjust spatial reference
spatref = dataframe.spatialReference
spatrefstring = 'PROJCS["US_National_Atlas_Equal_Area",GEOGCS["GCS_Sphere_Clarke_1866_Authalic",DATUM["D_Sphere_Clarke_1866_Authalic",SPHEROID["Sphere_Clarke_1866_Authalic",6370997.0,0.0]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",' + cm + '],PARAMETER["Latitude_Of_Origin",45.0],UNIT["Meter",1.0],AUTHORITY["EPSG",2163]]'
spatref.loadFromString(spatrefstring)
dataframe.spatialReference = spatref
# Select area's CWAs and zoom to them
cwaslyr.definitionQuery = ''
arcpy.SelectLayerByAttribute_management(cwaslyr, 'NEW_SELECTION', defq)
dataframe.extent = cwaslyr.getSelectedExtent(False)
arcpy.SelectLayerByAttribute_management(cwaslyr, 'CLEAR_SELECTION')
# Zoom and/or pan if needed
newscale = dataframe.scale
newscale = newscale + (newscale * scaleadj)
dataframe.scale = newscale
ext = dataframe.extent
ext.XMin = ext.XMin + xadj
ext.XMax = ext.XMax + xadj
ext.YMin = ext.YMin + yadj
ext.YMax = ext.YMax + yadj
dataframe.panToExtent(ext)
# Set title and other text
if mapset == 'pt_sus':
titletext1 = 'Freeze Susceptibility' + '\n' + ' *Trial Product*'
elif mapset[3:] == 'lmin':
titletext1 = 'Lowest Minimum Temperature (' + u'\u00B0F)' + '\n' + 'since 8/1 <FNT size="12">(' + u'10\u00B0F to 50\u00B0F' + ')</FNT>'
elif mapset[3:] == 'mmin':
titletext1 = 'Lowest Minimum Temp (' + u'\u00B0F)' + '\n' + 'since 8/1 <FNT size="12">(' + u'-38\u00B0F to 10\u00B0F' + ')</FNT>'
elif mapset[3:-3] == 'dtf':
titletext1 = 'Date of First ' + temp + u'\u00B0F Freeze' + '\n' + 'since 8/1'
elif mapset[3:-3] == 'date':
titletext1 = 'Date of Most Recent ' + temp + u'\u00B0F Freeze' + '\n' + 'since 8/1'
elif mapset[3:-3] == 'days':
titletext1 = 'Days since Most Recent ' + temp + u'\u00B0F Freeze' + '\n' + 'since 8/1'
elif mapset[3:-3] == 'dblw':
titletext1 = 'Number of Days with Minimum Temperature <= ' + temp + u'\u00B0F' + '\n' + 'During the Past 14 Days'
elif mapset[6:8] == 'mg' and mapset[9:11] <> 'lt':
titletext1 = 'Accumulated Modified Growing Degree Days' + '\n' + 'Since ' + str(int(mapset[-4:-2])) + '/' + str(int(mapset[-2:]))
elif mapset[6:8] == 'mg' and mapset[9:11] == 'lt':
titletext1 = 'Accumulated Modified Growing Degree Days' + '\n' + 'Since Most Recent ' + temp + u'\u00B0F Freeze'
elif mapset[3:5] == 'gd' and mapset[9:11] <> 'lt':
titletext1 = 'Accumulated Growing Degree Days <FNT size="12">(base ' + mapset[6:8] + u'\u00B0F)</FNT>' + '\n' + 'Since ' + str(int(mapset[-4:-2])) + '/' + str(int(mapset[-2:]))
elif mapset[3:5] == 'gd' and mapset[9:11] == 'lt':
titletext1 = 'Accumulated Growing Degree Days <FNT size="12">(base ' + mapset[6:8] + u'\u00B0F)</FNT>' + '\n' + 'Since Most Recent ' + temp + u'\u00B0F Freeze'
elm = arcpy.mapping.ListLayoutElements(mxd, 'TEXT_ELEMENT', 'Title1')[0]
elm.text = titletext1
elm = arcpy.mapping.ListLayoutElements(mxd, 'TEXT_ELEMENT', 'Title2')[0]
elm.text = 'As of ' + titledate
# Move around legends if needed
for legend in legends:
legend.elementPositionY = 7.49
if mapset[3:-3] == 'date' and (thismonthabv == 'Mar' or thismonthabv == 'Apr' or thismonthabv == 'May'):
if mapset[:2] == 'pt' and thismonthabv == 'Mar':
legends[2].elementPositionY = 6.49
elif mapset[:2] == 'py' and thismonthabv == 'Mar':
legends[3].elementPositionY = 6.49
elif mapset[:2] == 'pt' and thismonthabv == 'Apr':
legends[4].elementPositionY = 6.49
elif mapset[:2] == 'py' and thismonthabv == 'Apr':
legends[5].elementPositionY = 6.49
elif mapset[:2] == 'pt' and thismonthabv == 'May':
legends[6].elementPositionY = 6.49
elif mapset[:2] == 'py' and thismonthabv == 'May':
legends[7].elementPositionY = 6.49
else:
if mapset[:2] == 'pt':
legends[0].elementPositionY = 6.49
elif mapset[:2] == 'py':
legends[1].elementPositionY = 6.49
# Use ArcPy to make PNG
arcpy.RefreshActiveView()
if mapset[-3:] == 'sus':
pngname = area + '_freeze_' + mapset[:2] + '_' + mapset[-3:] + '_' + datadate
elif mapset[-4:] == 'lmin' or mapset[-4:] == 'mmin':
pngname = area + '_freeze_' + mapset[:2] + '_' + mapset[-4:] + '_' + datadate
elif mapset[3:5] <> 'gd':
pngname = area + '_freeze_' + mapset[:2] + '_' + mapset[3:-3] + '_' + temp + '_' + datadate
else:
if mapset[9:11] == 'lt':
if mapset[6:8] <> 'mg':
pngname = area + '_freeze_' + mapset[:2] + '_' + mapset[3:5] + mapset[6:8] + '_' + temp + '_' + datadate
else:
pngname = area + '_freeze_' + mapset[:2] + '_' + mapset[6:8] + 'dd_' + temp + '_' + datadate
else:
if mapset[6:8] <> 'mg':
pngname = area + '_freeze_' + mapset[:2] + '_' + mapset[3:5] + mapset[6:8] + '_' + mapset[-4:] + '_' + datadate
else:
pngname = area + '_freeze_' + mapset[:2] + '_' + mapset[6:8] + 'dd_' + mapset[-4:] + '_' + datadate
# Export and Copy maps
out_png = mapsfolder + '\\' + pngname + '.png'
print out_png
arcpy.mapping.ExportToPNG (mxd, out_png, '', 0, 0, dpi)
print pngname + ' exported'
try:
# Copy PNG to (M:)
pngcopy = 'M:\\' + pngname[:-9] + '.png'
shutil.copyfile (out_png, pngcopy)
except:
print '...FAILED to copy ' + pngname + ' to (M:)'
try:
# Copy PNG to (W:)
pngcopy = 'W:\\ROOT\\VIP\\frz_maps\\images\\' + pngname[:-9] + '.png'
shutil.copyfile (out_png, pngcopy)
except:
print '...FAILED to copy ' + pngname + ' to (W:)'
except:
print '...Map exports not complete', arcpy.GetMessages()
# Save and close MXD
mxd.save()
del mxd
... View more
08-21-2015
11:53 AM
|
0
|
0
|
1055
|
POST
|
I have noticed during my tests that the script will get significantly farther if I omit certain data sets from the list of maps to be exported. Python still eventually crashes, but some times I can get almost 500 maps (which is better than just 30 maps). Maybe I should just split this one big script into two separate scripts...
... View more
07-31-2015
11:53 AM
|
0
|
0
|
1055
|
Title | Kudos | Posted |
---|---|---|
1 | 04-07-2014 08:57 AM | |
2 | 01-06-2011 07:44 AM | |
1 | 01-27-2023 12:33 PM | |
3 | 06-18-2020 03:48 PM | |
1 | 02-11-2016 03:53 PM |
Online Status |
Offline
|
Date Last Visited |
07-11-2024
07:57 PM
|