Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7922815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:06:03+00:00 2026-06-03T17:06:03+00:00

First-time post and python newb who has exhausted all other options. I am interested

  • 0

First-time post and python newb who has exhausted all other options. I am interested in appending selected raster properties (using the arcpy.GetRasterProperties_management(input_raster, “property_type”) function) to a comma-delimited table, but am having trouble figuring out how to do this for multiple results. As an abridged example (of my actual script), I have created two ‘for’ loops; one for each raster property I am interested in outputting (i.e. Cell Size X, Cell Size Y). My list of rasters include S01Clip_30m through S05Clip_30m. My goal is to create a .txt file that should look something like this:

RasterName, CellSizeX, CellSizeY  
S01Clip_30m, 88.9372, 88.9375  
S02Clip_30m, 88.9374, 88.9371

The code I have so far is below (with some uncertain, botched syntax at the bottom). When I run it, I get this result:

S05Clip_30m, 88.9374
(last raster in the list, CellSizeY)

I appreciate any help you can provide on the crucial bottom code block.

import arcpy
from arcpy import env
env.workspace = ('C:\\StudyAreas\\Aggregates.gdb')
InFolder = ('C:\\dre\\python\\tables')
OutputFile = open(InFolder + '\\' + 'RasterProps.txt', 'a')
rlist = arcpy.ListRasters('*','*')
for grid in rlist:
    if grid[-8:] == "Clip_30m":
        result = arcpy.GetRasterProperties_management(grid,'CELLSIZEX')
        CellSizeX = result.getOutput(0)
for grid in rlist:
    if grid[-8:] == "Clip_30m":
        result = arcpy.GetRasterProperties_management(grid,'CELLSIZEY')
        CellSizeY = result.getOutput(0)
> I know the syntax below is incorrect, but I know there are *some* elements that 
> should be included based on other example scripts that I have...
> if result.getOutput(0) == CellSizeX:
>     coltype = CellSizeX
> elif result.getOutput(0) == CellSizeY:
>     coltype = CellSizeY
> r = ''.join(grid)
> colname = r[0:]
> OutputFile.writelines(colname+','+coltype+'\n')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T17:06:06+00:00Added an answer on June 3, 2026 at 5:06 pm

    After receiving help from another Q&A forum on my script, I am now providing the answer to my own GIS-related question to close this thread (and move to gis.stackexchange 🙂 – thanks to L.Yip’s comment). Here is the final corrected script which outputs my two raster properties (Cell Size in X-direction, Cell Size in Y-direction) for a list of rasters into a .txt file:

    import arcpy
    from arcpy import env
    env.workspace = ('C:\\StudyAreas\\Aggregates.gdb')
    InFolder = ('C:\\dre\\python\\tables')
    OutputFile = open(InFolder + '\\' + 'RasterProps.txt', 'a')
    rlist = arcpy.ListRasters('*','*')
    for grid in rlist:
        if grid[-8:] == "Clip_30m":
            resultX = arcpy.GetRasterProperties_management(grid,'CELLSIZEX')
            CellSizeX = resultX.getOutput(0)
            resultY = arcpy.GetRasterProperties_management(grid,'CELLSIZEY')
            CellSizeY = resultY.getOutput(0)
    OutputFile.write(grid + ',' + str(CellSizeX) + ',' + str(CellSizeY) + '\n')
    OutputFile.close()
    

    My results after running the script:
    S01Clip_30m,88.937158083333,88.9371580833333
    S02Clip_30m,88.937158083333,88.937158083333
    S03Clip_30m,88.9371580833371,88.9371580833333
    S04Clip_30m,88.9371580833308,88.937158083333
    S05Clip_30m,88.9371580833349,88.937158083333

    Thanks!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first post on this website, but I'm all the time getting
This is my first time here so I hope I post this question at
Every time I try to post to twitter in my rails app, the first
First of all, I have some time reading this page and I find very
First time I post a question, so here it goes. I want to push
first of all: I am not a python programmer, i just want to run
Ok, long time visitor, first time post. Instead of PowerShell telling me the result
Newbie user here, first time I post here so I'll try to make it
This is not the first time I'm using this method to send a POST
First time Java programmer. I'm wondering what my options are for loading XML on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.