Spatial Join. Is possible matching output fields ?

1314
20
Jump to solution
05-09-2022 03:41 AM
PasqualeLanera
New Contributor III

Hello I have ArcGIS 10.3.

I have 2 FC in a GDB, one is a polygon or regular cell of a grid (Grid), the other one is a point feature (PointHabitat). A poygon can contain one or more point. In Point Feature there are two field: AREA, a number that rapresent the surface, and HABITAT, the name of the habitat.

 

Case 3 point features in a cell 

If I do a Spatial Join between Target Feature (Grid) and Join Feature PointHabitat, and choose as Field of Join Features the field AREA Maximum, the output cell have the Field AREA with the value maximum between the 3 point; the Field HABITAT contains the first name of the habitats in alfabetical order.

Instead I want that the output of the Spatial Join will be a cell with the maximum value of the field AREA and for the field HABITAT the name of the habitat of the point feature that has the maximum Area. 

I hope it is clear. I'll prove all night but I don't found the solution. Maybe it's need a python script ?     

Help me, thanks !  

0 Kudos
1 Solution

Accepted Solutions
PasqualeLanera
New Contributor III

Thanks a lot.

I have tested you model also with a polygon without point: no errrors, no fail.

So too work and process to create a point feature with only a point in a polygon: the point with max value and his habitat with ArcGIS 10.3 !!!

Are with ArcGIS PRO or with another platform more easy ?

Thanks very much for the support and excuse me for the time that you spent for me.

Good Bye 

 

View solution in original post

0 Kudos
20 Replies
KimGarbade
Occasional Contributor III

I don't have 10.3 to test against, but if you spatial join the points with the polygons to move the cell IDs to the points first (points are the target). Then use a database of query to select the point within each cell that has the highest value for Area (Max query). Then export those points to a new feature class, and then run the spatial join with the GridCells as the target against just the Max value points. This might work without python or a model builder model  

0 Kudos
PasqualeLanera
New Contributor III

Thanks Kim

The polygon feature class (FC) "Grid" with over 100,000 cells (each cell is 1 km square) is the target Feature and the point FC "PointHabitats" is the Join Features. Each cell can intersect one or more points. 

I don't undestand how select in a new layer within a cell the only point with AREA = max and the corrispondence value of HABITAT. I have to use the command SELECT in ArcGIS ? Or I have to use an external database ?

I prove with the tool SELECT but I don't know the exact SQL statement to write. With: "Target.ID = Target.ID AND AREA is max" does not run. The points within the same cell have the same Target.ID

  

0 Kudos
KimGarbade
Occasional Contributor III

Sorry, just getting back....Quick questions. Is your data in a file geodatabase or an Enterprise GDB (I.E. SQL Server, Post GRE, Oracle, etc.)?

0 Kudos
PasqualeLanera
New Contributor III

In a File Geodatabase.

0 Kudos
KimGarbade
Occasional Contributor III

Hmmmm.... finding Max in a file geodatabase seems harder than it should be.  Database views are not supported in File GDBs and subqueries on file and personal geodatabases don't seem to support GROUP BY and Summarize cannot tell you which habitat has the Max Area.  I am seeing your problem.  Looks like Model Builder might be the answer if this is a process you have to repeat frequently.  Is this a one time process or will you have to repeat it often?

0 Kudos
PasqualeLanera
New Contributor III

This is a one time process or I will have to repeat some time. But it is very strange that with the Spatial Join I don't solve the problem. 

0 Kudos
KimGarbade
Occasional Contributor III

I have a model that will create a feature class containing one point for each polygon containing just the Maximum Area and the habitat for that area.  You should then be able to join this to your polygons using the polygons unique ID which is also an attribute of each point. 

Please keep in mind I tested this in ArcMap 10.8.1 so not 10.3

My test data has different field names and only contains 2 polygons and 13 points.  Here are snapshot of the starting tables.

MaxTestPoints:

KimGarbade_0-1652204893461.png

PolygonTest

KimGarbade_1-1652204953204.png

Using these two I did a spatial joint using points as the target to move the MyTestValue into the points.  The result I called MaxTestPoints_SpatialJoin2

KimGarbade_2-1652205072030.png

Then I created a model that pulls just one point for each polygon from this feature class and appends it into a new feature class I called "MaxTestPointsFinal".  Each point in MaxTestPointsFinal is the point representing the Maximum value for a MyTestValue polygon.... confusing I know, but when you see the output below I think it will make more sense.

KimGarbade_3-1652205627194.png

The model is pretty simple.  The top image is just the model.  The images that follow that show important details about the steps:

KimGarbade_4-1652205691053.png

Iterator on polygon layer, value is the unique ID of the polygon

KimGarbade_5-1652205740453.png

Select by attribute (gets all records that share max value)

KimGarbade_6-1652205831964.png

Select by Attribute (with Remove_From_Selection option) to exclude all points that do not fall within the polygon being considered.

KimGarbade_7-1652205895318.png

The append step just appends the identified point to a feature class of all Max value points.

There might be a MUCH easier way, but given the constraints of file GDB in ArcMap 10.3 I sure couldn't think of it.

Hope this helps.

K

0 Kudos
PasqualeLanera
New Contributor III

Thanks Kim,

I an not a expert with Models so it is a little difficult. I have some requests.

1) Why you add the field MyTasteValue in PolygonTest ? 

2) MyTasteValue  is to identify each polygon, so if there is 4 polygon I will have also TestPoly3 and TestPoly4 ?

3) Why don't use the field ObjectID instead of MyTasteValue 

4) Could you add the figure of the Apppend Tool ?

5) Why there is "(2)" or "(3)" after the name of an object in the green box

Could you send me yours GDB or shapefile of the example and the model saved like a tool ?

My email is planera63@gmail.com

 

Thanks, thanks, thanks 

 

0 Kudos
PasqualeLanera
New Contributor III

Hello Kim.

Excuse me with wich ESRI platform the solution of my problem will be more easy ?

My polygonal and point feature have over 500,000 records. Do your solution run also if a polygon is empty or if has only one point within ?  

0 Kudos