In a journal article I have read that two rasters, representing X and Y coordinates respectively (see attached figure), have been entered as predictors in a GIS-based Logistic Regression for a given reason (namely, in order to reduce possible auto-correlation issues). I was wondering how such rasters can be produced in ArcGIS (10.1). The reference is:

Hu, Z., & Lo, C. P. (2007). Modeling urban growth in Atlanta using logistic regression. Computers, Environment and Urban Systems, 31, 667–688. http://doi.org/10.1016/j.compenvurbsys.2006.11.001

@Luke pointed out an earlier thread. I read it, and I see that different approaches have been suggested, mainly outside arcGIS. I would rather prefer to stick with the latter. I saw something that could fit my need, but I do not understand one thing: in the suggested workaround: xmap = (FlowAccumulation(1) + 0.5)*cellsize + xmin, what that (1) stands for? The same applies to the (64) in the suggestion for the ymap (namely, ymap = (FlowAccumulation(64) + 0.5)*cellsize + xmin)

enter image description here


1 Answer 1


This script is so simple that you should just try it. Just change the filepaths and filenames to what you need.

import arcgisscripting
inraster  = r'C:\folder\your_raster' # if your raster is not a GRID, add the file extension (.tif etc)
latraster = r'C:\folder\latraster'
lonraster = r'C:\folder\lonraster'
gp        = arcgisscripting.create(9.3)
gp.SingleOutputMapAlgebra_sa("Con(IsNull({0}), {1}, $$XMap)".format(inraster, inraster),lonraster)
gp.SingleOutputMapAlgebra_sa("Con(IsNull({0}), {1}, $$YMap)".format(inraster, inraster),latraster)
del gp
  • Upon executing the script, I got this error. The issue is with the last two commands. Failed to execute. Parameters are not valid. ERROR 010394: Map Algebra expression: Syntax error at location 57 (around (bare) of expression Con(IsNull(C:\DEM\Geod\Raster images\DEM_(bare_earth)_frm_LiDAR\bearth1x1_clp), C:\DEM\Geod\Raster images\DEM_(bare_earth)_frm_LiDAR\bearth1x1_clp, $$XMap). Failed to execute (SingleOutputMapAlgebra).
    – NewAtGis
    Commented Jun 5, 2015 at 6:36
  • That's because the script is made for ArcGIS 9.3, which i assume you don't use (from the tags). It'll require a rewrite before you can use it in 10.1.
    – Martin
    Commented Jun 5, 2015 at 6:49
  • 1
    I managed to get what I was after using another approach (since the above script and the FlowAccumulation solutions did not work for me). Hope this will be useful sometime in the future to anyone jumping here: (1) I loaded a DEM and a shape file corresponding to the same area; (2) I created a fishnet (with the ArcGIS tool) with size 500mX500m, making sure to tick the 'create labels'; (3) I added x and y values to each generated point; (4) interpolated the x values by IDW, snapping to the DEM and using the same processing extent of the region shapefile. Same applies for y. DONE
    – NewAtGis
    Commented Jun 5, 2015 at 9:08
  • I have Arc10.2.2 and I can run that script just fine... but glad you found your own solution!
    – jotakah
    Commented Jun 5, 2015 at 14:51

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