POST
|
I would assume that the problem is you're giving the sum built-in function a single number when it expects a collection of numbers. 2. Built-in Functions — Python 3.7.0 documentation sum (iterable[, start])https://docs.python.org/3/library/functions.html#sum Sums start and the items of an iterable from left to right and returns the total. start defaults to 0 . The iterable’s items are normally numbers, and the start value is not allowed to be a string. Are your values Qs and Ls single float values or are they a collection of numbers?
... View more
08-10-2018
09:24 AM
|
2
|
1
|
1399
|
POST
|
Hi Samuel, I do apologize for dragging this out, but I still don't quite understand how the emit would not work. If you have time I'd be more than happy to have you log a support ticket and we can discuss this in more specifics. I wrote up a sample at http://jsbin.com/tuniwel/1/edit?js,output to test out my logic. Below is the relevant JS code. var url = "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0";
require([
"esri/map",
"esri/layers/FeatureLayer",
"dojo/domReady!"
],
function(
Map,
FeatureLayer
) {
// Create a map
var map = new Map("map", {
basemap: "hybrid",
center: [-82.44109, 35.6122],
zoom: 17
});
// Create a layer object
var layer = new FeatureLayer(url);
/* I'm using the timeout to force the issue to
occur. The application will wait 3 seconds
before wiring in the load event. This will
cause the load event to never fire. */
setTimeout(function() {
var msg = "using load event.";
// Wire into the load event.
layer.on("load", function() {
alert("Layer has loaded " + msg);
});
// Check if the layer has loaded.
/* If this is still false
then we're certain that the event was wired before the
layer finished loading and we can wait for it to fire
naturally. */
if (!layer.loaded) { alert("Waiting on load event to fire"); }
/* On the other hand, if this is true then assume that the
load event was wired after the layer has already loaded.
In this case we can force the load event to fire.
*/
else {
alert("Layer was loaded before we could finish wiring event.");
msg = "using emit to force load event.";
// Force the load event to fire
layer.emit("load", {"layer":layer});
}
}, 3000);
map.addLayer(layer);
}); You should note that if I specify 3000 on line 56 that 1) the layer loads before I can wire into the the load event and 2) the code is able to use emit to force the load event to fire. You should also note that if you change line 56 to zero that the load event fires as we would normally expect. Would you be able to modify this so that we unable to get the load event to fire? If you can then I would be able to easily display this issue to our developers so that we determine how to address this issue. I do understand that at the moment you're committed to using version 3.x of the JavaScript API. Although it's a moot point, I do feel that promises would resolve this issue in 4.x as they would implement what you're wanting to add to the FeatureLayer class in 3.x.
... View more
05-03-2018
02:51 PM
|
0
|
0
|
914
|
POST
|
Hi Samuel, I do know that depending on the browser it is possible for the layer to load as soon as it's constructed, but I rarely run into this situation. My goal is to help you to be able to move forward with the use of the 3.x API. Within the documentation it does mention this scenario against DynamicMapServicesLayers, but I'm curious if you ever implement this in your workflow. Below is the documentation I'm referring to and you'll see that an emit was used to resolve this issue in the event that the layer loads faster than you're able to wire in the event. ArcGIS API for JavaScript- Working with Events https://developers.arcgis.com/javascript/3/jshelp/inside_events.html In Internet Explorer, due to resource caching, the onLoad event is fired as soon as the layer is constructed. Consequently you should check whether the layer's loaded property is true before registering a listener for the "load" event: on example: require(["esri/layers/ArcGISDynamicMapServiceLayer", ...
], function(ArcGISDynamicMapServiceLayer, ... ) {
var layer = new ArcGISDynamicMapServiceLayer(...);
if(layer.loaded){
printInitialExtent({"layer":layer});
} else {
layer.on("load", printInitialExtent);
}
function printInitialExtent(evt) {
console.log(evt.layer.initialExtent);
}
}); However, on has a companion function, emit . Instead of directly calling the event handler, we could have forced the event to fire using emit : on example: require(["esri/layers/ArcGISDynamicMapServiceLayer", ... ], function(ArcGISDynamicMapServiceLayer, ... ) {
var layer = new ArcGISDynamicMapServiceLayer(...);
layer.on("load", printInitialExtent);
if(layer.loaded){
layer.emit("load",{
"layer":layer
});
}
function printInitialExtent(evt) {
console.log(evt.layer.initialExtent);
}
... View more
05-03-2018
12:30 PM
|
1
|
2
|
4623
|
POST
|
Hi Samuel, Are you able to replicate a situation where the FeatureLayer loads before the next line of code can execute to wire into the load event? If so would you be able to record a video of that and send it to me? I'd be very interested in replicating this if possible.
... View more
05-02-2018
02:57 PM
|
0
|
4
|
4623
|
POST
|
Have you tried either creating a layer from the selected features or applying a definition query to the layer to display a subset of features? Working with selected features http://desktop.arcgis.com/en/arcmap/latest/map/working-with-layers/working-with-selected-features.htm#ESRI_SECTION1_EA781C8D98E54C81A68DA4FAC7B98B7F Displaying a subset of features in a layer http://desktop.arcgis.com/en/arcmap/latest/map/working-with-layers/displaying-a-subset-of-features-in-a-layer.htm
... View more
03-21-2018
07:19 AM
|
1
|
1
|
7470
|
POST
|
Hi Surendran Neelakantan, As per our phone conversation earlier, we implemented the following to resolve this issue. import arcpy
import pythonaddins
class cbxClass1(object):
"""Implementation for ComboBoxExample_addin.cbx1 (ComboBox)"""
def __init__(self):
self.items = [chr(n) * 3 for n in range(65, 65+3)] # [AAA, BBB, CCC]
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWWWW'
self.width = 'WWWWWW'
cbxClass1._hook = self
def onSelChange(self, selection):
cbxClass2._hook.items.extend([selection])
class cbxClass2(object):
"""Implementation for ComboBoxExample_addin.cbx2 (ComboBox)"""
def __init__(self):
self.items = [chr(n) * 4 for n in range(90, 90 - 3, -1)] # [ZZZ, XXX, YYY]
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWWWW'
self.width = 'WWWWWW'
cbxClass2._hook = self
def onSelChange(self, selection):
cbxClass1._hook.items.extend([selection]) As I stated on our call, there will be more than way to accomplish this. I will ensure that this approach is documentation on a public facing knowledge article. I will also pass this information along to the necessary parties to determine how we can better explain this workflow within our documentation. Please let me know if you have any problems with this. Freddie G.
... View more
02-09-2018
09:06 AM
|
1
|
1
|
1124
|
POST
|
I would assume that you were using the out-of-the-box Buffer (Analysis) tool within ArcObjects to create the one-side buffer. Buffer (Analysis) http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/buffer.htm In the above documentation for the tool you'll see that it line side parameter allows you to specify the side of the feature that will be buffered. Within the JS API there is no functionality available to the client that would allow this out-of-the-box. The suggested workflow to implement this would be to do one of the following: 1. Publish the Buffer (Analysis) tool as a Geoprocessing Service. You could then supply your features to this service along with the buffer side and the out-of-the-box GP tool would handle returning you the results you're seeking. 2. Implement logic in the JS API to cut the buffer returned by the client (i.e. when using GeometryEngine to buffer) or a service, such as using GeometryService to buffer. In regards to the second suggestion, we do not have an example of this and I cannot write one for you, but I can provide you with enough logic to implement this on your end. For example, let's say that you were buffering a straight line as shown below. geometryEngine buffer Method https://developers.arcgis.com/javascript/3/jsapi/esri.geometry.geometryengine-amd.html#buffer To get top half of this buffer I would start by first creating a line that bisects the buffer polygon. This could done in several ways depending on the API. In a simple case like shown above I could either move the x coordinate of the vertices or I could leverage the envelope of the geometry and extend the lines to them as shown below. Polygon getExtent Method https://developers.arcgis.com/javascript/3/jsapi/polygon-amd.html#getextent geometryEngine nearestCoordinate Method https://developers.arcgis.com/javascript/3/jsapi/esri.geometry.geometryengine-amd.html#nearestcoordinate Polyline insertPoint Method https://developers.arcgis.com/javascript/3/jsapi/polyline-amd.html#insertpoint Now that I have a line that bisects the polygon I could use the cut method of the geometryEngine to cut the polygon into left and right halves. I would then need to decide on which halve to persist and whether I want to replace the existing geometry or insert the data as a new record into my GraphicsLayer or FeatureLayer. Now as I stated before, I cannot implement the code for the second suggestion above. It would be your responsibility to handle the logic for this task. You'll also want to note that the workflow I describe was intended for situations where the line is straight in a cardinal direction. This will not be the case with most real world data and you will find situations where the lines are curved or at angles. You'll need to ensure that you logic takes these situations into account when creating the line to cut the polygon. I'll leave you with the last set of examples. After reviewing my suggested workflow thing about how you'd handle the following programmatically to determine the top and bottom halves of the polygon.
... View more
04-14-2017
11:08 AM
|
3
|
1
|
6644
|
POST
|
Take a look at the example I sent in my previous message. Your problem is that you need to provide the 3rd parameter as a feature class or a geometry object. By default the da cursor will return geometry as a tuple. You will want to use the Shape@ token to have it return the geometry object. Just to provide a little more detail I've also included my logic below. # Example 1
geom = next(arcpy.da.SearchCursor("fnet", "SHAPE"))[0]
arcpy.management.SelectLayerByLocation("fnet", "INTERSECT", geom)
''' In the above example "SHAPE" returns (2124.3204345703125, 3.0001017252604063) '''
# Example 2
geom = next(arcpy.da.SearchCursor("fnet", "SHAPE@XY"))[0]
arcpy.management.SelectLayerByLocation("fnet", "INTERSECT", geom)
''' In the above example "SHAPE@XY" returns (2124.3204345703125, 3.0001017252604063) '''
# Example 3
geom = next(arcpy.da.SearchCursor("fnet", "SHAPE@"))[0]
arcpy.management.SelectLayerByLocation("fnet", "INTERSECT", geom)
''' In the above example "SHAPE@" returns <Polygon object at 0x2382fcf0[0x2382f3e0]> ''' In the above examples note what is returned from the cursor. If you were to run each of these expressions you'd not that only the third one works, whereas the first two return the following exception. Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\management.py", line 7320, in SelectLayerByLocation raise e RuntimeError: Object: Error in executing tool
... View more
09-30-2016
06:31 AM
|
2
|
0
|
1877
|
POST
|
Take a look at the parameters for the tool. Select Layer By Location http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/select-layer-by-location.htm Note that the second parameter is "overlap_type" (e.g. INTERSECT, CONTAINS, etc.) and you're supplying row[1], which is a tuple representation of the geometry with the value (-9645043.375313655, 3833831.999483527).
... View more
09-30-2016
06:11 AM
|
1
|
0
|
1877
|
POST
|
I don't believe there is an out-of-the-box way to accomplish this, but it is certainly possible to implement this in ArcObjects. If you're familiar with ArcObjects you can quickly build a tool to implement this and the bulk of the logic you'd need is shown on the following page. How to add a feature class to an existing or table to an existing replica https://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#da79f58c-971a-454e-bc52-974c2c47e26a.htm The implementation will vary depending on how you want to implement this. I typically leverage it as a console application or build my own GUIs to run this process outside of ArcGIS Desktop, but you could wrap this into a custom GPFunction pretty quickly.
... View more
09-17-2016
11:53 PM
|
1
|
0
|
562
|
POST
|
Have you tried setting the PrepData submodel as a precondition to the model containing the Table to Excel tool? Otherwise have you tried modifying your submodels so that you can leverage the output of one as input to another? This would ensure that the models always run in the order you're needing.
... View more
09-16-2016
10:55 PM
|
1
|
0
|
635
|
POST
|
Hi ravi prakash, Let me explain in a little more detail how the links I sent you will relate to what you're needing to do. Let me know if this is closer to the answer you're wanting. I apologize in advance for the length of this email. As a result of not needing a GUI in both scenarios we could leverage a custom geoprocessing tool with two parameters. The first parameter could be a GPLong Input that supports either single or multiple values. It would allow the users to input the unique id(s). The second parameter would be an output or derived GPFile. This would return the pdfs to the users. Off the top of my head I could come up with two scenarios to solve this problem, in which I would use the links I provided you earlier to help me get started. Option A In this option I'd start by looking at Tutorial: Basic web map printing and exporting using arcpy.mapping—Documentation | ArcGIS for Server. I'd want to pay particular attention to how they're manipulating the map document behind the scenes. Even though you don't need a UI, you're still going to need a map document to host the data so that you can create your pdfs (i.e. MapBooks). I'd start my tool by parsing out the unique ids supplied by the user. Without using data driven pages I could use these IDs to select the data in the map, zoom to the selected item and then call arcpy.mapping.ExportToPdf to export the current view to a pdf, which I could then give to the user. If you look at Tutorial: Basic web map printing and exporting using arcpy.mapping—Documentation | ArcGIS for Server you'll see that the bulk of the workflow is already on the page. I've quickly tweaked the sample on the page to highlight how your logic would start. Note that this is just a rough draft of the needed workflow. import arcpy
import os
import uuid
# Fetch the Unique ID...Assuming we only have one
uid = arcpy.GetParameterAsText(0)
# The template location in the server data store
templateMxd = r"\\MyComputer\MyDataStore\BasicTutorial\v103\WorldTopo_103Templatev2_288k_to_1k.mxd"
# Convert the WebMap to a map document
mxd = arcpy.mapping.MapDocument(templateMxd)
# Reference the data frame that contains the map
df = arcpy.mapping.ListDataFrames(mxd)[0]
# Select the feature with the specified Unique ID
arcpy.mapping.SelectLayerByAttribute(<LAYER>, "NEW_SELECTION", "{} = {}".format(<UNIQUE_ID_FIELD>, uid))
# Zoom to the select feature
df.zoomToSelectedFeatures()
# Manipulate data frame properties as needed
# df.scale = ....
# df.extent = ...
# df.rotation = ...
# Use the uuid module to generate a GUID as part of the output name
# This will ensure a unique output name
output = 'WebMap_{}.pdf'.format(str(uuid.uuid1()))
Output_File = os.path.join(arcpy.env.scratchFolder, output)
# Export the WebMap
arcpy.mapping.ExportToPDF(mxd, Output_File)
# Set the output parameter to be the output file of the server job
arcpy.SetParameterAsText(1, Output_File)
# Clean up - delete the map document reference
filePath = mxd.filePath
del mxd, result
os.remove(filePath) To see how to manipulate the data properties you can take a look at DataFrame—Help | ArcGIS for Desktop. You'll also note that I'm only creating a single page in the above example. If you wanted to leverage multiple pages you'd also have to determine how you want to handle appending the pages into a single pdf or how to return multiple pdfs to the user. The example shown at Creating a map book with facing pages—Help | ArcGIS for Desktop will quickly show you how to append multiple pages into a single one if needed. Below is an example from the page. You'll want to keep an eye on finalPdf. import arcpy, os
# Create an output directory variable
#
outDir = r"C:\temp\MBExample\final_output"
# Create a new, empty pdf document in the specified output directory
#
finalpdf_filename = outDir + r"\FinalMB.pdf"
if os.path.exists(finalpdf_filename):
os.remove(finalpdf_filename)
finalPdf = arcpy.mapping.PDFDocumentCreate(finalpdf_filename)
# Add the title page to the pdf
#
finalPdf.appendPages(r"C:\temp\MBExample\ancillary_pages\TitlePage.pdf")
# Add the index map to the pdf
#
finalPdf.appendPages(r"C:\temp\MBExample\maps\IndexMap.pdf")
# Create Facing Pages for the map book
# Create pages for left-hand side of the book
#
mxdPathLeft = r"C:\temp\MBExample\maps\Arenac County MB Left.mxd"
tempMapLeft = arcpy.mapping.MapDocument(mxdPathLeft)
tempDDPLeft = tempMapLeft.dataDrivenPages
# Loop creates individual pdf's for odd numbered pages
#
for pgNumLeft in range(1, tempDDPLeft.pageCount + 1, 2):
temp_filename = r"C:\temp\MBExample\temp_pdfs\MB_" + \
str(pgNumLeft) + ".pdf"
if os.path.exists(temp_filename):
os.remove(temp_filename)
tempDDPLeft.exportToPDF(temp_filename, "RANGE", pgNumLeft)
# Create pages for right-hand side of the book
#
mxdPathRight = r"C:\temp\MBExample\maps\Arenac County MB Right.mxd"
tempMapRight = arcpy.mapping.MapDocument(mxdPathRight)
tempDDPRight = tempMapRight.dataDrivenPages
# Loop creates individual pdf's for even numbered pages
#
for pgNumRight in range(2, tempDDPRight.pageCount + 1, 2):
temp_filename = r"C:\temp\MBExample\temp_pdfs\MB_" + \
str(pgNumRight) + ".pdf"
if os.path.exists(temp_filename):
os.remove(temp_filename)
tempDDPRight.exportToPDF(temp_filename, "RANGE", pgNumRight)
# Append right and left-hand pages together in proper order
#
for pgNum in range(1, tempDDPLeft.pageCount + 1):
print "Page", pgNum, "of", tempDDPLeft.pageCount
tempPDF = r"C:\temp\MBExample\temp_pdfs\MB_" + str(pgNum) + ".pdf"
finalPdf.appendPages(tempPDF)
# Update the properties of the final pdf
#
finalPdf.updateDocProperties(pdf_open_view="USE_THUMBS",
pdf_layout="SINGLE_PAGE")
# Save your result
#
finalPdf.saveAndClose()
# Delete variables
#
del finalPdf, mxdPathLeft, mxdPathRight, tempDDPLeft, tempDDPRight,
tempMapLeft, tempMapRight, tempPDF Option B This option would be very similar to the first option, but instead of manipulating each page manually you could leverage data driven pages to help with the look of the pages. Instead of selecting the features and zooming to them manually, you could use the user's unique ids to locate the pageName or pageNumber for the data driven pages. Once you have this information you could write out a single or multiple pages with a single call to the DataDrivenPages.exportToPdf function. DataDrivenPages—Help | ArcGIS for Desktop For example, let's say the user gave me the IDs 1, 2, and 3. With data driven pages I could just call exportToPdf(<PDF_LOCATION>, "RANGE", "1-3") and it would put all three pages in a single pdf. To do this with the first option would take several lines of code. DataDrivenPages would also allow me to easy establish the Extent with the properties of the DataDrivenPages in the Map Document. I could tell it that I always want scale to be a certain number or a number in the field, or I could use a grid to sure all of the extents are the same, or I could even have it adjust the extent by a percentage. In it's simplest form, let's say that you named your data driven pages using the unique ids. If this were the case I could create the mapbooks with code as simple as the following. import arcpy
mxd = arcpy.mapping.MapDocument(<PATH_TO_MAP_DOCUMENT>)
pageNames = arcpy.GetParameterAsText(0).split(';')
pageIDs = [mxd.dataDrivenPages.getPageIDFromName(pageName) for pageName in pageNames]
mxd.dataDrivenPages.exportToPDF(<PATH_TO_PDF>, "RANGE", ",".join([str(n) for n in pageNames]))
arcpy.SetParameterAsText(1, <PATH_TO_PDF>)
... View more
09-15-2016
09:14 AM
|
1
|
0
|
582
|
POST
|
Hi Darrell, I'm not sure about a timeline for the fix, but you'll want to use VS 2013 in the meantime to compile your code. The method should work the same way it worked in 10.3.1
... View more
09-15-2016
08:15 AM
|
1
|
0
|
571
|
Title | Kudos | Posted |
---|---|---|
1 | 01-19-2016 04:45 AM | |
1 | 09-24-2015 06:45 AM | |
1 | 09-15-2015 10:49 AM | |
1 | 10-12-2015 03:07 PM | |
1 | 11-25-2015 09:10 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|