General

Upcoming Posts page

If you have suggestions or questions relating to the general blog content (rather than specific posts), or requests for new tutorials/posts check out the Upcoming Posts page. I will use comments posted there to help direct new content for the blog.

Advertisements

8 thoughts on “Upcoming Posts page

  1. Great blog.
    I have a question when writing out messages to a text file is there a way to add more text to it?
    Like this: txtFile.write (“Line %i” % tb.tb_lineno, arcpy.GetMessages())
    I cannot get it to work.
    Thank you.
    John

    1. John, the write method only takes one argument – a single string. To write more than one thing you need to make them all into one string, either when you write it with:
      txtFile.write (“Line %i %s” % (tb.tb_lineno, arcpy.GetMessages())) # string notation
      or
      txtFile.write (“Line %i” % tb.tb_lineno + arcpy.GetMessages()) # appending second string to first

      Or by specifying the string first (which is a little more reader friendly):
      str = “Line %i %s” % (tb.tb_lineno, arcpy.GetMessages()) # string notation
      txtFile.write (str)
      or
      str = “Line %i” % (tb.tb_lineno) + arcpy.GetMessages() # appending second string to first
      txtFile.write (str)

      Cheers,
      Stacy

      1. Hi John,

        I don’t entirely understand the question, but the \n (note the slash direction – you had it the other way in your question) puts a new line wherever you have it. So:

        print ‘Hello \nWorld’

        would produce:

        Hello
        World

        For your previous question, I would suggest this method to get a new line between your line number and your messages:

        str = “Line %i\n%s” % (tb.tb_lineno, arcpy.GetMessages()) # string notation
        txtFile.write (str)

        You may in fact want two new lines, so it is spaced better, you can simply do \n\n to get that (or as many as you want).

        Regards,
        Stacy

  2. Stacy,
    I’m trying to get into the Remote Sensing part of ARCVIEW. I don’t have Spatial analyst. HOWEVER, I know that GDAL/PROJ4 has a few functions for classifying rasters. I’m curious if you know of a workflow/plugin that might have some stuff for getting into that side? I’ve only taken 1 RS class in my life (it was using ERDAS IMAGINE) and it’s been a while, but I’ve always loved the pictures that LANDSAT produces.

    Just a thought…

    1. Thanks for the comment. I will be putting up some posts soon regarding OGR, and that might help with GDAL, which might be what you are after…? I presume you have done some Arcpy/Python coding previously?

      GDAL is pretty straightforward, but a little different from Arc. In Arc you simply pass paths to every tool (i.e. input path, output path) as well as variables telling the tool what to do. With GDAL/OGR you actually open the dataset, then perform operations on it, then close it.

      This page: http://www.gdal.org/gdal_tutorial.html has a good amount of documentation to help you get started (Python examples are hidden below the C++ and C examples).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s