|
POST
|
There are 300+ lines of code here, a bit complicated to suggest ideas... I do notice multiple spatial selects inside loops. This will add to the execution time. Have you tried using a near table instead, just do it once in other words.
... View more
05-04-2017
12:21 AM
|
0
|
1
|
2986
|
|
POST
|
You have to give it a schema or template, so that the feature set knows what sort of geometry to expect - Point, Line or Polygon
... View more
05-02-2017
11:56 AM
|
0
|
0
|
2435
|
|
POST
|
If this is a geo-processing service, aren't you supposed to return some output to it? Like at the end SetParameter...()
... View more
05-02-2017
11:48 AM
|
1
|
1
|
1822
|
|
POST
|
Saw this question in LinkedIn as well. Thought it very strange. Google = viewing imagery, map directions, street viewing, maybe something I haven't thought of.. esri or ArcGIS, a fully fledged GIS, mapping, analysis, data management etc etc
... View more
05-02-2017
11:42 AM
|
1
|
0
|
5896
|
|
POST
|
Sorry, but... The script writes the output KMZ as expected but fails to show up in the scratch folder where it belongs but So where does the output go?
... View more
05-02-2017
11:29 AM
|
1
|
5
|
1822
|
|
POST
|
Sorry, but I have only dealt with feature sets input. And this is an important way to get user input in a geo-processing script. ie the user inputs some points, or draws a polygon, or what ever. If you want to suck in a geoJson file, or point to an existing feature in any sort of database, that is a different process.
... View more
05-02-2017
11:24 AM
|
0
|
0
|
2435
|
|
POST
|
Sorry, but I am not quite with you here.... You now have a bunch of variables, you can construct a list of those values, then push it through the csv writer to write each line.
... View more
05-02-2017
08:20 AM
|
0
|
0
|
2649
|
|
POST
|
You might do something like this, but you would have to be careful that the order in the fieldList is correct. vals = valueDict[SiteID]
outData = []
for i, fld in enumerate(fields):
outData.append(vals)
... View more
05-02-2017
08:08 AM
|
0
|
0
|
1145
|
|
POST
|
Row 10, the valuedict. Do you know that the first column in the variables from ListFields is actually the key value? Have you printed and looked at what dbffieldList contains. Line 15, I would call the item updateRow as this is the same name as the method on the cursor. So, SiteIDVal is a Key pointer into the valueDict. You would have to recover those values from the dict[keyval]. In what order they are in would depend on exactly what dbffieldList. If dbffieldlist looks like : ["KeyVal", "Val1", "Val2", "Val3"] Then index 0, becomes the Key in the dict and the value is a list starting with "Val1". Remember this when recovering the values after if siteIDval in valueDict: Like : vals = valueDict[siteIDval]
v1 = vals[0] # note that "Val1" from the dbf is now the first value in the list
v2 = vals[1]
v3 = vals[2]
# then go on and construct a data list for the updateRow Hope this helps.
... View more
05-02-2017
07:00 AM
|
1
|
0
|
1145
|
|
POST
|
Okay, so lets have a look at that script so far... The definition of the "fields" dictionary isn't making a lot of sense. fields = {
"OBJECTID": "OBJECTID",
"Global_ID": "Global_ID",
"Global_Copy": "Global_Copy",
"SHAPE@X": "POINT_X",
"SHAPE@Y": "POINT_Y",
"SHAPE@X": "LAT",
"SHAPE@Y": "LONG"
} Each row is a pair of key : value. Supposedly to map fields in the Fc with output fields in the csv. But why would "SHAPE@X/Y" appear twice? Because rows come out of a dict in an arbitrary order, what is mapping the XY to the name in the csv? The tokens "SHAPE@X" & "SHAPE@Y" recover the X & Y from the geometry column of the Fc and will be whatever coordinate system the Fc is in. Reading geometries—Help | ArcGIS Desktop So, maybe this little example will give you an idea. I made a small point feature (5 points), in UTM35S_WGS84. I can read it and print the XY metres, and also the Long/Lat. import sys, os, arcpy
inFgdb = r"C:\Data\ESRI-SA\ForumProblem\scratch.gdb"
inFc = "TestPoints_UTM"
inData = os.path.join(inFgdb, inFc)
inFlds = ["OID@", "SHAPE@"]
srIN = arcpy.Describe(inData).SpatialReference
print "Input SR is {}".format(srIN.name)
srOUT = arcpy.SpatialReference(4326) # GCS_WGS84
print "Output SR is {}".format(srOUT.name)
with arcpy.da.SearchCursor(inData, inFlds) as Cur:
for row in Cur:
ID = row[0] # first item of inFlds list
geom = row[1] # second item of inFlds list
# we have used the geometry object, not the XY tokens
X, Y = geom.centroid.X, geom.centroid.Y
geom2 = geom.projectAs(srOUT)
X2, Y2 = geom2.centroid.X, geom2.centroid.Y
# print out the coordinates, formatted
# 1 decimal for the metres based UTM coords
# 6 decimals for the degree based coords
print "ID {}, UTM metres {:.1f} {:.1f}, Long/Lat {:.6f} {:.6f}".format(ID, X, Y, X2, Y2)
Gives me this output >>>
Input SR is WGS_1984_UTM_Zone_35S
Output SR is GCS_WGS_1984
ID 1, UTM metres 542579.7 7064795.0, Long/Lat 27.427425 -26.536807
ID 2, UTM metres 562671.5 7084560.1, Long/Lat 27.628134 -26.357606
ID 3, UTM metres 590440.6 7078026.2, Long/Lat 27.906892 -26.415105
ID 4, UTM metres 595994.4 7060057.9, Long/Lat 27.963929 -26.576958
ID 5, UTM metres 574759.2 7034085.6, Long/Lat 27.752251 -26.812725
>>> In your script you are using the XY tokens, so have to construct a point geometry from them so it can be projected. I chose do do it using the geometry object itself. Hope this helps.
... View more
05-02-2017
04:58 AM
|
2
|
2
|
2649
|
|
POST
|
So that csv is already exported from a feature class? It has an OBJECTID column. And the presence of POINT_X, POINT_Y would also suggest that this has been used... Add Geometry Attributes—Help | ArcGIS Desktop So, if you haven't got the original feature instead of this exported version, why not just re-import it into ArcMap? There are several ways of adding the XY (in whatever form) back to the point feature. Generally, if the required coordinates are not the actual coordinates of the point feature, I use ArcMap, add the feature, change the coord sys of the data frame to the system I want, then use the calculate geometry option on 2 new columns, use the coord sys of the data frame.
... View more
05-02-2017
12:49 AM
|
0
|
4
|
2649
|
|
POST
|
Forever the scientist They may look nice, but are they representative. Sometimes, a nice picture is all that is required.... I have used kernel densities quite a lot in the past, but you have to be careful about search radii and output cell sizes to be able to interpret the output correctly.
... View more
05-02-2017
12:35 AM
|
0
|
2
|
1405
|
|
POST
|
You could just import the csv, make a point feature out of it, then re-project it to GCS_WGS84 directly. If you want a programmatic solution, then some details of what the csv file looks like would be good.
... View more
05-02-2017
12:27 AM
|
0
|
6
|
2649
|
|
POST
|
Well WKID 3346 appears to be some coordinate system in Lithuania. LKS94 / Lithuania TM: EPSG Projection -- Spatial Reference Line 29, is taking 2 values (X, Y), creating a point geometry in 3346 and then re-projecting them to WKID 4326, which is GCS_WGS84. If you already had a geometry object, the general form would be : geom2 = geom1.projectAs(newSR) Not sure in the original script where X & Y are coming from.
... View more
05-02-2017
12:24 AM
|
1
|
7
|
2649
|
|
POST
|
Have you put a print / AddMessage statement to see what is in the variable "list_of_files" And this if below.... if list_of_files==[]:
arcpy.AddError("list empty") If you want to test if list_of_files has something in it, then use... if len(list_of_files) == 0: Is there any reason that the variable _location_for_tables has to start with an "_". Not sure but that leading underscore might mean something
... View more
04-28-2017
07:12 AM
|
1
|
0
|
3407
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-08-2015 11:28 PM | |
| 1 | 12-20-2013 08:59 PM | |
| 1 | 05-14-2014 10:38 PM | |
| 1 | 12-16-2013 09:05 PM | |
| 1 | 05-31-2019 02:50 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|