POST
|
Joshua - This is exactly the issue. Here are the results of my tests to import arcpy: On work network: 153 sec (can range up to 5 min, rarely faster than this) Totally disconnected (no LAN cable/wifi): 3.5 sec On home internet connection, noVPN: 3.3 sec On home internet, with VPN: 280 sec Opening ArcMap is about the same. It gets stuck on "Initializing License" on the splash screen. Following your solution was exactly the issue. The reason it took me so long to reply was that I couldn't figure out your suggestion of removing the info for my license manager. The textbox where I would enter it is disabled and so is the "Change" button, so I couldn't edit them. Then, I remembered that I am not an administrator on my PC. I located the ArcGIS Administrator in my Windows Start menu, right-clicked on it, and chose "Run as administrator". The textbox is still not editable, but the change button works now. thanks! David
... View more
02-15-2018
11:55 AM
|
1
|
0
|
1161
|
POST
|
Hi everyone, I have some WRF model output data in NetCDF format, and I would appreciate any guidance on projecting it from anyone with experience with data from this model. (WRF = Weather Research Forecasting) These WRF runs use a Lambert Conformal Conic projection with a center of -121, standard parallels of 30 & 60 degrees North, and a latitude of origin of 45 degrees North. I think I have that figured out, but my data will be off if I don't use the right sphere/spheroid. My understanding is that WRF uses a sphere of 6370 KM with no flattening. Does this look right? PROJCS["WRF_LCC_PacificNW",
GEOGCS["WRF_Sphere_6370km",
DATUM["<custom>",
SPHEROID["<custom>",6370000.0,0.0]
],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]
],
PROJECTION["Lambert_Conformal_Conic"],
PARAMETER["False_Easting",0.0],
PARAMETER["False_Northing",0.0],
PARAMETER["Central_Meridian",-121.0],
PARAMETER["Standard_Parallel_1",30.0],
PARAMETER["Standard_Parallel_2",60.0],
PARAMETER["Scale_Factor",1.0],
PARAMETER["Latitude_Of_Origin",45.0],
UNIT["Meter",1.0]
]
If that is right (or if I need to adjust it), then I should be all set. I would appreciate any feedback I can get from anyone with experience in this. Based on slide 20 of this presentation, it looks right, but I'd appreciate as much help as I can get! That said, my process to bring these into ArcGIS is not for analysis is not straightforward at all, and I'd appreciate any suggestions to improve it. Here is how I do it: Use Make NetCDF Raster Layer to import to an in-memory raster and save to a GeoTIF. The GeoTIF has headers for the coordinate system, but it comes in as pixel coordinate space with no registration. Unfortunately, the Esri Define Projection did not work on this. I saw several other people griping about this in this forum. I use gdal_translate.exe -co PROFILE=BASELINE to strip out the file's coordinate system headers in the GeoTIF. I pre-generate a TFW and copy it to <filename>.tfw in the folder where <filename>.tif lives. (I do this for each time slice in the NetCDF that I export.) The NetCDF gives me the lower left, and I need the upper left in the TFW, so some basic math is needed with the cell size and number of rows. Use Define Projection to put it into the right coordinate system. It works now that there are no GeoTIF headers and a TFW file exists. I'm doing this in Python and it's automated. It doesn't take long, but YUCK! It seems like a lot of steps to get the data into the right coordinate system, especially considering that it came from a file where the coordinate system is well-defined, albeit in a different format. After this, I do some resampling, averaging, and export to polygons, so I feel like TIFs are a good intermediate format, but there is clearly room for improvement... thanks!
... View more
02-14-2018
12:24 PM
|
0
|
0
|
1736
|
POST
|
Rebecca - The "from . import" is valid. I don't understand it well, but have followed another programmer's code in my org to get it working. I think it just means from the current module, much like dot-slash means from the current directory in Unix/DOS. I've used it to import objects from __init__.py. You can also use "from .module_name import ClassName" to specify another module/Class in the same space as where you're currently located. Anyhow, this is probably getting a bit off on a tangent from the thread, so in order to not annoy the forum moderators, I'd suggest you start another post with this topic.
... View more
02-08-2018
10:08 AM
|
1
|
3
|
3277
|
POST
|
Thanks, Rebecca - Please let me know the results of your test.
... View more
02-07-2018
06:17 PM
|
0
|
6
|
3277
|
POST
|
When I import arcpy under the ArcGIS 10.5 python interpreter, it is REALLY slow! I am seeing times of 149 - 197 seconds. Every once in a while, it will import in about 2.5 seconds, but the 2-3 minutes times are more typical. Further info: I noticed it after borrowing a license for ArcGIS Desktop. I do need to take my laptop off the network, so going back to using the license server is not a good option. ArcMap and ArcCatalog also can take a similarly long time to start. They are stuck on "Initializing License" on the splash screen for a long time. This is in my IDE (PyDev/Eclipse), but I get the same loading python 2.7 from the DOS prompt. Having ArcCatalog or ArcMap already open speeds up neither python nor opening another window of ArcCatalog/ArcMap. Each of the imports below takes no less time individually than all together. Here is what I am doing to test the timing (plus using my wristwatch with ArcGIS Desktop): import timeit
start = timeit.default_timer()
import arcpy
from arcpy import env
from arcpy.sa import *
imports = timeit.default_timer()
print("completed arcpy imports: {} sec".format(int(imports - start))) Ideas? Thanks!
... View more
02-07-2018
05:44 PM
|
0
|
14
|
6275
|
POST
|
Indeed, hard-coding the password was what I was trying to avoid... I was thinking of generating a token (they seem to have a 2-week max length for AGOL) on some interval and putting it somewhere my code can access it, but no such luck. Generating a profile will at least get the storage out of my code and my Git repo, but it's still in clear text on the hard drive... >>> from arcgis.gis import GIS
>>> gis = GIS('https://xxx.maps.arcgis.com/', username='xxx', password='xxx', profile='my_profile')
I'm honestly thinking it is just easier to send JSON to the REST endpoint than to use the ArcGIS API for Python.
... View more
01-24-2018
11:31 AM
|
0
|
0
|
7116
|
POST
|
Thanks, Rebecca. I didn't specify, but I'd like this to run headless without a user prompt.
... View more
01-24-2018
11:19 AM
|
0
|
2
|
7116
|
POST
|
Hi Dan, I noodled around with this a bit. Not sure how this would work. I did note that if I put in bogus credentials, I get back an error that it cannot generate a token (which makes sense). I guess my question is still how would I skip the user/pass checking if I already have a token that was supplied? >>> from arcgis.gis import GIS
>>> gis = GIS('https://xxx.maps.arcgis.com/', username='xxx', password='xxx')
Unable to generate token.
Invalid username or password.
Traceback (most recent call last):
File "C:\Python36\lib\site-packages\arcgis\gis\__init__.py", line 257, in __init__
client_id=self._client_id)
File "C:\Python36\lib\site-packages\arcgis\_impl\portalpy.py", line 163, in __init__
client_id=client_id)
File "C:\Python36\lib\site-packages\arcgis\_impl\connection.py", line 284, in __init__
self.login(username, password, expiration, client_id)
File "C:\Python36\lib\site-packages\arcgis\_impl\connection.py", line 532, in login
newtoken = self.generate_token(username, password, expiration, client_id)
File "C:\Python36\lib\site-packages\arcgis\_impl\connection.py", line 397, in generate_token
ssl=True, add_token=False)
File "C:\Python36\lib\site-packages\arcgis\_impl\connection.py", line 1129, in post
self._handle_json_error(resp_json['error'], errorcode)
File "C:\Python36\lib\site-packages\arcgis\_impl\connection.py", line 1149, in _handle_json_error
raise RuntimeError(errormessage)
RuntimeError: Unable to generate token.
Invalid username or password.
(Error Code: 400)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Python36\lib\site-packages\arcgis\gis\__init__.py", line 264, in __init__
raise RuntimeError(e.args)
RuntimeError: ('Unable to generate token.\nInvalid username or password.\n(Error Code: 400)',)
... View more
01-24-2018
11:18 AM
|
0
|
0
|
7116
|
POST
|
I'm interested in using the ArcGIS API for Python to connect to an ArcGIS Online for Organizations account via a token, and not a username/password. All the examples I have found look like this: from arcgis.gis import GIS
gis = GIS("portal url", "username", "password") How would I pass a token into this API, instead of username/password? In case it matters, I want to connect to ArcGIS Online for Organizations, so my user name is <user>_<org_suffix>. My organization does not use an Enterprise Login, so I just log in directly at the Esri site. Bonus question: I know how to generate the token with Python and the REST API (using JSON). Any idea how to do so with the ArcGIS API for Python? thanks, David
... View more
01-23-2018
07:30 PM
|
0
|
15
|
15726
|
POST
|
Let's say you start with this: You can create another worksheet. In cell A1, type = to start a formula, open the other worksheet, and click on the cell you want to be in the upper left. The formula will look like =Sheet1!A5, assuming "Sheet1" is the name of the worksheet with data and cell A5 is the first one you want. Then, with cell A1 selected, select as many to the right as the columns you want. Hit CTRL-R to fill to the right. Select down as many rows as you want and hit CTRL-D to fill down. Use this worksheet when you import. If you want to just fill down a bunch of rows without worrying about the number of rows on worksheet 1, you can do this: =IF(LEN(Sheet1!A6)>0, Sheet1!A6, "") It will give you a blank cell if the reference cell doesn't have any length.
... View more
01-04-2018
03:56 PM
|
0
|
0
|
333
|
POST
|
The initial screenshots were done on my 2-core laptop. I ran the same process on a 4-core machine, and it was the same result. It might have been a pixel different here or there, but it wasn't anything I could discern with them side by side.
... View more
01-02-2018
11:14 PM
|
0
|
0
|
912
|
POST
|
Thanks for the explanation on creating the layer file. I am using ArcGIS Desktop 10.5. When I add that layer file to my map, I am starting to get a better sense of the problem. Here is the default "Filled Contours" symbology, with the contour lines borders drawn in blue (transparent fill) over top: They don't really line up, but I'm seeing the problem. If I switch to Grid symbology, it gets closer: If increase the number of grid cells it uses to draw, it gets closer to looking like the grid I saved out, but doesn't really explain the contours generated: In the end, I'm not sure this really gets me any closer to creating beautiful contour lines. Any idea where to go next? Is there some kind of cell size, resolution, or tolerance setting that I can adjust to make the contours higher resolution? Please note that my input was a raster. I converted it to points, and created my surface using IDW. Is there a way to create a Geostatistical Analyst layer starting directly with a raster? thanks!
... View more
01-02-2018
11:13 PM
|
0
|
0
|
912
|
POST
|
Hi Steve - I would be happy to, if only I knew how! In the python script, the arcpy.IDW_ga function has a parameter "out_ga_layer", to which I supply a string name. I named mine "output_geo_lyr" and I am able to work with this as an in-memory object in python, but can you tell me how to draw it in ArcMap? I suppose I need to persist it to disk somehow. I did try the script a while back and it crashed, which actually led me to this approach.
... View more
01-02-2018
10:26 AM
|
0
|
0
|
912
|
POST
|
I saw that, but it says "slightly different"... What I'm after is a night & day difference. I'll try it on a better machine tomorrow.
... View more
01-01-2018
07:34 PM
|
0
|
2
|
912
|
POST
|
Hi - I'm trying to produce contour polygons out of a Geostatistical Analyst layer. The contour polygons (GALayerToContour_ga tool) are super-generalized and look terrible. This screenshot shows is the resulting contour polygons in blue lines (transparent fill). The grid in the background was exported from the GA Layer (using the GALayerToGrid_ga tool), with the colors classified at the same cut-off elevations used to generate the contours: My question is: How do I generate contour lines that really follow the data much more closely? Is there some kind of scale or generalization setting in the environments that I'm missing? Here is what I am running: arcpy.GALayerToContour_ga(
in_geostat_layer="output_geo_lyr",
contour_type="FILLED_CONTOUR",
out_feature_class=output_path,
contour_quality="PRESENTATION",
classification_type="MANUAL",
classes_count="5",
classes_breaks="5;20;75;150;999999") Here is how I created the GA layer. It actually came from a raster-to-point export. For that reason, I set the min and max number of inputs to 1, to basically just make it a nearest neighbor interpolation: arcpy.IDW_ga(
in_features=in_features,
z_field="grid_code",
out_ga_layer="output_geo_lyr",
out_raster="",
cell_size="0.01",
power="2",
search_neighborhood="NBRTYPE=Standard S_MAJOR=1.1 S_MINOR=1.1 ANGLE=0 NBR_MAX=1 NBR_MIN=1 SECTOR_TYPE=ONE_SECTOR",
weight_field="") When I check the GA Layer with the GALayerToGrid_ga, it looks correct.That is the background in the screenshot above. If I run the Spatial Analyst Contour List tool, that creates something much more reasonable. Of course, these are just lines, so they don't meet my needs, since I'm trying to create polygons. Here is a view of those: Any ideas on how I can create polygons with boundaries that look like the lines in this screenshot? thanks! The Python script I'm using is attached. It runs and produces the grid background and polygon foreground in the first screenshot, above. I'm using ArcGIS Desktop 10.5 with its arcpy 2.7.
... View more
01-01-2018
06:47 PM
|
0
|
8
|
1358
|
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
|