Select to view content in your preferred language

"Have their center in" equivalent in ArcGIS API for Python

470
3
Jump to solution
3 weeks ago
Labels (1)
geo_sunriver
Occasional Contributor

Is there an equivalent method in the Geometry class in the ArcGIS API for Python to the "Have their center in" operation that is used selecting by location in ArcGIS Pro?

I'm trying to create a script in an AGOL Notebook that will query taxlots with their centers inside an unincorporated communities polygon.

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

it isn't in your extensive list, not online, so your plan of course would be to use

true_centroid (a true centroid if it is within or on the feature) since they also lack a labelPoint method

This would only be of concern if you have extremely concave polygons


... sort of retired...

View solution in original post

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

it isn't in your extensive list, not online, so your plan of course would be to use

true_centroid (a true centroid if it is within or on the feature) since they also lack a labelPoint method

This would only be of concern if you have extremely concave polygons


... sort of retired...
0 Kudos
geo_sunriver
Occasional Contributor

Thanks Dan! I'll continue forward with your advice. I'll post my solution once I complete it...

0 Kudos
geo_sunriver
Occasional Contributor

The methods below worked great.

dc_taxlots_sdf["CENTROIDS"] = dc_taxlots_sdf["SHAPE"].apply(lambda g: g.true_centroid)
dc_taxlots_sdf["SUNRIVER_TAXLOTS"] = dc_taxlots_sdf["CENTROIDS"].apply(lambda x: x.within(sb_geom_3857))

0 Kudos