|
POST
|
Not sure if this would help, but perhaps this is causing the issue?
cursor = arcpy.da.InsertCursor(shpname, ["SHAPE@"])
for f in featureList:
cursor.insertRow( )
Perhaps try:
with arcpy.da.InsertCursor(shpname, ["SHAPE@"]) as cursor:
cursor.insertRow([featureList])
... View more
07-18-2013
06:48 AM
|
0
|
0
|
1046
|
|
POST
|
You can use the Extent of the raster to get the lower-left, lower-right, upper-left, and upper-right points and just add these to a new polyline or polygon feature class.
inputRaster = r"C:\MyRaster"
desc = arcpy.Describe(inputRaster)
ext = desc.extent
ll = ext.lowerLeft
ul = ext.upperLeft
lr = ext.lowerRight
ur = ext.upperRight
arcpy.CreateFeatureclass_management(r"C:\Documents\ArcGIS\Default.gdb","extentoutput", "POLYGON")
outFC = r"C:\Documents\ArcGIS\Default.gdb\extentoutput"
array = arcpy.Array([ll, ul, ur, lr])
pg = arcpy.Polygon(array)
with arcpy.da.InsertCursor(outFC, ["SHAPE@"]) as cursor:
cursor.insertRow([pg])
Edit: If you want it as a polyline output FC, then be sure to add the starting point at the end to "close" the polyline as a bounding box:
inputRaster = r"C:\MyRaster"
desc = arcpy.Describe(inputRaster)
ext = desc.extent
ll = ext.lowerLeft
ul = ext.upperLeft
lr = ext.lowerRight
ur = ext.upperRight
arcpy.CreateFeatureclass_management(r"C:\Documents\ArcGIS\Default.gdb","extentoutput", "POLYLINE")
outFC = r"C:\Documents\ArcGIS\Default.gdb\extentoutput"
array = arcpy.Array([ll, ul, ur, lr, ll])
pl = arcpy.Polyline(array)
with arcpy.da.InsertCursor(outFC, ["SHAPE@"]) as cursor:
cursor.insertRow([pl])
... View more
07-18-2013
05:47 AM
|
0
|
0
|
990
|
|
POST
|
Excel is a good tool for cobbling... But getting the data squared away is not so very difficult with scripting. Mucking about with Calculate Field is not the way to do it, however. Assuming you have already added 6 new Results (numeric) fields to your table (Result1, Result2, and so on) and that the data string is in a field called BigFunkyField and the fc is c:\FileGeodatabase.gdb\inFC..... This is not elegent, and not tested, but.... It also turns the number strings into real numbers... No doubt. I tend to always approach my development from a database-centric position --- that is, if the database (or GIS layer in this case) is properly designed and maintained, then there is never any need to cobble things together and I set myself up to better be able to develop elegant solutions. Though I'd question if any of my python apps could be considered elegant 🙂 ...I am much more of a RDBMS database/N-Tier application developer that is now working in a python scripting world but continually find similarities where I can bring those experiences into my new world.
... View more
07-10-2013
11:08 AM
|
0
|
0
|
2096
|
|
POST
|
If it were me I'd focus on getting the data squared away first instead of attempting to cobble it all together with scripting. Use some proper database design technique and get the data of interest into appropriate fields --- you may even want to use another tool that has friendlier string manipulation functions like MS Excel, THEN get your spatial data in order. I wish I had a direct solution for you! But in your case it appears that you will be attempting to apply database methodology (what GIS data really is) to a hodgepoge of strings contained in a single field (an improper database design approach).
... View more
07-10-2013
04:19 AM
|
0
|
0
|
2096
|
|
POST
|
You could use a cursor with a sort on it: infc = my input feature class myField = field I am after the max value from OID = ObjectID field of my FC. maxValue = arcpy.SearchCursor(infc, "", "", "", myField+ " D").next().getValue(OID) change the myField field to the one you want the max value from and grab the "OID" of that record as maxValue variable. this would give you the values, could then use that to select by. R_ NICE!!! I will def use this one, Rhett.
... View more
07-09-2013
09:32 AM
|
0
|
0
|
4266
|
|
POST
|
Is there a way to select a record based on the highest value of a field? And also is there a way to check if a record is selected based on the highest value before I update a record? Thanks I don't have a specific example to show, but I can think of a few ways to go: 1. Summary Statistics usage. This would require you to output a table to some location, then you could grab the max value for the field you are summarizing on. Probably not best for an in-memory workflow though. http://resources.arcgis.com/en/help/main/10.1/index.html#//00080000001z000000 2. You could convert your fc/table to a numpy array and then derive the the max value from the array. This may be your most direct approach and can be done without writing anything to disk. Look at the code sample in the link as it shows a very simplified way to get your statistic (you could just set a variable to your max value then use it later in your updateCursor). http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000015000000 3. I suppose you could also just create a basic list of values from your field you want to summarize the max value for and set this to a variable. I'd probably opt for the #2nd option myself. j
... View more
07-09-2013
06:39 AM
|
0
|
0
|
4266
|
|
POST
|
Hi guys, Is there a way to force the updates to occur only on the selected record? Right now if I don't have something selected all the records are updated when the user enter the parameters. Thanks!! Maybe you can just test if there is anything selected with GetCount_management first? http://resources.arcgis.com/en/help/main/10.1/index.html#//0017000000n7000000 If it passes your validation, then run the updates, if not then just exit.
... View more
07-09-2013
06:26 AM
|
0
|
0
|
499
|
|
POST
|
You're right, my mistake. But my question is still similar, if I have a folder full of rasters, can I add them together in python? Or is there another way to do it with shapefiles? Here's an example of how to run two rasters through the Addition function of the raster calculator: http://resources.arcgis.com/en/help/main/10.1/index.html#//005m000000mv000000 What I am unsure of is how you will identify the individual pairs of rasters within the folder. Also, while it may not be necessary, I'd recommend managing the rasters with a File Geodatabase rather than simply keeping them in a folder. In some instances issues tend to popup if they simply reside in a folder, it may also aid in your arcpy processing too. j
... View more
07-08-2013
10:34 AM
|
0
|
0
|
1060
|
|
POST
|
Are they shapefiles or raster images? I thought the raster calculators' addition funciton is for adding cell values in a raster image? (I guess I am not understanding why you'd run a shapefile through a raster calculator operation -- I really don't know if that is possible or not).
... View more
07-08-2013
10:12 AM
|
0
|
0
|
1060
|
|
POST
|
It is SQL server. I think it's 2008. I am not sure if this is the issue, just something you may want to follow up on or look into since it's SQL Server 2008... http://msdn.microsoft.com/en-us/library/ms187005(v=sql.105).aspx Good luck! j
... View more
07-08-2013
05:13 AM
|
0
|
0
|
3614
|
|
POST
|
It's not citrix, just a regular work station. I've ran the script while I've been sitting in front of the computer and have it error out 3 minutes in. I've also had it finish while it's been locked. It just seems so random. I thought about it maybe a network or database issue. Is your SDE running on SQL Server?
... View more
07-08-2013
05:09 AM
|
0
|
0
|
3614
|
|
POST
|
Is your SDE running on SQL Server? Sounds more likely a problem related to network hiccup or updates/patches being applied overnite, maybe the workstation you are running this on is timed-out/logging-off/entering sleep mode during the run? Is this run on a Citrix machine? We have to adjust our session time-outs for long running batch processes otherwise the script will quit/fail when the session ends. James
... View more
07-08-2013
05:03 AM
|
0
|
0
|
3614
|
|
POST
|
Per my last post: I am not so sure that the Definition Query suggestion I made will work. Maybe I missed something along the way, but I published a map service with a definition query setup and it did not get honored after being published to ArcGIS Online portal (corporate account). Sorry for any confusion I may have caused and will do some additional testing to see if this is a viable approach. Edit: the documentation suggests that, yes, you can apply a def query before publishing the map service. http://resources.arcgis.com/en/help/main/10.1/index.html#//0154000004qs000000 I just must be missing something simple to get it applied. Edit (3:21pm): I just noticed my def query did actually get applied after some time had passed. I bet it has to do with the cache/clear cache or some such thing. So..... My OP suggestion just may be a viable approach --- I actually plan to implement a similar design where the .mxd's data source is updated, the def query set and .mxd published.
... View more
07-01-2013
10:08 AM
|
0
|
0
|
7966
|
|
POST
|
Hi! I have published a feature service and a web map to ArcGIS Online that shows some point features. Every feature has a date attribute that I would like to use for filtering. The filter is easy to set for a certain date but is it possible to set the filters value for current date? So that the filters value would be dynamic. If this is not currently possible, it is a feature that should be implemented. Any way that I can get around this problem? The point is that I have a lot of data in one feature service but I would like to see only those that are dated for current date. Maybe setup a definition query on the feature class (in ArcMap) before you publish it? It should honor the filter you apply to the field, but of course this will require a process to re-publish the map to contain the updates. Edit: you can use the CURRENT_DATE keyword in the definition query. It would look something like this using the query builder: [INDENT]"my_date_field" = CURRENT_DATE[/INDENT] Then you would just need to setup a scheduled task to publish the map service to get it automated.
... View more
07-01-2013
06:11 AM
|
0
|
0
|
7966
|
|
POST
|
Is it possible to create a legend element using Arcpy? I don't believe so (but I'll accept it if I am wrong on this 🙂 ---- the mapping module isn't quite that extensive in comparison to accessibility to ArcObjects with COM development.
... View more
06-26-2013
11:41 AM
|
0
|
0
|
879
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-17-2020 10:47 AM | |
| 1 | 10-25-2022 11:46 AM | |
| 1 | 08-08-2022 01:40 PM | |
| 1 | 02-15-2019 08:21 AM | |
| 2 | 08-14-2023 07:14 AM |
| Online Status |
Offline
|
| Date Last Visited |
01-22-2025
02:28 PM
|