|
POST
|
You are exporting a "Map", it sounds like you want to export "Data" As you dont provide a "Dataframe" parameter in this line of code, you will get that. arcpy.mapping.ExportToPDF(mxd, export + "\\" + preFix + pageName + ".pdf", resolution = res, df_export_width=1600, df_export_height=1200*ar, geoTIFF_tags=True) From help: ExportToTIFF (map_document, out_tiff, {data_frame}, {df_export_width}, {df_export_height}, {resolution}, {world_file}, {color_mode}, {tiff_compression}, {geoTIFF_tags}) data_frame A variable that references a DataFrame object. Use the string/constant "PAGE_LAYOUT" to export the map document's page layout instead of an individual data frame. (The default value is PAGE_LAYOUT)
... View more
11-11-2016
06:45 AM
|
1
|
1
|
1535
|
|
POST
|
You can and most likely do have multiple pythons on your computer! Therefore, your IDE is hooked up to the wrong python! E.g. if you type into dos: python C:\myfile.py it actually looks in a windows registry, and runs: (as an aexample, not your setup!) C:\python27\python.exe C:\myfile.py You need to make sure whatever you use to run it, uses the correct python.exe (Installed when you setup arcgis). This setup stage, should also allow autocomplete to work using any python IDE.
... View more
11-10-2016
10:09 AM
|
0
|
2
|
2735
|
|
POST
|
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0] #the 1st data frame
print df.extent
print df.extent.XMin
print df.extent.XMax
print df.extent.YMin
print df.extent.YMax
... View more
11-10-2016
09:56 AM
|
2
|
1
|
1631
|
|
POST
|
import arcpy
distances = ["1 Mile", "2 Mile"]
for distance in distances:
outfile = "wp%s" % distance
arcpy.Buffer_analysis(SP, outfile, distance, "FULL", "ROUND", "", "BUFF_DIST")
out = arcpy.env.workspace
lyr = ["wp1 Mile", "wp2 Mile"]
#shplist = arcpy.ListFeatureClasses(lyr, "Polygon")
merge_out_path = os.path.join(out, "mile1_2")
arcpy.Merge_management(lyr, merge_out_path)
dissolve_out_path = os.path.join(out, "mile1_2_dissolved")
arcpy.Dissolve_management(merge_out_path, dissolve_out_path, ["BUFF_DIST"]) This will give you the geometry you want. You need to work out how to combine the attributes yourself if needed. (e.g. the features in 1 mile, you have multiple Account Numbers + Pins that you now want to store in 1 row.
... View more
11-10-2016
06:57 AM
|
0
|
0
|
1182
|
|
POST
|
Hi there! The "OpenDocument" trigger, does not call an init, your code should probably look like this. import arcpy
import pythonaddins
class JoinRoads(object):
"""Implementation for RoadsScript_addin.extension2 (Extension)"""
def openDocument (self):
Roads_2015 = "Roads 2015"
Roads_2015__2_ = Roads_2015
All_roads = "private\\transportation_FA_wa\\All roads"
# Process: Add Join
arcpy.AddJoin_management(Roads_2015, "BRUCE_ID", All_roads, "BRUCE_ID", "KEEP_ALL")
... View more
11-10-2016
02:49 AM
|
2
|
0
|
1042
|
|
POST
|
If you had issues with indentation in pyscripter using your notepad ++ file, it sounds like you have got your notepad setup wrong for python! The problem is, you are mixing "Tabs" with "Spaces" To fix --> Open notepad ++ "Settings" --> "Preferences" --> "Language Menu / Tab Settings" Find Python On the right, tick the box "replace by space" and choose a number of spaces. Now when you use tab, it will behind the scenes put in spaces, and make sure that what you see is exactly as python will read the indentation.
... View more
11-10-2016
02:45 AM
|
1
|
1
|
2085
|
|
POST
|
You cant do what you asked. You can however achieve the exact same results by: Add 10 scale bars with unique names 'Off page', in different styles and stuff, and then use python to move them onto the page as needed for different maps. OR Create 10 "MXD" templates with different page setups, and use the code to determine which template to use. OR Think of something else ..be creative!
... View more
11-10-2016
02:03 AM
|
0
|
0
|
1821
|
|
POST
|
I have found testing to be 1000x easier since I installed my Add-in using a network location, instead of manually! 1) Delete the add-in if you already installed it. 2) Customise --> Add-in manager --> Options --> Search for additional add-ins in these folders" 3) Add the location that your "makeaddin.py" creates the .esriaddin file as a location. 4) Now, if you run "makeaddin.py", then reboot arcmap, you are using the latest version of the code without having to do an extra click to install it!
... View more
11-09-2016
08:08 AM
|
1
|
1
|
2085
|
|
POST
|
Please provide us with your script to maybe help us out a bit more, are the fields named the same in the Feautreset as the Table you tested with? Could you do: featureset = arcpy.FeatureSet() featureset .load(input_data) featureset .save(temporary_table.shp) tool_run(temporary_table.shp)
... View more
11-04-2016
09:06 AM
|
0
|
2
|
826
|
|
POST
|
My understanding of field mappings is you create an empty fieldmap. fieldmappings = arcpy.FieldMappings() Then you popupulate it using tables like we did, or alternatively you could do it totally manually as the example on the help page shows. There they create an output field mapping that has 2 fields. It looks pretty complex but heres a simple, 1 field output map! input_file1 = 'data.gdb/Trees'
input_file2 = 'Plants.shp'
######You could loop this bit
field_map = arcpy.FieldMap()
field_name_input_file1 = "Tree_Type"
field_name_input_file2 = "Tree_Species"
field_map.addInputField(input_file1, field_name_input_file1)
field_map.addInputField(input_file2, field_name_input_file2)
field_map.name = 'Tree_Classification'
fieldmappings.addFieldMap(field_map) With this in mind, our output fieldmap we have created, actually contains all of the 'target' and all of the 'append' layers fields, but as you are running append you dont see all the unmatched 'append' fields in the output. If you ran the same field map through a merge, you would end up with all the append layers fields as well.
... View more
11-03-2016
04:48 PM
|
1
|
1
|
3368
|
|
POST
|
__author__ = 'WebbL'
import arcpy
append_layer = r'C:\a_layer.shp'
target_layer = r'C:\target_layer.shp'
#This object looks like the empty grid of fields
#you see when you first open the append tool in the toolbox
fieldmappings = arcpy.FieldMappings()
#Like when you manually choose a layer in the toolbox and it adds the fields to grid
fieldmappings.addTable(target_layer)
fieldmappings.addTable(append_layer)
#####Lets map fields that have different names!
list_of_fields_we_will_map = []
#Lets chuck some tuples into the list we made
list_of_fields_we_will_map.append(('TaxPIN', 'Permanent_Identifier'))
list_of_fields_we_will_map.append(('SwissBankNo', 'RetirementFundAccNo'))
list_of_fields_we_will_map.append(('Balance', 'Amount'))
for field_map in list_of_fields_we_will_map:
#Find the fields index by name. e.g 'TaxPin'
field_to_map_index = fieldmappings.findFieldMapIndex(field_map[0])
#Grab "A copy" of the current field map object for this particular field
field_to_map = fieldmappings.getFieldMap(field_to_map_index)
#Update its data source to add the input from the the append layer
field_to_map.addInputField(append_layer, field_map[1])
#We edited a copy, update our data grid object with it
fieldmappings.replaceFieldMap(field_to_map_index, field_to_map)
#Create a list of append datasets and run the the tool
inData = [append_layer]
arcpy.Append_management(inData, target_layer, field_mappings=fieldmappings) Here you go
... View more
11-03-2016
04:16 PM
|
10
|
4
|
14977
|
|
POST
|
import arcpy
append_layer = r'C:\a_layer.shp'
target_layer = r'C:\target_layer.shp'
#This is like defining an empty grid of fields you see when you run it manually in the toolbox
fieldmappings = arcpy.FieldMappings()
#Add the target datasets fields to the field map table (Like when you manually choose a tagert layer in the toolbox)
fieldmappings.addTable(target_layer)
#Add the append datasets fields to the field map table (Like when you manually choose a tagert layer in the toolbox)
fieldmappings.addTable(append_layer)
#At this point, you have a grid like when you run it manually saved in your field mappings.
#####Lets map a field that have different names!
#Find which "Index" the field has as we cant refer to them by name when editing the data only index
field_to_map_index = fieldmappings.findFieldMapIndex("Field_name_in_target") #Field name that exists in the target layer but not append data source!
#Grab "A copy" of the field map object for this particular field
field_to_map = fieldmappings.getFieldMap(field_to_map_index)
#Update its data source to add the input from the the append layer
field_to_map.addInputField(append_layer, "Field_name_in_append")
#####Lets update the master field map using this updated copy of a field
fieldmappings.replaceFieldMap(field_to_map_index, field_to_map)
#Create a list of append datasets and run the the tool
inData = [append_layer]
arcpy.Append_management(inData, target_layer, field_mappings=fieldmappings) I havent tested this code, but I think it should work
... View more
11-03-2016
09:07 AM
|
4
|
6
|
14977
|
|
POST
|
The creators pretty bad but I have a workaround that works for me every time: 1) Take a copy of my "Addin.py" file with the UI (button) code in. 2) Delete the config.xml 3) Resave the addin using the wizard. (change a text box and then back if the save button is greyed out.) 4) Delete the new Addin.py file, and put mine back. I have no idea if this is it, but in In my config.xml files, in the 'toolbar' line of code, the refID matches the Class in the buttonas, in yours the Toolbar simply references 'button' not 'ButtonClass1' <Button caption="Select by Location" category="Select by Location" class="ButtonClass1" id="SelectbyLocation_addin.button" image="Images\SelectionSelectByLocation16.png" message="Select by Location" tip="Select by Location"><Help heading="Select by Location">Select by Location</Help></Button> Button refID="SelectbyLocation_addin.button"
# ---> Change to
Button refID="SelectbyLocation_addin.ButtonClass1"
in this line of code:
<Toolbar caption="select by location" category="Select by Location" id="SelectbyLocation_addin.toolbar" showInitially="true"><Items><Button refID="SelectbyLocation_addin.button" /></Items></Toolbar>
... View more
11-03-2016
07:39 AM
|
0
|
2
|
2171
|
|
POST
|
Make sure the tool is called "SelectByLocation" when you set up the toolbox in Arc through the GUI, that might be the label or description instead! Im not sure, but you could try open arcmap, then open the python window, then drag your tool from the toolbox into the window, it should maybe tell you what its name is there.
... View more
11-03-2016
07:03 AM
|
0
|
5
|
2171
|
|
IDEA
|
They need to fix this! (Yes another victim here ) ... this issue also holds back the implementation of newer versions within our organisation as we like to all update at once, for only this reason.
... View more
11-02-2016
07:18 AM
|
0
|
0
|
1335
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-29-2019 07:45 AM | |
| 1 | 05-13-2013 07:11 AM | |
| 1 | 05-24-2011 07:53 AM | |
| 1 | 05-22-2017 05:01 AM | |
| 2 | 07-29-2019 05:34 AM |
| Online Status |
Offline
|
| Date Last Visited |
10-22-2024
10:40 AM
|