howtos:how_to_download_features_using_the_arcgis_rest_api
This is an old revision of the document!
How to download features using the ArcGIS REST API
This script is just an example of using the ArcGIS REST API, but if you know the URL, you can easily adapt it.
# starting record offset offset=0 # max record count count=2000 # URL for the NFHL ArcGIS REST API url="https://hazards.fema.gov/arcgis/rest/services/FIRMette/NFHLREST_FIRMette/MapServer/1/query?where=1%3D1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&distance=&units=esriSRUnit_Foot&relationParam=&outFields=*&returnGeometry=true&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&havingClause=&returnIdsOnly=false&returnCountOnly=false&orderByFields=OBJECTID&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&historicMoment=&returnDistinctValues=false&resultOffset=---OFFSET---&resultRecordCount=$count&returnExtentOnly=false&datumTransformation=¶meterValues=&rangeValues=&quantizationParameters=&featureEncoding=esriDefault&f=geojson" # infinite while loop; : mean true, so while : means while true, which means forever; # you'll have to manually break out of this infinite loop while :; do # generate a filename fn=firm_panels_$offset.json [ -f $fn ] || wget -O $fn "$(echo "$url" | sed "s/---OFFSET---/$offset/")" # read wget error err=$? # if there was a wget error or the filesize is zero if [ $err -ne 0 -o ! -s $fn ]; then # print the wget error [ $err -ne 0 ] && echo "$fn: wget error $err" # delete broken file rm -f $fn # try it again continue fi # we will only stop when we reached the last record grep -q "exceededTransferLimit.*true" $fn || break # move to the next offset offset=$(expr $offset + $count) done
howtos/how_to_download_features_using_the_arcgis_rest_api.1721577510.txt.gz · Last modified: by hcho