|
POST
|
Dumb mistake: make sure not to check "Keep all target features" if you know some of them might be thrown out because they don't meet the condition... Fixed my problem.
... View more
06-22-2018
11:11 AM
|
0
|
0
|
1363
|
|
POST
|
I am using the geoprocessing tool Spatial Join (not to be confused with the right-click on layer > Join > spatial join). I have two polygons that are not near the base polygon. My spatial join clause is finding features within 55 meters of the base polygon, but it picks up these two features as well and I have no idea why. I have buffered the base polygon by 55 meters and it doesn't touch those two polygons (I have also buffered in the other direction, two polygons to base). I have also entered a distance of 0 and I still get these results.. I have also tried changing the method to intersect and again, still get these results... The projections are the same for each layer (USA Contiguous Albers Equal Area Conic). This is driving me nuts because it's very important this tool performs correctly for a production script. Measured... Buffered...
... View more
06-22-2018
10:48 AM
|
0
|
1
|
1466
|
|
POST
|
You always come through for me Robert. Thanks a lot.
... View more
06-20-2018
10:44 AM
|
0
|
0
|
1630
|
|
POST
|
I have been attempting to query all features in a layer and just return one field. Is this allowed? I cannot get it to work with any of my map services, but examples I have looked at in the API reference documentation do not always specify where clauses or objectIds to query, so that leads me to think it's allowed. I am trying to run this snippet, but every time I run it, it goes to the errorResults function: var printQLyr = new QueryTask("https://www.xxxxxx.org/xxxxxx/rest/services/HBM/HBD/MapServer/3");
printQuery = new Query();
printQuery.outFields = ["Name"];
printQLyr.execute(printQuery, printQResults, errorResults);
function printQResults(featureSet) {
var resultFeatures = featureSet.features;
console.log(resultFeatures[0]);
}
function errorResults(message) {
console.log(message);
} This is the error message I receive (entirely unhelpful): Error
at Object.A.m.load (init.js:1028)
at init.js:87
at c (init.js:103)
at d (init.js:103)
at b.Deferred.resolve.callback (init.js:105)
at c (init.js:104)
at d (init.js:103)
at b.Deferred.resolve.callback (init.js:105)
at init.js:92
at h (init.js:107) Even when I run this in the ArcGIS JS sandbox, I receive this error. I receive this same error for any map service I try (I change the outField when I change the map service so I know that's not causing an error). Additionally, if I add either a line like printQuery.where = "StateID = 'VA'"; or printQuery.objectIds = [1]; The query will run perfectly fine and return the records. I can run the query in the REST API as long as I specify something in the "where" box or the "objectIds" box. If I specify nothing but an outField it will not return anything but I do not get an error message either. How do I query all features in a dataset? Feature layer settings:
... View more
06-20-2018
10:30 AM
|
0
|
2
|
1841
|
|
POST
|
I know you can adjust the column count for the whole legend with the method adjustColumnCount(), but I am wondering if you can adjust the number of columns for a single legend item instead of the whole legend? I am creating a custom print task where users can select what layers they want to include and how to symbolize them - if they choose to symbolize it in a certain way (they choose a particular renderer), I would like to be able to split that layer into two columns in the legend. There is a different instance where if they choose a different renderer for the layer, it does not need to be split into two columns. Telling what renderer they choose is easy, it's figuring out how to apply a column count to a specific legend item that I'm not sure how to do.
... View more
06-18-2018
10:57 AM
|
0
|
1
|
1845
|
|
POST
|
Well I fixed it. I had to set the scratchWorkspace first. No idea why it was working before without setting that, but it no longer likes to have the scratch.gdb sitting in AppData\Local\Temp. Kinda stinks that I have to do this though because I'll need to remember to comment the scratchWorkspace line out when I publish it as a geoprocessing service since the GP service should use the jobs folder as it's workspace, thus the directory of the scratchWorkspace will never be the same and should not be set. Fixed code: arcpy.env.scratchWorkspace = r'C:\Users\xxx\Desktop\GIS_Testing'
scratchGDB = arcpy.env.scratchGDB
#scratchGDB now resides at C:\Users\xxx\Desktop\GIS_Testing\scratch.gdb
... View more
05-31-2018
06:56 AM
|
1
|
0
|
1948
|
|
POST
|
I am writing output data to the scratch geodatabase in a script - it was working great before but now it is no longer working and I'm trying to figure out if it's an IDE problem or something else. When I write data to the scratch geodatabase, it is treating it as a folder and appending ".shp" to the end of the output data instead of treating it as a file geodatabase and writing the output data as a feature class like it's supposed to. Additionally, it will run through the first tool call and write the output, but then the second tool call results in an error because it's trying to append ".shp.shp" to the output data name which is obviously invalid... I'm leaning towards this being an IDE problem because the script works great if I add the toolbox to ArcMap and run it inside there. Has anybody else seen this fishy behavior using PyCharm? The problem script: scratchGDB = arcpy.env.scratchGDB
#First tool call appends .shp to singlepart
#output looks like this: C:\Users\xxx\AppData\Local\Temp\scratch.gdb\singlepart.shp
svyPtFC = arcpy.MultipartToSinglepart_management(multipartFL, os.path.join(scratchGDB, 'singlepart'))
#Second tool call tries to append .shp.shp to FinalOutput
#Error says: ExecuteError: ERROR 000210: Cannot create output
#C:\Users\xxx\AppData\Local\Temp\scratch.gdb\FinalOutput.shp.shp
#ERROR 000354: The name contains invalid characters
filename = os.path.join(scratchGDB, "FinalOutput")
svyPtFC = arcpy.Eliminate_management(sliverFL, filename) It truly does write the shapefile out into the geodatabase folder: If I run this code to check if it's a geodatabase I get this: scratchGDB = arcpy.env.scratchGDB
desc = arcpy.Describe(scratchGDB)
print desc.workspaceType
#Prints "FileSystem" How do I get it to be seen as a file geodatabase when running in an IDE?
... View more
05-31-2018
06:34 AM
|
0
|
2
|
2532
|
|
POST
|
Is there a way to set this property in the New Feature Class dialogue? It seems kinda weird that you can't. Now instead of creating all my fields in this dialogue, I have to do it all through the "Add Field" button the attribute table, just so I can set the "allow nulls" to "no". Why can't I set "allow nulls" in this dialogue under Field Properties (this is an enterprise geodatabase)? Instead I have to do this after the feature class has been created: Seems inefficient.
... View more
05-23-2018
06:18 AM
|
0
|
1
|
1245
|
|
POST
|
Alright, I figured it out. Was something stupid I was doing as per usual . When I instantiate the map, there is a drop-down menu that will set the definition expression on the layer. The definition expression by default is set to show data from the current year, but we don't have any data for the current year yet. When I was picking a new year (a year that has data), I figured the table would automatically update, but I found you actually need to use the refresh method. Once I implemented attrTable.refresh(); in the function where the definition expression for the feature layer gets updated, it started populating with records. I still can't figure out why the header and column names won't show though upon load... The CSS is just this: #attribute-table{
display: none;
position: absolute;
height: 500px;
background-color: white;
bottom: 0;
z-index: 31;
}
... View more
05-07-2018
05:57 AM
|
0
|
0
|
2755
|
|
POST
|
No errors in the console and I just removed the fields option, but still no dice. It is interesting though when I open the console, suddenly the header and column names show up in the div when they don't initially on load. That's probably more of a CSS issue though. After I open the console and it resizes my map:
... View more
05-07-2018
05:48 AM
|
0
|
0
|
2755
|
|
POST
|
I've never created a feature table before so I'm sure I'm just missing something small, but when I implement the Feature Table widget it loads in the appropriate place but doesn't show any records. I've tried a few different things, but nothing has worked yet. Currently, my code looks like this: //Add the habitat patches feature layer
var patchesFL = new FeatureLayer("URL", {
refreshInterval: 10,
definitionExpression: 'EXTRACT(YEAR FROM "ObsvDate") = ' + currentYear,
visible: false,
infoTemplate: patchesPopupBox,
outFields: ["*"]
});
patchesFL.setMinScale(500000);
//Add the feature layers to the map object
map.addLayer(patchesFL);
//Create attribute table
var attrTable = new FeatureTable({
featureLayer: patchesFL,
editable: false,
outFields: ["StateID", "Point", "PatchNum", "IsDeveloped", "CropTypeID", "CropResidue", "CnpyOver12",
"CnpyDecid", "CnpyConif", "ShrubCover", "ShbHiStemsDens", "GrassCover", "ForbCover",
"FrbAsProtect", "ForbSpecies", "BareGround", "HerbHeight", "Overstory",
"Understory", "OfficialQH", "ObsvDate", "ObsvType"],
map: map
}, "attribute-table");
attrTable.startup(); I have attempted to add this line because I saw it in a bunch of examples, and changed the visibility property to true when instantiating the feature layer: mode: FeatureLayer.MODE_ONDEMAND, I have also tried changing the feature table options to be in quotes because I found it done both ways in the documentation and wasn't sure which was right: //Create attribute table
var attrTable = new FeatureTable({
"featureLayer": patchesFL,
"editable": false,
"outFields": ["StateID", "Point", "PatchNum", "IsDeveloped", "CropTypeID", "CropResidue", "CnpyOver12",
"CnpyDecid", "CnpyConif", "ShrubCover", "ShbHiStemsDens", "GrassCover", "ForbCover",
"FrbAsProtect", "ForbSpecies", "BareGround", "HerbHeight", "Overstory",
"Understory", "OfficialQH", "ObsvDate", "ObsvType"],
"map": map
}, "attribute-table");
attrTable.startup(); None of these changes have affected anything. I have made sure to zoom into my map to the appropriate extent where the feature layer is visible to see if that did the trick, it doesn't. Do I need to have records selected in order for anything to show up in the table? This is what I get when the map loads, you can see the Feature Table widget exists based on the ability to turn on/off fields but no records show up:
... View more
05-07-2018
05:28 AM
|
0
|
3
|
2919
|
|
POST
|
Thanks for the help. I misunderstood that post as I thought you were employing that workaround because you were loading basemaps from a configuration file, not because that's the way to do it! Although I did manage to figure out a different workaround too (not nearly as elegant as yours): DELETED Edit: this solution is much much simpler (thanks to Ken's advice below): on.once(basemapGallery, 'selection-change', function () {
var referenceLayer = map.getLayer(map.layerIds[1]);
map.removeLayer(referenceLayer);
});
... View more
05-04-2018
11:03 AM
|
0
|
1
|
2516
|
|
POST
|
I'm still having some trouble with this. I have the reference layer, and I can delete it successfully on the first basemap selection-change event. Then if I change it again, the reference layer never comes back, or if I change it to a basemap like "Terrain with Labels" it's own reference layer starts persisting, rather than being deleted upon change like my code dictates. This is what I have: basemapGallery.on('selection-change', function () {
var bmapTitle = basemapGallery.getSelected().title;
var referenceLayer = map.getLayer("layer1");
if (bmapTitle != "Imagery with Labels") {
map.removeLayer(referenceLayer);
console.log(map.basemapLayerIds);
}
}); I read in the discussion you linked to that maps.basemapLayerIds property doesn't change which seems to be reflected in my testing as if I change the basemap from "hybrid" to "satellite" on the first change, "layer 0", "layer1" are still contained in the array returned by map.basemapLayerIds when really only "layer0" should be there since the reference layer ("layer1") was removed. So if this is the case, how do you know if "layer1" truly exists or not to remove in future changes? On the third change of a basemap I get this: TypeError: Cannot read property 'id' of undefined
... View more
05-04-2018
10:22 AM
|
0
|
3
|
2516
|
|
POST
|
Ah, I see now. Thanks! I got it working when I moved it to an appropriate spot. Before, I had it inside this: patchesFL.on("click", function (evt) {
var graphic = map.infoWindow.getSelectedFeature();
}); While the popup does open and a feature gets selected in the onClick function above, I think it just doesn't register fast enough. I needed to get the geometry inside of a different function called by a link in the action pane anyway, so when I moved the line of code there, it worked.
... View more
05-02-2018
10:43 AM
|
0
|
1
|
3821
|
|
POST
|
What you're saying makes perfect sense but I couldn't get it to work that way, despite having an infoTemplate set for the feature layer being clicked on. I did find it works like this though: patchesFL.on("click", function (evt) {
var graphic = evt.graphic.geometry;
}); This didn't work: var graphic = map.infoWindow.getSelectedFeature(); Nor did this (I used popup instead of infoWindow because the documentation lists the method getSelectedFeature as a popup method not an infoWindow method): var graphic = map.popup.getSelectedFeature();
... View more
05-02-2018
10:14 AM
|
0
|
3
|
3821
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-18-2020 10:31 AM | |
| 2 | 09-16-2025 02:17 PM | |
| 3 | 09-12-2025 09:26 AM | |
| 1 | 08-16-2023 05:11 PM | |
| 1 | 02-27-2024 06:48 AM |
| Online Status |
Offline
|
| Date Last Visited |
09-16-2025
02:16 PM
|