3

I've done a fair bit of work previously with tools like Google Maps but I'm struggling to be able to do what I want with ArcGIS's REST service.

What I'm trying to do is search this data set using a lattitude/longitude from a user device using the REST API https://services2.arcgis.com/18ajPSI0b3ppsmMt/ArcGIS/rest/services/VicRoads_Declared_Roads/FeatureServer/0

In terms of use case, basically is this lat/long on one of the declared roads and what is the data associated with it

I can essentially mimmic the functionality I want via exploring using the map functionality itself, but it looks like there is some extra processing going on within Esri to convert it to geometry that I don't know how to acheive by just using the REST API

Any suggrestions or recommendations on what to try? I'm sure I'm missing something really obvious.

Vince
  • 20,017
  • 15
  • 45
  • 64
sivin80385
  • 33
  • 3
  • Thank you for the example, how do I go about converting a lat/long to just x,y? Feels like I’m getting close… – sivin80385 Apr 14 '23 at 11:02

2 Answers2

1

A few suggestions:

  • Play around with the query UI, it allows you to enter parameters in a form (use a GET so you can see the parameters in the constructed URL)
  • Read the query doc to see points are specified as just X,Y (Lon=X and Lat=Y)
  • Points will not likely be exactly on the line, so also specify a distance to buffer the point, you should specify the units as well.
  • The feature service spatial reference is EPSG:3111 - GDA94 / Vicgrid so you'll need to provide a spatial reference (inSR) for your Lon, Lat e.g. 4326 (WGS84) or 4283 (GDA94)
  • Specify the spatial relationship as spatialRel=esriSpatialRelIntersects

Example query in Gippsland that outputs geojson and uses the following parameters:

  • geometry=148.176,-37.491
  • geometryType=esriGeometryPoint
  • inSR=4326
  • spatialRel=esriSpatialRelIntersects
  • distance=20.0
  • units=esriSRUnit_Meter
  • outFields=* (return all attribute fields)

Here's the query UI for that example:

enter image description here

user2856
  • 65,736
  • 6
  • 115
  • 196
0

This REST query will return Road [GELANTIPY] within 50m from the lat/lng user2856 used. and all fields Returns GeoJSON

https://services2.arcgis.com/18ajPSI0b3ppsmMt/ArcGIS/rest/services/VicRoads_Declared_Roads/FeatureServer/0/query?where=1%3D1&objectIds=&time=&geometry=148.176%2C-37.491&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelIntersects&resultType=none&distance=50&units=esriSRUnit_Meter&relationParam=&returnGeodetic=false&outFields=*&returnGeometry=true&featureEncoding=esriDefault&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=&defaultSR=&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnQueryGeometry=true&returnDistinctValues=false&cacheHint=true&orderByFields=&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=pgeojson&token=

returns

{
  "type" : "FeatureCollection", 
  "features" : [
    {
      "type" : "Feature", 
      "id" : 804, 
      "geometry" : 
      {
        "type" : "LineString", 
        "coordinates" : 
        [
          [148.177030918245, -37.4913535086331], 
          [148.176888056326, -37.4913514573575], 
          [148.176748895893, -37.4913156772813], 
          [148.176586076459, -37.4912410266395], 
          [148.176210195704, -37.490943879949], 
          [148.175761338206, -37.4906135728498], 
          [148.175437440468, -37.49046789203], 
          [148.17516416374, -37.4904050752282], 
          [148.174820576907, -37.4903709408493], 
          [148.174494407311, -37.4903401202959], 
          [148.174150635502, -37.4902834395874], 
          [148.17394949469, -37.490237663762]
        ]
      }, 
      "properties" : {
        "OBJECTID" : 804, 
        "FNODE_" : 812, 
        "TNODE_" : 810, 
        "LPOLY_" : 0, 
        "RPOLY_" : 0, 
        "LENGTH" : 310.263910266854, 
        "CL_RDS_S_" : 804, 
        "CL_RDS_S_ID" : 8231, 
        "DEC_NAME" : "GELANTIPY", 
        "DEC_TYPE" : "ROAD", 
        "RD_NAME" : "GELANTIPY", 
        "RD_TYPE" : "ROAD", 
        "LOCAL_NAME" : "GELANTIPY", 
        "LOCAL_TYPE" : "ROAD", 
        "ALT_NAME" : " ", 
        "ALT_TYPE" : " ", 
        "ALT2_NAME" : " ", 
        "ALT2_TYPE" : " ", 
        "RD_SUFFIX" : " ", 
        "LOCAL_SUFFIX" : " ", 
        "ALT_SUFFIX" : " ", 
        "ALT2_SUFFIX" : " ", 
        "RD_NUM" : 5570, 
        "RD_SECTION" : "01", 
        "CLASSN" : "MR", 
        "SH_PARMS" : "EG", 
        "REG_PARMS" : 1, 
        "RD_STATUS" : "E", 
        "ARTERIAL" : "S", 
        "DIVIDED_RD" : "ND", 
        "OD_ROUTE" : 99, 
        "B_DOUBLE" : "Y", 
        "PROFILE" : 1, 
        "COMPLEX" : 0, 
        "RTE_NO" : 5570, 
        "CWAY" : "B", 
        "SERVICE_RD" : "N", 
        "RAMP" : " ", 
        "CBR" : "N", 
        "R_RTE_NO" : 0, 
        "R_CWAY" : " ", 
        "R_RAMP" : " ", 
        "SRNS1" : "C608", 
        "SRNS2" : "N", 
        "SRNS3" : "N", 
        "MEL30_ART" : "N", 
        "PPTN" : " ", 
        "RMANUM" : 5570, 
        "RMACLASS" : "AO", 
        "RAMP_NUM" : 0, 
        "RAMP_NAME" : " ", 
        "DEC_STATUS" : "DECLARED", 
        "PREV_RMA" : 0, 
        "AUSLINK" : "N", 
        "AMP" : 4, 
        "RMC" : 5, 
        "R_REG_CODE" : 1, 
        "HTVN_FL0" : 15374, 
        "HTVN_FL1" : 5135, 
        "LOCALITY_A" : "BUCHAN", 
        "LOCALITY_B" : "BUCHAN", 
        "Shape__Length" : 310.263910269316
      }
    }
  ]
}
Mapperz
  • 49,701
  • 9
  • 73
  • 132