PointGeometry to FeatureLayer work in python window, not in Tool (python)

4558
4
Jump to solution
04-05-2016 03:20 PM
RebeccaStrauch__GISP
MVP Emeritus

Similar issue to

MakeFeatureLayer_management does not add layer to TOC?    (which I even had answer to) and

https://community.esri.com/message/416673#comment-416673

I have tried many incarnations of the Make Feature Layer options from those two threads.  My tool works fine if I copy/past in the ArcMap python window, but when I run from the tool, my final result is an empty table (but with all the fields I added). No Error.    I also successfully use the MakeFeatureLayer command in this same tools, but those are coming from feature classes, not PointGeometry.

When I traced it backwards, with many print statements,  the difference seems to be that my FeatureLayer created from my PointGeometry is empty when running from the tool...but a count of one (as it should be) when running in the python window.

#  all the necessary variables are valid
ptGeom = arcpy.PointGeometry(arcpy.Point(ptX, ptY, 0, 0, ptid))
arcpy.MakeFeatureLayer_management(ptGeom, "origPtFL")  
resultCountPT = int(arcpy.GetCount_management("origPtFL").getOutput(0))
print("\n {}: {} recs".format("origPtFL", resultCountPT))

This is a snippet from a longer tool that wouldn't be practical to include, but all the variables, etcs are assigned. but since the count for "origPtFL" is now zerow, when I get down to

arcpy.SelectLayerByLocation_management(tmpContourFL, nearType, "origPtFL", nearDist)"  

the results perpetual zero records.

BTW - the ptX, ptY values are coming thru fields in a table in a searchcursor.   I know this isn't enough to be able to recreate the process, and I don't expect anyone to create a tool just to test this, but hoping someone else has a workable solution to this.  BTW - I have put in a support ticket, but haven't heard anything from them yet.

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

PointGeometry—Help | ArcGIS for Desktop

to Copy Features—Help | ArcGIS for Desktop

because Make Feature Layer—Help | ArcGIS for Desktop

requires a featureclass or feature layer... and I don't think you have one

but I haven't worked with those in some time.  I can give you a solution using numpy if you just want to convert a list of points to a featureclass, but have a look at that process manually first.

View solution in original post

4 Replies
DanPatterson_Retired
MVP Emeritus

PointGeometry—Help | ArcGIS for Desktop

to Copy Features—Help | ArcGIS for Desktop

because Make Feature Layer—Help | ArcGIS for Desktop

requires a featureclass or feature layer... and I don't think you have one

but I haven't worked with those in some time.  I can give you a solution using numpy if you just want to convert a list of points to a featureclass, but have a look at that process manually first.

RebeccaStrauch__GISP
MVP Emeritus

Thanks Dan.

What I was bringing in as the in_feature was the PointGeometry, and the need was to create a feature layer.  I hadn't thought about trying CopyFeature_management from the PointGeometry to a tmp file.  But that worked. yea!

# ...a lot of pre-processing
# create ptGeom from field value in table, from search cursor
ptGeom = arcpy.PointGeometry(arcpy.Point(ptX, ptY, 0, 0, ptid))
# copy the ptGeom to a temp file
arcpy.CopyFeatures_management(ptGeom, "tmpPtGeom")
# use the temp file to make the FL for the process to continue.
arcpy.MakeFeatureLayer_management("tmpPtGeom", "origPtFL")
# ......lots more processing

But it is still interesting that the MakeFeatureLayer_management would also accept the PointGeometry as input when in in the python window (in ArcMap) but not as a tool (also run in ArcMap);  One of those little inconsistencies.

Once again, Geonet solved my issues before even getting an incident assigned in support (not hassling support, I actually typically get good service).  What takes the longs here is trying to write it up in a way that doesn't bog the question down....quick screen shared provides much more info than can ever be typed here.  I will still follow thru with them however, to figure out if the python-window vs tool is a bug or an inconsistency that can be corrected.  At least now I can point them to this thread! 

DanPatterson_Retired
MVP Emeritus

Total side note...

One thing that I have used in teaching is video... I use a video production program called Camtasia which allows you to record both audio and video on screen (simple explanation).  A cheap alternative is Snagit from the same family, which you can grab the video at least (no audio).  The program is cheap (Camtasia more expensive) and Snagit is the goto screen grab program if you also want to get quick screen grabs with annotation etc.   www.techsmith.com  

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

I use to have  SnagIt and used it quite a bit for training others too,, providing live audio but canned video.  I haven't keep up maintenance so it is long gone.  I use Jing on occasion for quick 5-min videos, if needed.  Also a techsmith product.

0 Kudos