POST
|
Is there a standard way to re initialize a widget? I just want to enbable my users to reset the widget back to the initial state if they decide to start again. Cheers Jim
... View more
10-23-2019
05:47 AM
|
0
|
2
|
590
|
POST
|
I ended up turning my 2 feature classes into a single feature class and just clipping that, that way all features were clipped together and I managed to return both clipped polygons. So a workaround rather than an answer but works
... View more
10-23-2019
03:14 AM
|
0
|
0
|
641
|
POST
|
I'm trying to use a polygon supplied by the user to return a single feature class with multiple records in it. I am clipping from 2 polygons sucessfully, they both have the same attributes. I then thought I would just stick them into a feature class or set, return that and I would be good to go. I tried to create a FeatureSet then use .load() to load my results into it. But I only get the last result from the loop, it only ever returns a single result but I want to return multiple. arcpy.env.overwriteOutput = True
arcpy.env.workspace = r'C:\Jim\BSelect.gdb'
fcList = arcpy.ListFeatureClasses()
print(fcList)
poly = arcpy.GetParameterAsText(0)
limits = ['Limits_UK_Mosaic',
'Limits_UK_COMORG']
def cliplimit(clippee, clipper, output):
arcpy.Clip_analysis(clippee, clipper, output)
feature_set = arcpy.FeatureSet()
# loop limits and clip tifs
for i in range(len(limits)):
arcpy.AddMessage(limits[i])
output = 'in_memory\\' + limits[i]
cliplimit(limits[i], poly, output)
feature_set.load('in_memory\\' + limits[i])
arcpy.SetParameter(1, feature_set) There something I dont get about feature class/sets I think not sure. I just want to return a thing with both results in to my web app but I can only get one atm. Cheers Jim
... View more
10-15-2019
07:48 AM
|
0
|
1
|
706
|
POST
|
So it seems my error was originated when I extracted the geometry from graphic. _onDrawComplete: function(graphic) {
var geometry = graphic.geometry; The FeatureSet expects the entire graphic to be passed in rather than just the geom.
... View more
10-07-2019
04:10 AM
|
0
|
0
|
433
|
POST
|
I am trying to call a geoprocessor from WAB that will clip some tiffs and supply them to the user. I am passing in a list of boolean and a polygon to clip to. I am getting the polygon from the dawbox dijit as shown below. postCreate: function() {
this.inherited(arguments);
this.drawBox.setMap(this.map);
this.drawBox.showClear = true;
this.drawBox.keepOneGraphic = true;
this.own(on(this.drawBox, 'DrawEnd', lang.hitch(this, this._onDrawComplete)));
},
_onDrawComplete: function(graphic) {
var geometry = graphic.geometry; I then attempted to pass this directly into the geoprocessor which resulted in an error, apparently it needed to be a GPFeatureSet. I got around this error by creating a featureset with my geom in, and passing that to the geoprocessor. var features = [];
features.push(geometry);
var featureSet = new FeatureSet();
featureSet.features = features;
// setup gp stuff and params
var params = { "BoolList":boollist, "poly": featureSet };
var gp = new Geoprocessor('https://arcgispreprodent.admiralty.co.uk/server/rest/services/Jim/BathyClip/GPServer/BathyClip') The problem I appear to have now is that poly is always an empty string when I get to the geoprocessor. If I log poly before I execute the GP it has values, but if I log poly from within the GP its an empty string, the boolean list is passing fine but the poly param is empty. What do I need to do to pass a polygon to my geoprocessor?
... View more
10-04-2019
04:15 AM
|
0
|
1
|
499
|
POST
|
I abandoned this method in the end, went on the server, adjusted all the paths that it changed at upload to point at a local copy of my gdb, bit hacky but it worked.
... View more
10-02-2019
06:37 AM
|
0
|
0
|
531
|
POST
|
I have now published the gdb as a service I have a rest URL. If I want to clip the tiffs in there with a geoprocessor do I have to extract them first or can I just access them directly in the service? Bit confused as the docs for geodata services seem a bit slim compared to other areas.
... View more
09-30-2019
06:05 AM
|
0
|
1
|
531
|
POST
|
Hi I am trying to publish a geoprocessing service. I have a gdb file that is on a server that I am using as my worskpace, it contains a couple of tiffs to clip depending on a user drawn polygon. arcpy.env.workspace = r'\\dacspreprodstorage.file.core.windows.net\preprodcontentstore\Jim\BSelect.gdb' Once I publish my gp srvice it is unable to find this file, it fails as it doesnt find the features to clip. How do I host this GDB on the server so my GP can access it, I assumed as it was on the server it would find it but maybe the path is different from there Im not sure. Do I need to publish this GDB as a service? Will I then be able to set it as my workspace or will I have to change my code significantly? Can I just wack it in a datastore and have the server access it, this is kind of what I thought I had done but maybe my server cant see this storage area. Cheers Jim
... View more
09-30-2019
04:23 AM
|
0
|
2
|
573
|
POST
|
Thanks Brittney, I have got zipfile to work and I am creating a zip in the scratchfolder. Is this the best method if I want to launch this from a widget and have the user download the zip? would in_memory be any better? I still feel a bit confused about workspaces, scratch folders, in_memory. Its currently writing my zip to the default scratch folder, which is not the workspace i set but the default.gdb, will this give me issues? What if multiple users use the tool at the same time, will they be able to both write to the default gdb?, will they overwrite each other? I just feel a bit lost with questions implementing this, I'm going to try and get it firing from my web app and see how it goes! heres my code so far, poly will also become an input parameter. import arcpy, zipfile, os
# Set geoprocessing environments
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r"\\dacspreprodstorage.file.core.windows.net\preprodcontentstore\Jim\BSelect.gdb"
boolList = arcpy.GetParameterAsText(0)
if boolList == '#' or not boolList:
boolList = [True, False] # provide a default value if unspecified
outname = arcpy.GetParameterAsText(1)
if outname == '#' or not boolList:
outname = 'download.zip' # provide a default value if unspecified
#set params
poly = "clipit"
tiflist = ["Whole_UK_Mosaic", "Whole_UK_COMORG"]
def cliptif(clippee, clipper, output):
desc = arcpy.Describe(clipper)
extent = desc.extent
coord_string = "{} {} {} {}".format(extent.XMin, extent.YMin, extent.XMax, extent.YMax)
arcpy.Clip_management(clippee, str(extent), output, in_template_dataset=poly, clipping_geometry="ClippingGeometry")
# loop tiflist and clip tifs
for i in range(len(tiflist)):
# outTif = r"C:\Jim\BathySelect\output\output"+str(i)+".tif"
if boolList[i]:
outTif = os.path.join(arcpy.env.scratchFolder, 'output'+str(i)+'.tif')
cliptif(tiflist[i], poly, outTif)
# zip results
try:
zipper = zipfile.ZipFile(os.path.join(arcpy.env.scratchFolder, outname), 'w')
for i in range(len(tiflist)):
zipper.write(os.path.join(arcpy.env.scratchFolder, "output"+str(i)+".tif"), "output"+str(i)+".tif")
except RuntimeError:
print('there was an error trying to zip')
finally:
zipper.close()
... View more
09-25-2019
04:40 AM
|
1
|
0
|
874
|
POST
|
so it seems my 2 datasets were in different projections that's why I was getting different values for the extents. Once I changed my shapefile projectiont match my tiff projection all my numbers looked good and tif was cropped.
... View more
09-23-2019
04:01 AM
|
0
|
0
|
3047
|
POST
|
Hi I have made a simple tool to clip from a couple of rasters after a list of bool is passed in, it will eventually clip fromn more than just 2 rasters. The clipped rasters are sat in %scratch data% I want to zip them up and offer them as a download at the end of this tool. I have looked at the clip and ship example but that seems to ue a tool to zip and email all in one go, I want to zip then offer a download. How do I zip my clipped tiffs. How do I offer the resulting zip as a download. Should I be using "in_memory"? import arcpy
# Set geoprocessing environments
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r"\\dacspreprodstorage.file.core.windows.net\preprodcontentstore\Jim\BSelect.gdb"
boolList = arcpy.GetParameterAsText(0)
if boolList == '#' or not boolList:
boolList = [True, False] # provide a default value if unspecified
outname = arcpy.GetParameterAsText(1)
if outname == '#' or not boolList:
outname = 'download' # provide a default value if unspecified
#set params
poly = "clipit"
tiflist = ["Whole_UK_Mosaic", "Whole_UK_COMORG"]
def cliptif(clippee, clipper, output):
desc = arcpy.Describe(clipper)
extent = desc.extent
coord_string = "{} {} {} {}".format(extent.XMin, extent.YMin, extent.XMax, extent.YMax)
arcpy.Clip_management(clippee, coord_string, output, in_template_dataset=poly, clipping_geometry="ClippingGeometry")
for i in range(len(tiflist)):
# outTif = r"C:\Jim\BathySelect\output\output"+str(i)+".tif"
outTif = "%scratchFolder%\\output"+str(i)+".tif"
cliptif(tiflist[i], poly, outTif)
Thanks
... View more
09-23-2019
03:28 AM
|
0
|
2
|
987
|
POST
|
So I have made some progress, I realised I could export a modelbuilder version as a script and compare. The problem was my extent I was passing in wasnt in correct format. I now have the extent converted to a string and it runs, but it doesnt clip the right area import arcpy
# Set geoprocessing environments
arcpy.env.workspace = r"C:\Jim\BathySelect\BSelect.gdb"
arcpy.env.overwriteOutput = True
#set params
inTif = r"C:\Jim\BathySelect\Data\Bathy\Whole UK Mosaic.tif"
poly = r"C:\Jim\BathySelect\SelectPoly.shp"
desc = arcpy.Describe(poly)
outTif = r"C:\Jim\output.tif"
extent = desc.extent
arcpy.Clip_management(inTif, str(extent), outTif, poly, "0", "NONE", "NO_MAINTAIN_EXTENT") when I look at the generated script the values it passes in for the same polygon are :- "-610219.285476707 6629015.89017292 -581115.060601592 6655474.27642303" but the figures in my extent are :- “-5.48169310808 51.2315325764 -5.2202454077 51.3805117862” this looks like a lat/lng vs metres problem now but not sure, still after a bit of help.
... View more
09-19-2019
07:59 AM
|
0
|
0
|
3047
|
POST
|
Hi, Im trying to learn to make geoprocessing tools. Making a simple one to clip a raster but getting an error I cant decipher, from googling it looks like some kind of access violation. heres my code import arcpy
# Set geoprocessing environments
arcpy.env.workspace = r"C:\Jim\BathySelect\BSelect.gdb"
arcpy.env.overwriteOutput = True
#set params
inTif = r"C:\Jim\BathySelect\Data\Bathy\Whole UK Mosaic.tif"
desc = arcpy.Describe("SelectPoly")
outTif = r"C:\Jim\output.tif"
extent = desc.extent
rectangle = arcpy.Polygon(arcpy.Array([extent.lowerLeft, extent.upperLeft, extent.upperRight, extent.lowerRight, extent.lowerLeft]), desc.spatialReference)
arcpy.Clip_management(inTif, rectangle, outTif) heres my error C:\Python27\ArcGIS10.6\python.exe C:/Jim/BathySelect/BathySelect.py Process finished with exit code -1073741819 (0xC0000005) I eventually want this to fire from a widget in a WAB app and return a zip file of multiple clipped images.
... View more
09-19-2019
03:16 AM
|
0
|
3
|
4701
|
POST
|
Thanks again, I was just heading here to say I had managed to work it out after some reading about .this, dojo/on, and lang.hitch. Mine does look a little different to yours, I ended up with on(checkbox, "click", lang.hitch(this, this._amendTotal, checkbox.id)) and _amendTotal: function(id){
checkbox = Dom.byId(id)
if (checkbox.checked){
this.total += parseFloat(checkbox.value);
}
else{
this.total -= parseFloat(checkbox.value);
}
console.log(this.total)
}, So both really similar except I'm passing in the ID and I don't have the evt bit. Any chance you could explain the differences to help my understanding? evt seems to hold the checkbox id, what is evt, how does it have the id? why is it not passed in in the on statement? thanks Jim
... View more
09-17-2019
07:26 AM
|
0
|
1
|
1992
|
POST
|
Hi Im trying to attach an onclick functoion to a checkbox. My initial attempt was this, which worked fine checkbox.onclick = function(){
console.log("called")
if (this.checked){
total += parseFloat(this.value);
}
else{
total -= parseFloat(this.value);
}
console.log(total)
}; but the total variable I was amanding didnt have the scop I required, I wanted a global total variable. But the scop of this. has chacnged when in this function and I cant get to the global using this.total as this now refers to the checkbox. my second attempt was this checkbox.onclick = this._amendTotal(checkbox.id) which called _amendTotal: function(id){
checkbox = Dom.byId(id)
console.log(checkbox)
console.log(id)
if (this.checked){
this.total += parseFloat(checkbox.value);
}
else{
this.total -= parseFloat(checkbox.value);
}
console.log(this.total)
}, but this seemed to call it at runtime when checkbox had not been clicked and I got some undefined errors, dom.byID returns null and it crashes before its even drawn a checkbox to click. at this point Im confused, do I need to use dojo/on, if so how do I use that to solve the problem, and why is _amendTotal being called when no click event has happened? Cheers Jim
... View more
09-17-2019
03:06 AM
|
0
|
3
|
2175
|
Title | Kudos | Posted |
---|---|---|
1 | 09-25-2019 04:40 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|