|
POST
|
Hi Alice, You can do this using the UpdateCursor. You can specify a coordinate system that's in meters. Ex: fc = "Points"
sr = arcpy.SpatialReference(3032)
with arcpy.da.UpdateCursor(fc, ["SHAPE@XY", "XCOORD", "YCOORD"], "", sr) as cursor:
for row in cursor:
row[1] = row[0][0]
row[2] = row[0][1]
cursor.updateRow(row)
del row, cursor You can find the code of your coordinate system within the data frame properties > Coordinate System tab: [ATTACH=CONFIG]30312[/ATTACH] In addition to the above, you can also set the Transformation environment setting prior to opening your cursor and the transformation will be applied (you don't have to reference the transformation in the cursor set up). For example: arcpy.env.geographicTransformations = "NAD_1983_To_WGS_1984_5" I also wanted to mention that if you use a cursor with an alternative spatial reference on an XY Event Layer, the original layer coordinates in the table will automatically be converted just by opening the cursor even if you don't loop through any records. That behavior is potentially useful if you wanted the coordinates overwritten in their original fields anyway, but dangerous if you meant to keep the original spatial reference coordinate values and assign the transformed coordinates to another set of fields. To only transform coordinates in a new set of fields in an XY Event layer you should create the new coordinate fields in the table, duplicate the original spatial reference coordinates from the original fields into the new fields, create the XY Event layer using the new fields for the coordinates and the original spatial reference of those coordinates, and then apply the cursor with the alternative spatial reference.
... View more
01-07-2014
05:52 AM
|
0
|
0
|
1527
|
|
POST
|
I'm trying to add and calculate a text field in an existing dbf table by using a variable to set the value of the field. The AddField code is working fine. The CalculateField code sometimes does not work depending on the value of the variable I'm using to calculate the field. My statements (inside a for loop) to add and calculate the field are: for ascii in rasterList:[INDENT]outTable = r'D:\test.dbf'[/INDENT] [INDENT]dateField = 'Date'[/INDENT] [INDENT]fieldLength = 20[/INDENT] [INDENT]part = os.path.split(ascii)[1][/INDENT] [INDENT]fieldValue = os.path.splitext(part)[0][/INDENT] [INDENT]arcpy.AddField_management(outTable, dateField, "TEXT", "", "", fieldLength)[/INDENT] [INDENT]arcpy.CalculateField_management(outTable, dateField, fieldValue)[/INDENT] If I set fieldValue = os.path.splitext(part)[0], it does not work--the field remains blank. If I print fieldValue, I get ECR_TXT_201304, which is correct--it's what I want stored in the Date field for all records in the table. If I set fieldValue = "201304", it works--the Date field gets populated with 201304. I even tried fieldValue = str(os.path.splitext(part)[0]), and that didn't work either. I never get any error messages, the script runs without any indication of a problem. I'm baffled at this point why this code doesn't work when using the os.path variable. Thank you for any help! It is a very bad practice to name a field with a key word like 'Date'. I am surprised it even accepts that field name. That field name is bound to cause strange behaviors. Name the field something that qualifies the word Date as the first step (Mod_Date, Created, etc.). If for some reason the field believes it is a real date field, the all numeric text would work (since the text can be parsed to a number and internally dates are converted to numbers anyway), but any actual text that is not compatible with a true date parsing would fail.
... View more
12-30-2013
02:50 PM
|
1
|
0
|
2288
|
|
POST
|
I'm looking to create a map that has a large area in the background, and then a magnified portion of that area within the same map. I have found the magnify tool in data view, but cannot create this type of graphic in layout view. any ideas? Thanks Brian To do inset magnifying effects you have to insert a second data frame overlaying the first with all of the layers you need inserted into it and use the Clip to Shape options to make it a circle or any shape other than a rectangle/square.
... View more
12-30-2013
01:35 PM
|
1
|
0
|
2980
|
|
POST
|
If you have downloaded the Add-In contained in this thread and used it let me know if it successfully listed your Route features and updated the 3D measures or if you had any problems getting it to work.
... View more
12-29-2013
08:09 AM
|
0
|
0
|
5047
|
|
POST
|
The data were joined and the null values are non-matching records. There is no record existing to calculate a value into with a non-matching record join, which is why you cannot calculate a value into those (non-existent) records no matter what you might want. The Field Calculator never creates records, it only calculates to existing records. In any case, joins do not allow calculations ever on the joined table, since joins do not exist as real feature classes or tables except in memory which cannot be altered directly with a calculation. (because these joined fields only exist in memory the calculation has no where it can store the value of the calculation to disk and joins do not know if they are in reality based on a 1-1, M-1, 1-M, or M-M relationship). You would have to calculate the value into the original joined table directly to fill in a Null value in any real records. However, in this case you can't even calculate to the original table, since those records do not even exist for you to calculate anything into. You have to create these records somehow. Either you have to insert the unmatched join records into the original join data table so that they are no longer unmatched (and there is no easy way to do that) or you have to export the joined table to create a new table with all of the fields in real no longer joined records so that you can now calculate to the newly created Null fields in an actual table. So use Copy, Feature Class to Feature Class, Copy Features or some similar tool to create a new table from the joined table. Either that or create a calculation that uses the Null values they are with a code block calculation. Something like: Parser: VB Script Use Code Block: Checked Pre-Logic Script Code If IsNull([JoinedObjectIDField]) Then
Output = "SomeValueWhenRecordsAreUnmatched"
Else
Output = [OriginalValueInOutputField]
End If Expression: Output If the ObjectID field of the Joined table in Null the record is unmatched by definition and with the conditional calculation it does not matter if it has a value in it or not since you can process unmatched records differently from the way you process matched records.
... View more
12-27-2013
04:46 PM
|
0
|
0
|
7127
|
|
POST
|
I did. The field calculator is grayed when I try. if you are working on a joined feature class/table you cannot calculate values into the joined table or create records to replace the Null values without first exporting the joined data to a new feature class/table. If that is not applicable what is the data source location and type? How was the data created? Did you create it or are you just trying to access it?
... View more
12-27-2013
12:18 PM
|
0
|
0
|
7127
|
|
POST
|
This post was moved to from the General forum to the ArcObjects forum, since it is not a general ArcGIS question.
... View more
12-26-2013
08:30 AM
|
0
|
0
|
982
|
|
POST
|
If it is a shapefile, it is vector data...I will move this thread to the geoprocessing forum where it may get more traffic With vector data I always convert from a shapefile to a file geodatabase as the first step I do. Performance increases dramatically and I refuse to work with shapefiles any more. No one would use shapefiles in any significant geoporcessing operations if I had my way. Second, I would create two layers based on the same feature class, with one having a definition query where Productivity = 5 and the other had a definition query where Productivity = 1. Give the layers slightly different names to make it clear which layer contains which data (High Productivity and Low Productivity for example). Use a Spatial Join to intersect these two layers using the One to Many option and 0 tolerance. Keep only shapes that intersect, not all of the target shapes. This will pair all shapes with productivity of 5 with the attributes of the shapes that touch them having a Productivity of 1. Prior to running the tool you may want to turn off the visibility of fields that do not play a role in your analysis and only leave the fields that you need to compare or that provide a unique ID value for each polygon. The Spatially Joined attribute table will have two copies of the productivity field with one being the original name and the other being the original name with _1 appended to it. The Join will contain the original shape of the features with a productivity of 5 and a duplicate set of attributes representing the shape it touched with a productivity of 1. The Target_FID will link to the shape that has a productivity of 5 and the Join_FID fields will link to the touching shape with a productivity of 1. A quick and dirty way to see the related shapes together would be to create a new field in the original feature class to hold a long value. Join the layer with ObjectID of the layer with a productivity of 5 to the spatial Join TargetFID field and calculate the ObjectID of the Spatial Join output to the new field. Join the layer with ObjectID of the layer with a productivity of 1 to the spatial Join JoinFID field and calculate the ObjectID of the Spatial Join output to the new field. Now at least one pair of productivity 5 shapes will have the same value in this new field as the productivity 1 shapes in the original feature class. You could then use a new layer pointing to your original feature class with a definition query where the value in the new field is not null. In the attribute table of that new layer sort on the new field. You could then select or highlight the pairs of shapes with the same value in that field to zoom to them. You could also use that field value to set up a categorized symbology to make the paired shape have the same colors. However, this approach is quick and dirty because in reality you may have areas with productivity of 5 touch multiple areas of productivity 1 or areas of productivity 1 touching multiple areas of productivity 5. These multiple touched areas would not have a complete set of paired shape in all cases using the above method. If that happened you would have to use the Make Query Table tool instead to create a new layer that would contain all shape pairs for all of the Spatial Join IDs (which requires a geodatabases to work not a shapefile, which is another reason to convert). The details of how to set up the Make Query Table require more knowledge of your set up than I have, so I would need more information to lay out how to configure that tool.
... View more
12-26-2013
08:07 AM
|
0
|
0
|
1313
|
|
POST
|
Does anyone know how I can create feature to point in Arcgis 10.2 without extention? Thanks It does not require an extension, it requires that you have purchased an Advanced license. Without the correct license level you can't use that tool. About the best you can do within ArcMap without that license level is calculate the centroid XY coordinates of your features, export the data as a table, and then use the Make XY Event Layer to create a point layer from the coordinates. This method won't achieve the same results as the Features to Points tool, but it may get you close enough to what you need.
... View more
12-23-2013
12:22 PM
|
0
|
0
|
1588
|
|
POST
|
Jason's code comes the closest for VB, but you have to close all of the conditions with an End If statement at the end of the code block. I would use the Select Case syntax instead, since ELSEIF may fail after 7 levels (based on past experience with VBA). My Code would be: Parser: VB Script Use Code Block: Checked Pre-Logic Code Block: Select Case [MUN]
Case "0901" output = "Bayonne"
Case "0902" output = "East Newark"
Case "0903" output = "Guttenberg"
Case "0904" output = "Harrison"
Case "0905" output = "Hoboken"
Case "0906" output = "Jersey City"
Case "0907" output = "Kearny"
Case "0908" output = "North Bergen"
Case "0909" output = "Secaucus"
Case "0910" output = "Union City"
Case "0911" output = "Weehawken"
Case "0912" output = "West New York"
Case Else output = [MUNI]
End Select Expression (MUNI field) output
... View more
12-23-2013
10:01 AM
|
1
|
1
|
5159
|
|
POST
|
I am trying clean up a regional map I create in ArcGIS Desktop v 10. I took a list of zip codes and dissolved them into specific regions. However, I have a number of areas on the map that have no zip codes (areas in Maine, a National Forrest in California, Lake Okeechobee etc.) I would like to just further dissolve/merge these areas into the polygon area they are closest to. The problem is that the map recognizes all of the null areas as one polygon, not as individual null areas. Is there any way to split these up, or any tools to use that can smooth the map out? You are looking for the Explode tool. It is on the Advanced Editing toolbar. There is also a Geoprocessing tool in the Data Management Tools Toolbox, Features Toolset, Multipart to Singlepart.
... View more
12-23-2013
06:59 AM
|
0
|
0
|
765
|
|
POST
|
Richard, Thank you for contributing this add-in, however I cannot use it. Have installed it, turned on extension, and turned on dialog no problem. But the "Z and M Enabled Projected Layers" dropdown list remains consistently empty, even when I have perfectly good PolylineZM layers in my map that I would like to re-measure honouring the z values (i.e. in 3D). Any idea why this is happening? Using ArcGIS 10.0.5 at ArcInfo license level. Have tried polylineZM input layers that are both file GDB feature classes and shapefiles. First of all this thread is outdated and this was a known problem with the code referenced in this thread. Try using the Add-in from this thread first. If that does not work then provide the information below. Are you sure the data is in a Projected Coordinate System, not a Geographic Coordinate System? Only XY coordinates in Linear Units like feet or meters can be used, not coordinates in Angular Units like decimal degrees or radians. I don't know how to work with those units for determining measure lengths. If that is not the problem then what kind of data is it? File Geodatabase, Personal Geodatabase, SDE, Shapefile? There is separate code for each, since I have to be able to correctly detect the source in order to start or validate an edit session different ways depending on the data source. So i need to know which you have tried to know what to test. I personally prefer file geodatabases or SDE and did more testing on those than personal geodatabases or shapefile (which I personally avoid if at all possible). Is the data local or on a network drive? Anyway, all aspects of your set up could affect the code I need to examine. What operating system are you using? I have only tested it on a Windows NT machine, so I have not yet tested it against Vista, 7 or 8. Some aspects of the code could be affected by the OS and I would have to research it. Again, the code has to be able to initiate or validate that an edit session has started to work, and there are many variables. Some database types are more dependent on OS subroutines than others. I can try it on a Windows 7 machine next week, but it would be nice to know more about your configuration. Anyway, I thought I had isolated the problem, but if not I have not yet been able to reproduce the problem so far. I need more information, since it works with all of the test databases I have tried on my own system.
... View more
12-19-2013
10:03 PM
|
0
|
0
|
564
|
|
POST
|
Hello, I am a novice arc user. I would like to use a model or processing task whereby I can calculate the area of land not being used by our organization. The situation is that we have a jurisdictional boundary, and within the boundary there are parcels of land owned by citizens. You can see the division in the following screen shot:[ATTACH=CONFIG]30021[/ATTACH] I'd like to be able to subtract the size of the parcels in use (defined within a geodatabase) from the area of land within the Jurisdictional boundary (defined within a shapefile). Any help would be greatly appreciated. Thank you. Use the Union tool to merge the two polygon layers together (into the file geodatabase, please). Select all polygons where the FID of the geodatabase polygons is -1. The statistics table view menu item can give you a summary without creating a new table or you can use the Summarize (or Summary Statistics tool) to get the area of the left over area. These tools are available to users of all license levels. If you are trying to alter the shapefile by permanently removing the overlapping polygons that are in the geodatabase, you need an Advanced license to use the Erase tool. I doubt you have that license.
... View more
12-19-2013
02:34 PM
|
0
|
0
|
754
|
|
POST
|
I have point file "A" that I want to spatially join to point file "B" in order to get distance from the A points to the closest B point, but only when the A and B points at within the same polygon feature (e.g., county). What are the ways I can do this? I do not want to select each polygon one-at-a-time. Multistep processing is how you solve all problems like this. 1. After precalulating the X/Y coordinates of all points, spatially join both sets of points to the polygon file (two operations). I assume no two polygons overlap so each should have a single point for each original point (unless they touch the polygon boundary). 2. Spatially Join those outputs to each other within the tolerance you want using the One To Many option and get all matches (since the closest might not be in the same polygon). The tolerance should be no bigger than the widest distance across the widest polygon. 3. Select by Attributes where the joined points have the same polygon FIDs and export that point set. 4. Calculate the Euclidean distance of the points from the X/Y values of both points. 5. Summarize with the PointAFID values as the case field and get the Min Euclidean Distance. 6. Join the summary table back to the point pair join set and select where the distance is equal to the MIN distance. 7. Break the join. 7. Export the result and you have the set of points in A that were within the tolerance of point B that were in the same polygon. Geoprocessing is always supposed to be multistep for anything worth doing. Also, I never worry about creating more data than I need and throwing away what I don't want if no optimized direct tool is available. Time used to think up a more direct approach costs more than throwing away useless data and I find the direct approach often takes about as much processing time in the end anyway. Even if you wrote a more direct processing script, it pretty much has to do most of these steps anyway.
... View more
12-19-2013
01:51 PM
|
0
|
0
|
660
|
|
POST
|
I think you have to be more specific about what you want to accomplish and define some rules that you want your divisions to follow. There are an infinite number of solutions if you considered multipart polygon divisions as acceptable for the solution. Division into ring buffer, horizontal, vertical, diagonal, cubic and squiggly line sections are all possible valid approaches to the problem, but if only single part polygon divisions are allowed some classes of polygons won't have any solution with a strict adherence to some of these approaches. So without some kind of rules or preferences that limit or rank the possible solution set the problem has no single right solution and that uncertainty only increases the complexity of validating any result as a solution to the problem.
... View more
12-17-2013
09:28 PM
|
0
|
0
|
1363
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-24-2026 11:37 PM | |
| 1 | 03-24-2026 08:01 PM | |
| 7 | 02-23-2026 08:34 AM | |
| 1 | 03-31-2025 03:25 PM | |
| 1 | 03-28-2025 06:54 PM |
| Online Status |
Offline
|
| Date Last Visited |
07-09-2026
12:59 AM
|