Select to view content in your preferred language

Geometry is not a Function?

879
3
Jump to solution
10-19-2022 02:27 PM
DougBrowning
MVP Esteemed Contributor

When building a FeatureSet in the data expression I am trying to use geometry but it says that Geometry is not a valid function for some reason? Like umm its right there dude.

DougBrowning_0-1666213969213.png

Here is the code.  I found a post showing this but so weird on the function.

var Dict = {  
    'fields': [{ 'name': 'Project', 'type': 'esriFieldTypeString' },
            { 'name': 'PointID', 'type': 'esriFieldTypeString' },
            { 'name': 'StreamName', 'type': 'esriFieldTypeString' },
            { 'name': 'PointType', 'type': 'esriFieldTypeString' },
            { 'name': 'OrderCode', 'type': 'esriFieldTypeString' },
            { 'name': 'EvalStatus', 'type': 'esriFieldTypeString' },
            { 'name': 'Trip', 'type': 'esriFieldTypeString' },
            { 'name': 'CountUnresolved', 'type': 'esriFieldTypeString' }],  
    'geometryType': 'esriGeometryPoint',   
    'features': []};  
var index = 0;

var sql2 = "ResponseType = 'Log an issue' And (Resolved IS NULL Or Resolved = 'No')"
var tbl2All = Filter(FeatureSetByPortalItem(Portal(p),'713e3aaef9674e3493a64347d333b618',10,['PointID','ResponseType','Resolved'],geometry = false), sql2);
var tbl2text = ""
for (var i in tbl2All) {
    tbl2text = tbl2text + ", " + i.PointID
}

var isUnresolved = ''
//Cycles through each record in the input table
for (var f in tbl) {
    if (Find(f.PointID, tbl2text) > 0) {
        isUnresolved = 'Yes'
    }
    else {
	isUnresolved = 'No'
    }
     //This section writes values from tbl into output table and then fills the variable fields
    Dict.features[index] = {
        'attributes': {   
            'Project': f.Project,
            'PointID': f.PointID,
            'StreamName': f.StreamName,
            'PointType': f.PointType,
            'OrderCode': f.OrderCode,
            'EvalStatus': f.EvalStatus,
            'Trip': f.Trip,
            'CountUnresolved': isUnresolved
        },
	'geometry': Geometry(f)};   
    ++index;
    
}
return FeatureSet(Text(Dict));

thanks for any info

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

It's in line 15. The parameter is includeGeometry, and you don't actually need to explicitly reference it, you can just put "false".

The problem you're seeing is that in line 15, you're actually setting geometry to false. So later in your expression when you try using Geometry(f), that's equivalent to typing "false(f)", which won't do anything. So you get that "not a function" error because you've overwritten the function with a boolean.

Adjust line 15 and see how it runs.

- Josh Carlson
Kendall County GIS

View solution in original post

3 Replies
jcarlson
MVP Esteemed Contributor

It's in line 15. The parameter is includeGeometry, and you don't actually need to explicitly reference it, you can just put "false".

The problem you're seeing is that in line 15, you're actually setting geometry to false. So later in your expression when you try using Geometry(f), that's equivalent to typing "false(f)", which won't do anything. So you get that "not a function" error because you've overwritten the function with a boolean.

Adjust line 15 and see how it runs.

- Josh Carlson
Kendall County GIS
DougBrowning
MVP Esteemed Contributor

Sorry it actually cut my code off.  The top two lines were calling a diff layer that does have geometry turned on.

var p = 'https://arcgis.com/';
var tbl = FeatureSetByPortalItem(Portal(p),'713e3aaef9674e3493a64347d333b618',0,['Project','PointID','StreamName','PointType','OrderCode','EvalStatus','Trip'],true);

But you are correct that it is includeGeometry.  I got that part from some other code that was posted and I never double checked that.  How weird it never once complained on it.

The complete code now does work.  thanks!

BUT what I wonder is how does this work then - I pass to intersects with no geo and it works fine.

var plots = Intersects($feature,FeatureSetByName($map,"I_Indicators", ["PctFinesLessThan2mm"], false));
if (Count(plots) == 0) {
return "no plots in HUC"
}
else {
return Average(plots, "PctFinesLessThan2mm")
}

Is this the other issue we were talking about in the other post that it makes a second call to the layer?  Like you were showing.

I have code that does one FeatureSet call then it loops a filter.  But not it looks like it does another call for each filter which is super strange.

0 Kudos
DougBrowning
MVP Esteemed Contributor

I looked back at my code and I just have false in 99% of my calls this just happened to be code I copied from a post that was wrong I guess.

thanks again.

0 Kudos