FAQ
Hi users,

Found a solution to my Raster to ASCII conversion problem, so I thought I'd
post.

My raster was created in ArcGIS 9.3 as an ESRI GRID (folder with associated
info folder). I needed to use the ListRasters method (see
http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?id�8&pid�5&topicname=ListRasters_method)
to
get Python to recognize it as a raster. My functioning code is posted below.
import arcgisscripting
gp = arcgisscripting.create(9.3)
gp.workspace = "C:\Users\Lab User\Desktop\BKern\Blackwater\PVA\Scenario
1\Nov 15"
rasters = gp.ListRasters("","ALL")
for raster in rasters: print raster
...
scen1_11_15
InRaster = "scen1_11_15"
OutasciiFile = "C:\Users\Lab User\Desktop\BKern\Blackwater\PVA\Scenario
1\Nov 15\scen1.asc"
gp.RasterToASCII_conversion(InRaster, OutasciiFile)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101115/c4553654/attachment.html>

Search Discussions

  • MRAB at Nov 15, 2010 at 8:37 pm

    On 15/11/2010 20:14, Becky Kern wrote:
    Hi users,
    Found a solution to my Raster to ASCII conversion problem, so I thought
    I'd post.
    My raster was created in ArcGIS 9.3 as an ESRI GRID (folder with
    associated info folder). I needed to use the ListRasters method (see
    http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?id�8&pid�5&topicname=ListRasters_method
    <http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?id�8&pid�5&topicname=ListRasters_method>) to
    get Python to recognize it as a raster. My functioning code is posted below.
    import arcgisscripting
    gp = arcgisscripting.create(9.3)
    gp.workspace = "C:\Users\Lab
    User\Desktop\BKern\Blackwater\PVA\Scenario 1\Nov 15"
    rasters = gp.ListRasters("","ALL")
    for raster in rasters: print raster
    ...
    scen1_11_15
    InRaster = "scen1_11_15"
    OutasciiFile = "C:\Users\Lab
    User\Desktop\BKern\Blackwater\PVA\Scenario 1\Nov 15\scen1.asc"
    gp.RasterToASCII_conversion(InRaster, OutasciiFile)
    Be careful when using string literals containing backslashes. It's
    recommended that you use raw strings:

    gp.workspace = r"C:\Users\Lab
    User\Desktop\BKern\Blackwater\PVA\Scenario 1\Nov 15"

    OutasciiFile = r"C:\Users\Lab
    User\Desktop\BKern\Blackwater\PVA\Scenario 1\Nov 15\scen1.asc"

    You were lucky that none of the backslashes started an escape sequence.
    If you were using Python 3 then it would've complained about \U and \N.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedNov 15, '10 at 8:14p
activeNov 15, '10 at 8:37p
posts2
users2
websitepython.org

2 users in discussion

MRAB: 1 post Becky Kern: 1 post

People

Translate

site design / logo © 2022 Grokbase