|
POST
|
I just got the answer. Feel kinda dumb for missing the whole "GetParameterAsText" part. I just added metadata.max_scale = int(max_scale) and it worked fine.
... View more
09-05-2018
09:37 AM
|
0
|
0
|
3199
|
|
POST
|
am using a Python library called arcpy_metadata that uses 2 datatype called max_scale and min_scale that take integers: My code for that is just: import arcpy, arcpy_metadata as md....min_scale = arcpy.GetParameterAsText(5)max_scale = arcpy.GetParameterAsText(6)....metadata = md.MetadataEditor(file)...metadata. min_scale = min_scale metadata.max_scale = max_scale I am trying to turn this into a Python script in ArcMap toolbox. An example input for the max and min scale would 5000 and 150000000. Since there is no integer type and I don't really need decimals, I just entered double when configuring the parameters for the tool. I also set it as ``optional`. When I run the tool however, I keep getting the following error. What am I doing wrong here? RuntimeWarning: Input value must be of type Integer
... View more
09-05-2018
08:37 AM
|
0
|
4
|
3445
|
|
POST
|
Hey Guys, I was actually able to get this working using the arcpy_metadata mod/library. It's super simple, but has some limitations. 1) It only runs with Python 2.7, 2) It's 32-bit, 3) It can't add spatial reference or extent elements (also some of the contact data is a little wonky). Other than that, I made some loops to iterate through the target folder, some conditionals to handle for different file types (only works on features, .lyrs, .shp, and raster datasets). Handling some of these file types is a little difficult but for limited use, it works pretty good.
... View more
09-05-2018
07:50 AM
|
0
|
0
|
3621
|
|
POST
|
I am trying to write a Python script (or find a tool) to batch process metadata for a raster dataset. I have a folder with about 300 .tff files. I want to be able to go into ArcCatalog and see the standard (or FGDC) item description metadata for each of these files. Without creating a literal .xml file for each .tiff file, I am currently trying out the arcpy_metadata module (for Python 2.7 only right now). Is there a simpler way to do this using a tool? I've seen more complicated scripts using the lxml library. Would it better to go that route?
... View more
08-31-2018
06:15 AM
|
0
|
4
|
4468
|
|
POST
|
Yep. You can actually try it yourself with the code above. Thats a public Map service from fema. Just import requests, json and the rest of the code (except arcpy.env.workspace) down to print(cslf). It should work the same for you as me.
... View more
08-20-2018
01:04 PM
|
0
|
1
|
8682
|
|
POST
|
Here's the traceback: Traceback (most recent call last): File "<ipython-input-21-7d5d88079864>", line 1, in <module> runfile('C:/Workspace/Sandbox/ScratchTests/CSLF.py', wdir='C:/Workspace/Sandbox/ScratchTests') File "C:\Users\jbridwell\AppData\Local\Continuum\anaconda3\envs\acrpro\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile execfile(filename, namespace) File "C:\Users\jbridwell\AppData\Local\Continuum\anaconda3\envs\acrpro\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "C:/Workspace/Sandbox/ScratchTests/CSLF.py", line 20, in <module> arcpy.JSONToFeatures_conversion(cslfJson, os.path.join("cslfalso.gdb", "cslf")) File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 403, in JSONToFeatures raise e File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 400, in JSONToFeatures retval = convertArcObjectToPythonObject(gp.JSONToFeatures_conversion(*gp_fixargs((in_json_file, out_features), True))) File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 506, in <lambda> return lambda *args: val(*gp_fixargs(args, True)) RuntimeError: Object: Error in executing tool
... View more
08-20-2018
12:46 PM
|
0
|
3
|
8681
|
|
POST
|
I want to convert some json data being returned from a request to a feature class, but I keep getting a RuntimeError: Object: Error in executing tool . I made a test gdb in a folder 'C:/Workspace/Sandbox/ScratchTests/cslf.gdb' in which to populate my new feature class after conversion. To test that the request is correct and that I am returning Json data, I added a couple of print statements. Otherwise, everything is pretty straight forward. Does anyone see a problem with my code? I am following the arcpy [JSON to Features][1] directions from the documentation. The only thing I am doing differently is instead of using an actual file, I am just plugging in the variable 'cslfJson`. import arcpy, sys, os, arcgis, requests
arcpy.env.workspace = "C:/Workspace/Sandbox/ScratchTests"
params = {'f': 'json', 'where': '1=1', 'geometryType': 'esriGeometryPolygon', 'spatialRel': 'esriSpatialRelIntersects','outFields': '*', 'returnGeometry': 'false'}
r = requests.get('https://hazards.fema.gov/gis/nfhl/rest/services/CSLF/Prelim_CSLF/MapServer/3/query', params)
print(r.url)
cslfJson = r.json()
print(cslfJson)
arcpy.JSONToFeatures_conversion(cslfJson, os.path.join("cslf.gdb", "cslf"))
... View more
08-20-2018
06:55 AM
|
0
|
7
|
11319
|
|
POST
|
While I was not exactly able to solve the mystery of why the layer doesn't show up when I used something like: gis = GIS("<arcGIS Online URL>", "<user name>", "<pass>") myLyrs = gis.content.search(query="") I was able to find a work around. I basically had to call the specific layer: cslfLayer = gis.content.search(query="title: Prelim_CSLF") and then add it to the myLyrs list. Note: Because cslfLayers also gets returned as a list, I can to use a For loop to pull it out: for item in cslfLayer: myLyrs.append(item) cslfLyr = myLyrs[10] I could then view and work with the layer although I am still not sure why the content.search for MyLyrs didn't work.
... View more
08-20-2018
06:47 AM
|
0
|
0
|
1121
|
|
POST
|
I have a Web Map Layer (Prelim_CSLF) in my ArcGIS Online content that is not showing when I call it from the ArcGIS API in a Python script. The Layer comes from a public web mapping service. As you can see, there are other layers in my contents. The ACS Feature Layer also comes from an outside service. In my script, I use the API to connect to my ArcGIS Online content and just want to list the items there. agol = GIS("http://<arcGIS Online url>", "<username>", "<password>") agolList = agol.content.search("") agolList Results = [<Item title:"void_poly2" type:Feature Layer Collection owner:>, <Item title:"PANYNJ_Charrette_Data" type:Feature Layer Collection owner:>, <Item title:"Map_Tour_Fianl" type:Feature Layer Collection owner:>, <Item title:"April3_2018_update" type:Feature Layer Collection owner:>, <Item title:"VA_Port" type:Feature Layer Collection owner:>, <Item title:"GTS_Lidar_Project_Boundaries" type:Feature Layer Collection owner:>, <Item title:"PR_SDE_QC_Batch4" type:Feature Layer Collection owner:>, *<Item title:"ACS" type:Feature Layer Collection owner:jbridwell>*, <Item title:"East_Donegal_Water_Utility_Network" type:Feature Layer Collection owner:>, <Item title:"coastal_dg_polygons" type:Feature Layer Collection owner:>] However, I am not seeing the Prelim_CSLF layer. I do see the ACS layer though (starred *). When I try agol.content.search("Prelim_CSLF", item_type="Map Image Layer") it just returns an empty [] . What is the problem here?
... View more
08-16-2018
06:44 AM
|
0
|
1
|
1250
|
|
POST
|
OK. That is exactly what I was looking for. It appears I missed the part about using that functionality (GIS and .content.search) with an outside service. However, what if I added that service in my arcGIS online account? I could access it that way, right? BTW- Your mapping module idea looks like it will work fine as well.
... View more
08-15-2018
11:35 AM
|
1
|
0
|
10400
|
|
POST
|
This was a difficult question to answer but I was finally able to install Anaconda and having it working with my version of ArcGIS Pro (2.2) and Python (3.6). Most importantly, I can now use both the Jupyter Notebook AND the Spyder IDE. The Jupyter Notebook came bundled with the new version of ArcGIS Pro that I installed, so that issue was taken care of. However, I did a reinstall of Anaconda 3.6 and found that I did not have important packages like arcpy and arcgis (the ArcGIS API for Python essentially). I finally found a a work through that did the trick. Here's a link. Essentially, you have to copy the folder arcgispro-py3 from C:\Program Files\ArcGIS\Pro\bin\Python\envs and paste to C:\Anaconda2\envs. The, rename the copied folder arcgispro-py3 in C:\Anaconda2\envs to arcpro. You have to do 2 main things from there; launch your Anaconda Navigator and check in the Environments tab to make sure that there is an arcpro environment. Then, when you launch Spyder, it will ask you if you want Spyder to access the new arcpro environment. Just click yes. The test it out by typing `:import arcpy`. It should run the code without throwing an error. Finito!
... View more
08-15-2018
11:13 AM
|
0
|
0
|
6873
|
|
POST
|
Yes. I was able to get Jupyter Notebook working and import the arcgis api module. I pretty much scrapped the full Anaconda install yesterday, but just did a reinstall. The verdict is still out, but I'd like to get Spyder working as my primary 3.6 IDE and use Jupyter for testing.
... View more
08-15-2018
10:28 AM
|
0
|
0
|
4972
|
|
POST
|
Hey All- I have a public REST service that has several layers and feature classes that I want to access. According to the documentation. Once I have the 'arcgis' package imported, I can inject my outside REST service as such: *Note: I am using the Jupyter Notebook to test this code. from arcgis.gis import GIS
gis = GIS("https://hazards.fema.gov/gis/nfhl/rest/services/CSLF/Prelim_CSLF/MapServer")
Since this is a public service, I didn't have to include any username or password parameters. The service has several layers (item_type="Feature Layer) that I want to access; namely Special Flood Hazard Area Change layer, but perhaps others: Using the example from the API docs, I tried to do a search in the service just to see all the layers and any info I might need in future calls. I am using the '.search' method from the content manager. # search and list all feature layers in my contents
search_result = gis.content.search(query="", item_type="Feature Layer")
search_result Every time I try this, I get an either a KeyError='num' or a TypeError: must be str, not int (if I try to add a query). What am I doing wrong here and what is the proper way to search within this REST service?
... View more
08-15-2018
06:12 AM
|
0
|
11
|
15782
|
|
POST
|
I actually have ArcGIS Pro 2.0. This is just what was sent to me (my company IT department - I'm a new employee-trying to set up my dev environment) so I just went with it. My ultimate goal here is to access the arcgis package (specifically >import GIS from arcgis.gis) so that I can utilize the ArcGIS API for Python to make calls to a REST service map server. It was just recommended (by the ArcGIS API documentation and my coworkers) that I use Anaconda with Spyder/Jupyter notebook. At this point I don't think I have the option for Pro 2.2.x.
... View more
08-14-2018
08:08 AM
|
0
|
1
|
4972
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-19-2021 01:41 PM | |
| 1 | 11-05-2019 07:44 AM | |
| 1 | 11-05-2019 09:58 AM | |
| 1 | 01-06-2021 05:41 AM | |
| 1 | 12-24-2020 06:48 AM |
| Online Status |
Offline
|
| Date Last Visited |
03-19-2022
10:13 PM
|