Limit geoprocessing service working extent

3170
4
06-24-2015 07:08 AM
ModyBuchbinder
Esri Regular Contributor

Hello all

When you use query in WAB you get an option to limit the selection to the current
extent or any polygon.

I could not find any way to do the same for geoprocessing service.

For example I would like to buffer just lines in the current extent.

Is there any way to add this option in the service or in WAB?

Thanks

Mody

0 Kudos
4 Replies
FilipKrál
Occasional Contributor III

Hi Mody,

I don't think there is a really easy way to that but this is what I would try.

Add another parameter to your service to specify processing extent of the geoprocessing service and implement it internally in the script/model used for the service.

Alternatively, if you are sending in the lines to buffer as a parameter, bounce them off the server's geometry service clip operation to clip them before you send them to the buffer service. Some client side APIs should support the clip operation so you could do the clipping on the client side. All this is of course viable only if you are dealing with fairly few and simple features.

Filip.

XanderBakker
Esri Esteemed Contributor

Not sure if the extent parameter type when published to the server has the "Same as Display" option:

Would be an interesting test.  Set it as Filip Král suggests to the environment setting for processing extent:

arcpy.env.extent = extent

0 Kudos
ModyBuchbinder
Esri Regular Contributor

I tried it and it did not solve the problem (Ask to type in coordinates)

I found a solution that is not ideal but it is working.

See my screen shots.

  1. Define a parameter as feature set (polygon) in the script parameters
  2. In the script – use it for selection:

extentFeat = arcpy.GetParameterAsText(4)
arcpy.MakeFeatureLayer_management(City,
'cities_lyr')
arcpy.SelectLayerByLocation_management
'cities_lyr', 'INTERSECT', extentFeat)

Do buffer on 'cities_lyr'

  1. In WAB I get this as a polygon the user need to enter.

I do not have the option to SameAsDisplay but the user can easily draw a rectangle.

Any better idea?

Thanks

Mody

param1.pngparam2.png

FilipKrál
Occasional Contributor III

Hi, that is pretty much what I had in mind except that I thought you could supply the extent from map.extent in JavaScript. That would be like using "current map display" but I don't know how to do this in Web App Builder out of the box (or any other way).

Filip

0 Kudos