0

I'm trying to download hurricane data from ArcGIS. There are two things I can do.

  1. I can go to their web interface at https://services9.arcgis.com/RHVPKKiFTONKtxq3/ArcGIS/rest/services/Active_Hurricanes_v1/FeatureServer/1/query Set a few values ('Where' field I set to 1=1, 'Out Fields' I set to *) Then scroll to the bottom and click the "Query(GET)" button. Some values come up on the screen. All Good, but no shape data.

  2. I can use Python (this is my real goal). I have a script to do this.


import urllib.request, urllib.error, urllib.parse
import json



url_json= 'https://services9.arcgis.com/RHVPKKiFTONKtxq3/ArcGIS/rest/services/Active_Hurricanes_v1/FeatureServer/0/query?where=1%3D1&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=*&returnGeometry=false&featureEncoding=esriDefault&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnQueryGeometry=false&returnDistinctValues=false&cacheHint=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=pjson&token='    

response = urllib.request.urlopen(url_json) 

webContent = response.read()  # byte string of the JSON result

jsonContent = json.loads(webContent)  # create a JSON object from the byte string

for object in jsonContent['features']:
    rec = {}  # create an empty dictionary for each feature 

    for k in object['attributes'].keys():
        rec[k] = object['attributes'][k] 

To get the url I used in the python program, I just pressed the button on (1) and then used the info in the url bar. Only difference is I selected json instead of html for output.

Problem: I can't figure out how to get it to return the blob for the shape info.

Does his API permit that?

If so, what do I do to in the query window and in the url to get it?

4
  • 1
    You will likely need a python rest api library. example: pypi.org/project/bmi-arcgis-restapi – Mapperz Dec 16 '20 at 2:49
  • 1
    That query doesn't return any geometry, because you specified returnGeometry=false – Vince Dec 16 '20 at 4:45
  • I was unclear. I tried that switch, but it only returns a single point and not the polygon I expected. I think this particular service only is intended to return individual points and not polygons. Still looking at the relation between the different services, but I think that's what's going on. – elbillaf Dec 16 '20 at 4:53
  • Using the rest API would be a third way and that link is particularly useful, even though it doesn't immediately yield what I was expecting. – elbillaf Dec 16 '20 at 4:55
0

As this is too long for the comments...

Using this url for all the points in GeoJSON: https://services9.arcgis.com/RHVPKKiFTONKtxq3/ArcGIS/rest/services/Active_Hurricanes_v1/FeatureServer/1/query?where=1%3D1&objectIds=&time=&geometry=&geometryType=esriGeometryPoint&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=&returnGeometry=true&featureEncoding=esriDefault&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnQueryGeometry=false&returnDistinctValues=false&cacheHint=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=pgeojson&token=

Response:

{
  "type" : "FeatureCollection", 
  "features" : [
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          168.300000000745, -12
        ]
      }, 
      "properties" : {
        "STORMNAME" : "Yasa"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          168.60000000149, -12.1999999992549
        ]
      }, 
      "properties" : {
        "STORMNAME" : "Yasa"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          168.800000000745, -12.3999999985099
        ]
      }, 
      "properties" : {
        "STORMNAME" : "Yasa"
      }
    }, 
1
  • I'm about to knockoff for the evening and I have a few things I have to take care of in the morning, but I'll get back to this and try that. tx – elbillaf Dec 16 '20 at 5:27
0

A non python rather simple yet manual way

You can use QGIS to download the data using this the ArcGIS online rest url you provided https://services9.arcgis.com/RHVPKKiFTONKtxq3/ArcGIS/rest/services/ Right click on ARCGIS Feature server Select New Connection paste the URL

Find the data you need and right-click export layer to file and choose shp or geopackage. [export layer to file3

Extending this concept you can use pyqgis to automate this: Adding ArcGIS-FeatureServer-Layer to QGIS using PyQGIS?

1
  • This the way, normally this is the quickest route, but I think that @elbillaf is looking for a way in python to do this. – Mapperz Dec 16 '20 at 14:39

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.