|
POST
|
I was working out the SQL portion and noticed that Caleb has an excellent solution! Thanks -- this is useful. Edit: here's what I was working on. I just incorporated the sql from Caleb's example... def select_Even(): mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] for lyr in arcpy.mapping.ListLayers(mxd): if lyr.name=='thelayernameintheTOC': even = [] cursor = arcpy.SearchCursor(lyr) for row in cursor: if int(row.OBJECTID) % 2 == 0: even.append(int(row.OBJECTID)) field = "OBJECTID" even_sql = ' OR '.join('%s = %s' %(field,i) for i in even) arcpy.SelectLayerByAttribute_management(lyr, 'NEW_SELECTION', even_sql) else: arcpy.AddMessage("layer not found") select_Even() The SQL Modulus statement in the original post would work for some databases if it had been used with the SelectLayerByAttributes tool, but it would not work for all databases. Two SQL statements that work for virtually every database that do not require use of the modulus operator (which varies widely in its format from database to database) would be the following (the first statement selects even numbers and second selects odd): Round(NumberField / 2, 0) = NumberField / 2 Round(NumberField / 2, 0) <> NumberField / 2 Just make that the SQL statement (obviously substituting your real field name with correct field delimiters for NumberField) and make it the query expression for the SelectLayerByAttribute tool. The statements above assume the numbers you are evaluating are integers. If the numbers are doubles with fractional portions, the expression should be modified to the following: Round(Round(NumberField, 0) / 2, 0) = Round(NumberField, 0) / 2 Round(Round(NumberField, 0) / 2, 0) <> Round(NumberField, 0) / 2 Appending ObjectIDs into an SQL list is not a good approach if your database is very large (100K+ records), because the list will become huge and will take a long time to process (assuming it does not just fail). Plus by reading the database with a cursor you are effectively doubling the database read time, since the SelectLayerByAttribute tool will have to read the entire database again to select everything, making that approach very inefficient.
... View more
06-19-2013
06:25 AM
|
0
|
0
|
3591
|
|
POST
|
I did all of this and used & for the delimiter and CONTAINS as the merge rule. The problem has now become that if the "shapes" do not match perfectly it only takes the ones that do match. For instance if the snapping isn't 100% accurate my output will not include the sections that are not accurately snapped. My output field has 3 sections in some and 2 in others...etc. For what I'm doing I don't need to be so accurate that I need to go snap hundreds of features perfectly. There has to be a way to say... create a field and any section that you over lap at all, throw those sections into this field. It all of the shapes are more or less similar, such that centroids of the sections would always be covered when you consider it to overlap, extract the centroids of the sections and then do the Spatial Join to that with the multi-section polygons. Use the Feature to Points tool to get the centroids.
... View more
06-18-2013
02:18 PM
|
0
|
0
|
1320
|
|
POST
|
Thanks for the answer, Richard. But that 10 points were generated as a result of spatial join. So basically 845219448 hit 10 polygons and generated another 9 points. So I think there is another problem here. Thanks, You have not shown enough information. I cannot see the column headings in the picture of the table to know what the -1 value represents. I don't have a picture of your point / polygon example. You haven't shown a screenshot of the Spatial Join settings. A screen shot of the identify tool clicking on the polygons in about the same location would also be nice. I believe there is something wrong with the data or the tool configuration rather than something wrong with the tool in and of itself.
... View more
06-18-2013
02:13 PM
|
0
|
0
|
2132
|
|
POST
|
Oh! Sorry! i forgot to attach the file! Here i have attached the word file which have the details of the problem. Please find the attachment. However thanks for the reply. Now my answer is definitely use Network Analyst. This is exactly the problem is it designed to solve. It can trace distances around a point for a given distance along the roadway network for sure. There is no other tool in ArcGIS that will do that except Network Analyst. It is just the market area example shown in the link using a shorter distance. So follow the link in my first post and give me the point I deserve.
... View more
06-16-2013
07:16 PM
|
0
|
0
|
1479
|
|
POST
|
Hello everyone, I am having trouble spatially joining multipart polygons with points. The most interesting part is that there are polygons, whose attributes are joined, while for other polygons the attributes show null values. For example, in the attached image point 845219448 has intersected 10 polygons and shows null, while 845960850 intersected 4 and has all attributes of polygons in place. Any ideas or recommendations? Thanks, Hayk [ATTACH=CONFIG]25294[/ATTACH] Without seeing the position of the points that are not matching relative the polygon I cannot verify that there is anything wrong with the result. It may make perfect sense if I could see the original data, but without that I can't tell you what is going on. It actually appears that your points are multi-points with 10 locations that did not hit any polygon, but were kept in the output due to your checking the keep all target features option. The -1 in the first column almost certainly means no polygon was hit by the point and that the records are only there because there were 10 instances of that point object (a multi-point).
... View more
06-16-2013
12:54 PM
|
0
|
0
|
2132
|
|
POST
|
I have faced a problem while preparing my thesis. I am stuck in that problem and cant solve this 😞 . Please anybody can solve the problem identifying the GIS tools/commands?? Details of the problem is elaborated in the word file in the attachment. There are also 2 shape files in the attachment for your convenience. You can also contact with me directly at: [email protected] Thanks in advance 🙂 Best Regards, Md. Nazmul Ahsan I didn't see a word file in the attachment, but the tool set you almost certainly need to use is the Network Analyst extension. Start with the help What is the ArcGIS Network Analyst extension? and follow the other help links to the left to find a solution that fits your problem. Once you have identified the basic function that most closely fits your specific problem you can get more help here to modify it to your specific needs.
... View more
06-16-2013
03:20 AM
|
0
|
0
|
1479
|
|
POST
|
Here are a few suggestions, which I found simply by searching the help for side of line. About making a parallel copy of a line Buffer - See the options for buffering one side of the line. Make Route Event Layer (Linear Referencing) - See the offset_field and offset_direction field options So basically create a parallel line or buffer on a known side of the line a short distance from the shoreline and use that to select the polygon features on a given side. If you use the buffer option make it slightly larger than you need and then select by location with a slightly negative buffer.
... View more
06-14-2013
10:54 PM
|
1
|
0
|
1642
|
|
POST
|
How do I modify the Python code so that it returns the angle in a different projection? I want to use the code in the Field Calculator in ArcMap. My data is in BC Albers and I want to return the angle in UTM Zone 11N. You hack it. Make sure each line has a unique ID and Project the lines to UTM Zone 11N. Do the calculation above. Join to the original lines and calc the result over. No one has shown a way to use the Field Calculator to do on the fly projections that I have seen. Easy enough to build a ModelBuilder model to do this with an in memory output of the projection step.
... View more
06-13-2013
02:10 PM
|
0
|
0
|
16538
|
|
POST
|
Ok.. this may sound like a simple one, but i am a bit flummoxed... I am using the New Mexico BLM FGDB PLSS grid and points. if someone can either guide me along with or help me make a new feature class Ill be highly appreciative. What needs to be done is to remove all of the Quarter quad points and leave only the section points in a query. The problem is that the data table does not have a deliniator for such. So, is there a way to grab the points that ONLY intersect the corners of the Sections and NOT the Quarter Sections? Basically, wherever two lines intersect, I can grab that point. Not the points ALONG the line? The blue points are my target, but ONLY those that are intersected by TWO lines, not one. [ATTACH=CONFIG]25224[/ATTACH] Assuming the lines are unbroken (except where they intersect), you could use a Spatial Join with the points as the primary and the lines as the secondary. You could use the One to One option and set one of the fields to create a comma separated list by accesssing its properties, making sure it is a text field with enough characters and using the join option. If at least one comma occurs in that field on a point after the join, more than one line hit that point.
... View more
06-12-2013
11:02 AM
|
0
|
0
|
1020
|
|
POST
|
If I understand correctly, you want to SUM the field MarketShare, grouped by some field (what is the Block Group?). Two ideas: 1.) This is commonly done with the Summary Statistics tool (statistic=SUM, case_field=the Block Group field). Then, join (Add Join or Join Field) the result to the original table. Calculate the value into SUM_MarketShare. This can be done with Python or tools. 2.) Use cursors (SearchCursor and UpdateCursor) to sort, then loop through adding, then loop through updating, your data. This is Python only. Not sure which takes longer to run. If you're doing this once, I'd use the tools. If not, spend time figuring out the cursors. Paired cursors in any form always take longer than Summary Statistics and Field Calculator in my experience. Those two tools are far more optimized than the Python or ArcObjects cursors.
... View more
06-11-2013
03:20 PM
|
0
|
0
|
1224
|