Using REST services to query and export GIS data

REST services provide an alternative way interact with GIS servers. It can be used to select records by attributes and/or location and export the selected data to an open source format. Accessed from a web browser, REST services are form based, rather than graphical, so it can also provide a faster way to query GIS data if a corresponding web map application is slow. In this post I describe how to navigate the REST service for GeoNB and provide examples of how to query and export GIS data using the LiDAR index as an example Map Service layer. I also describe how to extract the URLs to download multiple LiDAR LAZ files using a bounding box and the GeoNB LiDAR index layer.

  1. The REST service for GeoNB can be found here:
  2. This page shows a list of Map Services that GeoNB provides. For demonstration purposes click on GeoNB_SNB_LidarIndex
  3. This page shows metadata about the Lidar Index. Click on the link to the Lidar Inventory / Inventaire de donées Lidar under the Layers section. Note: there can sometimes be multiple layers per service.
  4. This page provides additional meta data pertaining just to this layer in the service. Take note that the MaxRecordCount is set to 50000. This means that you can query up to 50,000 records at a time. For large datasets with complex geometry the MaxRecordCount is often set to 1,000 so multiple large queries don’t affect the performance of the server. Also take note of the field names, these could be useful when querying the data.
  5. Click on the Query link at the bottom of the page. Here is where you can query the data and export to HTML, JSON, AML or KMZ formats.
  6. Here are some examples of queries:
    • Determine the number of records in this layer (enter the following into the relevant sections of the form)
      • Where: 1=1, Return Geometry: False, Return Count Only: True, Format: HTML
      • After clicking on the “Query (Get)” button, the output will be located at bottom of screen, and reads (as of June 28, 2017): Count: 48816
      • There are 48,816 records/polygons in this layer
    • Look at the attributes for the record with an OBJECTID of 1
      • Where: OBJECTID=1, Output fields: *, Return Geometry: False, Return count only: False, Format: HTML
      • Output is located at bottom of screen should show attributes
    • Look at the spatial geometry (coordinates of the polygon vertices) for OBJECTID = 1. A precision of 1 decimal place is also specified, and change the output to JSON so you can see all of the coordinates.
      • Where: OBJECTID=1, Output fields: <leave blank>, Return Geometry: True, Geometry Precision: 1Return count only: False, Format: JSON
      • Output should be located in a new window. Scroll down to see the vertex coordinates of the polygon.
    • Export polygons and attributes with an ObjectID between 1000 and 2000 to a KMZ file
      • Where: OBJECTID>=1000 AND OBJECTID < 2000, Output fields: *, Return Geometry: True, Geometry Precision: <leave blank>, Return count only: False, Format: KMZ
      • A dialogue box should appear prompting you to save the KMZ file. Open the saved file in Google Earth to see the polygons, and the attributes should appear when you click on a polygon.
    • The document at this link provides methods to download multiple LAZ files from GeoNB using a download manager. The URLs are contained in the LiDAR index, and below is an example of how to export the URLs for a bounding box. The bounding box is defined by: min x, min y, max x, max y
      • Input Geometry: 2460720,7384900,2503510,7415750 Out Fields: File_URL, Format: HTML
      • The output can be found at the bottom of the screen, and gives the number of records (1,408) and the list of URLs. These URLs can be used with a download manager to do a bulk download of LAZ files from GeoNB.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s