Creating TIN, Surface Difference python script with ArcPy?


I have been trying to develop a master script to go through a series of geoprocessing tools and executing them. I am trying to generate a TIN and contours from a raw xyz file. Below is a very simple script that integrates the various tools. I am having difficulty inserting the correct inputs and outputs for the TIN generation and Surface Difference calculation/generation. Let me know if i am missing an input/output specification or a simple default value. I tried doing this same workflow on Model Builder to then export its python script, however i was unable to execute a successful TIN Output since for some reason only allowed for a Raster Output.

Note: I decided not to insert variables, i went directly to its filename.

import arcpy, exceptions, sys, traceback
from arcpy import env
from datetime import datetime

start_time = datetime.now()
print "The program has began processing", start_time


try:
    #Enables ArcGIS 3D Toolbox
    arcpy.CheckOutExtension("3D")
    #Set workspace
    env.workspace = "C:Standalone"
    #Set Spatial Reference using Well-Known ID  NAD 27 State Plane Missouri East FIPS
    sr = arcpy.SpatialReference(26796)
    #XYZ Processing to Point Shapefile
    arcpy.ddd.ASCII3DToFeatureClass("004d1214_3x3.xyz", "XYZ","004d1214_el.shp", "POINT", "1",sr,)
    arcpy.AddMessage("Processing Complete")


    #Add XY Coordinates 
    in_features = "004d1214_el.shp"
    arcpy.AddXY_management(in_features)

    #Create TIN surface out of the generated point shapefile
    arcpy.ddd.CreateTin_3d("tin004d1214_el",sr,"C:Standalone04d1214_el.shp POINT_Z Mass_Points <None>","DELAUNAY")

    #Delineate TIN Area. Verify that maximum edge length is greater than the point spacing.
    arcpy.ddd.DelineateTinDataArea("tin004d1214_el", 10, "ALL")
    arcpy.AddMessage("Complete")

    #Trigger Surface Difference to yield new elevation, Insert optional directories for TIN output
    inSurface = "tin004d1214_el"
    inReference = "CLASSIFIED PATH DIRECTORY"
    outTin = "tin004d1214_lrp"
    outPoly = arcpy.CreateUniqueName("004d1214_lrp.shp")
    arcpy.SurfaceDifference_3d(inSurface,inReference,"C:Standalone04d1214_lrp.shp",outTin) #Check for syntax

    #Generate Surface Contours off the Reference Survey surface
    arcpy.SurfaceContour_3d(outTin,"004d1214_contours.shp")  #Check for contour field add


except arcpy.ExecuteError:
    print arcpy.GetMessages()
except:
    # Get the traceback object
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    # Concatenate error information into message string
    pymsg = 'PYTHON ERRORS:nTraceback info:n{0}nError Info:n{1}'
            .format(tbinfo, str(sys.exc_info()[1]))
    msgs = 'ArcPy ERRORS:n {0}n'.format(arcpy.GetMessages(2))
    # Return python error messages for script tool or Python Window
    arcpy.AddError(pymsg)
    arcpy.AddError(msgs)

end_time = datetime.now()
print ('Duration: {}'.format(end_time - start_time))

Create a specific number points that are equidistant from each other and a constraining polygon


I want to create voronoi data visualizations per a set of constraining polygons, but to show the distribution of data between categories, I first need points that will serve as the reference for thiessan polygon creation.

Is there a way that I can create a specific number of points (these relate to the categories within my data) equidistant from a constraining polygon?

How to calculate frontages of city parcel data in ArcMap 10.0?


I need to calculate the length of polygon frontages (along streets) from our city’s parcel (i.e. lot) data in order to do an analysis on lot frontages in various zoning districts. How can I do this?

Multibuffer in arcpy is too slow?


I have to make multibuffer to a several shp’s (30 or +) and with this code the it takes 30 minutes or more.

    import arcpy,time,glob,os
def multibuffer (probe,Zona_trab,nombarch3,recortes2):
    x=0
    bufdef = (Zona_trab,"\bufferRing",time.strftime("%H%M%S"),".shp")
    bufferRings = ''.join(bufdef)
    if probe == 1:
        with open (nombarch3) as p:
            for x in recortes2:
                dtaring = p.readline()
                arquet, valbuf2, datperm= dtaring.split(",")
                valbuf2=float(valbuf2)
                a= valbuf2*0.3
                b= valbuf2*0.5
                c= valbuf2
                distances = [a,b,c]
                puntselec1a2 = (Zona_trab,"\puntsele",x,".shp")
                puntsele2 = ''.join(puntselec1a2)
                print puntsele2
                print distances
                arcpy.MultipleRingBuffer_analysis(puntsele2,"capadeRingbuff"+str(x)+".shp", distances, "meters", "", "ALL") 
        p.close
        wcard="puntsele*"
        try:
            dir=Zona_trab+os.sep+wcard+'.shp'
            flist=glob.glob(dir)
            arcpy.Merge_management(flist, bufferRings)
        except:
            print "error"

The code works, it have no errors, so it will work slow, but safe. My question is:

what would you do for speed up the process?

EDIT 1:

The first part of the program is done instantly, but this call:

arcpy.MultipleRingBuffer_analysis(puntsele2,"capadeRingbuff"+str(x)+".shp", distances, "meters", "", "ALL") 

Make the stop of several minutes in the script.

With this new info, someone know how to speed up this part? Doing several MultipleRingBuffer at once or something like that? (I think is not posible to make that)

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

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