CLAWRIM Wiki

The Computational Lab for Advanced Water Resources Informatics and Modeling

User Tools

Site Tools


howtos:how_to_download_features_using_the_arcgis_rest_api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
howtos:how_to_download_features_using_the_arcgis_rest_api [2024-09-24 06:54 am] hchohowtos:how_to_download_features_using_the_arcgis_rest_api [2024-09-24 07:35 am] (current) hcho
Line 1: Line 1:
 ====== How to download features using the ArcGIS REST API ====== ====== How to download features using the ArcGIS REST API ======
  
-This script is just an example of using the ArcGIS REST API to download DFIRM panel features, but if you know the URL of an ArcGIS REST service, you can easily adapt it. +This script requires [[https://jqlang.github.io/jq/|jq]].
-<code bash> +
-./download_arcgis_rest_features.sh https://hazards.fema.gov/arcgis/rest/services/FIRMette/NFHLREST_FIRMette/MapServer/1 firm_panels +
-</code> +
 <file bash download_arcgis_rest_features.sh> <file bash download_arcgis_rest_features.sh>
 #!/bin/sh #!/bin/sh
  
 if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then
- echo "Usage: download_arcgis_rest_features.sh REST_URL filename_prefix"+ echo "Usage: download_arcgis_rest_features.sh REST_URL output"
  exit  exit
 fi fi
Line 17: Line 13:
 rest_url=$1 rest_url=$1
  
-# filename prefix +output filename 
-prefix=$2+output=$2 
 + 
 +prefix 
 +prefix=$(echo $output | sed 's/\..*//')
  
 # starting record offset # starting record offset
Line 90: Line 89:
         offset=$(expr $offset + $count)         offset=$(expr $offset + $count)
 done done
 +
 +# merge geojson files
 +jq 'reduce inputs.features as $s (.; .features += $s) | del(.properties)' *.geojson > $output
 </file> </file>
 +
 +Here is an example:
 +<code bash>
 +./download_arcgis_rest_features.sh https://hazards.fema.gov/arcgis/rest/services/FIRMette/NFHLREST_FIRMette/MapServer/1 firm_panels
 +</code>
howtos/how_to_download_features_using_the_arcgis_rest_api.1727182494.txt.gz · Last modified: by hcho

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki