Select to view content in your preferred language

ArcGIS Pro SDK for .NET: Support for System.IO.Stream in Geoprocessing tools

381
1
12-14-2022 07:50 AM
Status: Open
Labels (1)
DanielRatzlaff
Occasional Contributor

I've been working on an add-in for Pro 3.0 that automates fetching various GIS data from online sources, processing them and adding them to our projects.  Sometimes it would be very handy if the geoprocessing tools could accept a System.IO.Stream as input rather than a file.

Currently, I am downloading GeoJSON files archived in .zip files and have to extract the files to disk before passing the extracted files to geoprocessing tools. (In this case, JSON to Features)  If I could pass a Stream, I wouldn't have to write all the files to disk first, I could access the ZipArchiveEntry's Stream directly without extracting, processing, and deleting the files again.

I can imagine other use cases as well, like passing a Stream directly from HttpClient to a geoprocessing tool.

1 Comment
JonathanNeal

@DanielRatzlaff Would this code be helpful to you?

import json  
import zipfile  

d = None  
data = None  
with zipfile.ZipFile("./data/drug-event-Q4-0001-of-0013.json.zip", "r") as z:
   for filename in z.namelist():  
      print(filename)  
      with z.open(filename) as f:  
         data = f.read()  
         d = json.loads(data.decode("utf-8"))