|
POST
|
Hello, I need to create a layer, then delete it and then create a layer of the same name again. The script below works as expected in Python 2.7 32 bit, but fails in Python 3.4 64 bit in ArcGIS 10.3.1. Can anyone explain why? import arcpy
in_fc=r'C:\dump.gdb\zn3_0'
w = "STATION=3001"
lrname = 'lr1'
# create a layer
lr = arcpy.management.MakeFeatureLayer(in_fc, lrname, w).getOutput(0)
print(arcpy.Exists(lrname)) # True
# delete the layer
arcpy.management.Delete(lr)
arcpy.management.Delete(lrname)
del lr
print(arcpy.Exists(lrname)) # should be False but returns True in Python 3.4!
# create the layer again fails in Python 3.4
lr = arcpy.management.MakeFeatureLayer(in_fc, lrname, w).getOutput(0)
# ERROR 000725: Output Layer: Dataset lr1 already exists.
# and indeed the layer still exists after the error
print(arcpy.Exists(lrname)) # True
arcpy.management.GetCount(lrname).getOutput(0) # 1 Filip.
... View more
11-13-2015
05:35 AM
|
0
|
7
|
5619
|
|
POST
|
Hi all, I also agree that this is a really serious issue in practical terms so please post back here if you have any news about this. Today I really had to deal with the shapefile I mentioned in my original post and this is a work around I came up with based on responses from Vince Angelo. It is far from generic but it worked in my situation. You will likely need to adjust it and check it for your cases. I must acknowledge my colleague helped me figure out the ins and outs of the _fix_short function. He's really good with binary stuff. """Rewrite a shapefile to a feature class in ArcGIS 10.3.1 and fix SHORT integer.
This example assumes input shapefile in_shp with columns WBID and DBAREA.
DBAREA is a DOUBLE and WBID is the incriminated integer column.
"""
import numpy
in_shp = 'c:/temp/poly.shp'
out_fc = 'c:/temp/db.gdb/poly'
def _fix_short(a):
"""Fix 16 bit SHORT to the right 32 bit LONG in ArcGIS 10.3 context.
a -- input integer to convert to unsigned 32 bit integer
For reasoning see https://community.esri.com/thread/159997
"""
i = 65535 # i.e. int(16*'1', 2), the largest 16 bit integer
return numpy.int32(numpy.int16(a) & i)
# create the new output feature class
sr = arcpy.Describe(in_fc).spatialReference
out_fc = arcpy.management.CreateFeatureclass(
os.path.dirname(out_fc),
os.path.basename(out_fc),
"POLYGON", spatial_reference = sr
).getOutput(0)
arcpy.management.AddField(staging_lakes, "WBID", "LONG")
arcpy.management.AddField(staging_lakes, "DBAREA", "DOUBLE")
# rewrite rows using cursors
with arcpy.da.SearchCursor(in_fc, ["SHAPE@", "WBID", "DBAREA"]) as sc:
with arcpy.da.InsertCursor(staging_lakes, ["SHAPE@", "WBID", "DBAREA"]) as ic:
for row in sc:
wbid = _fix_wbid(row[1])
ic.insertRow([row[0], wbid, row[2]]) Filip.
... View more
11-11-2015
06:24 AM
|
2
|
0
|
2169
|
|
POST
|
Good tip, I tried look for some relevant repositories there but I didn't find any .aprx files.
... View more
11-05-2015
01:56 PM
|
0
|
0
|
1083
|
|
POST
|
Hello, If I commit an ArcGIS Pro project including its directory to a git repository and share it with other people, am I giving away my ArcGIS credentials? I need the project in the repository because it is used to make some maps in python using arcpy.mp. This isn't really about git but about sharing projects generally. Do any of my credentials or username get stored in the project files or folders when I tick "sign me in automatically"? I believe it doesn't but cannot find anything to prove it. Any information/recommendation about this will be much appreciated. Filip. Message was edited by: Filip Král
Changed title from "Adding ArcGIS Pro Project to Git repository" to something more generic and that better frames the question.
... View more
11-05-2015
09:27 AM
|
0
|
2
|
3341
|
|
POST
|
Oh, today it turned out that my suggestion above actually does not work because the pure sqlite3 package does not understand the AsText function used in the sql query. One would have to use the pyspatialite package instead. Like this: import arcpy, os
from pyspatialite import dbapi2 as db
from contextlib import closing
# create spatial reference from well known ID
wkid = 4326 # you need to know the well known ID
sr = arcpy.SpatialReference(wkid)
# create feature class and add columns
fc= r'c:\path\to\file.gdb\featureclass'
fc = arcpy.management.CreateFeatureClass(os.path.dirname(fc), os.path.basename(fc), "POLYGON", spatial_reference=sr).getOutput(0)
arcpy.management.AddField(fc, "col1", "LONG")
arcpy.management.AddField(fc, "col2", "TEXT", field_length=100)
# insert rows from sqlite to the feature class
with arcpy.da.InsertCursor(fc, ["SHAPE@", "col1", "col2"]) as ic:
with closing(db.connect(r'c:\path\to\database.sqlite')) as conn:
cr = conn.cursor()
for row in cr.execute("select AsText(geom), col1, col2 from mytable;"):
shape = arcpy.FromWKT(row[0], wkid)
ic.insertRow([shape] + row[1:])
del cr
del ic Filip.
... View more
10-30-2015
12:58 PM
|
1
|
0
|
2723
|
|
POST
|
Hmm... not sure where the problem is. There are a few things I'd have to try step by step but here are some suggestions: The in_table parameter of MakeEventLayer tool should be a Table View so I'd call MakeTableView on the "points" table before you pass it to MakeRouteEventLayer(3). The output of MakeRouteEventLayer is a layer stored in memory of the computer but that does not mean it is in an in-memory workspace. Anyhow, I'd try making the final layer "segment" persistent by calling CopyFeatures on it. Even CopyFeatures to in_memory\something might help. Models exported to Python often need quite a bit of work to tidy them up so don't expect them to run straight away. Filip.
... View more
10-28-2015
03:22 PM
|
1
|
5
|
3622
|
|
POST
|
Hi Terry, In-memory workspaces have certain limitations but I cannot see from your description why and how exactly is your model failing. Can you provide more details about what you are trying to do? Maybe a diagram of your model would help. Also, does your question relate to what Brendan asked in the first place? Are you trying to publish your model as a service? If not, it might also be best to create a new thread for your question. Just mention @FIlip_Kral in the text of your question and I'll get a notification. Filip.
... View more
10-28-2015
01:24 PM
|
0
|
7
|
3622
|
|
POST
|
Hi Michael Volz, The exact problem I had is described in my original post. Basically, a shapefile created in 10.2.x had a WBID column of type LONG with values from 1 to 50235. When I loaded this to ArcMap 10.3.1 the WBID column properties indicated type SHORT and it had values from -32767 to -15301 and from 1 to 32767. Note that 32767 is the upper bound of short integer. I think 32768 changed to -32767, 32768 to -32766, ... and 50235 to -15301. I don't have ArcGIS on this PC but I attached a sample of that shapefile to my later post. Filip.
... View more
10-24-2015
09:32 AM
|
0
|
2
|
4447
|
|
POST
|
Hello, In short, I killed ArcGIS using Task Manager. The network was not built so I could not run any analysis. Anyhow, while experimenting with the smaller network it turned out that Service Area Task got really slow if the "drive distance" (and so the resulting service area) got larger (say containing thousands of edges). I guess the bottle neck was dissolving the service area polygon rather than looking up the edges. Eventually I concluded this was not a viable option for what I wanted to do. At least for now. Thank you for your answers anyway. Filip.
... View more
10-14-2015
11:09 AM
|
0
|
1
|
1178
|
|
POST
|
Hello, I created a network dataset and let it build straight after creating it. It has been building for over 5 days now - I can still see the "progress bar": The machine I am building it on has plenty of memory and CPUs so it cannot be due to lack of resources. There seems to be nothing going on when I look into task manager. CPU is at 0%, plenty of free memory. What should I do? Is it possible that the network has been built but ArcMap didn't receive the right signal? Is it going to corrupt my file geodatabase if I kill ArcMap from task manager? The network I am trying to build has nearly 100 million edges. It is a drainage network derived from an outflow direction raster. I built a network from the same kind of dataset with 7.5 million edges before and it was quite quick. I would be grateful for any suggestions? Filip.
... View more
09-17-2015
01:09 AM
|
0
|
4
|
4417
|
|
BLOG
|
There have been some more improvements in GeoJSON support I think. You can now select GeoJSON as output format for the query operation. See for example this. Another interesting change I noticed just is is the quantisation parameter. Thanks to that you can compress the geometries and drastically reduce the size of JSON responses (EsriJSON only though).
... View more
08-28-2015
02:18 AM
|
0
|
0
|
2221
|
|
POST
|
Hi, In case of the TabulateArea tool, the temporary rasters get created when input zones are features and not a raster. The only way I found around this issue was to convert my zones from polygons to raster before the tabulate area is called. That way, it is possible to control where the raster is created and so it can be deleted afterwards. Other tools in the Zonal Statistics toolset may require similar approach to avoid the Fatal ERROR (INFDEF). I also found that this error may occur with other SpatialAnalyst tools in Python when you do not explicitly save them to hard drive - ArcGIS saves temporary rasters to temporary directory and doesn't clean up. Here is how to avoid it: # when a and b are rasters:
c = arcpy.sa.Add(a, b) # c is is "temporary" and resides in temporary folder
c.save("c:\sws.gdb\temp") # c is "permanently" saved in specified path and removed from the temporary folder
arcpy.management.Delete(c) # c is removed from where it was "permanently" stored There are rules about how ArcGIS determines the scratch folder but unless you can direct the temporary rasters to a geodatabase or save them as something else than ArcINFO Grids, you are going to run into the same issue. If you know a more elegant solution, I am eager to hear about it. Filip.
... View more
07-10-2015
01:18 AM
|
0
|
0
|
538
|
|
POST
|
Hello, I ran into the exact same problem. My Python script fails with "Fatal ERROR (INFDEF)" because the number of temporary files is apparently too high for the info grid format. Is there any workaround? Can I control the format of these temporary files so they can be stored as IMG instead? Is there a way to cleanup the temporary files during the script run? These are not "intermediate" files, ArcGIS seems to create them behind the scenes. My workspace and scratch workspace are set to two different file geodatabases but these temporary files seems to be created in C:\Users\<username>\AppData\Local\Temp regardless. Can I control where these files get created? Regards, Filip.
... View more
07-06-2015
09:52 AM
|
0
|
1
|
538
|
|
POST
|
Hi, Our sys admin has increased the table space size (it was 32GB in size but only 198MB free, 99% used) and everything seems to work now. He's kicking himself for misreading the error message Thank you all for your help. Filip.
... View more
07-03-2015
06:30 AM
|
1
|
0
|
3561
|
|
POST
|
Hah, looks like a similar question was asked nearly at the same time: Automated Pipe Count in Attribute Field?
... View more
06-26-2015
02:07 PM
|
0
|
0
|
495
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-05-2014 04:40 AM | |
| 1 | 02-08-2015 12:49 PM | |
| 1 | 07-20-2014 12:41 PM | |
| 1 | 03-23-2017 01:48 PM | |
| 1 | 08-18-2014 04:14 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|