Querying a feature layer with a large amount of points

476
9
Jump to solution
12-14-2021 09:08 AM
Barty
by
New Contributor II

Greetings! Working in ArcGIS JS API 4.22:

I am trying to query a feature layer (polygons) with a large amount of points (~1000) in order to find which polygons the points intersect with (by name only, no need for geometries. Doing this with a loop for each point individually is extremely slow and errors out. I've tried condensing the points to a multipoint geometry in hopes of speeding the process to no avail. Is there a solution to this that I am just overlooking?

const layer = new FeatureLayer({
            url: "https://arcgis-server.lsa.umich.edu/arcgis/rest/services/IFR/glahf_classification_poly/MapServer/0",
            outFields: ["AEU_Code"],
        });
//gets a server error at about 250 points
var multipoint = new Multipoint({
            points: [
                [-86, 45],
                [-85, 47],
                [-84, 49]
            ]
        });

        const query = new Query();
        query.geometry = multipoint;
        query.outSpatialReference = { wkid: 102100 };
        query.returnGeometry = false;
        query.outFields = ["AEU_Code"];

        layer.queryFeatures(query).then(function (results) {
            console.log(results.features);  // prints the array of features to the console
        });

Thanks!

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
BlakeTerhune
MVP Regular Contributor

See if you can do this querying on the client side rather than calling on the server.

Turbo charge your web apps with client-side queries (esri.com)

View solution in original post

9 Replies
RichardMoussopo
Occasional Contributor II

Hi Barty, could you please share your code so we can better understand what you are trying to achieve? 

0 Kudos
Barty
by
New Contributor II

Yep - edited post with code!

0 Kudos
Barty
by
New Contributor II

that process does work for the display which is great, however, featureFilters won't return any of the attribute data which I need in order to determine the names of the polygons that intersect the points.

0 Kudos
BlakeTerhune
MVP Regular Contributor

See if you can do this querying on the client side rather than calling on the server.

Turbo charge your web apps with client-side queries (esri.com)

Barty
by
New Contributor II

This works great, thanks! Is it possible to return the attributes from each of the geometries queried? At the moment, I can only return unique values. For example, I'm querying 500 points on the polygon layer (contains 77 OIDs), and the query only returns the unique polygons that intersect with the points. But rather, I would like to return the value of the intersecting polygon for each point (e.g., generating a list of 500 polygon OIDs).

0 Kudos
BlakeTerhune
MVP Regular Contributor

I have to admit, I haven't had a chance to test out client side processing but it seems like you should have access to all the attributes like normal are you specifying the attributes you want in the query outFields parameter?

0 Kudos
Barty
by
New Contributor II

I did specify the outFields param, but it just is only returning the value for only one instance of the point layer intersecting a polygon (featureLayerView). So, even if 50 points are intersecting one of the polygons, it only returns the outField value once per feature (when in reality I want it to return it 50 times).

0 Kudos
sidrakiyani
New Contributor

So you have two separate layers in this situation right? A polygon layer and a points layer? Use the pairwise intersect tool, it should result in an feature class where the attribute table has all of your points along with the fields from the polygon layer they intersect with. 1000 points really isn't that many, this should not be very computationally intense.

If this is not what you're doing can you be more descriptive with the data you have and what you are trying to accomplish?

The other way I interpret the question is that you already have the feature layer I described, but are trying to query it in some way. If this is the case can you elaborate on what you are trying to glean from the data? I don't understand why you would need to query each point individually.

0 Kudos