1

I'm running a script for different controls for a map, and want this to be automated. But when i run this script it will bring up a popup window during the process that says: "New ArcInfo Workspace" and asks me to add a name manually, this stops the process and i need to manually close this popup window to make the script continue. How to i remove this popup from appearing in my script?

enter image description here

This is the code I'm using:

#!/usr/bin/python
# -*- coding: iso8859_10 -*-
import arcpy, sys, string, os, datetime, copy

arcpy.env.overwriteOutput = True

#Lokale stier for henting og lagring av filer
sti_ny = r"Y:\Kartografi\N50_Kartdata\Arbeidsfiler\Kontroll\Script\N250_Kontroll\Dataoppdatering\Orginaldata\kartdata_ny.gdb\\"
sti_gml = r"Y:\Kartografi\N50_Kartdata\Arbeidsfiler\Kontroll\Script\N250_Kontroll\Dataoppdatering\Orginaldata\kartdata_gml.gdb\\"
gdb_ny = r"Y:\Kartografi\N50_Kartdata\Arbeidsfiler\Kontroll\Script\N250_Kontroll\Dataoppdatering\Orginaldata\kartdata_ny.gdb\\"
gdb_gml = r"Y:\Kartografi\N50_Kartdata\Arbeidsfiler\Kontroll\Script\N250_Kontroll\Dataoppdatering\Orginaldata\kartdata_gml.gdb\\"
sti_data = r"Y:\Kartografi\N50_Kartdata\Arbeidsfiler\Kontroll\Script\N250_Kontroll\Dataoppdatering\Orginaldata\omradeinndeling.gdb\\"
sti = r"Y:\Kartografi\N50_Kartdata\Arbeidsfiler\Kontroll\Script\N250_Kontroll\Dataoppdatering\Endringsdata\\"
sti_org = r"Y:\Kartografi\N50_Kartdata\Arbeidsfiler\Kontroll\Script\N250_Kontroll\Dataoppdatering\Orginaldata\\"
sti_endring = r"Y:\Kartografi\N50_Kartdata\Arbeidsfiler\Kontroll\Script\N250_Kontroll\Dataoppdatering\Endringsdata\finn_endring.gdb\\"

# Local variables:
Arealer = sti_endring + "Arealer_TB"
Kirke = sti_endring + "Kirke"
Kirke_Punkt_N250 = sti_endring + "Kirke_Punkt_N250"
Golfalpin_N250 = sti_endring + "GolfAlpin_N250"
Golfalpin_N50 = sti_endring + "GolfAlpin_N50"
N50_golfalpin_buffer = sti_endring + "N50_golfalpin_buffer"
N250_golfalpin_feil = sti_endring + "N250_golfalpin_feil"
Arealer_Intersect_Kirke = sti_endring + "Arealer_Intersect_Kirke"
Kirke_mangler_punkt_N250 = sti_endring + "Kirke_mangler_punkt_N250"
N250_Alpin = sti_endring + "N250_Alpin"
N50_Skitrekk = sti_endring + "N50_Skitrekk"
Alpinbakke_feil = sti_endring + "Alpinbakke_feil"
Golfbane_feil = sti_endring + "Golfbane_feil"
Grunnriss_kirke_feil = sti_endring + "Grunnriss_kirke_feil"
ArealdekkePunkt = sti_ny + "ArealdekkePunkt"
Bygningsflate = sti_ny + "Grunnriss"
ArealdekkeFlate_N50 = sti_ny + "N50_ArealdekkeFlate"
ArealdekkeFlate = sti_ny + "N250_ArealdekkeFlate"
N50_AnleggsLinje = sti_ny + "N50_AnleggsLinje"
Bygningspunkt = sti_ny + "Bygningspunkt"


'''----Alpinbakke og Golfbane Kontroll----'''

# Process: Select
arcpy.Select_analysis(Bygningsflate, Kirke, "\"BYGGTYP_NBR\" = 671 AND \"Shape_Area\" >= 800")
arcpy.Select_analysis(ArealdekkeFlate, Arealer, "\"OBJTYPE\" = 'Tettbebyggelse' OR \"OBJTYPE\" = 'BymessigBebyggelse'")
arcpy.Select_analysis(ArealdekkePunkt, Golfalpin_N250, "\"OBJTYPE\" = 'Golfbane' OR \"OBJTYPE\" = 'Alpinbakke'")
arcpy.Select_analysis(ArealdekkeFlate_N50, Golfalpin_N50, "\"OBJTYPE\" = 'Golfbane' OR \"OBJTYPE\" = 'Alpinbakke'")


# Process: Buffer
infeaturee = Golfalpin_N50
arcpy.Buffer_analysis(infeaturee, N50_golfalpin_buffer, "200 Meters", "FULL", "ROUND", "LIST", "")

# Process: Erase
in_feature = Golfalpin_N250
erease_features = N50_golfalpin_buffer
arcpy.Erase_analysis(in_feature, erease_features, N250_golfalpin_feil, "")

#Process Select, selekterer golfbaner til eget lag
arcpy.Select_analysis(N250_golfalpin_feil, Golfbane_feil, "\"OBJTYPE\" = 'Golfbane'")

#Process Select N250 Alpinbakker og N50 skitrekk
arcpy.Select_analysis(N250_golfalpin_feil, N250_Alpin, "\"OBJTYPE\" = 'Alpinbakke'")
arcpy.Select_analysis(N50_AnleggsLinje, N50_Skitrekk, "\"OBJTYPE\" = 'Skitrekk'")

#Process Near, sjekker alpinpunkt fra N250 mot skitrekk i N50
in_featuress = N250_Alpin
near_features = N50_Skitrekk
search_radius = "200 Meters"
angle = "NO_ANGLE"
arcpy.Near_analysis(in_featuress, near_features, search_radius, "#", angle)

#Process Select, selekterer punkter som ikke er i nerheten av skitrekk
in_featuree = N250_Alpin
out_featuree = Alpinbakke_feil
arcpy.Select_analysis(in_featuree, out_featuree, "NEAR_DIST = -1")


'''----Kirke Kontroll----'''

# Process: Intersect
infeatures = [Arealer, Kirke]
arcpy.Intersect_analysis(infeatures, Arealer_Intersect_Kirke, "ALL", "", "INPUT")

# Process: Select
arcpy.Select_analysis(Bygningspunkt, Kirke_Punkt_N250, "\"BYGGKAT\" = 64")

#Process: Spatial Join
targetFeatures = Arealer_Intersect_Kirke
joinFeatures = Kirke_Punkt_N250
out_feature_class = Kirke_mangler_punkt_N250
arcpy.SpatialJoin_analysis(targetFeatures, joinFeatures, out_feature_class, "JOIN_ONE_TO_MANY", "KEEP_ALL", "#", "INTERSECT", "200 Meters", "#")

#Process Select, selekterer Kirke grunnriss fra N50 som skal være med i N250
arcpy.Select_analysis(Kirke_mangler_punkt_N250, Grunnriss_kirke_feil, "Join_Count = 0")
  • you posted the entire script? I dont see any code asking for a user input... – NULL.Dude Nov 1 '17 at 12:08
  • add a new variable workspace = r'path\to\work\space' underneath arcpy.env.overwriteOutput = True – NULL.Dude Nov 1 '17 at 12:09
  • Yes this is the entire script, I tried removing the arcpy.env.OverwriteOutput = true, but I still got the popup. – proxmo Nov 1 '17 at 12:12
  • No, do not remove it, add the new variable workspace underneath it. The workspace path would be the path to your GDB or SDE – NULL.Dude Nov 1 '17 at 12:13
  • I still got the same popup, even with the workspace path. – proxmo Nov 1 '17 at 12:18
2

You need to use arcpy.env.workspace as an input workspace. If the problem remains, you can change raw to unicode :

example of raw to unicode:

u"Y:\Kartografi\N50_Kartdata\Arbeidsfiler\Kontroll\Script\N250_Kontroll\Dataoppdatering\Orginaldata\kartdata_ny.gdb\"

Assigning UNC Path to arcpy.env.workspace

  • 3
    You're going to need to escape the backslashes ("\" --> "\\") if you switch from raw to unicode. – nmpeterson Nov 1 '17 at 20:19
  • 1
    Thank you, that fixed my issue, and I needed the double backslashes aswell to make the code run through. Much appreciated. – proxmo Nov 2 '17 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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