|
POST
|
I would assume that there is something different between your solver in ArcMap and your solver in your standalone python application. I would suggest running your standalone code in the python window of a new blank session of ArcMap so that you can verify the data in the same environment.
... View more
09-24-2015
06:53 AM
|
0
|
2
|
2794
|
|
POST
|
As an alternative to the try/catch approach you could just check if the layer supports datasource. import arcpy
import os
import sys
from arcpy import mapping as m
arcpy.env.workspace = r"C:\Project"
counter = 0
for mxdPath in arcpy.ListFiles("*.mxd"):
print(mxdPath)
mxd = m.MapDocument(mxdPath)
df = m.ListDataFrames(mxd, "Layers")[0]
for lyr in m.ListLayers(mxd, "", df):
if not lyr.supports("DATASOURCE"):
continue
if lyr.dataSource == r"D:\PROJECTS\zfonGivatShmuel\gis\layers\6_9_15\gvul.shp":
m.RemoveLayer(df, lyr)
print("Remove")
mxd.save()
del mxd
... View more
09-24-2015
06:45 AM
|
1
|
0
|
4433
|
|
POST
|
Would you be able to upload a small sample of your data, a map document with your solved od cost matrix layer, and script that I can use to take a closer look at this?
... View more
09-24-2015
06:36 AM
|
0
|
1
|
2794
|
|
POST
|
You'd need to use a geodatabase feature class instead of a shapefile to accomplish this. Shapefiles do not support NULL values. This is documented on the following page: Add Field (Data Management) http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/add-field.htm As shown in the screenshot below, Null values are only supported for fields in a geodatabase.
... View more
09-23-2015
04:05 PM
|
2
|
0
|
2451
|
|
POST
|
You have two things you need to look into for your issue. First is the esri related problem. You have to understand the workflow of iterating through a workspace to locate files one at a time so that you can perform your query against them and export the needed records. It sounds like you understand the bulk of the workflow (i.e. making the layers, performing the selection, checking to see if anything was selected, and exporting the selected records to a new table) so I'll skip the part. The latter part is not related to Esri and is more of a programming technique question. You'll want to look into using the threading or multiprocessing modules in python. I've added links to these modules below. It sounds to me like you need to create a workflow where you can use a single thread to locate the paths to your data, upload this data to a queue and have multiple threads or processes pull jobs from this queue for processing. Python Queue - A thread-safe FIFO implementation https://pymotw.com/2/Queue/ multiprocessing - Process-Based "threading" interface https://docs.python.org/2/library/multiprocessing.html Multiprocessing Basics https://pymotw.com/2/multiprocessing/basics.html threading - Higher-level threading interface https://docs.python.org/2/library/threading.html Python Multithreaded Programming http://www.tutorialspoint.com/python/python_multithreading.htm threading - Manage concurrent threads https://pymotw.com/2/threading/
... View more
09-23-2015
03:28 PM
|
1
|
0
|
3099
|
|
POST
|
That portion of the code is about using Dictionaries. You can read up on this concept on the following page: C# Dictionary http://www.dotnetperls.com/dictionary This is a data structure in .NET that is not related to ArcObjects. Think of it like an actual dictionary. In a dictionary a word (i.e. key) will be defined once and the definition (i.e. value) will consist of multiple words, which can be repeated. I used the name of the feature dataset as the key in the dictionary and used the names of the feature classes as the values so that I easily organize which feature classes were in which feature dataset and print out a "prettier" list of the results. If you want you could simplify this logic as follows: ILayer layer;
// while ( (layer = enumLayer.Next()) != null)
// {
// var fc = (layer as IFeatureLayer).FeatureClass;
// if (fc.FeatureDataset != null)
// {
// if (results.ContainsKey(fc.FeatureDataset.Name))
// results[fc.FeatureDataset.Name].Add(fc.AliasName);
// else
// results[fc.FeatureDataset.Name] = new List<string> {fc.AliasName};
// }
// else
// Console.WriteLine("Skipping {0}...NOT within a Feature Dataset", fc.AliasName);
// }
//}
//foreach (var kvp in results)
// Console.WriteLine("FEATURE DATASET: {0}\n...{1}\n", kvp.Key, String.Join("\n...", kvp.Value));
while ((layer = enumLayer.Next()) != null)
{
var fc = (layer as IFeatureLayer).FeatureClass;
if (fc.FeatureDataset != null)
Console.WriteLine("FEATURE CLASS: {0,-20} | FEATURE DATASET: {1}", fc.AliasName, fc.FeatureDataset.Name);
} Below are screenshots of the results of these two options. ** Option A : using dictionary ** ** Option B **
... View more
09-22-2015
05:07 PM
|
1
|
0
|
1383
|
|
POST
|
I just downloaded the tools and it appears to come with an installer that registers the toolbar with the various commands, tools, etc. To use this tool in python you'd need access to the source code of the tools so that you could wrap their logic as functions that you could either leverage in a variety of ways. Have you tried contacting the US Forest Service to determine if they'd be willing to expose the source code for this toolbar?
... View more
09-22-2015
04:47 PM
|
2
|
0
|
1169
|
|
POST
|
You should be able to check if cast the layer to IFeatureLayer and then check if the FeatureLayer.FeatureClass.FeatureDataset is equal to null. If it is null then the dataset is not within a feature dataset. I would assume that your code would fail on the call the pDataset.Name when the dataset is not within a feature dataset because the call to pFeatureClass.FeatureDataset will be null. Below is the code I used to confirm along with a sample that will display this for you. using System.Collections.Generic;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.esriSystem;
using System;
using System.IO;
using System.Reflection;
namespace ListFeatureDatasets
class Program
{
private static readonly LicenseInitializer m_aoInit = new LicenseInitializer();
private static readonly String m_srcPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
private static readonly String m_mxdPath = Path.Combine(m_srcPath, @"data\SanDiego.mxd");
[STAThread()]
static void Main(string[] args)
{
//ESRI License Initializer generated code.
m_aoInit.InitializeApplication(new [] { esriLicenseProductCode.esriLicenseProductCodeAdvanced }, new esriLicenseExtensionCode[] { });
var mxd = new MapDocumentClass();
mxd.Open(m_mxdPath);
Dictionary<string, List<string>> results = new Dictionary<string, List<string>>();
for (int i = 0; i < mxd.MapCount; i++)
{
var map = mxd.Map;
var uid = new UIDClass {Value = "{40A9E885-5533-11D0-98BE-00805F7CED21}"}; // IFeatureLayer
var enumLayer = map.Layers[uid, true];
enumLayer.Reset();
ILayer layer;
while ( (layer = enumLayer.Next()) != null)
{
var fc = (layer as IFeatureLayer).FeatureClass;
if (fc.FeatureDataset != null)
{
if (results.ContainsKey(fc.FeatureDataset.Name))
results[fc.FeatureDataset.Name].Add(fc.AliasName);
else
results[fc.FeatureDataset.Name] = new List<string> {fc.AliasName};
}
else
Console.WriteLine("Skipping {0}...NOT within a Feature Dataset", fc.AliasName);
}
}
foreach (var kvp in results)
Console.WriteLine("FEATURE DATASET: {0}\n...{1}\n", kvp.Key, String.Join("\n...", kvp.Value));
Console.WriteLine();
Console.Write("Press enter to exit...");
Console.ReadLine();
//ESRI License Initializer generated code.
//Do not make any call to ArcObjects after ShutDownApplication()
m_aoInit.ShutdownApplication();
}
}
}
... View more
09-22-2015
03:35 PM
|
1
|
2
|
1383
|
|
POST
|
You should be able to change the sources of your layers using logic shown on the following page. How to change the data source of a layer http://help.arcgis.com/en/sdk/10.0/vba_desktop/conceptualhelp/index.html#//0001000000m5000000 I would think if you wanted this to all happen when the map document is loaded that you'd want to implement this within an application extension where you'd need to incorporate logic on how to determine which geodatabase version to connect to. Creating an application extension http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#//00010000001v000000
... View more
09-22-2015
02:46 PM
|
1
|
0
|
961
|
|
POST
|
I believe this is what you're looking for. How to work with geoprocessing services http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#//0001000001qn000000
... View more
09-22-2015
11:20 AM
|
0
|
0
|
1358
|
|
POST
|
Have you tried using the Activator to instantiate the workspace? // Instantiate a file geodatabase workspace factory and create a file geodatabase.
// The Create method returns a workspace name object.
Type factoryType = Type.GetTypeFromProgID(
"esriDataSourcesGDB.FileGDBWorkspaceFactory");
IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance
(factoryType);
IWorkspaceName workspaceName = workspaceFactory.Create(path, "Sample.gdb", null,
0);
// Cast the workspace name object to the IName interface and open the workspace.
IName name = (IName)workspaceName;
IWorkspace workspace = (IWorkspace)name.Open();
return workspace; Creating Geodatabase http://help.arcgis.com/en/sdk/10.0/Arcobjects_net/conceptualhelp/index.html#//0001000004t8000000
... View more
09-22-2015
11:04 AM
|
0
|
0
|
940
|
|
POST
|
你可以编辑feature class和shapefile用cursors在ArcObjects里 请查看下这个pdf文件 希望对你有所帮助 Understanding Cursors in ArcObjects http://www.esri.com/news/arcuser/0706/files/cursors.pdf
... View more
09-22-2015
10:55 AM
|
0
|
0
|
905
|
|
POST
|
Hi Thomas, You are correct. The Visual Editor project was deprecated. I believe that if you want to use the ArcObjects pallette you'd need to use the WindowBuilder project. Once you have WindowBuilder installed you should be able to import the arcobjects.jar and gain access to the needed Visual Beans.
... View more
09-22-2015
10:00 AM
|
1
|
0
|
1283
|
|
POST
|
Did you try deploying the jar using one of the following deployment methods? Copy the .jar file to the ARCGISHOME/java/lib/ext folder. This ensures that the extension gets automatically registered with ArcGIS the next time the application is started. This is a Java-friendly way and a recommended practice for deploying all ArcGIS extensions. Explicitly register the .jar file with ArcGIS either through the API exposed on the com.esri.arcgis.interop.extn.RegTool class or through the "regtool.bat"/"regtool.sh" script available under ARCGISHOME/java/tools. Utility Objects http://resources.arcgis.com/en/help/arcobjects-java/concepts/engine/index.html#//00010000051r000000
... View more
09-22-2015
09:57 AM
|
0
|
0
|
740
|
| 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
|