POST
|
using C#, visual studio 2010, ArcGIS 10.1 - I'm using the following code to create a new RasterDataset in a file geodb - //create IRasterWorkspaceEx rWS = (IRasterWorkspaceEx)ws; IRasterStorageDef2 rStorage = new RasterStorageDefClass(); rStorage.CellSize = new Pnt(){X=cellsize,Y=cellsize}; rStorage.Origin = origin; IRasterDef2 rDef = new RasterDefClass(); rDef.SpatialReference = srOut; rds = (IRasterDataset2)rWS.CreateRasterDataset(strName, 1, ptype, rStorage, "", rDef, null); This works, but the output RasterDataset is only 1 pixel big. When you call CreateRasterData through IRasterWorkspace (for file based rasters) you can specify the width and height. Basically I have a 2d array I'm trying to write into the raster - how do I do this when the output is only 1 pixel big? I've tried casting to IRasterProps and changing the Width and Height props but that throws a COMException even though in the help they look to be read/write props - IRasterBandCollection rbc = (IRasterBandCollection)rds; IRasterProps rProps = (IRasterProps)rbc.Item(0); rProps.NoDataValue = nodataval; rProps.Width = Data.GetLength(0); //Error here rProps.Height = Data.GetLength(1); A push in the right direction would be appreciated! Thanks, Terry
... View more
09-30-2013
01:52 PM
|
0
|
2
|
606
|
POST
|
Thank you Upendra, explicitly setting the opacity as 1.0 solves the problem. Terry
... View more
09-17-2013
11:45 AM
|
0
|
0
|
297
|
POST
|
Cory, Thanks for the idea but there's no equivalent to disableClientCaching in the JS API. I've used that in the SL api in the past to make sure data from a feature layer based on a query layer (pulling lat/longs from SQL server) would refresh after the underlying DB was updated. TG
... View more
08-29-2013
12:02 PM
|
0
|
0
|
436
|
POST
|
This issue pops up when you add a feature layer to a map too (using JSAPI at least). In that case, how would I add a time stamp to alter the query string ? Thanks, TG
... View more
08-29-2013
09:30 AM
|
0
|
0
|
436
|
POST
|
Looks like this is one of those 'known issues' Bug report here - http://support.esri.com/en/bugs/nimbus/TklNMDg2MzQ5 There a work around if you're using a query task (append timestamp to make it unique request) but how can I do that when I'm adding the feature layer to the map?? Thanks, TG
... View more
08-29-2013
09:10 AM
|
0
|
0
|
195
|
POST
|
Running Server 10.1 SP1 on a Win2008R2 box. I'm trying to root out an issue we're seeing with our JSAPI base map application. The map simply has an Esri basemap and a featurelayer from our server. The featurelayer does not load every time. Using Firebug and IE's f12 tools I can see the response from the Query op issued when the layer is added to the map as
{"error":{"code":400,"message":"Unable to complete operation.","details":[]}}
It happens when I issue query requests to the service without a map too. If I put the following simple query in my browser (happens in IE, FF, Chrome) it works every other time - http://servername:6080/arcgis/rest/services/folder/service/MapServer/0/query?where=1=1&f=pjson 1st, 3rd, 5th, etc... GET requests yield valid results
{
"displayFieldName": "Name",
"fieldAliases": {
"Name": "Name"
},
"geometryType": "esriGeometryPolygon",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
"fields": [
{
"name": "Name",
"type": "esriFieldTypeString",
"alias": "Name",
"length": 50
}
],
"features": [
{
"attributes": {
"Name": "ALC2"
},
"geometry": {
"rings": [
[
[
-107.0837499999999,
38.841250000000059
],
[
-107.0837499999999,
38.841250000000059
],
.... and so on
alternating requests return the same error shown above. There are no errors shown in the server logs in Manager. I have logging set to verbose and I can see to requests/response (below, the failure has the smaller response size) FINE Aug 29, 2013 10:58:22 AM REST request successfully processed. Response size is 62359 characters. Folder/Service.MapServer
FINE Aug 29, 2013 10:58:22 AM End Query Folder/Service.MapServer
VERBOSE Aug 29, 2013 10:58:22 AM End of preparation. Folder/Service.MapServer
VERBOSE Aug 29, 2013 10:58:22 AM Begining of preparation. Folder/Service.MapServer
FINE Aug 29, 2013 10:58:22 AM Begin Query Folder/Service.MapServer
FINE Aug 29, 2013 10:58:22 AM REST request received. Request size is 329 characters. Folder/Service.MapServer
FINE Aug 29, 2013 10:58:22 AM REST request successfully processed. Response size is 650 characters. Folder/Service.MapServer
FINE Aug 29, 2013 10:58:22 AM End Query Folder/Service.MapServer
VERBOSE Aug 29, 2013 10:58:22 AM End of preparation. Folder/Service.MapServer
VERBOSE Aug 29, 2013 10:58:22 AM Begining of preparation. Folder/Service.MapServer
FINE Aug 29, 2013 10:58:22 AM Begin Query Folder/Service.MapServer
FINE Aug 29, 2013 10:58:22 AM REST request received. Request size is 329 characters. Folder/Service.MapServer Any ideas what's going on and how to fix this? Thanks, TG
... View more
08-29-2013
09:09 AM
|
0
|
1
|
1240
|
POST
|
I have a featurelayer in my map which contains polygons with an outline but no fill. It displays in the map correctly, but in the legend widget, it shows up with a black fill (under 'UpperColorado' in the 1st image below). If I look at the legend for the map service's REST endpoint, the symbol looks correct (2nd image). Any idea how to fix this? Thanks, TG [ATTACH=CONFIG]26734[/ATTACH] [ATTACH=CONFIG]26735[/ATTACH]
... View more
08-15-2013
03:04 PM
|
0
|
3
|
664
|
POST
|
Based on what I learned so far this can not be done by JavaScript alone. That's pretty much true. If your users are using IE it can be done through ActiveX but it doesn't work at all in other browsers. Below is some old code I have that loops through the graphics on a map and dumps some attributes into a text file, which then gets opened in Word. The user is prompted a few times along the way & if I recall we had to change some security settings in IE too. Otherwise I think you'll need to send the graphics (or JSON created from them) back to a web service that would prompt the user to save a text file.
function exportToWord() {
//exports the addresses of the parcels in the graphics file to a text file
//on the users desktop and then opens it with the Word label template.
if (!dojo.isIE) {
alert("Exporting to Word only works with Internet Explorer");
return false;
}
//note this will give them a warning about ActiveX object running
var wshshell = new ActiveXObject("wscript.shell");
var strDesktop = wshshell.SpecialFolders("Desktop");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var bolOwner = false;
//text file for property locations
fProps = fso.CreateTextFile(strDesktop + "\\plist.txt", true);
fProps.WriteLine("NAME;ADDRESS;ZIP");
var graphic;
for (var i = 0, il = map.graphics.graphics.length; i < il; i++) {
graphic = map.graphics.graphics;
if (graphic.attributes) {
fProps.WriteLine(graphic.attributes["OWNER1"] + ";" + graphic.attributes["ADDRESS1"] + ";" + graphic.attributes["ZIPCODE"]);
}
}
fProps.Close();
//now open the word label template which contains VBA to dump the olist.txt into a new doc
var w = new ActiveXObject('Word.Application');
w.Visible = true;
w.Documents.Open("C:\\TEMP\\Plabeltest.docm");
}
... View more
08-06-2013
06:29 AM
|
0
|
0
|
969
|
POST
|
Sorry, I should be been more clear in my original post. I'm writing out a Raster Dataset & need to determine the appropriate value to pass in to IRasterProps::NoDataValue after using CreateRasterDataset from a RasterWorkspace, hence my line of thinking of using a combination of the pixel type and bit depth.
... View more
07-01-2013
12:57 PM
|
0
|
0
|
199
|
POST
|
In ArcCatalog if you open the propreties of a RasterDataset you can edit the value of the NoData value. On the Edit form, there's a button that says Compute (see attached). I'm guessing this is based on the raster's pixel type & depth. Is there a method on one of the many raster interfaces that can determine this value for you or do I need to write my own, e.g. using IRasterInfo::PixelType and switch statement? Thanks, TG
... View more
06-19-2013
10:05 AM
|
0
|
2
|
456
|
POST
|
I know I can open a GP tool using code like this -
//Opens the Clip Raster GP tool
IGPToolCommandHelper2 gpHelper = new GPToolCommandHelperClass() as IGPToolCommandHelper2;
string toolboxName = extMain.GetArcGISDir() + "ArcToolbox\\Toolboxes\\Data Management Tools.tbx";
gpHelper.SetToolByName(toolboxName, "Clip");
try
{
gpHelper.Invoke(null);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
but is there a way to open a tool in batch mode, similar to when you right click on a system GP tool in the Toolbox and you get 'batch' in the context menu? Thanks! TG
... View more
06-14-2013
01:55 PM
|
0
|
0
|
395
|
POST
|
The custom tool works fine if it's the 1st and only tool in the queue, but not if I have to run CopyRaster before hand to make a Tiff to pass to it. I ended up switching to a synchronous pattern instead, that seems to work regardless of which tools are in my queue. Not my preferred solution but it'll work for now..
internal void RunTool(Queue<GPFunction> GPFuncs)
{
//Runs a TauDEM GP tool. Input GPFunction queue can also contain conversion & clean up GP tasks
//since TauDEM only reads/writes UnCompressed TIFFs
try
{
_gp.AddToolbox(_strTauDEM + "TauDEM5Arc\\TauDEM Tools.tbx");
foreach (GPFunction gpfunct in GPFuncs)
{
_gp.OverwriteOutput = true; // gpfunct.OverwriteOutput;
_gp.AddOutputsToMap = gpfunct.AddtoMap;
if (gpfunct.Environments != null)
{
foreach (KeyValuePair<string, object> kvp in gpfunct.Environments)
{
_gp.SetEnvironmentValue(kvp.Key, kvp.Value);
}
}
_gp.Execute(gpfunct.ToolName, gpfunct.ToolParams, null);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Error in RunTool");
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
... View more
06-12-2013
07:05 AM
|
0
|
0
|
255
|
POST
|
I'm trying to follow the asynch pattern described in the SDK sample "Executing geoprocessing tools in the background" (online here) but keep getting a COMException in my ToolExecuted handler when I try dequeque the next tool call ExecuteAsync. Event handlers are set in the constructor of the class -
_gp = new Geoprocessor();
_gp.ToolExecuted += new EventHandler<ToolExecutedEventArgs>(GPToolExecuted);
_gp.ToolExecuting += new EventHandler<ToolExecutingEventArgs>(GPToolExecuting);
The first tool in my Queque is called in this method -
internal void RunTool(Queue<GPFunction> GPFuncs)
{
//Runs a TauDEM GP tool. Input GPFunction queue can also contain conversion & clean up GP tasks
//since TauDEM only reads/write UnCompressed TIFFs
GPFunction gpfunct = null;
try
{
_gpfunctions = GPFuncs;
gpfunct = _gpfunctions.Dequeue();
_gp.OverwriteOutput = true; // gpfunct.OverwriteOutput;
_gp.AddOutputsToMap = gpfunct.AddtoMap;
_gp.AddToolbox(_strTauDEM + "TauDEM5Arc\\TauDEM Tools.tbx");
if (gpfunct.Environments != null)
{
foreach (KeyValuePair<string, object> kvp in gpfunct.Environments)
{
_gp.SetEnvironmentValue(kvp.Key, kvp.Value);
}
}
_gp.ExecuteAsync(gpfunct.ToolName, gpfunct.ToolParams);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Error in RunTool");
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
The first tool (usally CopyRaster to convert to Tif which is the only input a custom tool will take) fires and and when it completes it will go into ToolExecuted but bombs on the ExecuteAsync
private void GPToolExecuted(object sender, ToolExecutedEventArgs e)
{
//Fires when a GP tool completes (fail or success)
IGeoProcessorResult2 result = e.GPResult as IGeoProcessorResult2;
GPFunction gpfunct = null;
if (result.Status == esriJobStatus.esriJobSucceeded)
{
System.Diagnostics.Debug.WriteLine(result.Process.ToolName.DisplayName + " completed");
if (_gpfunctions.Count > 0)
{
try
{
gpfunct = _gpfunctions.Dequeue();
_gp.OverwriteOutput = true; //gpfunct.OverwriteOutput;
_gp.AddOutputsToMap = gpfunct.AddtoMap;
if (gpfunct.Environments != null)
{
foreach (KeyValuePair<string, object> kvp in gpfunct.Environments)
{
_gp.SetEnvironmentValue(kvp.Key, kvp.Value);
}
}
_gp.ExecuteAsync(gpfunct.ToolName, gpfunct.ToolParams); //throws exception here
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Error in ToolExecuted");
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
}
else
{
System.Diagnostics.Debug.WriteLine(result.Process.ToolName.DisplayName + " did something else");
IGPMessages msgs = result.GetResultMessages();
for (int i = 0; i < result.MessageCount; i++)
{
IGPMessage msg = (IGPMessage)msgs.GetMessage(i);
System.Diagnostics.Debug.WriteLine(msg.Description);
}
}
}
If I click on the button on my form after the Exception occurs it will write my debug statements to the Output panel 2x. Anyone have an idea what I'm doing wrong & why it seems to be executing the ToolExecuted handler 2x?? Thanks, Terry
... View more
06-11-2013
02:53 PM
|
0
|
1
|
2799
|
POST
|
I don't think you can directly add KML to ArcMap (I could be wrong here), but you can use the KMLtoLayer tool to make a .lyr file in the user's temp folder and then add that layer. It sounds like you're code is not running inside of ArcMap but another application. If so, try using the AppROT class (in Esri.ArcGIS.Framework) to find ArcMap (if it's open) or to open ArcMap & add the layer created from the geoprocessing tool.
... View more
06-04-2013
06:05 AM
|
0
|
0
|
209
|
POST
|
It's been a while but my recollection from dealing with street centerlines is that both resulting geometries would follow the direction of the origin polyline. A polyline has a FromPoint and ToPoint which gives you an idea of the direction it is going. If you need to know which is upstream for the other, check the new segments ToPoint & FromPoint... if lineA.FromPoint = LineB.ToPoint then Line B is 'upstream' (according to the original feature's direction).
... View more
05-22-2013
05:55 PM
|
0
|
0
|
150
|
Title | Kudos | Posted |
---|---|---|
1 | 06-15-2016 03:27 PM | |
1 | 01-14-2016 09:55 AM | |
2 | 12-14-2012 09:38 AM | |
2 | 10-23-2017 01:22 PM | |
3 | 01-15-2013 07:31 AM |
Online Status |
Offline
|
Date Last Visited |
08-04-2022
03:13 PM
|