Posts

Showing posts with the label ArcMap

Upgrade or Install Python PIP in ArcGIS Desktop 10.4.1

ArcGIS  Desktop 10.4.1’s default pip, C:\Program Files (x86)\Python27\ArcGIS10.4\Scripts  failed to install the packages throwing following error – Fatal error in launcher: Unable to create process using '"C:\Python27\ArcGIS10.4 \python.exe" "C:\Python27\ArcGISx6410.4\Scripts\pip.exe"  The following steps to make the pip to work Step 1. Open command terminal as Administrator and see if pip works       Make sure              C:\Program Files (x86)\Python27\ArcGIS10.4\Lib;             C:\Program Files (x86)\Python27\ArcGIS10.4\Scripts;             C:\Program Files (x86)\Python27\ArcGIS10.4       are in path                             pip install <package_name> , no luck [ You can Jump directly to #4]       ...

Code Snippet: Select feature polygon(s) on Mouse Click ArcObjects C#

Code snippet of custom feature(s) selection tool on mouse click and highlight it using ArcObjects and C#. class SelectFeatureTool : ESRI.ArcGIS.Desktop.AddIns.Tool { protected override void OnMouseDown(MouseEventArgs arg) { IMxDocument mxDocument = ArcMap.Application.Document as IMxDocument; IActiveView activeView = mxDocument.ActiveView; IMap map = mxDocument.FocusMap; ILayer layer = map.get_Layer(0); //Get 1st Layer IFeatureLayer featureLayer = (IFeatureLayer) layer; IPoint identifyPoint = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y); ESRI.ArcGIS.Carto.IIdentify identifyLayer = (IIdentify)layer; IArray array = identifyLayer.Identify(identifyPoint); int oid = -1; if (array != null) { object obj = array.get_Element(0); IFeatureIdentifyObj fobj = obj as IFeatureIdentifyObj; IRowIdentifyObject ir...

Catch Exception - Attempted to read or write protected memory in ESRI ArcObjects .Net 4.0 Framework

First - Don't write the code to throw "Attempted to read or write protected memory" ..it is bad. Second - If you are working on legacy codes and COM objects that throws "Attempted to read or write protected memory" while writing ArcMap add-ins, catch exceptions to prevent application crash, in my case ArcMap. Step #1 - Add following snippet to config file - app.config for Arc-addin <configuration> <runtime> < legacyCorruptedStateExceptionsPolicy enabled = "true" /> </ runtime > </ configuration > Step #2 Add - [HandleProcessCorruptedStateExceptions] [SecurityCritical] on the top of function you are tying catch the exception [HandleProcessCorruptedStateExceptions] [SecurityCritical] public IFeatureLayer GetOrCreateFeatureLayer ( string path , esriGeometryType type , ISpatialReference sr ) { //body }

Building ArcMap’s Add-in using command line

Image
Couple of days I have been spending on creating a build automation for ArcMap’s Add-in using Jenkins . In order to accomplish that I need to able to build my visual studio add-in solution using MSBuild.exe . When I try to build the solution using via command line – msbuild.exe MyArcMapAddin.sln /t:Clean,Build The console throws the following error-   (PrePackageArcGISAddIn target) ->   C:\Program Files (x86)\MSBuild\ESRI\ESRI.ArcGIS.AddIns.targets(37,5): error MSB4062: The "ValidateAddInXMLTask" task could not be loaded from the assembly ESRI.ArcGIS.AddIns.SDK, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86. Could not load file or assembly 'Microsoft.VisualStudio.Shell.9.0, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are avail...

Getting into ESRI ArcGIS Add-in Development in .Net and ArcObjects

Image
Recently, I landed into a project for ArcGIS/ArcMap Desktop add-in development using ArcObjects in C#. I am a newbie in both ArcObjects and add-in development. Googling through I got tons of snippets on the ArcMap add-in development, but I was not familiar with tailoring them to make a working application. Then, I started to look after Youtube and Amazon to see if any good basic books or tutorials that gives me basic concepts on tailoring the  ArcObjects/.Net snippets. On youtube, I came across a video tutorials series on “.Net programming with ArcOjects” , an excellent tutorial on ArcObjects and .Net development with sample Gis data and codes to download  by Hussein Nasser. I watched all 15 episodes on add-in development using VB.Net. From the Amazon, I bought a book entitled, “Beginning ArcGIS for Desktop Development using .NET ” by Pouria Amirian, with a blind believe on the reviewers, but it turned out the  The book is wonderful! The author does an excell...

Parenting Win-form and WPF form in ArcMap

Parenting of Win-form windows and WPF windows within a ArcMap application using C#.Net code snippets- Step 1: Create a ArcMapWrapper.cs, wrapper class         using System;         using System.Windows.Forms;         using ESRI.ArcGIS.Framework;         namespace ArcMapClassLibrary2         {                 class ArcMapWrapper : IWin32Window                {                      private IApplication _arcMapApplication;                      public ArcMapWrapper( IApplication mApplication)                     {                        _arcMapApplicatio...

Create standalone feature class and feature class inside feature dataset on Geodatabase using ArcObjects

public void StartUp() { try { //create gdb const string path = "D:/SampleDatasets/NewShp"; const string fileGDBName = "sample.gdb"; const string fileGDBAddress = path + "/" + fileGDBName; const string featureDatasetname="polygonFeatureClasses"; const string featureClassname = "MytestPolygons"; if (System.IO.Directory.Exists(fileGDBAddress)) { Console.WriteLine("already exist"); // return; } Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType); IWorkspaceName workspaceName = workspaceFactory.Create(path, fileGDBName, null,ArcMap.Application.hWnd); MessageBox.Show("gbd created!");   //Create feature dataset ...

Good Book for GIS Beginners : Book II

Image
Understanding GIS: An ArcGIS Project Workbook , is a very user-friendly written book for those interested to begin using ESRI ArcGIS Desktop 10 or ArcGIS Desktop 10.1 using real data from the City of Los Angeles' Department of Public Works, Bureau of Engineering's Mapping Division, and Department of Recreation and Parks and to manipulate it using the power of GIS.  Don't expect to become a GIS expert at the end because this is simply a good introduction to ArcGIS. The book guides the reader step-by-step, mouse-click-by mouse-click, decision-by-decision through a GIS project to determine for yourself which locations along the river are best suited for public recreational use in Los Angeles. At the end, you will have learned many of the fundamentals of GIS generally and ArcGIS specifically which aims at finding a suitable land parcel(s)for a new park area in Los Angeles .You use real data which comes in the companion DVD. When you reach the final stage in chapter 6 and fo...

Popular GIS Books

Image
Books Pro Cons It provides solid guide to how geospatial analysis work, particularly with respect to GIS. The book emphasizes conceptual workflows and with basic math which is helpful for creating own code and also getting an understanding of what's happening under the hood in contemporary GIS. It is better to have an update because lots of changes in GIS software over last five years. This book is for typical GIS user aspiring to design good maps. It is illustrating GIS map software and throughout with map samples in color which is especially useful for those who has little prior training or experience in map making. This is acceptable book for beginners but very little information of advanced users. It hardly touches on advanced cartographic representations. This book explains the computational geometry and algorithms concisely and very readable. It emphasis on describing algori...

GIS Programming for GIS Analyst using Python

Image
Penn state has a nice collection of ArcGIS & Python programming step by step guide for their GEOG 485 students, which is also available for non-students via Penn state website.  This course’s is main aim is to make student able to use the Python scripting language to automate GIS tasks in ArcMap, assemble ArcView geoprocessing tools into models to solve GIS problems, and run the tools from scripts to automate GIS tasks.  Although n o previous programming experience is assumed, the course's target is to make a student as a GIS programmer/analyst in ArcGIS and Python environment.  The course is basically divided into four parts:

Dissolve ERROR 999999: Error executing function. The Geometry has no Z values.

Solution to   Dissolve ERROR 999999: Error executing function. The Geometry has no Z values. ArcToolbox>Repair Geometry and delete features with empty geometries ArcToolbox > Conversion Tools>To Shapefile>Environments>General Settings>Output has Z values = Disabled, Output has M values = Disabled>OK>Input features/Output features>OK ArcToolbox>Dissolve> happy :)) Source

Solved: AutomationException 0x80004005 - Unspecified error

I was writing ArcGIS extension for Geoprocessing using JAVA and ArcObjects 10. My need was to process about 1000 PRISM raster datasets globally to compute various environments. My application did work up to 45- 50 raster files without any problems in loop, then if fails with “ AutomationException 0x80004005 - Unspecified error ”. If I restarted the application again works for next 45-50 raster files and then crashes with the same error. I still couldn’t figure out what was the exact cause for application failure-my guess is it may be due to memory management/garbage collection problem among ArcGIS COM objects and JAVA objects. Fortunately, I solved this issue by reinitializing ArcGIS engine (hope re-initialization breaks the locks and flushes the garbage) after 20 raster files processing. Now, the application works well without any breaks but little bit slower while initializing the ArcGIS engine after 20 raster files processing.

Raster Misalignment with Base Data in ArcMap10

Image
In the early Friday morning of mid May, I got an email from one of my team member about raster misalignment problem in ArcGIS10. I also tried to overlay couples of previously working Tiff and Grid raster files in ArcMap9.3 and ArcMap10 . The ArcMap9.3 overlay raster files perfectly aligned as we all desired, but ArcMap10 did not. Unaligned Aligned From the ESRI website, I got to know that the issue of misalignment of Tiff in ArcMap10 is a bug in ArcGIS 10. The ESRI team announced two solutions to solve Tiff shift into wrong geographic locations:

Map re-projection in ArcMap or ArcGIS

Here, I am trying to show how to project/re-project US shape file into AEA conic USGS projection using ArcMap. Follow the following steps: 1. Right click on Layer -> click on Coordinate System 2. Unfold Predefined -> Unfold GCS -> Unfold North America 3. Select North American Datum 1983 4. Click Apply and Click OK 5. Add Feature Data (Points/Lines/Polygons) 6. A warning may appears but ignore it. 7. Find Data Management Tools -> Select Project (feature) Tool 8. Input Dataset or Feature Class (Enter the name of layer needed to be projected.) 9. Input Coordinate System -> Click on Hand icon -> Click Select -> Unfold GCS -> Unfold North America -> Select North American Datum 1983 10. Click Add 11. Click Apply and Click OK 12. Output Dataset or Feature Class (Enter the location of output file and location name: *.shp) 13. Output Coordinate Systemè Click on Hand icon -> Click Select -> Unfold PCS -> Unfold Continental -> Se...

Mapping the Disease Trends

Image
West Nile Virus (WNV) is the most widespread arbovirus (viruses that are transmitted by arthropods) in theworld. . During the period of 1996 -1999, the WNV became prevalent insouthern Romania, the Volga delta in southern Russia, and the northeastern United States. The spread of WNV covered the United States from coast to coast in four years, and by then it had 7 infected about one million Americans, killing about eight hundred. Here I mapped the spatial trends of WNV virus in the United States of America. Check website - http://globalmonitoring.sdstate.edu/eastweb/maps/wnv1999_2011/

How to get Color Brewer Ramp in ArcMap 10?

There are two ways to achieve this: Method A steps: 1. Download Color Brewer Color Ramp Style Set from http://arcscripts.esri.com/details.asp?dbid=14403 2. Unzip it. 3. Open the Layer properties and click on ‘Symbology’ tab in ‘ArcMap 10’. 4. Double click on one of the color symbol beneath ‘Symbol’ that gives you a ‘Symbol Selector’ window. 5. Click “Style References..” 6. Click “Add Style to List..” and add ‘ColorBrewer.style’ that is obtained from setp 2. 7. If you made it correctly it should be listed in the ‘Style References’. 8. Select ‘ColorBrewer.style’ and make it default. 9. Close the layer properties once and open it again, you will see newly generated color ramp. Method B steps: 1. You have to pick each color ramp value manually from http://colorbrewer2.org/ . 2. Open the Layer properties and click on ‘Symbology’ tab in ‘ArcMap 10’. 3. Double click on one of the color symbol beneath ‘Symbol’ that gives you a ‘Symbol Selector’ window. 4. Click...