Eliminate in Arcpy


I am attempting to move away from Coverages. One of the tools we have did a great job of eliminating slivers from our datasets based on hard and soft boundaries for elimination rulesets; howver, it is programmed in AML and utilizes coverages.

I am working on coding this to Python and have some theory/process questions that I need answered. I have run eliminate in the polygon world before and have found that I needed to do the eliminate multiple times in order to eliminate all slivers. This is due to the fact that there might be multiple slivers adjacent to each other and the elimination process can only remove one of them at a time. In AML, simply, arcs are removed of the polygon shapes that meet the criteria making this a non-issue. So, in the past, I have just iterated through the same eliminate function using the output as the new input until I did not see a reduction in table row counts.

Here is my theory on how to process my datasets so far:

import arcpy, os, sys
from arcpy import env
print 'Starting....'
env.OverWriteOutput = True
import datetime
import time
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
print st

fcName = 'C:\David\Eliminate\El_20150122\TSA_PE_L3.shp'
TheLayer = 'C:\David\Delete\ListTest\TheLayer.shp'
OutputLOC = "C:\David\Delete\ListTest\"
myList = set([row.getValue('F_DEL') for row in arcpy.SearchCursor('C:DavidEliminateEl_20150122TSA_PE_L3.shp', fields='F_DEL')])
FCLayer = "C:\David\Delete\ListTest\FCLayer.lyr"
FCsLayer = "C:\David\Delete\ListTest\FCsLayer.lyr"
TheEX2 = "C:\David\Delete\ListTest\TheEX2.lyr"
TableView = "C:\David\Delete\ListTest\TableView.lyr"
Output = "C:\David\Delete\ListTest\Output.shp"

print 'Deleteing existing layers'

if arcpy.Exists(FCLayer):
    arcpy.Delete_management(FCLayer)
if arcpy.Exists(OutputLOC + "Exclude.shp"):
    arcpy.Delete_management(OutputLOC + "Exclude.shp")
if arcpy.Exists(TheLayer):
    arcpy.Delete_management(TheLayer)
if arcpy.Exists(TheEX2):
    arcpy.Delete_management(TheEX2)
arcpy.MakeFeatureLayer_management(fcName, FCLayer)

print 'Selecting blocks for creating the hard boundary exclusion layer'

arcpy.SelectLayerByAttribute_management(FCLayer, "NEW_SELECTION", " "BLOCKS" <> ''")
arcpy.FeatureClassToFeatureClass_conversion(FCLayer, OutputLOC, "Exclude")
arcpy.SelectLayerByAttribute_management(FCLayer, "CLEAR_SELECTION")
Name4 = OutputLOC + "Exclude.shp"
arcpy.MakeFeatureLayer_management(Name4, TheEX2) # last input into eliminate

print 'Finished creating exclusion layer'
print 'Creating copy of dataset for elimination'

arcpy.FeatureClassToFeatureClass_conversion(fcName, OutputLOC, "TheLayer")
#myList = set([row.getValue('F_DEL') for row in arcpy.SearchCursor("'"+Name2+"'", fields='F_DEL')])

print 'Finished creating layer'
print 'Working on elimination of slivers'

for a in myList:
    #print '"F_DEL"= {}'.format('"'+a+'"')
    #break
    Last = 1
    Count = 2

    while Count <> Last:
        print "Count = " + str(Count) + ", and Last = " + str(Last) 

        Count = Last


        if arcpy.Exists(FCsLayer):
            arcpy.Delete_management(FCsLayer)
        arcpy.MakeFeatureLayer_management(TheLayer, FCsLayer)
        if arcpy.Exists(Output):
            arcpy.Delete_management(Output)

        arcpy.SelectLayerByAttribute_management(FCsLayer, "NEW_SELECTION", " "AREAHA" <= 0.1")
        arcpy.SelectLayerByAttribute_management(FCsLayer, "REMOVE_FROM_SELECTION", " "BLOCKS" <> ''")
        arcpy.Eliminate_management(FCsLayer, Output, "AREA", '"F_DEL" = {}'.format("'" + a + "'"), TheEX2)

        arcpy.Delete_management(TheLayer)
        arcpy.CopyFeatures_management(Output, TheLayer)

        if arcpy.Exists(TableView):
            arcpy.Delete_management(TableView)

        arcpy.MakeTableView_management(TheLayer,TableView)  
        Last = arcpy.GetCount_management(TableView)
        ts2 = time.time()
        st2 = datetime.datetime.fromtimestamp(ts2).strftime('%Y-%m-%d %H:%M:%S')
        print st2
    break

So this script is working but it is taking forever and will not get out of the While loop when LAST = COUNT. Are there any ways to improve the processing time of this? This is still working on one group of F_DEL to which there are 11 and then once this test is complete I will be iterating this on 12 different layers (12 layers X 11 hours per layer = 7 days of processing). In coverage world this would process in 2 hours.

enter image description here

Unable to view my local geoserver in that dropdown menu of Open Geosuite 4.5 Version?


I’m using GeoExplorer(Web Map Client) in Open Geo Suite4.5 version. I use to upload the layers from my LocalGeoserver by clicking on Add Layers Button. But now i’m unable to view my local geoserver in that dropdown menu.

How can I troubleshoot this problem?

run the GP tool “create enterprise gdb” from ArcObjects


hello i work with arcobjects and c#.net , i try to create entreprise geodatabase in Postgresql using the following code

using ESRI.ArcGIS.Geoprocessor;
using ESRI.ArcGIS.DataManagementTools;

public void create_ent_geodatabase()
{
        Geoprocessor gp = new Geoprocessor();
        CreateEnterpriseGeodatabase ceg = new CreateEnterpriseGeodatabase();

        ceg.database_platform = "PostgreSQL";
        ceg.instance_name = "localhost";
        ceg.database_name = "database";
        ceg.database_admin = "postgres";
        ceg.database_admin_password = "password";
        ceg.gdb_admin_name = "sde";
        ceg.gdb_admin_password = "password";
        ceg.authorization_file = @"D:server10.2.ecp";


        gp.Execute(ceg, null);
       }

but the operation failed i get the following message :
Error HRESULT E_FAIL has been returned from a call to a COM component.” at “gp.Execute”

any help will be appreciated!

How to remove geoprocessing history in ArcGIS 10.2.2 for Desktop?


I have grown dependent upon the awesome add-in called Clear Geoprocessing History.

It does not appear to work with my upgrade to 10.2.2

Does someone know of a different route?

Or perhaps how to modify the tool to make it work?

Buffer ring problem with uses of make feature layer


Im trying to create a buffer ring shape but gets me the error 210:

arcgisscripting.ExecuteError: ERROR 000210: Cannot create output
C:Trabajo CartoTempPrograma”capa de Ringbuff70″.shp Failed to
execute (Dissolve).

Failed to execute (MultipleRingBuffer).

with open (nombarch3) as p:
for x in recortes2:
    dtaring = p.readline()
    arquet, valbuf2, datperm= dta.split(",")
    valbuf2=float(valbuf2)
    a= valbuf2*0.3
    b= valbuf2*0.5
    c= valbuf2
    distances = [a,b,c]
    c=str(x)
    arcpy.MakeFeatureLayer_management(outsal,'"capa de Ringbuff'+x+'"')
    arcpy.MultipleRingBuffer_analysis(outsal,'"capa de Ringbuff'+x+'"', distances, "meters", "", "ALL")
p.close
first = True
entrada = []
for x in recortes2:
    if not first:
        entrada=entrada+","+ '"capa de Ringbuff'+x+'"'
    else:
        first = False
        entrada='"capa de Ringbuff'+x+'"'
arcpy.Merge_management(entrada,bufferRings)

QGIS How to multiply (repeat n times) a point by field


I have a point layer in QGIS that has a field named “Amount” that stores an integer value for every point in the layer.

I want to create N points in the exact place of the feature that has N as value in the amount “field”. I mean, if a point has in the amount field 16, I need to create 15 more points in that exact lat long (1+15 so that there are 16 in total) of that point.

After this process, the sum of “Amount” values in the starting layer should be equal to the sum of points in the new layer.

I need it to create a heatmap with the new layer. What is the easyest way of achiving this?

Regards

Exporting feature class into multiple feature classes based on field values?


I have a feature class with over 2,000 features, and I need to make them all individual feature classes based on a field.

I know there has to be a way to do this, but I just can’t figure it out!

Any takers?

Mapinfo : How to cut a raster with a vector layer?


With mapinfo 12, i would like cut my raster layer .tab with one of my vector layer.
How to do this basic task with mapinfo?
Is it possible with mapinfo to convert .tab raster table toward any standard formats (ecw, tif, etc)

Thank you.

Is there a geoprocessing tool that I can use to find the closest road to a point on a map?


I have a Network Dataset layer that I use to perform routing. Even if a starting or ending point is not near a road in the Network Dataset layer, I still want to perform routing using those points.
Is there a way that I can get the routing to start at the nearest place on the ND, to the starting point, or end on the route at the closest place near the ending point?

ArcGIS 10.1 – Error No spatial reference exists


I’m encountering a new error on some geoprocessing. It originally showed up while running commands in arcpy but now it crops up whenever I run some tools. I’ve been using the Extract by Mask on some rasters, and then using the Focal Statistics function on the resulting clipped grid. The main error that’s showing up is:

ERROR 999999: Error executing function
Unexpected operation
No spatial reference exists

A screen grab of the error messages is attached. The other two errors (010302 and 010067 ) have no helpful information. I’ve been running similar processes for months and haven’t encountered this before. Both the input layers (a raster and polygon feature) are in WGS84 with their coordinate system defined. Both of these input layers are in a File GDB and I did export them to a shapefile and GRID and the process executed successfully. I could run this series of processes outside of the GDB but it’d be nice not to.

Any thoughts on why this is happening?error message

Question and Answer is proudly powered by WordPress.
Theme "The Fundamentals of Graphic Design" by Arjuna
Icons by FamFamFam