ArcGIS API for javascript - how to get records count of zipped shapefile

821
3
Jump to solution
08-26-2020 05:56 AM
MichaelLev
Occasional Contributor III

ESRI example code in Create a FeatureLayer from a shapefile adds zipped shapefile into map.

This code uses ArcGIS REST API Generate to create the feature collection, but it is limited and can't create if total recors number is greater than 4000.

So, I want to analyze the zipped shapefile prior to generating features using Generate operation, in order to know the number of records, either total, or better - per layer.

 

My questios are:

  1. How can I add in this code a query to only get the total number of records (in the input zipped shapefile (in order to know apriory if it is greater than 4000)?
  2. How can I add in this code a query to get the total number of records per layer (I know the layer names, but maybe I could get the number of records per layer also without knowing apriory the layer names)?

 

I'll appreciate help,

Michael

0 Kudos
1 Solution

Accepted Solutions
MichaelLev
Occasional Contributor III

So there is no convenient way to get total records count of zipped shapefile before passing it to arcgis rest ap generate".

So I always pass the zip to "generate", and I'm using "generate" returned error message to inform the user that this zip has more than 4000 records.

Michael

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Michael,

  My suggestion is to start looking for a JS library for shapefiles. I know there where a couple of them years ago. Using one of them clientside you can read and create a featurelayer clientside and get past your feature limit issue. But this is a not something others will be able to provide help with as I have seen little to no discussion of this on esri forums for the last 10 or more years.

0 Kudos
HarishPalaniappan
New Contributor III

HiMichael Lev‌,

To process a zip file or uploaded file you will need to work with the server-side. Javascript will only be able to process if the server-side responds with data. JS libraries that can process zip files or uploaded files are executed on server usually as node libraries.

 

So this is not a client-side javascript question, as that technology is restricted for security reasons by browsers in reading files from file system.

 

IF for your scenario Generate returns a response, only that you cannot place the feature entirely as a layer – then you may be able to read and extract information from the response object to a generate call and take necessary actions.

Note here, you are asking ArcGIS REST API running on server (probably using python with pyshp(https://pypi.org/project/pyshp/) like libraries to process shape) to process the file.

Thank You!

MichaelLev
Occasional Contributor III

So there is no convenient way to get total records count of zipped shapefile before passing it to arcgis rest ap generate".

So I always pass the zip to "generate", and I'm using "generate" returned error message to inform the user that this zip has more than 4000 records.

Michael

0 Kudos