Hot answers tagged

25

Keep in mind that Arcpy is essentially a wrapper around ArcObjects. But if you're just trying to call some Python scripts that you don't want to have to rewrite you can spawn a process that calls the python executable with your args. var startInfo = new ProcessStartInfo() { CreateNoWindow = false, UseShellExecute = false, FileName = ...


24

The answer to this question is yes and no. It is possible with some effort to do everything in Python that you could do in .Net, but easy and possible are two very different things. Following that, the simplest interpretation is no, Python Add-Ins cannot do as much as .Net Add-Ins. However, the tasks Python Add-Ins can accomplish are much easier and faster ...


13

Short answer: In my experience, there should be absolutely no problem developing .NET 3.5-based code for ArcGIS 9.3 in Visual Studio 2010 (with C# language version 4), as long as you explicitly target the .NET Framework 3.5. The C# language version is mostly irrelevant here. P.S.: This answer does not go into the differences that exist between developing ...


12

If you are using Arcpy scripting, data lock issues have become even more problematic with 10.1. If the locks are being created by your code, then you aren't cleaning up after yourself. Release all references to feature classes, workspaces, cursors, etc. The locks are removed when you have no more references to the objects being locked. Well, that is the ...


12

I have investigated this and while it might be possible at some level by writing wrappers in C++ using them in .NET it is a hell of a lot of work because you also have to wrap the Qt framework at the same time. There might be hacks that you could use to get it to work but they will always be hacks. My advice: Learn Qt C++ or/and PyQt Python. Qt makes life ...


10

NetTopologySuite offer what you need, and much more: http://code.google.com/p/nettopologysuite/


10

In ArcObjects, like other COM-based libraries, interface testing is the main way you determine the type (using that term loosely) of object you have: if (element is ITextElement): // Do something else if (element is IMarkerElement): // Do something else etc. Another thing you can do is, if the object implements IPersist, you can get its CLSID using ...


9

Take a look at PostGIS and Entity Framework. The main library for connecting .NET to PostgreSQL is Npgsql, which can be used with (e.g.) SharpMap, NetTopologySuite, GdalOgrInCsharp, etc., depending on what you are doing. Regarding geometry data types, Npgsql uses System.Byte[] in C# to represent WKB (Well-Known Binary). This byte array type can be selected ...


9

When creating a new project using an ArcGIS template, you have to make sure you target the .NET Framework 3.5 instead of 4, which comes up by default


9

You can use the GDAL C#/.Net bindings to do this.


9

libLAS can indeed be used commercially. So can Martin Isenburg's LASlib, which is LGPL, and speaking as the author of libLAS, faster and more completely supported than libLAS. Both are indeed C++ libraries, however, and there isn't too much in the ASPRS LAS space for native .NET. I'm also the primary author of PDAL, and PDAL can also read ASPRS LAS data, ...


9

I feel your pain. I went through the same sort of thing with NetTopologySuite (v1.13) and had some success looking at the unit tests. First off, you might check out the DotSpatial library which was referenced in a similar question specific to DS shapefile operations I am personally happy with the NTS library. Once you figure out the object model it's not ...


9

It looks like I found your holy grail! SharpMap has a WFS implementation. Code here: https://github.com/SharpMap/SharpMap/blob/master/SharpMap/Data/Providers/WFSClient.cs Main web page here: https://github.com/SharpMap/SharpMap. If I were you, I'd use that as much as I could. It'll save you doing all the tedious implementation stuff...


9

I think I know what you mean, you should do that by 2 tools step by step first step find in arctoolbox intersect (Analysis) and then create intersect point layer in Intersection tools window choose "point" in output type field intersect(Analysis) finally [Step2] by Split line at point tools in ArcToolbox you can split polyline based on intersection points ...


8

You will not be able to delete a dataset (e.g. a workspace, feature dataset, feature class, table) when any references are held onto it, as they are implicitly locked. That being said, you do not need to worry that somebody will delete a dataset from under your hands while you are still referencing it. This can happen for IName-based instances, but not for ...


8

A file geodatabase has 3 types of locks. SR - schema lock RD - read lock ED - edit lock The proposed solution by @StacyR will work in all situations except for exclusive edit locks (ED) according to arcgis help documentation. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//003n0000007t000000


8

In ArcObjects .NET, use the RuntimeManager e.g.: Listing all installed runtimes: var runtimes = RuntimeManager.InstalledRuntimes; foreach (RuntimeInfo runtime in runtimes) { System.Diagnostics.Debug.Print(runtime.Path); System.Diagnostics.Debug.Print(runtime.Version); System.Diagnostics.Debug.Print(runtime.Product.ToString()); } or, to just get the ...


8

Use IGeometryBridge2.SplitAtDistances(). Also see the documentation on the equivalent IPolycurve2.SplitAtDistances() and the singular IPolycurve.SplitAtDistance() methods for more explanation. The IGeometryBridge2 version must be used in .NET. Edit: This code works for me: private static IEnumerable<IPolyline> SplitPolylineIntoEqualSegments(...


7

As far as I can tell you are implementing the error handling that ESRI is currently putting out there as best practice. If you were to grab a hold of the application's (ArcMap) unhandled exceptions you could potentially be then displaying messages about errors that were not part of your AddIn. Most of the AddIns you write are probably going to be buttons ...


7

After doing some research, I found a solution and it's called Assembly Binding Redirection Basically, for any .net .exe, you can add XML code in the application config file to redirect a referenced assembly from a version number to another. Esri implemented this in 10.0 and up versions in their EsriRegasm.exe utility. (located here : %commonprogramfiles(...


7

If the locks are being created by your code, then you aren't cleaning up after yourself. Release all references to feature classes, workspaces, cursors, etc. The locks are removed when you have no more references to the objects being locked.


6

Here's some Python I wrote, which I am sure can be moved to C# quite easily: # Ellipsoid model constants (actual values here are for WGS84) sm_a = 6378137.0 sm_b = 6356752.314 def projLatLonToWorldMercator(lat,lon,isDeg=False): """ LatLonToWorldMercator Converts a latitude/longitude pair to x and y coordinates in the World Mercator ...


6

Well, all things being equal, I would normally point out that your .NET dictionary is implemented as a tree, and if it were balanced, (otherwise the time complexity would be worse) the time complexity would be O(log n) while ESRI's FindField is internally implemented as a Hash table, and thus a time complexity of O(1) which is much better. Of course I said ...


6

How about using GDAL's OGR .NET bindings? http://bjarte.com/post/gdal-in-csharp and its KML driver through libkml http://www.gdal.org/ogr/drv_libkml.html Alternatively, you could use libkml directly.


6

Reinstalling the ArcObjects SDK will install the VS2010 templates provided VS2010 is installed. I had this happen as a result of installing the ArcObjects SDK before installing VS2010. I had been using VS2005, and after installing VS2010 the ArcObjects templates were not available. Reinstalling the ArcObjects SDK resolved the issue.


6

You could look at http://dotspatial.codeplex.com/ that has just released 1.0. From what I can remember this pulls together a number of other components such as Proj4 library and Topology suite.


6

This prints: 319524.804848596 174709.885049006. private static void TestProjection() { Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"); System.Object obj = Activator.CreateInstance(factoryType); var srf = obj as ISpatialReferenceFactory3; // Create Transformation from WGS84 to OSGB86 var geoTrans =...


6

It is a replacement ArcGIS Pro .NET SDK: The Road Ahead – SDK and API No need for “external” PIAs (primary interop assembly) like with Arcobjects. Simply install ArcGIS Pro. This is the fully fledged 64-bit version that will use more than 4GB of RAM for processing a long drawback of ESRI - welcome to the 21st century Still limited At Final Release: No ...


6

To get the messages in the catch block, the gp variable needs to be accessible outside try. You could also use finally if you want to get the messages regardless of success. IGeoProcessor2 gp = new GeoProcessorClass(); gp.AddToolbox(@"C:\Users\mxxx\Desktop\GIS_Testing\HbtatTesting\HabitatMon.tbx"); IVariantArray parameters = new VarArrayClass(); ...


5

SharpMap has a polygon class with an Area method. But before calling that, you should consider projecting the polygon's coordinates into an equal area projection to yield meaningful results. It looks like SharpMap uses ProjNet, which has Albers, but I also see there is now a c# wrapper for Proj4.


Only top voted, non community-wiki answers of a minimum length are eligible