Quantcast
Channel: Forums - Geoprocessing
Viewing all 1751 articles
Browse latest View live

Dissolve tool for table features

$
0
0
Does anyone know if there is a way to dissolve table rows that have duplicate attributes in one field, by performing a MEAN statistic on another attribute field. The table is created to have just these two fields but there are multiple values for many of other values in the other field.
See below:
Attachment 26927
So what I want to do is essentially truncate the entire table so it has just an average "dbthirdbar" value for each unique MUKEY.
Any suggestions welcome.
Thanks.
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG‎
Views:	N/A
Size:	14.7 KB
ID:	26927  

Model Builder - preconditions

$
0
0
I am building a procedure using the model builder, but I have a problem with some tools that require the feature class to be created previously, and sometimes even showing in the table of contents of my project.
I have tried setting the preconditions but it still won't work.

I've had this problem up to now with "select attributes" and with "join fields". Is there any way to set the model for this to work?

Thanks

Multiple distance calculation with formula calculation for each

$
0
0
Ok my task I've metioned here becomes a little more sophisticated. First I've attached a graphic to explain it.

I've got two Layers - shown as blue and red containing like 10.000 polygons each.

I need to calculate for every blue polygon one value. This value is calculated by the distance (Distance 1) between one blue polygon (Area 1) and one red polygon with a unique value (Value 1) --> Value 1 needs to be divided by Distance 1 --> and the result is a factor (X1). This must be done with all other red polygons (10.000 times). --> So finaly I've got one faktor for each Area 1 - red polygon connection - so 10.000 factos. For these factors the average value must be calculated. So far so good - it's just one blue polygon. BUT I've got like 9.999 other where exactly the same needs to be done.

I hope I've explained my problem understandable :rolleyes:

What do you think I should do? Can you help me?
Attached Thumbnails
Click image for larger version

Name:	Example.jpg‎
Views:	N/A
Size:	67.8 KB
ID:	26939  

problem with 2 processes

$
0
0
Hi
When I am running a geoprocessing service (for example building cash) my other geoprocessing services don't work. I am using flex viewer 3.2 and ArcGIS server 10.1 with all extentions. Background processing is enabled in my ArcGIS too. please help me.
Regards

Model Builder - Write calculated output to shapefile field

$
0
0
I am somewhat new to creating models and have run into a problem with the one that I am currently working on. My goal is to Iterate rows of one shapefile, "sections", and perform a select by location to find the "tracts" that have their centroid in each section. Then, I would like to summarize a field for these selected tracts within each section.

I have successfully done this and output the values to a table, although the table will only keep one record at a time, overwriting the table each time instead of adding a new row. Even so, I am trying to figure out a way to add this calculated value to a field of the current record in the iteration of my "sections" shapefile.

I have explored the option of trying to do a table join, but I don't think that this will work because of the many to one (tracts to section) relationship and that there is no unique key between the two. I will attach my script and graphic. Any advice would help, thanks in advance!

Attachment 26997


Code:

# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# Test.py
# Created on: 2013-08-26 15:08:04.00000
#  (generated by ArcGIS/ModelBuilder)
# Description:
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Load required toolboxes
arcpy.ImportToolbox("Model Functions")


# Local variables:
LPMGIS_LEASE_ACTIVE_TRACT = "Core Layers\\LPMGIS.LEASE.ACTIVE_TRACT"
Sections_Result = "Sections_Result"
Sections = "Sections"
I_Sections = "I_Sections_FID"
LPMGIS_LEASE_ACTIVE_TRACT__3_ = "Core Layers\\LPMGIS.LEASE.ACTIVE_TRACT"
grs_acre_sum = "U:\\SectionAcreageTest\\grs_acre_sum"

# Process: Iterate Row Selection
arcpy.IterateRowSelection_mb(Sections, "", "false")

# Process: Select Layer By Location
arcpy.SelectLayerByLocation_management(LPMGIS_LEASE_ACTIVE_TRACT, "HAVE_THEIR_CENTER_IN", I_Sections, "", "NEW_SELECTION")

# Process: Summary Statistics
arcpy.Statistics_analysis(LPMGIS_LEASE_ACTIVE_TRACT__3_, grs_acre_sum, "T_GRS_AREA SUM", "")

# Process: Get Field Value
arcpy.GetFieldValue_mb(grs_acre_sum, "SUM_T_GRS_AREA", "Double", "0")

Attached Thumbnails
Click image for larger version

Name:	Test.png‎
Views:	N/A
Size:	14.7 KB
ID:	26997  

Model Builder: Continue Processing If Features Selected

$
0
0
I have a feature class that may or may not have a number of features selected. If there are features selected, I want to process them using a Model Builder sequence I have prepared. How do I check "if features are selected, continue, otherwise stop processing"? I tried the following from looking at another post, but regardless whether the Boolean Output is "True" or "False", the model still continues processing past the Boolean Output point. Does anyone have any suggestions to either improve upon my sequence or another solution that will do the checking for selected features?

Attached are two screenshots. One is the sequence I set up in Model Builder, with the "check for selected features" Calculate Value first, and the second is the code within that Calculate Value tool.

Attachment 27006

Attachment 27007

I would assume this is pretty basic, but it's stumping me. Thank you for any assistance.
Attached Thumbnails
Click image for larger version

Name:	MB.png‎
Views:	N/A
Size:	19.5 KB
ID:	27006   Click image for larger version

Name:	CalcValue.png‎
Views:	N/A
Size:	34.3 KB
ID:	27007  

Creating layer from attribute table field

$
0
0
I have an attribute table with demographic data for "counties" and need to make each field a layer. For example "POP2000" needs to be it's own layer. It's easy with rows but can't figure out the columns...

How to extract values from a table (or raster pixel) in ModelBuilder

$
0
0
Hello everyone, my name is Cris and I'm a student just getting into this world of Arcmap and Modelbuilder. I am trying to use maximum and minimum temperature values to solve for a very simple equation. The temperature values come from a raster image. Although I've searched, I have not been able to find a straight forward way of extracting the min and max temperature values (or any other value for that matter) from the raster or the accompanying attribute table. I have been able to look at the values (through the statistics tools) but that would only allow me to "hard code" a value for a single raster image. The goal is to be able to extract the min and max temperature values as an intermediate step and then use these values as further inputs of the model, then run the model over several of the temperature rasters. Anybody have any leads or ideas on how this can be accomplished? Thank you in advance for any help you may offer, take care and be safe.

-Cris

Geoprocessing with ArcGIS Server 10.1

$
0
0
I'm new to Geoprocessing, but would like to determine if I have a model created in ArcGIS Desktop Model Builder, can I convert that model to a Python Script for publishing to ArcGIS Server?

I would like to convert it to Python because I want to add a couple of things that don't seem to be possible in Model Builder, such as write some output to a CSV file or even a text file. The Model Builder only seems to support GeoDatabases for output. Is there a way to output data to a CSV file once published to ArcGIS Server?

Thanks,
Charlie

Combing Multiple Models

$
0
0
I'm starting to get a feel for Model Builder, but I can't figure this out:

I've got 9 geoprocessing models that are all part of the same essential process. I want to have one model, or script, that will run each one of them consecutively. I tried doing everything in a single model, but I got red exes on some of the tools because I am overwriting some datasets. At the same time, it could be useful to keep each step separated anyway.

So, does anyone know of anyway to automate running 9 models consecutively?

Thanks!

Copy Features from joined layer speed

$
0
0
In model builder, I have a model that takes the iterative table input and joins it to a point (28k count) file using the Add Join tool.
The join happens rather quickly, but the Copy Features takes almost 2 minutes.

If I execute the same series of event from the table of contents, the data export only takes around 10 seconds.

Both are going to a local SSD.

Attachment 27064

Any ideas as to the what and why for this being so much slower?
Attached Thumbnails
Click image for larger version

Name:	model.jpg‎
Views:	N/A
Size:	30.5 KB
ID:	27064  

Con tool error: The truth value of a raster is ambiguous

$
0
0
I'm trying to execute the Con statement below in a Python script and keep getting the error: 'The value of the truth raster is ambiguous'. I've read all the postings on this subject and tried every possible combination of parentheses I can think of but the problem persists.

outGrid = Con(((Raster(pSaltmarsh) > 0) & ((Raster(pLuwet) == 5940) or (Raster(pLuwet) == 5942) or (Raster(pLuwet) == 5943) or (Raster(pLuwet) == 5944) or (Raster(pLuwet) == 5955) or (Raster(pLuwet) == 5947) or (Raster(pLuwet) == 5948) or (Raster(pLuwet) == 5949) or (Raster(pLuwet) == 5950) or (Raster(pLuwet) == 5952) or (Raster(pLuwet) == 5958) or (Raster(pLuwet) == 5959) or (Raster(pLuwet) == 259260) or (Raster(pLuwet) == 894516) or (Raster(pLuwet) == 59400) or (Raster(pLuwet) == 59490) or (Raster(pLuwet) == 59500))),pSaltmarsh,pLuwet)

Any help would be much appreciated!

Help to create a Bhutan map in shape file format

$
0
0
Where can we get a Geo referenced map of Bhutan or How can i create a shapefile for Map of Bhutan

Semi-random point distribution with customized point count per polygon

$
0
0
I'm trying to disperse the clustering that is caused by zip code-based geocoding. Our statewide geocoding process results in an average of 5 percent of the geocodes ending up at the zip code level. I want these geocodes to be scattered throughout the zip code area as opposed to clustered to the zip code centroid. I do not want the points to be distributed entirely random however, but instead distributed semi-randomly within each zip code using the area's population density as a distribution weight.
The website spatialecology.com provides two tools that are very close to what I am looking for. Unfortunately, both tools appear to be short one feature that the other tool provides. The genrandompnts (Generate Random Points) tool allows the distribution to be weighted through the use of its 'probsurf' option, which allows a raster layer (in this instance, a raster containing the population distribution of the state) to be used as a probability density surface. However, applying this option does not allow the use of a polygon (in this instance, the zip code tabulation areas feature class for the state) to be used as strata for stratified random point distribution, which is something that the tool genstratrandompnts (Generate Stratified Random Points) does allow. However, the latter tool does not allow the use of a raster layer as a probability density surface.
Does anyone know of any tools that might provide a combination of the features of both aforementioned tools? Or an effective method for applying both tools to get the desired end result? The best that I can think of is creating population distribution surfaces for each zip code and applying the genrandompnts tool to every zip code individually on a piece meal basis. Any suggestions would be much appreciated.
Thanks!

exit loop in iterator model

$
0
0
I have a model that iterates a couple steps for all the rows in a table. It works well and does exactly what I want it to do, however, the whole process takes a really long time to run. So I don't have to watch the model constantly, I attempted to set up an alarm of sorts by writing a python script that sends out an email to me. However, I ended up basically spamming myself because it sends out an email every time it iterates.

Is there a way to put in logic that will run this script once after the iterator is finished?

Is there a way to combine fields when using the Union tool?

$
0
0
I have two feature classes, treesa_clip and orchard_clip. The fields for the first one looks like this . . .
Attachment 27113 and the fields for the second one looks like this . . .
Attachment 27114
When I use the Union tool to combine the two into one feature class, I end up with 28 fields, in other words, even though there are fields in common (with common names), it creates two separate fields for those (such as f_code and tile_id). Is there a way that I could get the Union tool, or some other tool, to create an output feature class that also combines fields with names in common?
Thanks!
Attached Thumbnails
Click image for larger version

Name:	fields_treesa.jpg‎
Views:	N/A
Size:	9.0 KB
ID:	27113   Click image for larger version

Name:	fields_orcharda.jpg‎
Views:	N/A
Size:	7.3 KB
ID:	27114  

Combining data from different shapefiles?

$
0
0
I am working on a town sewer system right now and have run across a bit of a problem. I have gps every manhole in the town, and then I proceeded to draw in the sewer lines snapping them to each manhole, like connecting the dots. In my attribute table for Manholes i have a column that wants the SegmentID (Sewer Line) for each manhole. I would just manually type them in but there are thousands of manholes. Is there a quick way that i can run a tool or something that will pick up which manhole is on what line and put it in that column? I don't know how to explain it better than that.

Thanks,

Select/Delete Polygons that are surrounded by other Polygons

$
0
0
We are trying to convert our Address Annotation Feature Class into a Shapefile. I was able to use the "Feature to Polygon" tool in order to do this conversion, but it filled in all the holes in the numbers with additional polygons (please see attached photo for example). I need to select and delete all these additional polygons as efficiently as possible; since there are over 100k features, it would take WAY too long to do it by hand.

Is there a way to select all the polygons that are completely surrounded by other polygons within the same shapefile?

Additional notes: There are all sorts of font sizes in the Anno, so I can't just select the additional polygons by area. Also, I am not a programmer, so if you give me code, please also tell me how to use it. Thanks!!!
Attached Thumbnails
Click image for larger version

Name:	AddrAnnoPoly.jpg‎
Views:	N/A
Size:	56.7 KB
ID:	27120  

Geoprocessing Service from Python Toolbox to create a web map?

$
0
0
Hi guys, I have created a python toolbox for 8 tools. One of the tools calculates a plan id based on the county where the polygon is drawn and the year from a date entered by the user.

I would like to create a web app with all these tools. My web app (javascript) already has editing capabilities and the feature service created for these tools can be already be edited in the web app.

But I need to calculate that PlanID field (the field is already in the database), so I am guessing I need to convert my toolbox script to a geoprocessing service.

If so, how can I do that, since I already have the editor part working in the web app, so I don't need that part of the script to enter the data, just the part that after getting the data, it calculates the planid based on the county where the polygon created is. Here is the python tool script ( I deleted some parts like some of the parameters and messages so it would fit here)
What would I need to change in my code for it to work, should I call a geoprocessing service in javascript or redodo all this code in javascript? Can you please take a look at the python code and give me some advice on what to do? Any idea, or general idea on where to go from here would be awesome! The javascript code is in the following post.
Thank you!!!

Code:

class Stewardship(object):
   
    def getParameterInfo(self):
        """Define parameter definitions"""
   

        param1 = arcpy.Parameter(
        displayName = "Forester",
     
        name = "Forester",
        datatype = "String",
        parameterType = "Required",
     
        direction = "Input"
        )

             

        params = [param0, param1, param2, param3, param4, param5, param6, param7, param8, param9,

param10, param11, param12, param13, param14]
        return params
 
    def execute(self, parameters, messages):
     
           
             
        Status =  parameters[2].valueAsText
        DateStart =  parameters[3].valueAsText
     

# This is to send the data input to the database
        with arcpy.da.UpdateCursor("Stewardship", ("Status", "Office", "Forester",

"DateStart","PlanLength", "PlanEQIP", "RecipientLast", "RecipientFirst",
    "MailAddress", "City" , "State", "ZipCode", "Phone", "Email", "Underserved")) as rows:
        # row comes back as a tuple in the order specified here, so Office is row[0], Forester is row[1]
            for row in rows:
                row[0] = StatusCode
                row[1] = OfficeCode
            rows.updateRow(row)
       
     

# This is to save only the year to the FFY field from the DateStart field
        with arcpy.da.UpdateCursor("Stewardship", ("FFY")) as rows:
     
            Datestarstr1 = str(DateStart)

            arcpy.AddMessage(Datestarstr1)
            if len(Datestarstr1) == 9:
            # if for example 6/28/2013 or 10/4/2013
                yearonly = DateStart[5:9]


            if len(Datestarstr1) == 8:
                yearonly = DateStart[4:8]
            if len(Datestarstr1) > 9:
            # if for example 10/10/2013
                yearonly = DateStart[6:10]

               
            for row in rows:
                row[0] = yearonly


                rows.updateRow(row)
       
       

# This is to create centroids of the stewardship boundaries to select the county that contains the

centroid (stewardship), to be used to create the PlanID

        Countieslayer = 'Counties FL'  # this is a string that represents the Counties feature layer
        Stewardshiplayer = 'Stewardship FL'  # this is a string that represents the Stewardship feature

layer
        Stewardshipcentroidslayer = 'Stewardship centroid FL'  # this is a string that represents the

Stewardship feature layer
        if arcpy.Exists(Countieslayer):
            arcpy.Delete_management(Countieslayer)
            # make feature layer
        arcpy.MakeFeatureLayer_management("Counties", "Countieslayer")

        if arcpy.Exists(Stewardshiplayer):
            arcpy.Delete_management(Stewardshiplayer)
            # make feature layer
        arcpy.MakeFeatureLayer_management("Stewardship", "Stewardshiplayer")


create the layer after creating centroids
        outstewardshipcentroids = "StewardshipCentroids2"
   
        if arcpy.Exists(outstewardshipcentroids):
            arcpy.Delete_management(outstewardshipcentroids)
            # make feature layer
        # Create centroid
        arcpy.FeatureToPoint_management("Stewardshiplayer",  outstewardshipcentroids,"INSIDE")

        if arcpy.Exists("Stewardshipcentroidslayer"):
            arcpy.Delete_management("Stewardshipcentroidslayer")
            # make feature layer
        arcpy.MakeFeatureLayer_management(outstewardshipcentroids, "Stewardshipcentroidslayer")

        arcpy.SelectLayerByLocation_management("Countieslayer", "CONTAINS", outstewardshipcentroids, "",

"NEW_SELECTION")

    # To get the code of the county from the counties layer to send it to the County field in

Stewardship
        # Takes the first row of the cursor (there is only one object in the county centroid).
        # The first index is the first row, the next [0] index is the first attribute, which there is

only one (FIPS_TXT)
        countycode = tuple(arcpy.da.SearchCursor("Countieslayer", "FIPS_TXT"))[0][0]
        urows = arcpy.da.UpdateCursor("StewardshipLayer", "County")
        for urow in urows:
            urow[0] = countycode
            urows.updateRow(urow)

        del urows, urow
       
    # To add 1 to the year if month starts in October

        import time
        from datetime import datetime, date
        #sim_date_counter = 1

        with arcpy.da.UpdateCursor("Stewardshiplayer", ("FFY")) as rows:
          for row in rows:
            #get the value of the date

            FFY = row[0]
            FFYnumber = int(FFY)
            #convert to string
            DateStartstr = str(DateStart)
            arcpy.AddMessage(DateStartstr)
            # Get only the month
            # To get only the first two characters:
            DateStart2 = DateStartstr[0:2]
            arcpy.AddMessage(DateStart2)
            if "/" in DateStart2:
                        # if for example 6/28/2013
                    DateStart3 = DateStart[0:1]
                    FFYnumbercount = FFYnumber
                    arcpy.AddMessage(DateStart3)
                    arcpy.AddMessage(FFYnumbercount)
            if "/" not in DateStart2:
                # if for example 10/10/2013
                DateStart4 = int(DateStart2)
                FFYnumbercount = FFYnumber + 1

                arcpy.AddMessage(DateStart4)
                arcpy.AddMessage(FFYnumbercount)
            row[0] = str(FFYnumbercount)

            rows.updateRow(row)
       
        trows = arcpy.SearchCursor("Stewardshiplayer")

        for row in trows:

                  FFYtxt = row.getValue("FFY")
                  Countytxt = row.getValue("County")
     
        del trows, row

    # we list the layer to create a layer feature without a selection (because it is selected by the

user)
        lyr = arcpy.mapping.ListLayers(arcpy.mapping.MapDocument('CURRENT'), 'Stewardship')[0]

        arcpy.MakeFeatureLayer_management(lyr.dataSource, "TMP")
    # To get the total ammount of records, not only the selected
        result = int(arcpy.GetCount_management("TMP").getOutput(0))


    # write a query to get the county and year using the FFY and County of the object id of the

Stewardship layer (the one that is selected)

        query = "FFY" +"=" + "'"+ str(FFYtxt)+"'" + "AND " + "County" +"=" + "'"+ str(Countytxt)+"'"

        # select all the records that have the FFYcounty the same as the FFYCounty of the hightest

ObjectID
        arcpy.SelectLayerByAttribute_management("TMP",  "NEW_SELECTION", query )
        result = int(arcpy.GetCount_management("TMP").getOutput(0))


    # if there are more than 1 records with the same ffy and county
        # select only the record witht the highest sequencenumber (sort first, then select)
        if  result > 1:
            maxValue4 = arcpy.SearchCursor("TMP", "", "", "", "SequenceNumber D").next().getValue

("SequenceNumber")
 
            query = "SequenceNumber = "
            arcpy.SelectLayerByAttribute_management("TMP",  "SUBSET_SELECTION", "SequenceNumber = " +

str(maxValue4))
            result = int(arcpy.GetCount_management("TMP").getOutput(0))


    #  to get the sequence number
       
        rows = arcpy.SearchCursor("TMP")

        for row in rows:

              Seqnum = row.SequenceNumber
             
        del rows, row

    # If the sequence number is equal or higher than 1 it means there are other records with the same

FFY and County, so we add 1 to the number
      # rows = arcpy.UpdateCursor("Stewardshiplayer")


        with arcpy.da.UpdateCursor("Stewardshiplayer", ("Sequencenumber")) as rows:


            if Seqnum >= 1:
 
                    vsn = Seqnum + 1
            else:
 
                    vsn = 1
            for row in rows:


            #get the value of the date


              row[0] = vsn

              rows.updateRow(row)
   
    # we Create the Plan ID concatenating the FFY, the county and the Sequence number, adding zeros in

front of the sequence number if necessary to make the lenght always 3
        with arcpy.da.UpdateCursor("Stewardship", ("PlanID")) as rowsffycounty2:
            for row in rowsffycounty2:
                row[0] = str(FFYtxt) + "-" + str(Countytxt) + "-" + str(vsn).zfill(3)

                rowsffycounty2.updateRow(row)

       

       
   
        return

Problems with Parse Path

$
0
0
Hello Everyone,

I'm having trouble with Parse Path. I have created a model, that iterates over multivalues. I need to to drag - drop a lot of different layers, that are stored at a lot of different locations from arcmap into the parameter dialogue of the model. I need the model to parse the name of each shapefile, which works fine, and I need the model to parse the path of each shapefile. I use the Parse Path tool, set the parameters to Path, but I only get empty outputs.
When I open the ArcToolbox from ArcCatalogue and run the model from there, it works, but I can not browse to hundred of different shapes at lots of different locations and add them step for step to the dialogue box. That will take hours.
So I need the convienience to run the model from arcmap, I need to open the layerfile in arcmap and drag drop all contents to the dialogoue box and run the model.

I would really appreciate some help on that issue, as it's driving me crazy.

Thanks a lot!!
Viewing all 1751 articles
Browse latest View live