Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3667

Downloading REST data which contains date_time attributes

$
0
0

I am attempting to download data from ArcGIS REST services in ArcGIS Pro using custom geometry. After some help, I've managed to get this to work and save the data as a shapefile. The data I'm downloading contains a "date_time" field, and only the "date" portion is being returned. After doing some reading, I've learned that shapefiles cannot store date_time. I tried saving to a gdb, but it was more complicated than I expected, and I'm a beginner.

Is there a simple way to save this to a gdb and retain "date_time"?

Or modify the query to calculate a "date" and "time" column separately?

Or return "date_time" as a string that I can then convert to "date" and "time" manually?

from arcgis.gis import GISfrom arcgis.features import FeatureLayerfrom arcgis.geometry.filters import intersectsgis = GIS("pro")#The ESRI JSON used to subset the REST datageometry = {"spatialReference": {"wkid": 4326},"rings": [    [      ["-124.785944", "49.142568"],      ["-125.439631", "50.001049"],      ["-124.928766", "50.335311"],      ["-123.735655", "49.654732"],      ["-124.404157", "49.265739"],      ["-124.785944", "49.142568"]    ]  ]}# The REST service URLrest_service_url = "https://gisp.dfo-mpo.gc.ca/arcgis/rest/services/FGP/MSDI_Dynamic_Current_Layer/MapServer/0"# Access the feature layer using the REST service URLlayer = FeatureLayer(rest_service_url)# Query the feature layerfeatures = layer.query(where="1=1", geometry_filter=intersects(geometry, 4326))print(f"Number of features found: {len(features.features)}")# Save to local Diroutput_dir = r"C:\Users\name\Documents\"  # Save features to shpfeatures.save(output_dir, "currents.shp")

Thanks!


Viewing all articles
Browse latest Browse all 3667

Trending Articles