POST
|
Robbie Bagby & Eric Shreve put me on the right trail above. The key is this method: https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.features.managers.html#arcgis.features.managers.FeatureLayerCollectionManager.overwrite Connect to your server, get the right layer (named 'layer' in the code snippet below), and then do the following: collection = arcgis.features.FeatureLayerCollection.fromitem(layer)
overwrite_result = collection.manager.overwrite(file_path) In my case, I was creating a hosted feature layer from a GeoJSON, but it will work with a shapefile, FGDB, etc. It will create duplicate items with the same name, but one is type "Feature Layer (hosted)" in the web interface (which is callled "Feature Service" in the API) and the other is JSON, FGDB, shapefile, etc. You want to find and use the former layer in the example above. Also note that when I was doing this last year, it would always overwrite the symbology I set on it every time I updated the data. This seemed like a bug, so maybe it's fixed now, but FYI.
... View more
01-29-2019
04:24 PM
|
2
|
1
|
4012
|
POST
|
Geofy Admin - Thanks for the info. Glad to hear they're listening to our forum posts! I am using an earlier version, so will look to upgrade the next time I re-open this project. The docs say this is only for built-in security - does that mean this is not available when using enterprise logins?
... View more
09-12-2018
03:06 PM
|
0
|
2
|
3287
|
POST
|
No, not in the Python API. It sounds like it intentionally abstracts it for you. Note that if you put in a bad user/pass combination, the error will say it was unable to generate a token. You might be able to open the wheel file and figure out how they do it, but that might violate the EULA, but more importantly, you'd be maintaining your own code, which defeats the purpose of using an API that's supposed to do basic stuff like this for you. Kelly posted some links on how to do it with the REST API, which you could easily automate with Python. I just went with creating a "profile" in the GIS() constructor. It leaves your user/pass sitting around on a server, so you just want to make sure that is appropriately locked down. Since the tokens only last two weeks, I would probably automate a solution to create a new one. I was thinking I might run that on my PC and FTP it over to the server. In the end, that seems too fragile to depend on a desktop machine, so automation would send me back to having my username and password sitting around on a server. With all paths leading to my user/pass sitting on a server, I didn't perceive that there was any benefit to pursuing this further... I wish we could create a longer length token, like you can with ArcGIS Server (up to one year).
... View more
09-12-2018
10:41 AM
|
0
|
4
|
3287
|
POST
|
Jon - I think you are looking for info on ArcPy. This thread is about Esri's other major Python API, called the "ArcGIS API for Python" (not a very creative name). ArcPy requires licensing, whereas the ArcGIS API for Python does not. That is more about working with server products, so you usually have to authenticate to the server, but you don't need any license to use the API itself.
... View more
09-10-2018
05:54 PM
|
1
|
0
|
3182
|
POST
|
I don't know about running a Jupyter notebook. I would recommend making it a .py script and run it at your command line. Assuming this is Windows (since you said "scheduled task" and not "cron"), make sure you can call it from the DOS prompt. I recommend calling it as "<python executable> <script> <parameters>". Get it working that way, and then you should be able to schedule it no problem. In the "actions" tab of a Windows scheduled task, I specify the full path to my Python executable for the "Program/script" textbox, e.g.: "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" Note that this is in double-quotes because it contains a space. Then, in the "Add arguments (optional)" text box, I specify the full path to the Python script, again putting it in double quotes if it contains a space in it. On the "General" tab, I've found that checking "Run with highest privileges" is necessary in some cases. Full disclosure - I don't really understand that, but it resolved some issues I had once, so I check it.
... View more
08-24-2018
11:08 AM
|
0
|
0
|
1163
|
POST
|
Hi Rachel, Thanks for the link. My question was asking if the symbology options for raster data wind barbs in ArcMap/Pro also exist in AGOL. They are really handy since my data are already in raster format and they also resample the data nicely at multiple scales. I suspect that I will end up creating point layers at a few scales and displaying them using this methodology in order to publish to AGOL.
... View more
07-23-2018
01:15 PM
|
0
|
0
|
1103
|
POST
|
I updated the source using the same dataset for the in and out and it worked! Thanks! datapath = 'C:\\temp\\2018-06\\WRF_wind_barbs_screenshots'
import arcpy
import os
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps('*')[0]
lyr = m.addDataFromPath(os.path.join(datapath, 'wrfout_d3.2015081400.f13.0000.UV10.tif'))
lyr0 = m.listLayers()[0]
print(lyr0)
asfl = arcpy.ApplySymbologyFromLayer_management(lyr0, os.path.join(datapath, 'wind_barbs_uv.lyrx'))
in_dict = {'dataset': 'wrfout_d3.2015081400.f13.0000.UV10.tif', 'database': datapath}
out_dict = {'dataset': 'wrfout_d3.2015081400.f13.0000.UV10.tif', 'database': datapath}
lyr0.updateConnectionProperties(in_dict, out_dict)
... View more
06-29-2018
12:12 PM
|
1
|
0
|
4472
|
POST
|
Updating the connection (same input and output) worked for me, thanks! datapath = 'C:\\temp'
import arcpy
import os
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps('*')[0]
lyr = m.addDataFromPath(os.path.join(datapath, 'wrfout_d3.2015081400.f13.0000.UV10.tif'))
lyr0 = m.listLayers()[0]
print(lyr0)
asfl = arcpy.ApplySymbologyFromLayer_management(lyr0, os.path.join(datapath, 'wind_barbs_uv.lyrx'))
in_dict = {'dataset': 'wrfout_d3.2015081400.f13.0000.UV10.tif', 'database': datapath}
out_dict = {'dataset': 'wrfout_d3.2015081400.f13.0000.UV10.tif', 'database': datapath}
lyr0.updateConnectionProperties(in_dict, out_dict)
... View more
06-29-2018
12:07 PM
|
0
|
1
|
3974
|
POST
|
That was adding the layer, then getting the reference to it from the layer list, and then applying the symbology. I wasn't doing the middle step, instead using the layer object. When I tried that approach, I got the same result. Thanks, though.
... View more
06-25-2018
03:09 PM
|
0
|
0
|
4472
|
POST
|
Hi all, I am trying to add a TIF file as an ArcGIS Pro map layer and apply symbology from a .lyrx file. If I manually drag a TIF file onto the map and import the .lyrx file, it draws just fine. These data layers are dynamic, so I want to automate adding many of these TIF files and symbolizing them via python. I found 2 different ways to use python to add a TIF file as a new map layer, but I'm stuck on applying the .lyrx file. With either approach, I then use arcpy.ApplySymbologyFromLayer_management to try to set the symbology. I never get a python error, but it doesn't have any effect. The new layer is just there with the default stretched black-to-white color ramp. datapath = 'C:\\temp'
import arcpy
import os
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps()[0]
# approach 1 - creates a layer with a name I assign
arcpy.MakeRasterLayer_management(os.path.join(datapath, 'wrfout_d3.2015081400.f13.0000.UV10.tif'), 'f13')
<Result 'f13'>
asfl = arcpy.ApplySymbologyFromLayer_management('f13', os.path.join(datapath, 'wind_barbs_uv.lyrx'))
asfl
<Result 'f13'>
# approach 2 - creates a layer with the same name as the TIF
lyr = m.addDataFromPath(os.path.join(datapath, 'wrfout_d3.2015081400.f13.0000.UV10.tif'))
asfl2 = arcpy.ApplySymbologyFromLayer_management('wrfout_d3.2015081400.f13.0000.UV10.tif', os.path.join(datapath, 'wind_barbs_uv.lyrx'))
asfl2
<Result 'wrfout_d3.2015081400.f13.0000.UV10.tif'>
Possibly relevant details: I am using the "Vector Field" symbology type The TIF has 2 bands for the U and the V direction components (these are set in .lyrx file) I also tried plugging the default band names ("Band_1" & "Band_2") into the "symbology_fields" parameter of the ApplySymbologyFromLayer_management function. It also had no effect. Updated from 2.1.2 to 2.1.3 with the same result. I'm not sure if I'm doing the wrong thing or missing a step. In the help, it shows ApplySymbologyFromLayer_management being used to apply symbology to another layer file, so I'm guessing it's not meant to applied to a map layer, but I don't know where to go from there. Thanks!
... View more
06-25-2018
12:05 PM
|
0
|
9
|
6415
|
POST
|
I have been using the "Vector Field" option for displaying wind barbs from raster data representing the U,V components of wind speed. I'm pretty happy with that in Pro or ArcMap, since it works with the data I have, so I don't have to convert it to vector data. Here is the methodology I'm using. Drawing raster data using vector symbols—Help | ArcGIS for Desktop I was wondering if anyone has had any luck doing something like this in ArcGIS Online?
... View more
06-19-2018
01:11 PM
|
0
|
3
|
1341
|
POST
|
Check this out: https://www.esri.com/arcgis-blog/products/product/analytics/displaying-speed-and-direction-symbology-from-u-and-v-vectors/ I think this answers your questions, but note that you can also display raster wind data as point wind barbs. Met data often come in raster U & V components (speed east, speed north - negative values go the opposite direction), and ArcMap (and ArcGIS Pro) can symbolize the rasters as points. This isn't really what you're asking, so I won't go into detail, but if you start with a raster, you don't need to convert it into points.
... View more
06-19-2018
11:59 AM
|
0
|
0
|
830
|
POST
|
Do you mind posting the whole script to update the resources and publish it? I have the same issue with a GeoJSON file I published as a hosted feature service. thanks!
... View more
03-07-2018
12:31 PM
|
0
|
1
|
3401
|
POST
|
Hi everyone - I have a GeoJSON file that I loaded to ArcGIS Online as a hosted feature layer. The GeoJSON file updates periodically, and I want to automate overwriting the whole AGOL hosted feature layer layer with the latest data. I am using Python to automate this, and I honestly don't care if I use the ArcGIS API for Python or just interact with the REST services directly. I'd like to avoid ArcPy so I can install it on a linux server with no other ArcGIS software. Manually, it's really easy to do this (see screenshot). I initially loaded a GeoJSON file to AGOL. I find its hosted feature layer, click on "Update Data", select the overwrite option, select the new file, and it's all taken care of. This is the process I'd like to automate. In the ArcGIS API for Python, I see the FeatureLayer object has an append method, which looks like what I want. That method has an "upload_format" input, and "geojson" is one of the options. But where and how do I pass in the GeoJSON file itself? I couldn't find any code samples of this. Note1: I suppose I could read the GeoJSON and construct a "regular" feature request, but I'd like to find a way to just upload the whole GeoJSON file, like I can do with the AGOL web GUI. Note2: I probably need to delete old features before I append, but I know how to do that, if needed. As I said, I am ok with just interacting with the REST API via Python, if that's any easier. I tried watching Chrome Developer Tools while I did the manual steps above, but I couldn't quite figure out how to replicate that. thanks!!!
... View more
03-06-2018
05:43 PM
|
0
|
8
|
5060
|
POST
|
Rebecca - I have not noticed any difference in my IDE or at the DOS prompt. I use the PyDev plugin to Eclipse. When you set up a new python project, you have to point it to your interpreter (I have a 2.7 from ArcGIS and a 3.6 I installed myself, plus I think Pro has one and QGIS might, too). Once you do that, it is pretty much the same thing as running it at the DOS prompt, except that you get debugging and integration into your project (right-click >> run), but the actual execution is pretty much the same.
... View more
02-15-2018
03:45 PM
|
0
|
0
|
3171
|
Title | Kudos | Posted |
---|---|---|
1 | 09-10-2018 05:54 PM | |
1 | 11-17-2017 05:15 PM | |
1 | 02-08-2018 10:08 AM | |
1 | 02-15-2018 11:55 AM | |
1 | 06-29-2018 12:12 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|