🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.python
3 messages
3 total messages Started by Nateysz Wed, 19 Jan 2011 21:21
ArcGIS - problem
#27884
Author: Nateysz
Date: Wed, 19 Jan 2011 21:21
51 lines
2525 bytes
Witam,

męczę się z tym skryptem już dłuższy czas.


Niestety nie potrafię stwierdzić, czy błąd siedzi, gdzieś w moim skrypcie,
czy może sam program.


Pierwsze wykonanie pętli przebiega bezproblemowo.

==========================================


import sys, string, os, arcgisscripting

gp = arcgisscripting.create()

gp.CheckOutExtension("spatial")


gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial 
Analyst Tools.tbx")

gp.extent = "590492,455187569 168523,37147041 606454,902048855 
186493,384441414"
gp.cellSize = "20"


for i in range(1,3):
     Idw_punkty = "C:\\Dane14\\Idw" + '_' + str(i)
     wynik= "C:\\Dane14\\wynik" + '_' + str(i)
     obliczenia = "C:\\Dane14\\obliczenia" + '_' + str(i)
     wzor_nmt = "C:\\Dane14\\wzor_nmt"
     statystyki_IDW_TXT = "C:\\Dane14\\statIDW" + '_' + str(i)+'.txt'
     punkty= "C:\\Dane14\\punkty.shp"
     wiadomosc='Wyniki obliczen dla wykladnika ' + str(i)
     formulkaMap='Abs("' + Idw_punkty + '" - "' + wzor_nmt +'")'
     formulkamap2='wzor_nmt' + ';' + Idw_punkty
     #
     gp.Idw_sa(punkty, "Wysokosc", Idw_punkty, "20", i, "VARIABLE 12", "")
     # obliczenie roznicy
     gp.Minus_sa(Idw_punkty, wzor_nmt, wynik)
     #
     #obliczenie modulu
     gp.Abs_sa(wynik, obliczenia)
     #wypisanie statystyk
     gp.BandCollectionStats_sa(obliczenia, statystyki_IDW_TXT, "BRIEF")
     f=open(statystyki_IDW_TXT,"r")
     gp.AddMessage(wiadomosc)
     gp.AddMessage(f.read())
Re: ArcGIS - problem
#27885
Author: Nateysz
Date: Wed, 19 Jan 2011 22:06
4 lines
1117 bytes
sam sobie odpowiem - zabrakło zamknięcia pliku
f.close()

Przepraszam za zamieszanie.
Re: ArcGIS - problem
#27886
Author: Artur M. Piwko
Date: Thu, 20 Jan 2011 07:50
26 lines
1559 bytes
In the darkest hour on Wed, 19 Jan 2011 22:21:15 +0100,
Nateysz <43t4@vbr.pl> screamed:
> gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial 
> Analyst Tools.tbx")
>

Raz masz tak...

>      Idw_punkty = "C:\\Dane14\\Idw" + '_' + str(i)

...a raz tak.

Jesli chcesz korzystać z '\' to raczej konstruuj ścieżki tak:
       Idw_punkty = r"C:\Dane14\Idw_" + str(i)

>      f=open(statystyki_IDW_TXT,"r")
>      gp.AddMessage(wiadomosc)
>      gp.AddMessage(f.read())

Brak f.close(). Ale to już zauważyłeś.

-- 
[ Artur M. Piwko : Pipen : AMP29-RIPE : RLU:100918 : From == Trap! : SIG:221B ]
[ 08:48:27 user up 12688 days, 20:43,  1 user, load average: 0.09, 0.89, 0.54 ]

                    Any program that runs right is obsolete.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads