Help with updating an old arcgisscripting file to arcpy.

528
11
11-08-2017 08:17 AM
WhitneyNewcomb
Occasional Contributor

Hi everyone.

I was put to the task of comparing some data and found the perfect script already created that did pretty much everything I need. HOWEVER it's was written originally for ArcMap9.3 and used the arcgisscripting python library. 

I've just about used the extent of my python knowledge to convert it to arcpy. 

I was able to use this script to compare point shapefiles, but now I need it to work on polygons as well. And I keep getting an error on line 69. I believe that it is having a problem with the differences to the describe function between the two libraries. 

I'm totally stuck on this and really need this script to work. I feel a little bad just dumping my script here and hoping someone can fix/figure out what's wrong with the script.

((I also realize that within the script I have not updated everything to be the quickest (i.e. arcpy.SearchCursor changed to arcpy.da.SearchCursor) This is because I tried and failed to do so..))

0 Kudos
11 Replies
JoshuaBixby
MVP Esteemed Contributor

Instead of trying to migrate older code, sometimes it is easier to propose the problem to GeoNet users and see what solutions they come up with.  What does your data look like?  What are you trying to do to it?

WhitneyNewcomb
Occasional Contributor

Thank you for your advice. I've posted the problem to GeoNet/Analysis: https://community.esri.com/thread/204867-help-with-updating-an-old-arcgisscripting-file-to-arcpy 

And thank you kindly for your time Joshua.

0 Kudos
curtvprice
MVP Esteemed Contributor

Whitney, just a tip for the future, please don't make another thread, instead, just cross-reference the thread like this to Analysis‌ - this makes this thread show up in both places. (And change your thread title if the subject of the thread changes this dramatically, since you started the thread you can do this.)

The cross-reference link btw just pointed back here; here's the correct one:

How to determine the changes between two polygon shapefiles of similar data 

WhitneyNewcomb
Occasional Contributor

Thank you Curtis, I greatly appreciate your tip. 

This is really my first time actively using a forum and I appreciate any knowledge drops to help me get my help faster.

0 Kudos
RandyBurton
MVP Regular Contributor

Does Feature Compare do some of what you want?

0 Kudos
RebeccaStrauch__GISP
MVP Esteemed Contributor

I converted your discussion to a question.  Questions tend to get more views and responces. For some other tips on posting, check out https://community.esri.com/community/help-and-feedback/blog/2016/08/15/community-news-and-tips-how-t...

i agree with Joshua that sometimes it is easier to start from scratch, but of course that depends on the complexity. (Sorry,  I can't offer anything advice since I'm not able to open the attachment for a few days. )

curtvprice
MVP Esteemed Contributor

Why re-code it all? arcgisscripting is still there -- the old script may yet work at 10.x. I have many scripts that run unmodified in all versions after 9.3 (and Pro).

RandyBurton
MVP Regular Contributor

The "AreaFieldName" is a property for a Geodatabase Feature Class.  You are comparing shape files (.shp) which do not have this property - and thus the error at line 69.

# String representing original feature class path
featureClassB = "J:/GIS/GIS_PROJ/parcels/Comparisons/2017_02-03/Data/03_DOIT_SOI.shp"

dscB = arcpy.Describe(featureClassB)
shapeType = str(dscB.ShapeType)

if shapeType == "Polygon":
    areaField = dscB.AreaFieldName  # line 69
    attributesToCompare.append(areaField)

# AttributeError: DescribeData: Method AreaFieldName does not exist‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

You may wish to post your code in a code block (see Code Formatting... the basics) to get more comments.  Also, as Joshua Bixby‌ suggested, you may want to provide a short description of what you are trying to accomplish.

If I understand your code, you are trying to compare two shape files and write the differences to a third shape file.

WhitneyNewcomb
Occasional Contributor

Hi Randy,

I apologize for my sparse post. 

I didn't put my code in a code block because I didn't know where to focus and instead wanted to just post all of it which I felt wouldn't work well with a code block. Is this an incorrect assumption? 

Do you have any solutions for the AreaFieldName? I realized that was one of the problems with the script and couldn't find a fix.

0 Kudos