POST
|
It seems that no matter how many and which rasters I add, the last one that was added is fine, while the others show the warning and revert back to default symbology.
... View more
04-03-2020
10:44 AM
|
0
|
1
|
868
|
POST
|
I am trying to apply symbology to a group of raster layers, and one feature layer with an add-in. Everything appears to work fine with all layers loaded into the map and showing the correct symbology, however, when I click on any raster symbology in the contents pane, an Update Colorizer Failed! warning shows up in the symbology pane, and the symbology reverts back to default. My current workaround is the save the map, close the project, and reopen before I click on anything in the contents. This seems to correct the update colorizer issue. Is there anything I can do so I don't have to close/reopen to get this to work? Code shown below: public async void loadLayers(string path, string plan)
{
string projectPath = path;
string modelPath = System.IO.Path.GetDirectoryName(projectPath);
string planName = plan;
string depthPath = System.IO.Path.Combine(modelPath, plan,"Depth (Max).hydroDEM.tif");
string durationPath = System.IO.Path.Combine(modelPath, plan, "Duration (0.5ft hrs).hydroDEM.tif");
string elevationPath = System.IO.Path.Combine(modelPath, "Terrain", "Terrain.hydroDEM.tif");
string velocityPath = System.IO.Path.Combine(modelPath, plan, "Velocity (Max).hydroDEM.tif");
string wsePath = System.IO.Path.Combine(modelPath, plan, "WSE (Max).hydroDEM.tif");
string meshPath = System.IO.Path.Combine(modelPath, "2DMesh.shp");
string depthLayer = System.IO.Path.Combine(AddinAssemblyLocation(), "Content", "depth.lyrx");
string durationLayer = System.IO.Path.Combine(AddinAssemblyLocation(), "Content", "duration.lyrx");
string elevationLayer = System.IO.Path.Combine(AddinAssemblyLocation(), "Content", "elevation.lyrx");
string velocityLayer = System.IO.Path.Combine(AddinAssemblyLocation(), "Content", "velocity.lyrx");
string wseLayer = System.IO.Path.Combine(AddinAssemblyLocation(), "Content", "WSE.lyrx");
string meshLayer = System.IO.Path.Combine(AddinAssemblyLocation(), "Content", "mesh.lyrx");
RasterLayer velocityMap = null;
RasterLayer depthMap = null;
RasterLayer durationMap = null;
RasterLayer elevationMap = null;
RasterLayer wseMap = null;
FeatureLayer meshMap = null;
CancelableProgressorSource ps = new CancelableProgressorSource("Starting Process...", "Cancel", true);
if(MapView.Active != null)
{
if(System.IO.File.Exists(elevationPath))
{
ps.Progressor.Message = "Loading terrain grid";
elevationMap = await QueuedTask.Run(() =>
{
return (RasterLayer)LayerFactory.Instance.CreateLayer(new Uri(elevationPath), MapView.Active.Map, 0, "Terrain");
});
}
if (System.IO.File.Exists(wsePath))
{
ps.Progressor.Message = "Loading WSE grid";
wseMap = await QueuedTask.Run(() =>
{
return (RasterLayer)LayerFactory.Instance.CreateLayer(new Uri(wsePath), MapView.Active.Map, 0, "Maximum WSE");
});
}
if (System.IO.File.Exists(depthPath))
{
ps.Progressor.Message = "Loading depth grid";
depthMap = await QueuedTask.Run(() =>
{
return (RasterLayer)LayerFactory.Instance.CreateLayer(new Uri(depthPath), MapView.Active.Map, 0, "Maximum Depth");
});
}
if (System.IO.File.Exists(durationPath))
{
ps.Progressor.Message = "Loading duration grid";
durationMap = await QueuedTask.Run(() =>
{
return (RasterLayer)LayerFactory.Instance.CreateLayer(new Uri(durationPath), MapView.Active.Map, 0, "Duration over 0.5ft depth");
});
}
if (System.IO.File.Exists(velocityPath))
{
ps.Progressor.Message = "Loading velocity grid";
velocityMap = await QueuedTask.Run(() =>
{
return (RasterLayer)LayerFactory.Instance.CreateLayer(new Uri(velocityPath), MapView.Active.Map, 0, "Maximum Velocity");
});
}
if (System.IO.File.Exists(meshPath))
{
ps.Progressor.Message = "Loading 2D mesh polygon";
meshMap = await QueuedTask.Run(() =>
{
return (FeatureLayer)LayerFactory.Instance.CreateLayer(new Uri(meshPath), MapView.Active.Map);
});
}
}
await QueuedTask.Run(() =>
{
ps.Progressor.Message = "Applying symbology...";
if (MapView.Active != null)
{
if (elevationMap != null)
{
var elevationDoc = new LayerDocument(elevationLayer);
var elevationParams = elevationDoc.GetCIMLayerDocument();
var elevationColorizer = ((CIMRasterLayer)elevationParams.LayerDefinitions[0]).Colorizer as CIMRasterStretchColorizer;
elevationMap.SetColorizer(elevationColorizer);
}
if (wseMap != null)
{
var wseDoc = new LayerDocument(wseLayer);
var wseParams = wseDoc.GetCIMLayerDocument();
var wseColorizer = ((CIMRasterLayer)wseParams.LayerDefinitions[0]).Colorizer as CIMRasterDiscreteColorColorizer;
wseMap.SetColorizer(wseColorizer);
}
if (depthMap != null)
{
var depthDoc = new LayerDocument(depthLayer);
var depthParams = depthDoc.GetCIMLayerDocument();
var depthColorizer = ((CIMRasterLayer)depthParams.LayerDefinitions[0]).Colorizer as CIMRasterClassifyColorizer;
depthMap.SetColorizer(depthColorizer);
}
if (durationMap != null)
{
var durationDoc = new LayerDocument(durationLayer);
var durationParams = durationDoc.GetCIMLayerDocument();
var durationColorizer = ((CIMRasterLayer)durationParams.LayerDefinitions[0]).Colorizer as CIMRasterClassifyColorizer;
durationMap.SetColorizer(durationColorizer);
}
if (velocityMap != null)
{
var velocityDoc = new LayerDocument(velocityLayer);
var velocityParams = velocityDoc.GetCIMLayerDocument();
var velocityColorizer = ((CIMRasterLayer)velocityParams.LayerDefinitions[0]).Colorizer as CIMRasterClassifyColorizer;
velocityMap.SetColorizer(velocityColorizer);
}
if (meshMap != null)
{
LayerDocument meshDocument = new LayerDocument(meshLayer);
var meshParameters = meshDocument.GetCIMLayerDocument();
var layerRenderer = ((CIMFeatureLayer)meshParameters.LayerDefinitions[0]).Renderer as CIMRenderer;
meshMap.SetRenderer(layerRenderer);
}
}
}, ps.Progressor);
};
... View more
04-02-2020
11:49 AM
|
0
|
3
|
1125
|
POST
|
As I said in my original question, the data type listed in the documentation is value table. My question is what data type in C# corresponds to data table. I have tried KeyValuePair, array of KeyValuePairs, lists of KeyValuePairs, and dictionaries. None of these will work.
... View more
05-02-2019
04:03 PM
|
2
|
1
|
649
|
POST
|
Has anyone else had problems getting Mosaic or Mosaic to new Raster tools to work in an ArcGIS Pro Add-in? I have an add-in that searches folders for rasters, the mosaics the found rasters. The Add-in works fine on my Windows 7 machine, but the mosaic fails on Windows 10 machines. I have tried both Mosaic and Mosaic to new Raster, and both have the same results. I have had the same problems in python scripts. Running the Mosaic and Mosaic to new Raster as geoprocessing tools from the toolbox works in Windows 10, it only fails when it is in a script or add-in.
... View more
05-02-2019
03:59 PM
|
0
|
0
|
231
|
POST
|
I am trying to run CalculateGeometryAttributes_management, but I can not figure out what data type to use for the geometry_property[[Target Field, Property],...]. It appears to be an IEnumerable<KeyValuePair<string,string>>. I tried to use a dictionary, as it has this value type, but it gave me an error. Here is what I have: Dictionary<string,string> items = new Dictionary<string, string> { "Area", "AREA" }; arguments1 = Geoprocessing.MakeValueArray(floodShape, items, "FEET_US", "SQUARE_FEET_US"); gpResult1 = Geoprocessing.ExecuteToolAsync("CalculateGeometryAttributes_management", arguments1, enviroment, null, null, GPExecuteToolFlags.None); Anyone know what data type to use?
... View more
04-30-2019
11:35 AM
|
1
|
4
|
765
|
POST
|
I have created an add-in using the template in Visual Studio and I added my own custom tab in the ArcGIS Pro ribbon to hold my buttons. The Add-In tab that is included in the base template still shows up in my ribbon, and hold identical buttons to my custom tab. How do I remove the add-in tab so I do not have two identical tabs? This does not change the functionality of my add-in, but it is a bit annoying. Here is the tab section of my daml: </AddInInfo> <modules> <insertModule id="Floodplain_Plotting_Module" className="Module1" autoLoad="false" caption="Floodplain Plotting"> <tabs> <tab id="Floodplain_Plotting_Tab1" caption="Plotting" keytip="p"> <group refID="Floodplain_Plotting_Group1" /> </tab> </tabs> <groups> <group id="Floodplain_Plotting_Group1" caption="Plot" appearsOnAddInTab="true" keytip="P"> <button refID="Floodplain_Plotting_ShoreliningTool" size="middle" /> <button refID="Floodplain_Plotting_ExpanderWindow" size="middle" /> <button refID="Floodplain_Plotting_ExpandToBoundaryWindow" size="middle" /> </group> </groups>
... View more
04-26-2019
09:55 AM
|
1
|
2
|
1333
|
POST
|
The Raster.GetNoDataValue() returns an object according to the ArcGIS Pro API reference, but I don't see any further details on the object. What data does the object hold, and how to I access it?
... View more
04-26-2019
09:34 AM
|
1
|
0
|
222
|
POST
|
Thanks. I was able to get the string of the raster storage path. I did not realise that these tools generated the raster results in the scratch workspace with an arbitrary name.
... View more
04-26-2019
09:26 AM
|
0
|
1
|
519
|
POST
|
That works for number outputs, but how can you save a raster output?
... View more
04-22-2019
01:12 PM
|
0
|
3
|
519
|
POST
|
I have the same issue with the select Accelerator. I hope they fix this one soon. The other tools I have tried work fine.
... View more
12-13-2018
09:56 AM
|
0
|
1
|
4572
|
POST
|
I am using raster to polyline in a python script, and it is not generating the results I would expect. When I run the toolbox raster to polyline with the same parameters, I get the results I expect. In the attached image, the green shows the input raster cells (cell value of 1), the blue line shows the toolbox results and the black line shows my script results. Any ideas as to what would be causing the difference in the line output when the input and the parameters are exactly the same? Here is the raster to polyline command in the script: arcpy.RasterToPolyline_conversion(Filter3, breaklinesFull, "ZERO", cellSize*1.42, "NO_SIMPLIFY")
... View more
01-12-2017
08:36 AM
|
0
|
1
|
1604
|
POST
|
I am not sure if this solves your problem, but this is how I convert a polygon to lines for smoothing, then convert back to polygon with the same attributes using a spatial join with the original basins. # Convert polygon to line
arcpy.PolygonToLine_management(basins,basinsLine, "IDENTIFY_NEIGHBORS")
# Smooth line
arcpy.SmoothLine_cartography(basinsLine, smoothLine, "PAEK", smoothTolerance)
# Simplify line
arcpy.SimplifyLine_cartography(smoothLine, simplifyLine, "POINT_REMOVE", simplifyTolerance, "", "NO_KEEP", "")
# Convert line back to polygon
arcpy.FeatureToPolygon_management(simplifyLine, smoothBasins, "", "ATTRIBUTES", "")
# Join attributes from original basins into new basins
arcpy.SpatialJoin_analysis(smoothBasins, basins, newBasins, "", "KEEP_ALL", "", "HAVE_THEIR_CENTER_IN")
... View more
01-15-2015
11:53 AM
|
2
|
0
|
233
|
POST
|
I was able to get it working with the following code: # Import system modules
import arcpy
from arcpy.sa import *
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Set workspace from input
ws = arcpy.GetParameterAsText(0)
db = arcpy.GetParameterAsText(1)
arcpy.env.workspace = ws
arcpy.env.scratchWorkspace = db
# Set input rasters
D10 = arcpy.GetParameterAsText(2)
D25 = arcpy.GetParameterAsText(3)
D50 = arcpy.GetParameterAsText(4)
D100 = arcpy.GetParameterAsText(5)
D500 = arcpy.GetParameterAsText(6)
# Set environment variables from input rasters
arcpy.env.snapRaster = r"D10"
arcpy.env.extent = r"D10"
arcpy.env.outputCoordinateSystem = r"D10"
#cord = arcpy.env.outputCoordinateSystem
arcpy.env.cellSize = r"D10"
#cs = arcpy.env.cellSize
#arcpy.env.overwriteOutput = True
# 10 and 25 Log-Linear Interpolation Map Algebra
X25 = Power((Log10(4)) - Raster(D25) * ((Log10(4) - Log10(10)) / (Raster(D25) - Raster(D10))),10)
X25.save(ws + "\X25")
... View more
04-16-2014
11:08 AM
|
0
|
0
|
360
|
POST
|
Now I am thinking that my map algebra is fine. I think my issues may be in how I am stetting the environmental variables. Here is more of the script: # Import system modules
import arcpy, sys
from arcpy.sa import *
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Set workspace from input
ws = sys.argv[1]
db = sys.argv[2]
arcpy.env.workspace = db
arcpy.env.scratchWorkspace = db
# Set input rasters
D10 = sys.argv[3]
D25 = sys.argv[4]
D50 = sys.argv[5]
D100 = sys.argv[6]
D500 = sys.argv[7]
# Set environment variables from input rasters
arcpy.env.snapRaster = D10
arcpy.env.extent = D10
arcpy.env.outputCoordinateSystem = D10
cord = arcpy.env.outputCoordinateSystem
arcpy.env.cellSize = D10
cs = arcpy.env.cellSize
arcpy.env.overwriteOutput = True
# 10 and 25 Log-Linear Interpolation
#X25 = ws + "\Calc1.gdb\X25"
X25 = Power((Log10(4)) - Raster(D25) * ((Log10(4) - Log10(10)) / (Raster(D25) - Raster(D10))),10)
X25.save(ws + "\X25") Anyone see anything wrong here?
... View more
04-16-2014
09:50 AM
|
0
|
0
|
360
|
Title | Kudos | Posted |
---|---|---|
1 | 04-26-2019 09:34 AM | |
2 | 05-02-2019 04:03 PM | |
1 | 04-26-2019 09:55 AM | |
1 | 04-30-2019 11:35 AM | |
2 | 01-15-2015 11:53 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|