Random offset for points using max distance and constrain to polygons

1495
3
01-11-2012 12:58 PM
SamBlanchard
New Contributor
Hello I hope this is the correct forum to post this question:

This is my situation:
I have a point shapefile with each point representing a patient that has been geocoded to the census block centroid and I have overlapping points because there are multiple people living in the same block. What I am trying to do is randomly offset the patient points to a specified max distance of 10 m and constrain the offset so that the points in a particular block are kept in that same block and are not offset into a different adjoining block. The issue is that I have tried this tool: http://forums.esri.com/thread.asp?c=93&f=1728&t=235074 and it successfully offset the points from the block centroid using my specified 10 m max but after checking the offset distances points were offset up to 14 m away from their original locations - this seems to be systematic as this happened to single points that do not have overlapping points. This may be a result of how the hypotenuse is calculated. While 4 m off from my max is not that bad the tool did not stick to my rigid max distance. The tool is also unable to constrain the offset to be within the same census block polygons. I am stuck on how to actually offset the points by 10 m max while constraining them to the census block they are in.

I know in ArcGIS with the Create Random Points tool you can create random points inside polygons using a max distance and also specify the number of points in each polygon; I can do exactly what I want to do with this tool with the exception that the created random points would not have a identifier or field that I could join the patient data with. Using a spatial join would not work either because in some cases patients in adjacent blocks may be closer to the new random points and there would be a mismatch in joining the data. If there was a way to transfer the attributes from the original patient data to the new random points this would work well. Tools in Hawths and Geospatial Modelling Environment also cannot do the particular operation I am seeking to do.

Does anyone have any suggestions on how to go about doing this or can suggest a tool, script, or additional open source/ free software that can do this? I know I could probably write my own code to do this but this is my first shot at seeing what is out there after finding not much on the web or forums.

Thanks.
3 Replies
JimW1
by
Occasional Contributor II
Just some thoughts:

The script you linked allows a random X or Y offset up to 10m but doesn't check if the absolute offset is greater than 10m. For example, a Y offset of 9m with a X offset of 8m gives an offset of ~12m. I used to have VBA code that then looped the resulting offset to check if it was greater than the max dist and re-ran the randomizer but VBA is dead so that would be a waste of your time. You'd have to code the same kind of error-checker into the python script.

I do something similar but with client data so for you I'd suggest:

-Take your geocoded patient point file and add the centroid coordinates from the census block (join the census block data to the patient layer or spatial join if you geocoded to addresses)
-Make a XY event from the table of the geocoded based on the centroid values (to keep your source data intact)
-Add the randomizer script to model builder and run the XY even through the script
-Spatial join the randomized points to the census blocks
-Make two outputs- Matches to Census Blocks, Do not Match
-export the records that match the census block to an intermediate dataset
-take the remaining incorrectly placed patient points and re-run them through the randomizer step
-Spatial join again to export out the correctly placed points
-Then repeat the loop until the incorrect count is zero

You should be able to do all that in Model builder without coding (but don't quote me on that).
I can't help with the Python... I'm loyal to VBA
0 Kudos
SamBlanchard
New Contributor
Just some thoughts:

The script you linked allows a random X or Y offset up to 10m but doesn't check if the absolute offset is greater than 10m. For example, a Y offset of 9m with a X offset of 8m gives an offset of ~12m. I used to have VBA code that then looped the resulting offset to check if it was greater than the max dist and re-ran the randomizer but VBA is dead so that would be a waste of your time. You'd have to code the same kind of error-checker into the python script.

I do something similar but with client data so for you I'd suggest:

-Take your geocoded patient point file and add the centroid coordinates from the census block (join the census block data to the patient layer or spatial join if you geocoded to addresses)
-Make a XY event from the table of the geocoded based on the centroid values (to keep your source data intact)
-Add the randomizer script to model builder and run the XY even through the script
-Spatial join the randomized points to the census blocks
-Make two outputs- Matches to Census Blocks, Do not Match
-export the records that match the census block to an intermediate dataset
-take the remaining incorrectly placed patient points and re-run them through the randomizer step
-Spatial join again to export out the correctly placed points
-Then repeat the loop until the incorrect count is zero

You should be able to do all that in Model builder without coding (but don't quote me on that).
I can't help with the Python... I'm loyal to VBA


Thank you withershin that is a great idea. I will give it a try. Thanks again.
0 Kudos
NasserSharareh1
New Contributor III

Have you been able to find any simpler approach? I am using claims data and have the same problem. I wonder whether overlapping points might be a problem for GWR.

0 Kudos