I am currently working in ArcGIS 10.2.2 for Desktop and would like to know if there is a workflow for creating a unique ID for polygons within a shapefile based on their location. I am using data driven pages that are clipped to individual Township/Range/Sections of a city. There is polygon information that spans the entire city, but would like to create some type of unique identifier that allows users (of the exported attribute table) to quickly see where a polygon is located based on the identifier. What I currently have in mind is to list the Township/Range/Section and add a numeric suffix. For example, in the image below the first polygon in Township26-Range42-Section27 (highlighted in red) would be 26-42-27-1. The Township/Range/Section information is saved in another shapefile, so I am not sure the best process to append that info to the individual polygons within this other shapefile based on location.
4755
I have used the Grid index feature tool to create an index grid. The label/attribution of the page names are populated in a "row" orientated manner. eg lef to right a1,a2,a3,a4,a5,a6 b1,b2,b3,b4,b5,b6 c1,c2,c3,c4,c5,c6  How can I calculate a field so I can have the page names label/attribution in a "column" orientation?eg:  a1,b1,c1,d1,e1 a2,b2,c2,d2,e2 a3,b3,c3,d3,e3 a4,b4,c4,d4,e4
6755
I have several thousand irregularly shaped polygons in a shapefile. I want to be able to split each polygon into three areas, and to specify what the size of those areas (they sum to the previous total area). It does not matter what the sub-polygon shape is, as this is for visualization purposes.  How can I go about doing this? Is there a standard algorithm that exists that I can use?    One approach I considered was to get all the points that make up the polygon. Then, I would join two randomly together using a straight line, split the polygon, then check if the area was within a satisfactory tolerance. If it was too small, I would change the point in one direction; if it was too large, I would change to a point in the opposite direction.
71353
I have a line vector layer which has multiple segments within individual polygons in a separate polygon layer. I have spatially joined the attributes so that each line segment now has the same ID as its corresponding polygon.  I need to calculate the lengths of the lines within each polygon according to the polygon ID. Is there an expression I can use to do this? I have already calculated the lengths of the individual segments but I need to get the sum of these according to each unique polygon ID.  I am a novice at complex SQL expressions within QGIS, ideally I would like a new column displaying the info.
79937
I am using ArcGIS 10.2 for Desktop, and I've been looking through this site, and can't seem to figure out my answer yet. Very new to VBA and Python, but lots of years with ArcGIS.  I know I can do this the slow way with Select By Attributes, but It's time consuming.  I am attempting a spatial join between cases of a disease (points layer) and US Census Tracts (polygon layer). This requires count data. For each point/case, I have a field called YEAR with date ranges 2001 to 2012 depending on what year the case happened. I need a count column for each year. For example, the first one I'm calling COUNT01. If the case date in YEAR is 2001, then COUNT01 will have a 1 in it. If it is any other year (2002-2012), then there will need to be a 0. I will have COUNT02, COUNT03...COUNT12 columns. Can't have a "Null" value.   Here's what I've tried so far    And here is what the data looks like in Arc.
124279
I have two feature classes, a polygon of sales areas for a city, and point layer of addresses. I want to select the addresses based on the sales area they are in and update their attribute table to show the sales area. I have searched python+point+in+polygon for other posts and I know how to select the polygons but I can't figure out how to populate the address points.   I found the following script that works but takes almost two hours to run.  import arcpy import os  # Allow overwrite  arcpy.env.overwriteOutput = True  # Script user input parameters polygonLayer = arcpy.GetParameter(0) pointLayer = arcpy.GetParameter(1) workspace = arcpy.GetParameter(2) copyField = = arcpy.GetParameterAsText (3)   # Add new field to target feature class  fieldList = arcpy.ListFields(pointLayer) fieldNameList = [] for field in fieldList:    fieldNameList.append(field.name) fieldType = arcpy.ListFields(polygonLayer,copyField)[0].type if not copyField in fieldNameList:     arcpy.AddField_management(pointLayer, copyField, fieldType)  arcpy.MakeFeatureLayer_management(polygonLayer, "PolygonLayer")  pntCursor = arcpy.UpdateCursor(pointLayer) for pnt in pntCursor:     rowID = pnt.OBJECTID     arcpy.MakeFeatureLayer_management(pointLayer, "PointLayer", '"OBJECTID" = ' + str(rowID))      # Polygon selection based on CONTAINS selection method     arcpy.SelectLayerByLocation_management("PolygonLayer", "CONTAINS", "PointLayer")      # Copy field values from polygon to point layer         polyCursor = arcpy.SearchCursor("PolygonLayer")             for poly in polyCursor:         pnt.setValue(copyField, poly.getValue(copyField))         pntCursor.updateRow(pnt)      arcpy.Delete_management("PointLayer")          del pntCursor, polyCursor, pnt, poly   I don't think I need to create a new field so I have simplified my script too:  # Import arcpy module import arcpy import os  # Allow overwrite  arcpy.env.overwriteOutput = True  # Script user input parameters polygonLayer = arcpy.GetParameter(0) pointLayer = arcpy.GetParameter(1) workspace = arcpy.GetParameter(2) fsaPoly = arcpy.GetParameterAsText (3) #FSA in FSA_Boundaries fsaPnt =  arcpy.GetParameterAsText (4) #FSA in Addresses   # Select all Address in FSA     polyCursor = arcpy.SearchCursor("PolygonLayer")      for poly in polyCursor: # Select based on CONTAINS      arcpy.SelectLayerByLocation_management(poly, "CONTAINS", "PointLayer")  # Add FSA to Address         pntCursor = arcpy.UpdateCursor("pointLayer")               for pnt in pointCursor:             pnt.setValue(fsaPnt, fsaPoly)             pntCursor.updateRow(pnt)   del pntCursor, polyCursor, pnt, poly   I know my update cursor is wrong but i'm stuck on how to update one feature class using information selected from the other.   I know I can do this manually but I need to do it for multiple cities so I would like to automate the process.   I am using Arc 10.2.2 to run my python script.
65803
I do a lot of editing, in this case areas. Sometimes I add an area to one shapefile, only to realise a bit later that it should have been in another.   Is there an easy way of copying only that polygon into the proper shapefile? Something along the lines of rightclick the row in attribute table, copy and then paste in the next attribute table.   I do know that I can select the polygon and use , but this seem unnecessary complicated?
44998
I have two shapefiles, Point and Polyline. I'm trying to populate my polyline layer with the point data ID (systemID) where the lines start to where they end; eg. create two columns (from and to). The lines already have flow direction assigned to them. I am using ArcHydro tools but Arcpy is also fine.  In ArcHydro I have tried using Attribute Tools > Generate From/To Nodes for lines but it creates values for To and From that are not from my point data. My other alternative was using Feature to Vertices and joining the result to my point data table to get the systemID. But then I would have to update the polyline layer as well. I am sure there is a easier way of doing it.  Note: not all the lines have points at the vertices, blank values are fine for them.
106953
Is there something out there for QGIS that is similar to the Append Tool in ArcMap? Reason I am looking: I am currently working on a storm drainage project that involves GPSing Storm drain lids. My issue is when I capture the points with the GPS unit, and then bring them into the office. The GPS unit produces a CSV file for me to import into QGIS. It gives the CSV file with generic header names ( field1, field2, field3..etc) This is fine, until I try to copy it into the working shapefile that has all the other storm drains. The beautiful thing with ArcMap's append tool was that I could map each field from my CSV file to the destination shape file...ex... &quot;field1&quot; from CSV is equal to &quot;Elevation&quot; field in my shapefile. And thus update my shapefile with the newest points.
104565
Where is the ArcGIS 10 tool for creating a shapefile from current dataframe extents in layout view?  Have looked around and the closet thing i can find is Toolbox's Grid/Strip Map Index tools under Data Drive Pages.  I just want to be able to create a single polygon rectangle shp file based on the data frame (in layout view) for any given scale / page setup.
76620
I'm working on Arcgis 10.  I have a point shapefile representing events with several points having coinciding coordinates (They have the same coordinates). For representing them in a dynamic way, I found a nice way - .  Problem is: I was asked to produce a static (paper) map of the events. Is there a tool that can take these events and shift them apart a bit so all will be seen?  (I know that spreading them about will alter their coordinates, but I am prepared to do so on a duplicate shapefile for the display on the map).
43815
So I found this python script on another post here and was trying to adjust it for my needs.  I'm a very novice python user so I'm struggling with how to modify the script.  I have a Feature Class stored in a feature Dataset that I want to search a field for duplicate values and populate a new field with Y for duplicate or N for none.  The below script is what I found that looks like it will work once I find a way to drill down into my file geodatabase.          from arcpy import *          inShapefile = pointsShapefile          checkField = "xyCombine"         updateField = "dplicate"         #List of values found once         occursOnce = []        #list of values found twice         occursTwice = []       cursor = da.SearchCursor (inShapefile, [checkField])           for row in cursor:           #Check value is not null        if row[0]:     #If not already found to occur twice, proceed     if not row[0] in occursTwice:         #If hasn't occured once yet         if not row[0] in occursOnce:             #Add to occurs once list             occursOnce.append (row[0])         #If value has already been found once         else:             #Add to occurs twice list (duplicates)             occursTwice.append (row[0])     del cursor       cursor = da.UpdateCursor (inShapefile, [checkField, updateField])      for row in cursor:       #Check value is not null         if row[0]:            #check if value in occursTwice list (i.e. is duplicate)     if row[0] in occursTwice:         row[1] = "Y"     else:         row[1] = "N"     cursor.updateRow(row)    del cursor
63470
Two days ago I asked a question about the internal storing order for the vertices of a polygon in ESRI shapefiles. That question was answered () and it was also answered in an old post () But now my question is more general, and I don't know if it has an unique answer. Is the clockwise order only for ESRI shapefiles or for general GIS formats? And what about the internal representation for a GIS software? For example, if I use QGIS and I read a *.shp containing polygons I suppose the internal representation of the outer bound is clockwise as in the original shapefile, but what about for all the file formats supported by QGIS? And for ArcGIS? And in the case there exists a file format with polygons stored in counterclockwise, if these files are loaded in QGIS, ArcGIS, etc., is the orientation changed internally, so if I read the data using PyQGIS, for example, the polygons are clockwise ordered? My purpose is to write a plugin for QGIS, but the source of data can be ESRI shapefiles or other formats. As I need to check the angles between consecutive sides of polygons using their azimuths I need to known if the order is clockwise. One solution is computing the area of each polygon and, if I remember correctly, if it is positive the order is clockwise and if negative the order is counterclockwise. Area computation is not an intensive task, so it will not slow my plugin so much. But in the special case of QGIS, anybody knows if it stores the polygons clockwise or counterclockwise, regardless the order in the original source? By now I'm working with ESRI shapefiles and the coordinates in layer.getFeatures().geometry().asPolygon() are stored in clockwise for the outer border and counterclockwise for the holes, i. e. as in the original *.shp.
64736
I have 4 multipart polyline shapefiles (download a sample dataset ).   The geometries are identical, except for the length of segments in each shapefile. They represent 4 variables describing an identical shoreline. From these 4 overlapping polylines, I would like to create a resulting polyline that has segments for each unique set of the 4 input lines.    My approach was to use an intersect. This, however, breaks down when I try to run it on 4 huge feature classes.  My question is whether there is a more efficient way to combine polyline attributes stored in separate layers. I thought a union would be good, but it only works on polygons. Spatial Join seems inefficient, as I would end up with many to many joins for a single segment. Turning the segment end points into a point layer, then splitting the line at those points?  I have access to arcpy, PostGIS, and shapely.  Has anyone had experience doing this before on large datasets? Is there a more efficient way to store these variables?
90053
Every month I have to QA/QC some streets data for an entire county (over 47,000 records). The first step is to compare the two files. Currently, I'm using a tool that was created in house via VBA approx 5 years ago. It works compares the two files and reports back the differences based on a few factors (added records, deleted records, address changes, city changes, segment length/vertices changes). I then export these to individual shapefiles. Additionally, the tool works in ArcGIS 9.3 but will no longer work in ArcGIS 10.1  The tool works great, but it takes approximately an hour to complete.  I've started to work on hopefully improving this tool to speed up the performance. I've looked into a variety of methods including the Compare Feature Tool and Select by Location.   Both of these tools work significantly faster, however, they don't seem to capture everything that I need. The big issue I have with the Compare Feature Tool is that I cannot choose which field to compare on. It defaults to ObjectID when I need to compare by Segment_ID. There isn't an option to select that.   Does anybody have a good solution or ideas on how to achieve a full compare like I've described?    For some reason, ArcGIS isn't recognizing the join that I'm attempting per RyanDalton's answer.   But  Taking the advice of a join I have figured out how to find the added records and deleted records differences in the two files by:   Joining the Previous Month shapefile to the Current Month shapefile via the Segment_ID field Performing a definition query where Segment_ID IS NULL Exporting that to a new shapefile (Added Features)   I then reverse the joins and find the Deleted Features  Still working on a way to find the other differences listed and then string them all together in a model.    I can find all records that have changed by performing a select by location records from one of the datasets that are identical to the other dataset. I then switch the selection and it gives me all the records that are not identical.  I'll put it all in a model and hopefully it works just as well.
17297
I would like to use a Python script that is not based on arcpy to do things like  query a shapefile by attributes, create new layer from selection, and calculate areas of a polygon and convert polygons to points.  Anyone have any code examples of using other Python modules or libraries? I am able to do this easily using arcpy but i wanted to explore other options.
105875
A quick background for context is maybe helpful for this.  Essentially we have "vacation rentals" and I would like to add additional data to them automatically. We create booking websites for customers who have very niche sites, for example,    "Pet Friendly" rentals.  "Olympic Cottages" "Surfing Adventure Lettings".    Quite often each of our customers always ask the same questions,   "It would be awesome if we could plot the distance and sort properties based on their relative distance from XYZ".   Usually XYZ is something like a list of dog friendly beaches, or cycle tracks, or wine vinyards. So esesntially points of interests which are easily definable. In those cases, we've always just asked the customer to provide a list of the lat/lngs of every possible "point of interest" that they would like us to calculate distance from".  More recently we've been asked to include "Close to Coastline".   What I want is to come up with a standard way of automating this. My ideas so far are to create a shapefile. For example, let's say we wanted to do "Close to Coastline", we could use something like     At this point, I'm somewhat stuck in knowing how would be most efficient to calculate the distance from the edge of the coastline.   I'm thinking about being able to just create/add a shapefile per "concept" that the customer wants us to use for their product. But then do not know the process/tools available to me to know distance from each edge, or vector point.
11649
I've created polygons from a table that has two columns- an OBJECTID and a string of coordinates (Polygon_Coordinates). The resulting polygons (called &quot;testing&quot; in the code below) are in the correct locations, but I can't seem to figure out how to carry over the ID, which I need for a join later in the workflow. Any idea on how to build geometry, but maintain the attributes? fields = ['Polygon_Coordinates', 'OBJECTID']  with arcpy.da.SearchCursor(table, fields) as table_cursor:     for row in table_cursor:         #skip null rows         if row[0] != '-9999':                          #turn string of coordinates into a list but split them at the commas             coords= list(row[0].split(','))                          #break up list into list of pairs             pairs = [coords[i:i + 2] for i in range(0, len(coords), 2)]             coord_ints = [[float(i) for i in p] for p in pairs]              #create insert cursor for geometry creation             geocursor = arcpy.da.InsertCursor(testing, [&quot;SHAPE@&quot;])             array = arcpy.Array()                          #grab pairs from list, put into array             for a in pairs:                 array.add(arcpy.Point(a[1],a[0], ID=row[1]))                          #set crs, build polygon              wgs = arcpy.SpatialReference(4326)             poly = arcpy.Polygon(array, wgs)             geocursor.insertRow([poly])