|
POST
|
Hi all, Arcapi has these kind of functions for joining tables: join_using_dict https://github.com/NERC-CEH/arcapi/blob/master/arcapi.py/#L2052-2153 update_col_from_dict https://github.com/NERC-CEH/arcapi/blob/master/arcapi.py/#L1207-1272 In many cases it is much faster than the Join Tool. Filip.
... View more
07-20-2014
12:41 PM
|
1
|
0
|
1025
|
|
POST
|
Have you considered pyscripter - An open-source Python Integrated Development Environment (IDE) ? If yes, are you aware of any advantages of Python Win over PyScripter? I found PyScripter better in every regard and everyone I recommend PyScripter to then always prefer it to Python Win. F.
... View more
07-20-2014
12:26 PM
|
0
|
0
|
5898
|
|
POST
|
Hi Tom, how about the code below? That's what I would do in your situation. I haven't tested it so you might need to tweak it a bit. I hope search cursors on shapefiles support the ORDER BY sql_clause, otherwise this won't work.
import arcpy
fc = 'c:/myfc.shp' # input feature class
# object id column (FID), column with ids where some repeat, column with dates
cols = ["OID@", "IDCOL", "DATECOL"]
orderby = 'ORDER BY "DATECOL" DESC'
object_ids_to_delete = []
last_id = None
with arcpy.da.SearchCursor(fc, cols, sql_caluse=(None, orderby)) as sc:
for row in sc:
this_id = row[1]
if this_id == last_id:
this_object_id = row[0]
object_ids_to_delete.append(this_object_id)
last_id = this_id
# cleanup in ArcGIS <10.2
del row
del sc
# one way to delete the old features where there is a newer feature:
# create where clause like "FID" IN (1,2,3)
# create layer containing only the features you need to delete
# delete the features
where = '"FID" IN (%s)' % ",".join(map(str, object_ids_to_delete))
lr = arcpy.management.MakeFeatureLayer(fc, "tmp", where).getOutput(0)
arcpy.management.DeleteFeatures(lr)
# cleanup (delete the layer object)
arcpy.management.Delete(lr)
del lr
... View more
07-16-2014
02:29 PM
|
0
|
1
|
734
|
|
POST
|
Hi Tim, The key idea really is described in the sample you have probably discovered too: Using jQuery | ArcGIS API for JavaScript If you want more, check out this example or esri.github: Esri/jquery-mobile-map-js · GitHub Go through some of the other repositories there, you can learn a lot from it. I have been using ArcGIS API for JavaScript with jQuery too and it makes many things so much easier. Filip.
... View more
07-16-2014
10:45 AM
|
2
|
0
|
2354
|
|
DOC
|
ArcAPI is a lightweight Python library that makes coding with arcpy faster and easier on the programmer. You can download the module from GitHub: NERC-CEH/arcapi · GitHub We make sure that arcpy has no dependencies other than those that come with arcpy. Thanks to that, arcapi is highly portable and super easy to start working with. Arcapi is for free, licensed under the Lesser General Public License 3.0 and developed in the spirit of open source software. Check out the tutorial to an idea what arcapi is about: arcapi/arcapi_tutorial.py The bulk of arcapi development is going on on GitHub. If you have experience with GitHub and want to contribute with some code or comments, you are more than welcome to get involved in any way you see fit. This group on GeoNet, on the other hand, is the ideal place to discuss any ideas around arcapi for those who don't have/want GitHub account. Also, more generic discussions about the direction of arcapi and about best practices in using arcpy take place here. Happy coding!
... View more
07-14-2014
02:59 PM
|
4
|
0
|
532
|
|
POST
|
Hi again, I have managed to publish it today after I re-built the map document from scratch and I indexed all the fields involved in the join and the time field. I am still not entirely convinced that missing indices were behind the strange behaviour but everything seems to work now. Filip.
... View more
07-02-2014
05:47 AM
|
0
|
0
|
749
|
|
POST
|
Hi Dave, greetings from CEH. I haven't used Identify extensively but maybe some of my experience with Dissolve and alike might help: 1) If the geometries you are dealing with are really complicated (meaning they have lots of vertices, some features are very small while other features are very big, etc.), consider using the Dice tool to split it into more manageable chunks. I am not sure how to use this with the Identify tool though (it will probably complicate your work flow a bit). All I am saying it that "godzzilla" geometries may be a problem. See dicing-godzillas-features-with-too-many-vertices. 2) A trick that helped me in the past was to run the 'memory expensive' tool in a separate subprocess. 3) Do you need to run it from PythonWin? Try to run the script from command line and see if that makes any difference. I haven't experienced this myself, but some posts I read mentioned that some things that didn't work in PythonWin or PyScripter worked when the script was executed from cmd.exe. Let us know how you get on and I hope someone else can add more tips. Filip.
... View more
07-01-2014
01:54 PM
|
0
|
0
|
587
|
|
POST
|
Hi, I need to publish a polygon feature layer and be able to symbolize the polygons based on a value measured in specific time. Values are measured at regular intervals, one measurement per polygon per time instance (month). So I have a polygon feature layer with attributes like: IDO, NAME 1, A Name 2, Another Name and a table with some values measured in time like: IDO, THETIME, VLU 1, 2014-01-01 00:00:00, 0.1 2, 2014-01-01 00:00:00, 0.3 1, 2014-01-02 00:00:00, 0.4 2, 2014-01-02 00:00:00, 0.3 1, 2014-01-03 00:00:00, 0.2 2, 2014-01-04 00:00:00, 0.1 In ArcMap, I joined my values table to my polygons layer (on IDO field) and opened the time slider. After a bit of hacking around the time ranges I got it to do what I needed - I can step through time month by month and the layer is symbolized by values measured in the selected month. I need to publish this map document as a service (and consume it JS API), but when I analyze the map, I get a warning: 10066: Map is not time enabled and all the data in time enabled layers will draw by default. The only way of time-enabling a map I found was via the time slider and I think my map surely is time enabled when I can step through time with time slider. I tried to ignore the warning and publish the map anyway, but the result certainly wasn't what I wanted (I was not able to get any features out of it over the rest API query interface). Am I missing anything here? Is there another way to do this? As a work around I was thinking about Publishing the polygons as a feature layer and coloring them in some other way, but the polygons have tons of vertices so am worried feature layer would be really slow. I am using ArcGIS for Server 10.2.2 Filip.
... View more
07-01-2014
10:17 AM
|
0
|
1
|
2358
|
|
POST
|
Hi, I need to publish a polygon feature layer and be able to symbolize the polygons based on a value measured in specific time. Values are measured at regular intervals, one measurement per polygon per time instance (month). So I have a polygon feature layer with attributes like: IDO, NAME
1, A Name
2, Another Name and a table with some values measured in time like: IDO, THETIME, VLU
1, 2014-01-01 00:00:00, 0.1
2, 2014-01-01 00:00:00, 0.3
1, 2014-01-02 00:00:00, 0.4
2, 2014-01-02 00:00:00, 0.3
1, 2014-01-03 00:00:00, 0.2
2, 2014-01-04 00:00:00, 0.1 In ArcMap, I joined my values table to my polygons layer (on IDO field) and opened the time slider. After a bit of hacking around the time ranges I got it to do what I needed - I can step through time month by month and the layer is symbolized by values measured in the selected month. I need to publish this map document as a service (and consume it JS API), but when I analyze the map, I get a warning: 10066: Map is not time enabled and all the data in time enabled layers will draw by default. The only way of time-enabling a map I found was via the time slider and I think my map surely is time enabled when I can step through time with time slider. I tried to ignore the warning and publish the map anyway, but the result certainly wasn't what I wanted (I was not able to get any features out of it over the rest API query interface). Am I missing anything here? Is there another way to do this? As a work around I was thinking about Publishing the polygons as a feature layer and coloring them in some other way, but the polygons have tons of vertices so am worried feature layer would be really slow. I am using ArcGIS for Server 10.2.2 Filip.
... View more
07-01-2014
10:15 AM
|
0
|
0
|
1292
|
|
POST
|
Hello, Sensor Observation Service (SOS) is an OGC Standard that is becoming popular for sharing time series data. It is related to Water Markup Language 2 (WML2), which I need to work with too. See demos from 52 North to get an idea what it's all about. Can you help me consume SOS in ArcGIS API for JavaScript applications? At least the important parts of it. It seems to me that we could subclass the Graphics Layer, or maybe even the FeatureLayer and get the data from SOS as something like an array of features where attributes of each feature would contain a an array with the time series. I know attributes are not meant to be array but hey, it's a start. [
{ geometry: {"x" : -118.15, "y" : 33.80, "spatialReference" : {"wkid" : 4326}},
attributes: {'kvp': [['2014-06-17', 1.1], ['2014-06-18', 1.4]]}
},
{ geometry: {"x" : -117.15, "y" : 34.80, "spatialReference" : {"wkid" : 4326}},
attributes: {'kvp': [['2014-06-17', 1.0], ['2014-06-18', 1.2]]}
},
...
] I did something like with OGS WMS by subclassing esri.layers.DynamicMapServiceLayer and overriding the getImageUrl method but I don't know how to go about feature layer. There has been some effort to get this working with OpenLayers.js (and SOS.js that uses open layers) but I am not sure if that is a point so start from. Any ideas and examples(!) would really help. Filip.
... View more
06-18-2014
03:12 AM
|
0
|
0
|
857
|
|
POST
|
Hi, I believe your script doesn't work because the third parameter to GACreateGeostatisticalLayer_ga is not supposed to be a layer file, but a name of a layer that will be created in Python's memory. Try changing the following rows: #outlyr=lyrpath+"/"+fc+"_GA.lyr" outlyr = 'galayer' #arcpy.GACreateGeostatisticalLayer_ga(modelxml,infc,outlyr) outlyr = arcpy.GACreateGeostatisticalLayer_ga(modelxml,infc,outlyr).getOutput(0) # and add the following right above your 'except' statement # to delete the in-memory layer object before the next iteration arcpy.Delete_management(outlyr) del outlyr Hope this helps, Filip.
... View more
04-25-2014
11:13 AM
|
0
|
0
|
642
|
|
POST
|
Hi, I keep getting that same message when trying to connect to server 10.2 from desktop 10.1 SP1: 'We were unable to connect to: <url>. Error: Proxy server got bad address from remote server (verify the server is running).' I am using ArcGIS Server authentication tier. I can establish user connection from desktop 10.1 to http://myserver/arcgis/services I can establish user, publisher, and administrator connections from desktop 10.2 on myserver to http://myserver/arcgis. Tried the following with firewall on the server switched off. Using ip instead of computer name. However, since the name resolves for the user connection it should work for any other connection. Using servername:6080 and without 6080 in the url - Web Adaptor has been configured and I tried switching 'Enable administrative access to your site through the Web Adaptor' on/off. Observations: Local connections from desktop 10.2 on myserver can be established using url with or without the port number. When such local publisher or administrator connection is established, the url in the connection properties is then always http://myserver/arcgis/admin (may include :6080) I am quite sure I didn't set the security to require https; https://myserver:6443/arcgis didn't work anyway. The help suggests that connections publishing from desktop 10.1 to server 10.2.2 is possible. Is this not the case for server 10.2? Honestly I don't know what else to try so any hints will be much appreciated. Filip.
... View more
04-14-2014
03:32 AM
|
0
|
0
|
566
|
|
POST
|
Hi wtgeographer, I am guessing your problem is that your condition on line 6 always evaluates to False. Try it this way:
def updateParameters(self):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parmater
has been changed."""
wkid = getattr(getattr(arcpy.Describe(self.params[0]), "spatialReference", None), "factoryCode", None)
if wkid != 2275:
self.params[0].setErrorMessage("Coordinate System Must be SPC 4201")
I think your condition is always False because you are comparing two objects that are in fact different (in different places in memory?), whereas comparison of integer numbers (like factory codes of spatial reference objects) should work as you would expect. My line 5 basically says `wkid = arcpy.Describe(self.params[0]).spatialReference.factoryCode`, but my version won't fail if the attributes are not present, for whatever reason. Hope this helps. Filip.
... View more
04-11-2014
02:38 PM
|
0
|
0
|
1169
|
|
POST
|
Hi John, If your data is in a Geodatabase you can use arcpy.da.SearchCursor, which allows you to specify ORDER BY clause of an SQL Select Statement as part of the sql_clause parameter. For example, here is a function to get an object ID (or FID for Shapefiles) of the feature with the highest value of an attribute: import arcpy def get_id_of_higest(fc, attr): """Return object ID of a feature with the highest value of attribute attr. Returns None if fc is an empty feature class. fc -- feature class (MUST BE STORED IN A GEODATABASE!!!) attr -- name of the attribute to examine """ ret = None with arcpy.da.SearchCursor(fc, ['OID@', attr], sql_clause=(None, 'ORDER BY "' + str(attr) + '" DESC')) as sc: for row in sc: ret = row[0] break return ret myfc = r'c:\temp\cities.shp' myattr = 'pop_max' maxido = get_id_of_higest(myfc, myattr) # now you can use maxido to select the feature You might need to refactor this code to better suit your need and save computational time but hopefully it will help you to get it done. Filip
... View more
04-10-2014
12:36 PM
|
0
|
0
|
681
|
|
POST
|
Good effort Justin, I think I see where you are coming from and where you want to go. So far arcapi has just functions rather than classes because functions are easier to manage at this stage. I think for what arcapi does, functions will be suitable quite some time into the future, but having an object-oriented library is a good idea. Feel free to borrow from and contribute to arcapi! Filip.
... View more
04-10-2014
11:50 AM
|
0
|
0
|
386
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-05-2014 04:40 AM | |
| 1 | 02-08-2015 12:49 PM | |
| 1 | 07-20-2014 12:41 PM | |
| 1 | 03-23-2017 01:48 PM | |
| 1 | 08-18-2014 04:14 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|