0

Using the Query Generator on an ArcGIS REST Feature Layer, I generated a URL that filters the data by a geometry extent ({xmin: -104, ymin: 35.6, xmax: -94.32, ymax: 41}) enter image description here

This returns Current River Conditions from 417 Gauge Stations from the NWS Observations Rest Service.

I want to take this queried layer and add it as a layer in an ArcGIS JavaScript 3.30 Application I am building. I was previously able to add the entire layer (no extent query) as a Feature Layer like so:

#--------------Flood Stages-------------
/*
1) Current Flood Stage Points for Texas with custom symbology and attribute info
*/
var currentFloodStg = new FeatureLayer("https://idpgis.ncep.noaa.gov/arcgis/rest/services/NWS_Observations/ahps_riv_gauges/MapServer/0", {
    copyright: "NOAA/NWS/NWC"
});
map.addLayer(currentFloodStg);

enter image description here However it is a requirement that I filter down the number of points to a restricted area, I am aware that I can potentially query this Feature layer as a Graphics Layer, however considering I have the queried ArcGIS REST API URL, is there a way to add this as an interactive layer on the map through the URL produced by the Query Generator without needing to perform the queries using JavaScript?

I suppose I could adjust that URL to produce a GeoJSON/KMZ/JSON output, and then map that file type in accordance to how the ArcGIS JavaScript 3.30 API documentation dictates that particular data structure can be mapped as its own layer. If there is a simpler method I am all ears!

2

I think a better solution both for performance and simplicity might be to use the FeatureLayer with a definitionExpression. This is possible since your data is point data and the latitude and longitude information is available as specific attribute fields (not just in the geometry).

latitude between 35.6 and 41 AND longitude between -104 and -94.32

REST example

Using JSAPI:

var featureLayer = new FeatureLayer(
  "https://idpgis.ncep.noaa.gov/arcgis/rest/services/NWS_Observations/ahps_riv_gauges/MapServer/0",
  {
    definitionExpression: "latitude between 35.6 and 41 AND longitude between -104 and -94.32"
  }
);
| improve this answer | |
0

UPDATE: This works, however Bjorn pointed me in the right direction with his answer using definitionExpressions, it is significantly more lightweight and seemingly better on performance!

So looking at my options more, I see that the easiest way for me would be to change to ArcGIS Javscript 4.13 and edit the URL to return a Geojson and map it using the GeoJSONLayer Method:

var geojsonLayer = new GeoJSONLayer({
  url: url,
  copyright: "NOAA/NWS/NWC",
  popupTemplate: template
});

To handle this in ArcGIS Javascript 3.3

  • I would need to adjust the URL to return a JSON file.
  • Then using the Javscript API create a new Feature Collection
  • Then create new Layer Definition to match the JSON structure returned by the URL and define the attributes I care about.
  • I can then map that featureCollection as a new FeatureLayer (similar to this Example from the ArcGIS Javascript 3.3 documentation).
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.