#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    1
    Rep Power
    0

    Problem in GIS, script only solution!


    First post! I'm new to python and I'm getting into it because I'm constantly facing novel problems in gis, and scripts seem to be the only way to get around them.

    I'm tasked with determining the total area of land affected by road salt in Northern New York. More or less 6 million acres. Going small area by small area is easy, but it would take months.

    What I need my script to do:

    The program must go cell by cell on a dem array. Once it hits a cell flagged as a ROAD a 8 neighbor window will be created. All cells less than the elevation of the road in the 8 neighbor window will be exported. This will run until the end of the array. The script will loop back and go cell by cell until it hits one of these "exported" cells. Once it hits these exported cells another 8 neighbor window will be created. All cells less than the elevation of the targeted (previously exported) cell will exported. This will loop and loop to completion. This process will be completed once there aren't any cells less than the targeted cells. When it hits a stream it will stop at the stream because the only cells less than the targeted cells will be downstream... Hopefully producing a raster representing all land affected by road salt (land lower in elevation, yet continuous on a down slope.)



    So I'm interested in what particular module will help with this. And where should I start looking for this cell by cell encoding stuff. I know fortran would be perfect. But I need esri compatibility. Hence python
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,931
    Rep Power
    481
    You've described a directed graph problem in which it's okay to discover the graph as you go. Each grid knows its nearest neighbors and that's enough. Cells with paved roads are the starting points for each graph search. As tempted as I am to make an artificial surface with artificial roads and streams, and to write a code that marks potential surface salt distribution, it's not likely to help.

    If you want to write the code look up Dijkstra's graph algorithm now on youtube. Otherwise it would be more effective, I think, for someone to start with knowledge of gis. You'll have two changes from Dijkstra's algorithm. Multiple starting points, unspecific goal. Unspecific in that "everywhere that can be reached by monotonic descending function" is not the same as "node 8". As you described, you'll continue to expand the frontier in all directions to low spot or stream.

    To make the algorithm efficient maintain a global list of visited quads (grids or whatever you called the land parcels). Check the global list before adding new territory to the frontier. This optimization is intended to handle multiple starting points.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo