Counting number of grid cells in polygon using ArcGIS Desktop?

Counting number of grid cells in polygon using ArcGIS Desktop?

Is there a way ArcGIS could count the number of 15 seconds interval grid cells within a polygon after digitizing that polygon?

This should appear in a field in the attribute table.

Yes - to do this I would:

  • Use the extent of the polygon just digitized to Create [a] Fishnet of the same size
  • Use SelectLayerByLocation on the fishnet just created to select those that overlap the polygon geometry that you digitized
  • Use GetCount to count how many of the fishnet cells overlap with the polygon geometry
  • Use an update cursor or CalculateField to write that number into the field

I would do the above using ArcPy (perhaps as a Python AddIn), but it should not be beyond ModelBuilder either.

How to get count of non-NA raster cells within polygon

I've been running into all sorts of issues using ArcGIS ZonalStats and thought R could be a great way. Saying that I'm fairly new to R, but got a coding background. The situation is that I have several rasters and a polygon shape file with many features of different sizes (though all features are bigger than a raster cell and the polygon features are aligned to the raster). I've figured out how to get the mean value for each polygon feature using the raster library with extract:

The issue I have is that I also need an area based ratio between the area of the polygon and all non NA cells in the same polygon. I know what the cell size of the raster is and I can get the area for each polygon, but the missing link is the count of all non-NA cells in each feature. I managed to get the cell number of all the cells in the polygon [email protected]$Cnumb1000 <- cellFromPolygon(ras, proxNA) and I'm sure there is a way to get the actual value of the raster cell, which then requires a loop to get the number of all non-NA cells combined with a count, etc. BUT, I'm sure there is a much better and quicker way to do that! If any of you has an idea or can point me in the right direction, I would be very grateful!

You can think of Summarize Within as taking two layers, the input polygons and the input summary features, and stacking them on top of each other. After stacking these layers, you peer down through the stack and count the number input summary features that fall within the input polygons. Not only can you count the number of features, you can calculate simple statistics about the attributes of the input summary features, such as sum, mean, minimum, maximum, and so on.

The Summarize Within and Summarize Nearby tools are conceptually the same. With the Summarize Within tool you can summarize features within existing polygons, whereas with the Summarize Nearby tool you can generate areas around points, lines, or polygons, and summarize features within those derived areas.

You can create groups by specifying a group field from the input points. For example, if you are summarizing crimes within neighborhood boundaries, you may have an attribute Crime_type with five different crime types. Each unique crime type forms a group, and the statistics you choose will be calculated for each unique value of Crime_type .


Input raster representing the true or false result of the desired condition.

It can be of integer or floating point type.

The input whose values will be used as the output cell values if the condition is true.

It can be an integer or a floating point raster, or a constant value.

The input whose values will be used as the output cell values if the condition is false.

It can be an integer or a floating point raster, or a constant value.

A logical expression that determines which of the input cells are to be true or false.

The Where clause follows the general form of an SQL expression. It can be entered directly, for example, VALUE > 100 , if you click the Edit SQL mode button . If in the Edit Clause Mode , you can begin constructing the expression by clicking on the Add Clause Mode button.

Return Value

Input raster representing the true or false result of the desired condition.

It can be of integer or floating point type.

The input whose values will be used as the output cell values if the condition is true.

It can be an integer or a floating point raster, or a constant value.

The input whose values will be used as the output cell values if the condition is false.

It can be an integer or a floating point raster, or a constant value.

A logical expression that determines which of the input cells are to be true or false.

The expression follows the general form of an SQL expression. An example of a where_clause is "VALUE > 100" .

Return Value

Code sample

In this example, the original value will be retained in the output when the input conditional raster value is greater than2000 the value will be NoData when it is not.

In this example, the original value will be retained in the output except NoData, which will be replaced with 0.

In this example, two different rasters are used to create the conditional raster.

In this example, multiple Con tools are used inside a Con .

In this example, when the value of the input conditional raster is greater than or equal to 1500, the output value will be 1 when it is less than 1500, the output value will be 0.


The input utility raster is often the output from a suitability model. A suitability model identifies how suitable each location is based on the desired attributes actually found at the location. Suitability modeling is one of the most common applications for Spatial Analyst . For additional information on suitability modeling, see Understanding overlay analysis.

The higher the input values in the utility raster, the greater the utility.

The settings for Minimum distance between regions and Maximum distance between regions take precedent over Total area . For example, if five regions are desired, but due to the specified minimum and maximum distances only four regions can be located, then only four regions will be selected. As a result, the Total area will not be met. When possible, a warning will be issued, but this is not the case for all situations.

The parameterized region-growing (PRG) algorithm grows based on utility values within the input raster—the higher value cells are more preferred in the growth. The Evaluation method determines which of the candidate regions are selected it has no influence on the region growth.

The Locate Regions tool is very computationally intensive. There are steps you can take with how you set up your input data and the settings of certain parameters to influence this.

To speed up processing, locations that should not be considered in the selection processing should be set to NoData as a preprocessing step or eliminated using the Mask. No regions will grow from these excluded locations or be allocated in the selection process. Unlike Input raster or feature of existing regions , excluded areas have no effect on the Minimum distance between regions and Maximum distance between regions in the parameterized region-growing (PRG) algorithm or in the selection of the candidate regions.

The options that are selected for the Number of seeds to grow from and Resolution of the growth parameters can greatly affect the processing time.

Selecting the Small and Low options for these parameters, respectively, will provide the best performance. Selecting Small , Medium , or Large for Number of seeds to grow from and Low , Medium , or High for Resolution of the growth produces the most reliable results within a reasonable amount of time.

If the Number of seeds to grow from or the Resolution of the growth are specified to any option other than Maximum , data will be lost due to not growing regions from every cell and resampling to a coarser resolution. However, depending on the size of the input raster, the Maximum option may be very slow therefore, the other options may be more practical.

Depending on the size of the input raster, selecting Maximum for Number of seeds to grow from or Resolution of the growth can take a long time. The Locate Regions algorithm implements a two-step process. It first grows candidate regions and it then selects the best regions from the candidate regions. The growing of the regions for large input rasters can take a long time. However, in the selecting regions step, a distance matrix is first loaded. If the matrix cannot be loaded due to memory limitations, the tool will end processing. If this occurs, either select a smaller number of seeds to grow from or specify a coarser resolution of growth.

The default values for Number of seeds to grow from and Resolution of the growth are dependent on the number of cells in the input raster. The more cells in the input raster, the longer this tool takes to execute. To avoid extremely long execution times, these default values are set accordingly.

When the Number of regions is greater than eight, it is recommended to use the Sequential option for the Region selection method . Using the Combinatorial method with more than eight regions selected may result in slow performance.

Usually, the Number of seeds to grow from value has the greatest impact on the processing speed. The higher the number of seeds to grow from, the longer the tool takes to operate. However, in most cases the results are similar, regardless of the value specified.

The Number of seeds to grow from are distributed within the input raster based on utility values—areas with higher utility values receive more seeds. The Evaluation method has no influence on their distribution.

The Resolution of the growth sets the resolution on which the parameterized region growing will occur. The input raster is resampled to the defined resolution using the bilinear resampling method. Once the regions are selected, before the final output raster is created, the results are resampled to the environment Cell Size using the nearest neighbor resampling method.

A shape adjustment is implemented for the regions at the edge of the input raster. If at least one cell should fall outside the input raster's boundary in order to maintain the shape, the utility of the region will be reduced by 50 percent. Because of this utility reduction, the region is less likely to be selected, but the reduction does not eliminate the region from the selection process.

The area selected can be more than the specified total area if Islands not allowed in regions is checked. To determine if the discrepancy between the selected area and the specified total area is based on the no-island parameter, rerun the tool with this parameter unchecked. Add the number of cells from COUNT in the output raster attribute table from the original run then rerun the tool, multiply the sum of each by the area of a cell, and compare the results to the specified area.

If the Resolution of the growth is specified with any option other than Maximum , through a postprocess, the original utility values for each region can be identified using Zonal Statistics . Enter the output region raster from Locate Regions as the zone raster and the input utility raster as the value raster.

See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

Analyze patterns

These tools help you identify, quantify, and visualize spatial patterns in your data by identifying areas of statistically significant clusters.

This tool creates a density map from point or line features by spreading known quantities of a phenomenon (represented as attributes of the points or lines) across the map. The result is a layer of areas classified from least dense to most dense.

  • Calculate densities of hospitals in a county. The result layer shows areas with high and low accessibility to hospitals, and you can use this information to determine where new hospitals should be built.
  • Identify areas that are at high risk of forest fires based on historical locations of forest fires.
  • Locate communities that are far from major highways to plan where new roads should be constructed.

This tool identifies statistically significant clustering in the spatial pattern of your data.

  • Determine if your points (crime incidents, trees, traffic accidents) are clustered.
  • Discover a statistically significant hot spot (for spending, infant mortality, consistently high test scores).

This tool identifies statistically significant outliers in the spatial pattern of your data.

  • Find anomalous areas in the pattern of your data (crime incidents, trees, traffic accidents).
  • Discover a statistically significant outlier (for spending, infant mortality, consistently high test scores),

This tool finds clusters of point features in surrounding noise based on their spatial distribution.

  • Find clusters of houses infested with pests.
  • Find clusters of crime incidents, such as theft.

This tool allows you to predict values at new locations based on measurements from a collection of points. The tool takes point data with values at each point and returns areas classified by predicted values.

  • Predict pollution levels at locations that don't have air quality management district sensors that measure pollution levels, such as locations with at-risk populations—schools or hospitals, for example.
  • Predict heavy metal concentrations in crops based on samples taken from individual plants.
  • Predict soil nutrient levels (nitrogen, phosphorus, potassium, and so on) and other indicators (such as electrical conductivity) in order to study their relationships to crop yield and prescribe precise amounts of fertilizer for each location in the field.
  • Predict temperatures, rainfall, and associated variables (such as acid rain) and other meteorological applications.

  • Are there anomalous spending patterns in Los Angeles?
  • Where are the sharpest boundaries between affluence and poverty in the study area?
  • In your area, are there retail stores that are struggling with low sales despite being surrounded by high-performing stores?
  • Where are there unexpectedly high rates of diabetes across the study area?
  • Are there counties in the United States with unusually low life expectancy compared to their neighboring counties?

The input features can be points or areas.

The Find outliers of parameter is used to evaluate the spatial arrangement of features. If your features are areas, a field must be chosen. Outliers will be determined using the numbers in the chosen field. Point features can be analyzed using a field or the Point Counts option. If Point Counts is used, the tool will determine if the points themselves are unusually dispersed or clustered, rather than high and low field values.

If points are being analyzed with Point Counts , two additional options will be available. The Count points within parameter allows the points to be aggregated within a Fishnet Grid , Hexagon Grid , or an area layer from the Contents pane, such as counties or ZIP Codes. The Define where points are possible parameter is used to create an area or multiple areas of interest. The three options for this parameter are None , meaning all points are used, an area defined by an area layer from the Contents pane, and areas created using the Draw tool.

Your data can be normalized using the Divide by parameter. The Esri Population data uses GeoEnrichment and requires the use of credits. Another option is to normalize using a field from the input layer (available when the Find outliers of parameter is set to a field, rather than Point Counts ). Values that can be used for normalization include number of households or area.

Esri Population data is not available for the Divide by parameter when your organization has a custom GeoEnrichment service configured.

The statistic used by this tool uses permutations to determine how likely it would be to find the actual spatial distribution of the values that you are analyzing by comparing your values to a set of randomly generated values. Choosing the number of permutations in the Optimize for parameter is a balance between the Precision option and increased processing time (the Speed option). A lower number of permutations can be used when first exploring a problem, but it is a best practice to increase the permutations to the Precision option for final results.

The Options drop-down menu can be used to set a specific Cell Size value or Distance Band value for your analysis.

The output layer includes additional fields containing information such as the Cluster/Outlier Type , the number of neighbors each feature included in their analysis, the Local Moran's I Index , and the Value and Score for each feature. The output layer also contains information about the statistical analysis in the Description section of its Item Details page.

Click Show Credits before you run your analysis to check how many credits will be consumed.

Enable display filters on a layer

You manage display filters from the Display filters tab in the Symbology pane of a layer. You must enable the display filters for them to be respected by the map display. Click the Enable display filters toggle button to turn it on. This activates existing display filters and allows you to author new display filters.

You can disable display filters at any time without losing their definitions. To temporarily suspend the display filters, click the Enable display filters toggle button to turn it off. The scale settings and queries remain intact, but layer drawing does not respect them until the toggle button is switched on again. This way, you can compare the display with and without the filters applied.

The ArcGIS Software

The ArcGIS software that Amherst College provides has made "desktop GIS" a reality.

Geographic Information Systems have been around for more than forty years, but have become increasingly accessible as computing power has increased.

Amherst College has one of the best GIS available, the Arc products from Environmental Systems Research Institute.

Their newest software, , has made GIS significantly easier than it was even a few years ago.

ArcGIS consists of three primary programs:

  • : create, view, and manipulate maps (shown).
  • : view and organize the various pieces of data that go into making a map.
  • : convert data from one format to another and perform many types of geographic analyses.

There are also a large number of extensions, for example for spatial or three-dimensional analysis.

Anyone with a Windows computer can install the free program (available from the Software (K:) drive), allowing them to view "published maps" produced by ArcGIS.

ArcGIS is available on all Windows computers in most campus computer labs, as well as on classroom projection computers.

In particular, there is a GIS computer classroom where faculty members can teach students about GIS or other subjects applying GIS, and give them a chance to work on projects with the latest hardware and software.

Faculty and staff can install ArcGIS on any College-provided Windows computer, from the Software (K:) drive.

Laptop (off-network) installation of ArcGIS requires a hardware key.

Free one-year licenses are also available for students taking GIS-related courses or programs visit this ESRI web site for more information.

Contact Academic Technology Services for more information or assistance.

How To: Tune the multi-level grid spatial index

A spatial index is used to perform fast geographic searches for features in a feature class. ArcSDE uses a multi-level grid spatial index for feature classes in several geometry storage types, including compressed binary (LOB, LONG RAW or BINARY) OGC-WKB, DB2 Spatial Extender and the Spatial Type for Oracle. Tuning the spatial index grid size may improve performance of spatial queries. This article provides some background about the multi-level grid spatial index, and also provides tips about tuning it.

The multi-level grid spatial index defines an imaginary X/Y grid. There may be one, two, or three imaginary grids, also known as grid levels, defined per feature class. Most feature classes need only one grid level, but more levels may be needed if the average sizes of the feature envelopes vary greatly. Each feature is indexed using only one of the grid levels: small features in the first level and larger features in second or third level, if present. ArcSDE places an entry or a row in the spatial index for every instance where a single feature intersects a single cell in the specific grid level used for that feature.

During the primary filter operation of a spatial query, ArcSDE finds the X/Y envelope of the spatial filter shape and determines which spatial index grid cell intersects that envelope. Next, ArcSDE performs a query to return all features whose envelopes also intersect those grid cells. The results of this primary filter operation are the candidate features. Later, secondary filtering reduces the result set to only the candidate features that satisfy the exact conditions of the spatial query, such as 'intersects', 'crosses' or 'within'.

Tuning the spatial index means balancing selectivity of the primary filter operation versus reducing the number of entries in the spatial index. The per feature cost of the primary filter is much lower than the secondary filter, because the secondary filter performs detailed computations while the primary filter is a simple query on the spatial index table. The outcome of specifying smaller grid cell size is usually more entries in the spatial index table and finer selectivity from the primary filter operation. This means that the secondary spatial filter must examine fewer features. However, more spatial index entries also increase the size of the spatial index, thus slowing the primary filter operation and consuming more space in the database.

Fortunately, ArcSDE provides statistics about the spatial index which, along with performance testing, can ease the tuning process. The command 'sdelayer -o si_stats' is the primary tool for reporting spatial index grid statistics used to tune the spatial index. Here is an example of the output of this command:

Watch the video: Filling Attribute Table Automatically with Simple Steps in ArcMap Using Field Calculator