POST
|
I have a set of points. For each point, I want the values from a raster within a buffer radius around the point. The radius of the buffer can vary. Once I have these values, I compare them to a value from the point attributes. I'm checking to see if at least one value from the raster is +/- 1.0 from the point's value. I have figured out how to do this with ArcPy, however I have thousands of points and it takes about 30 seconds to run just 10 points. Is there a faster way to do this? I'm running Python 3.11: with arcpy.da.UpdateCursor(TestPts, fields, wclause) as cursor:
for row in cursor:
# Create a buffer polygon geometry around this point
geom = row[0]
buff = geom.buffer(thisbuffdist)
# Set the extent to just the buffer polygon
arcpy.env.extent = buff.extent
# Extract raster cells within the buffer
OutRasEBM = ExtractByMask(Ras, buff, 'INSIDE')
# Convert extracted Raster to numpy array
arr = arcpy.RasterToNumPyArray(OutRasEBM)
# Clear buff and OutRasEBM from memory
del buff, OutRasEBM
# Find if a value in the array is within 1 foot of pointvalue
pointvalue = row[1]
diffarr = arr - pointvalue
for rw in diffarr:
for x in rw:
if x > -1.0 and x < 1.0:
row[2] = 'P'
break
cursor.updateRow(row)
... View more
07-11-2024
09:40 AM
|
0
|
2
|
221
|
POST
|
I'm making a web map using the 4.23 version of the JavaScript API. I have lines in my map as a feature layer. I've created a custom symbol that includes a dot at the beginning and end of each line. I figured out how to do it using the LineSymbolMarker property while setting up my SimpleLineSymbol. However, the dots are much larger than I'd like (screenshot attached). I'd like them to be about half this size. Unfortunately, I don't see a "size" or "width" setting in the properties for the LineSymbolMarker. Has anyone else been able to change the size of the markers? If it helps, here's the line where I define the symbol: var xsSymbol = new SimpleLineSymbol( {style:'solid', color:[0,0,0,1.0], width:1.5, marker:{color:"black", placement:"begin-end", style:"circle"} });
... View more
01-27-2023
12:33 PM
|
1
|
1
|
557
|
POST
|
My web mapping application uses a custom print task, print service, and associated MXD to create a PDF of the map for users. I have a legend in MXD - it works fine, but upon adding my graphics layer to the list of Layers for the Legend (using the legendLayers property in the layoutOptions for the Print Template), the label next to the symbol says "Override 1" (see attachment). I can change the text above the symbol ("Selected Structure"), however I can not figure out how to change the piece of text to the right of the symbol. I'm using the JS API version 4.12. I tried rolling back to 4.5 but that didn't help. I also tried upgrading to 4.15 but I'm going to have to revise a bunch of my code for that version to work. I found this two-year-old post: [Override-item-names-in-legend-print-task]... But it sounds like the answer was to roll back the JS API version. Has there been any new development on this?
... View more
06-18-2020
03:48 PM
|
3
|
1
|
853
|
POST
|
I'm exploring using the Editor widget (with version 4.12) in a web map. This web map asks users to draw a polygon, then attribute the polygon with comment text and contact info. There are 6 fields for the user to fill out. Since I'm asking folks to add multiple polygons, I'd like to cut down on the amount of typing they have to do by pre-populating the contact info fields. I have a splash screen that asks for this info when they first get to the web map, so it's already saved to string variables in my JS code. Can I assign these values to the text boxes in the Editor widget right after a user completes a new polygon, so they don't have to repeatedly type in these values every time they add a new feature? This seems like something that could be in the layerInfos > fieldConfig property.
... View more
12-02-2019
03:47 PM
|
0
|
13
|
5549
|
POST
|
Are graphic elements within data frames accessible using ArcPy? I'm attempting to adjust a graphic element that I have in a MXD using ArcPy. However, it is not an element from the page layout (layout view), it is within a data frame (data view). I can't use the ListLayoutElements function because: "ListLayoutElements only returns elements from a page layout and not map annotation elements that may exist within a data frame." There's no way to accomplish this task manually - my script needs to export many images and the extent of the data frame changes for every image. Big picture: I'm trying to work around label overprints of an inset data frame just like the "Don't ignore data frames" problem in this thread: How do I force Maplex to ignore transparent polygons, not ignore Data Frames?
... View more
07-24-2019
10:06 AM
|
0
|
0
|
440
|
POST
|
Hi Robert, Thanks for the quick reply. After examining the sample and experimenting with my WMA’s code, I think another piece is setting the max-height in addition to overflow-y. Just removing the overflow: hidden; from my class’s CSS didn’t appear to help, but then adding a max-height did make the scrollbar appear when the div content was long. This will make it possible to scroll when the content of the div is longer than a set value, which is definitely helpful. However, this doesn’t 100% replicate what I was hoping. I’ve noticed that, when placed in an Expand, some widgets like Legend will automatically add or remove the vertical scrollbar depending on the height of the browser window (see screenshots below). The only difference between these two screenshots is that, for the second image, I made the browser window shorter. It seems either the Expand or the Widget is set to change its own height depending on the height of the browser window…?
... View more
02-14-2018
12:29 PM
|
0
|
0
|
1476
|
POST
|
I’ve learned that I really like the Expand widget in the ArcGIS API for JavaScript 4.X. When I simply add a single widget (like BasemapGallery or Legend) to an Expand, a vertical scrollbar will appear if the content of the expanded pane is longer than the bottom of the screen. This is great, it’s what I want. It happens often enough, like when I’m demoing a web map in a meeting room with a projector. However, when I make up custom content to put in an Expand, the vertical scrollbar doesn’t appear. The content I’m making is a div with HTML (text, input buttons, etc). I’ve tried creating a class to assign to the div, with the settings of overflow:hidden; overflow-y:auto; but this hasn’t worked.
... View more
02-13-2018
11:34 AM
|
0
|
2
|
2256
|
POST
|
Well, after months of working on other things, I inadvertently stumbled upon a work-around that removed the field name from the legend. I'm now using version 3.16. I set the attributeField property of the ClassBreaksRenderer to a function (instead of just giving it the name of a field). So, the line of code that creates my ClassBreaksRenderer is: flyrRenderer = new CBRenderer(null, rendfunc0); And the function that determines the values (located just above the renderer-creating line) is: rendfunc0 = function(feature) {
var value = (feature.attributes)[field];
return value;
} I kept everything else the same - setting class breaks, symbols, etc. And now there is no field name showing up in the legend. This accomplishes the task I was setting out to do... There may be a better answer out there (perhaps in JS API 4?).
... View more
06-17-2016
12:36 PM
|
0
|
0
|
1402
|
POST
|
I have a feature layer of polygons in my map (I'm using version 3.16). I have fields in this layer that I want to use to label the polygons. I have been able to use LabelClass and labelExpressionInfo to simply label the polygons with values from individual fields. Now I want to take it a step further. Is it possible to use a function to label my polygons with the result of subtracting one field’s values from another? For example, I have two fields named JanTemp and JanNormTemp. One polygon has a JanTemp value of 27.9 and a JanNormTemp of 29.4. I’m trying to symbolize and label the polygons with the departure from Norm value, which in this case would be -1.5. I don’t want to just add a new field to the polygons and calculate the departures… I’m trying to have this figure itself out programmatically. I was able to get the ClassBreaksRenderer to do this. Here is the function I defined first: // Function for renderer
rendfunc = function(value) {
var attr = value.attributes;
var start = attr[field1];
var minus = attr[field2];
return (start-minus);
} And then here is the line I used to create the CBR: // Set up renderer
var flyrRenderer = new CBRenderer(null, rendfunc); So far I have unsuccessful with my attempts at labeling the polygons in a similar fashion. Has anyone else done this?
... View more
06-03-2016
12:14 PM
|
0
|
0
|
1589
|
POST
|
I edited my code a bit more, so I figured I'd share. For the 'Clear' button, instead of running code similar to the 'Set' function, now it simply sets the values of the text boxes in the left pane to blank strings, and then runs the 'Set' function. function clickBtnClearDefaultInfo() {
txt1.value = '';
txt2.value = '';
txt3.value = '';
txt4.value = '';
clickBtnSetDefaultInfo();
}
... View more
04-27-2016
07:41 AM
|
0
|
0
|
817
|
POST
|
Wow, Robert, your help has saved me so much time! I had to tweak the code a bit to get it to work in my WMA, but now it is doing exactly what I wanted! Users have the option to enter their default information in the text boxes in the left pane, and click OK: Here is the code for the function that runs when the OK button is clicked: function clickBtnSetDefaultInfo() {
var inname = txt1.value;
var incomm = txt2.value;
var inemail = txt3.value;
var inphone = txt4.value;
// Set auto population of commenter fields
theEditor.settings.editor.templatePicker.on("selection-change", lng.hitch(this, function() {
var selected = theEditor.settings.editor.templatePicker.getSelected();
if (selected) {
fLayerPt.on("before-apply-edits", lng.hitch(this, function(evt){
if(evt.adds && evt.adds.length > 0){
if(evt.adds[0].attributes.hasOwnProperty('CommenterName')){ evt.adds[0].attributes.CommenterName = inname; }
if(evt.adds[0].attributes.hasOwnProperty('CommenterComm')){ evt.adds[0].attributes.CommenterComm = incomm; }
if(evt.adds[0].attributes.hasOwnProperty('CommenterEmail')){ evt.adds[0].attributes.CommenterEmail = inemail; }
if(evt.adds[0].attributes.hasOwnProperty('CommenterPhone')){ evt.adds[0].attributes.CommenterPhone = inphone; }
theEditor.settings.editor.attributeInspector.refresh();
}
}));
}
}));
} And then here is the popup when the user adds a new point: The Clear button will run a similar function to the OK button, it sets the text box values and the default values to "". Thanks again!
... View more
04-25-2016
04:23 PM
|
0
|
1
|
817
|
POST
|
I have successfully edited my own feature service with a web mapping application I created starting with the “Editor widget with simple toolbar” sample. Now, I’m trying to add something extra to the new WMA and haven’t quite figured it out. My features are points. They are all contained in one feature layer in my WMA. When the user clicks on or adds a new point, they see a popup with seven editable attributes. My assumption is that some users will want to add many points, but since some of the attributes will be the same for all of their points, they would want to be able to set default values for some of these attributes. I have been able to set up text boxes in the left pane of my WMA to accept default values, now I just need to figure out how to make them show up in the popup when a user adds a new point. Screenshot of the popup (for a point that already exists) Screenshot of the left pane (for setting default values)
... View more
04-25-2016
01:04 PM
|
0
|
3
|
2749
|
POST
|
...and, after getting lunch with another GIS-savvy co-worker, I figured out a solution. The selections on my feature layers needed to be cleared. I added two lines to the beginning of my refresh function, so now it looks like this: function refresh() {
map.infoWindow.hide();
flyrTracks.clearSelection();
flyrCounties.clearSelection();
// SET UP defquery STRING HERE
flyrTracks.setDefinitionExpression(defquery);
flyrTracks.redraw();
}
... View more
04-01-2016
11:11 AM
|
1
|
0
|
520
|
POST
|
I have two feature layers in my map. I have separate info templates defined and assigned to each. One feature layer is of contiguous polygons (counties), so clicking on one to show the info window popup is not difficult for the user. However, the other feature layer is lines, which requires some precision to click and see the info window popup. So, I added some code to create a buffer extent around the clicked map point. However, I think this workaround had an unintended consequence. In addition to viewing the lines, I also have a few options (radio buttons, etc) on the side, so the user can filter which lines are viewed. This is accomplished by having a ‘refresh’ function that runs when one of the filter options are used. It calculates a definition query and assigns it to the lines feature layer. My problem occurs when the user clicks a line (showing the popup), and then sets one of the filter options. The line with the current popup gets ‘stuck’, and will show even if it does not match the definition query. Once the user clicks on a different line, or on the map, then the problem line disappears. Any ideas as to what causes the line to be ‘stuck’ on? Is it a graphic thing? Here are the parts of my code that I think are relevant. First the buffer & map onclick functions: // Buffer function
function pointToExtent (map, point, toleranceInPixel) {
var pixelWidth = map.extent.getWidth() / map.width;
var toleranceInMapCoords = toleranceInPixel * pixelWidth;
return new Extent(point.x - toleranceInMapCoords,
point.y - toleranceInMapCoords,
point.x + toleranceInMapCoords,
point.y + toleranceInMapCoords,
map.spatialReference);
}
// Set up feature layer popups (to include buffer for tracks)
var query = new Query();
map.on("click", function (event) {
if (rdo1.checked == true) {
query.geometry = pointToExtent(map, event.mapPoint, 8);
var deferred = flyrTracks.selectFeatures(query, FeatureLayer.SELECTION_NEW); }
else if (rdo2.checked == true) {
query.geometry = pointToExtent(map, event.mapPoint, 1);
var deferred = flyrCounties.selectFeatures(query, FeatureLayer.SELECTION_NEW); }
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(event.mapPoint);
}); And the refresh function that runs to filter the lines: function refresh() {
map.infoWindow.hide();
// SET UP defquery STRING HERE
flyrTracks.setDefinitionExpression(defquery);
flyrTracks.redraw();
}
... View more
04-01-2016
10:03 AM
|
0
|
1
|
3926
|
POST
|
I was using the ArcPy documentation. I wrote a script to create my test exports. The Production PDF stuff is new to me, however, I'm not sure I have access to the Production Mapping extension... I put " import arcpyproduction " in my script and got a 'No module' error. My desktop is running ArcGIS 10.2.2. We do have a few machines with 10.3, I'll look into using this when one is available. We have a good mix of data types on these maps... A raster (photo) basemap, with multiple layers of polygons (7), lines (11), and a few points(2). Plus a few (3) annotation layers for good measure. It seems a lot of threads I found on GeoNet related to PDF export issues were typically about fonts/marker symbols, or ArcMap getting hung up/crashing. LIke you said, there are a lot of unique issues out there. I feel like Issue #1 isn't as important, since really all the user has to do is zoom in and see that the lines don't actually look like that.
... View more
03-08-2016
11:37 AM
|
0
|
0
|
598
|
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
|