|
POST
|
Basically, ' '.join(x) makes a new string inserting a space between the items in x. filter(None,y) removes None from a tuple, y. You need to make a new tuple to fit your needs. return ' '.join(filter(None, THE_TUPLE_TO_REMOVE_NONE_FROM))
... View more
03-01-2017
01:04 PM
|
1
|
7
|
3407
|
|
POST
|
Similar to here: join 4 strings to the one if they are not empty in python - Stack Overflow return ' '.join(filter(None, ([INSERTEDMAINSIZE],[INSERTEDMAINMATERIAL])))
... View more
03-01-2017
11:42 AM
|
1
|
10
|
3407
|
|
POST
|
I suppose you could try something like the following, although I've can't think of a time where hardcoding a sleep time solved the real problem: import time
time.sleep(60) # wait for 60 seconds
... View more
03-01-2017
11:28 AM
|
1
|
1
|
2018
|
|
POST
|
Are you sure you need to open ArcMap at all? You can work with things you normally associate with ArcMap (mxds, layers, exporting maps, etc.) from Python (PyScripter) without actually loading the ArcMap application. Are you actually opening the ArcMap application, or just assigning an mxd to a variable?
... View more
03-01-2017
11:07 AM
|
0
|
3
|
2018
|
|
POST
|
Hmmm related to current AWS situation...? edit: yes, Esri just confirmed on Twitter.
... View more
02-28-2017
11:04 AM
|
1
|
5
|
6514
|
|
POST
|
Have you tried a web search? Sorry, but it doesn't take long to figure out that it's called an IDE (integrated development environment). PyScripter - Wikipedia I still use PyScripter; there's not a whole lot more that I'm looking for.
... View more
02-27-2017
09:49 AM
|
1
|
2
|
3107
|
|
POST
|
I'm surprised that it's possible to save a file in the in_memory workspace ending in '.png', although I see that you can. The file isn't actually .png format, though, it's a geodatabase raster (check the layer properties).
... View more
02-24-2017
01:18 PM
|
1
|
1
|
3567
|
|
POST
|
That's only for vector data. Try the Project Raster tool:
... View more
02-23-2017
03:41 PM
|
1
|
0
|
1867
|
|
POST
|
Technically, this works. I'm not always the one to do things the "right" way either, but there are a few reasons not to do it this way: - you need to manually count the field index - this method reads every feature in the feature class. Using a where clause only reads the matching features, through the magic of SQL, which I don't understand, but from the help, "When a query is specified for an update or search cursor, only the records satisfying that query are returned." Anyhow, it seems to take about 3x longer to read through everything, but it likely depends on the data and how many matches there are. Also, to be fair, the results below are representative of several runs, except the first run, which adds about 3s in actually constructing the table view. So, I suppose the main point is that this method is just fine for small data sets, but likely worse for large data sets. import timeit
fc = 'bc_geoname_albers' # ~45,000 features
# SQL method
start_time = timeit.default_timer()
arcpy.MakeTableView_management(fc, "myTableView", "CGNDBKEY LIKE '%C%'")
Count = int(arcpy.GetCount_management("myTableView").getOutput(0))
print (Count,str(timeit.default_timer() - start_time))
# Count method
start_time = timeit.default_timer()
with arcpy.da.SearchCursor(fc, "*") as cursor:
Count = 0
for row in cursor:
if "C" in str(row[4]):
Count+=1
print (Count,timeit.default_timer() - start_time)
(13531, 0.64809157931) # SQL method: 0.65s
(13531, 1.87391371297) # Count method: 1.87s
... View more
02-23-2017
03:22 PM
|
0
|
1
|
2610
|
|
POST
|
I don't have access to 3D Analyst, but as with a lot (all?) of the tools in Spatial Analyst, the results will be in terms of the linear unit of your input data. So, in your case, cubic degrees. Project your DEM to get units that make more sense.
... View more
02-23-2017
01:47 PM
|
1
|
2
|
1867
|
|
POST
|
The city's extent at least appears to be in the correct coordinate area. The Airbnb data seems to have been brought in incorrectly. I downloaded the listings csv and it has the correct coordinates (latitude ~45dd). Try bringing it in again from the csv, specifying WGS84 when you do so.
... View more
02-23-2017
11:14 AM
|
2
|
1
|
1903
|
|
POST
|
The second parameter in the SearchCursor can either be a single field or a list of fields. In your case, you're calling the individual rows 'row', so row[0] is the first field, row[1] is the second field, and so on. with arcpy.da.SearchCursor(fc,['SHAPE@','FACILITYID'],spatial_reference=sr) as cursor: ^ row[0] would hold the shape, row[1] holds facility ID.
... View more
02-22-2017
02:06 PM
|
1
|
2
|
2605
|
|
POST
|
What are the data types for !field_1!, !field_2!, and the field you're calculating into? The syntax 'abs(!field_1! - !field_2!)' should work with the python parser. Is there a selection on your feature layer?
... View more
02-22-2017
01:17 PM
|
0
|
0
|
6215
|
|
POST
|
Your state plane CRS has a linear unit of foot, so the coordinates are reported in units of foot. If you want to report units of decimal degrees, you need to project to a CRS with that unit, like WGS (or perhaps NAD83 for your data). Note that I'm using the PointGeometry object (converted to Point object) returned using the SHAPE@ token, as opposed to the raw coordinates returned by SHAPE@XY. >>> fc = 'points'
... sr = arcpy.Describe(fc).spatialReference
... with arcpy.da.SearchCursor(fc,'SHAPE@',spatial_reference=sr) as cursor:
... for row in cursor:
... print ('{0}, {1}'.format(row[0].centroid.X, row[0].centroid.Y))
... wgs = '4326'
... print ('{0}, {1}'.format(row[0].projectAs(wgs).centroid.X, row[0].projectAs(wgs).centroid.Y))
...
652440.868186, 6194884.158
-120.56334429, 55.8752926871
652438.441583, 6194881.05195
-120.563384785, 55.8752655714
652435.723788, 6194875.81049
-120.563431131, 55.8752193782
652439.541643, 6194871.86322
-120.563372388, 55.8751827363
... View more
02-22-2017
11:49 AM
|
2
|
5
|
2605
|
|
POST
|
Ah, yes, that's right. I was back on the original idea of using SelectLayerByAttributes, which now that I look at it, needs to be preceded by MakeFeatureLayer (or MakeTableView).
... View more
02-22-2017
11:38 AM
|
0
|
0
|
5986
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-30-2013 02:22 PM | |
| 1 | 04-12-2011 11:19 AM | |
| 1 | 09-17-2021 09:43 AM | |
| 1 | 04-04-2012 12:05 PM | |
| 2 | 07-16-2020 11:31 AM |
| Online Status |
Offline
|
| Date Last Visited |
07-15-2023
12:11 AM
|