Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

My eventual goal is to automate kernel density calculations for a large corpus of point data; however, if all points are identical (for example, if there are 7 points all stacked on top of one another because they have the same long/lat values), the kernel density function in arcpy will not work. It will result in the following error:

"Error 010246: All input points are identical A valid window must be specified"

Since this will be an automated process, I need a way to check the points in the current input to be sure they aren't all the same using python/arcpy. Is there a way to do that?

EDIT: I specified a grid size and an extent, so a lot of the errors are fixed; however, identical points still give me the "valid window must be specified." I have tried to use the FindIdentical function to look for identical points, but this returns a DBF file, that I cannot read in the script. Is there some way to read a DBF easily in python, or can I find if all points are identical in another way?

share|improve this question
4  
This should not be an error condition: it is perfectly valid--and sometimes necessary--to produce a kernel density from such data. Are you sure the problem is not because you have failed to explicitly provide an extent and cellsize for the output? –  whuber Jan 7 '13 at 18:01
    
Oh. Well, it could very well be that I am doing something wrong in my call to the KDens. Right now I am calling it with: outKDens = KernelDensity(feature_outfile, "NONE", 0.528710004, 40, "SQUARE_KILOMETERS"). The cell size may need to differ for each feature_outfile, though, so that may be causing the problem. I am not 100% comfortable with kernel density yet. –  N-C Jan 7 '13 at 22:20
1  
I don't think the problem is with the call per se. In any raster programming or processing environment, the software needs instructions about the extent and cellsize of the output it is supposed to produce. In most cases it can infer reasonable defaults, such as using the full extent and smallest cellsize of all raster inputs. But when there is no raster input and the input features have no extent at all--which is the case of your coincident points--it will need your explicit instructions. I believe that's what "a valid window" may be referring to. –  whuber Jan 8 '13 at 14:01
    
@whuber How do I provide these explicit instructions? I have tried setting the env.extent and env.cellSize variables, but they don't seem to eliminate the error. –  N-C Jan 31 '13 at 22:18
add comment

4 Answers 4

You can use Find Identical (selecting Shape field) and Delete Identical. Both tools can be scripted in python.

share|improve this answer
5  
The problem with deleting identical points is that it will (or at least should) change the kernel density estimate. –  whuber Jan 7 '13 at 18:48
    
Ah, this might still be useful, though. Since there is no point in calculating density for a file with all the same points (I think), I can just use FindIdentical to determine if the points are the same, then not run the KDens if they are. –  N-C Jan 7 '13 at 22:25
    
You are correct that the density calculation with identical points is trivial, but it can have a purpose. Its output will be a recentered version of the density kernel being used--weighted by the total weight of all the points. The output can be used for cartography and subsequent analysis and in both those cases the total weight is likely to matter. –  whuber Jan 8 '13 at 14:02
    
That makes sense. From what I have seen, FindIdentical returns a table that lists all the points, then a FEAT_SEQ value that is the same for points in the same location. If I wanted to check if all the points were identical, I would have to just iterate through this table and make sure all the FEAT_SEQ values are the same. Is there a simpler way to do this? Can I make sure the output of this function is an array, instead of a file, so I don't have to do file reading/string manipulation? –  N-C Jan 14 '13 at 20:00
add comment

How to get the extent of each polygon in a shapefile?

I hope the extent calculation may help...

my assumption here: even 7 points have same lat/long, but the 8th point is different, then kernel density function will work.

share|improve this answer
1  
Unfortunately, for some files I am using, ALL the points are the same. I am iterating over many different files, each with different sets of points. For example, one of the files may have 7 points, and they are all identical. Another file may have 3 points, and 2 are the same, yet the other is different. The latter case usually works fine. –  N-C Jan 7 '13 at 22:23
add comment

Did you think about searching for find and delete duplicate features if the problem is solely for identical features. There are many python scripts for this. Some are : 1, 2, 3.

share|improve this answer
add comment
up vote 0 down vote accepted

Well, I found a decent way to find if all points are identical that suits my needs. I used the getExtent() function from the Layer class to find the extent of the points in the current dataset layer. If the extent's XMin == XMax and YMin == YMax, that means that the data points are all the same, since the extent is a single point.

By inserting a check with a simple if statement, I was able to choose not to perform the kernel density calculation if all the points were the same. If the points are not the same, I am able to correctly set an extent and cell size for each dataset, and the kernel density calculation moves ahead with no problems.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.