|
POST
|
Hi all, What do you think about this new module in arcapi? I called it 'arrest.py', for 'ArcGIS REST Python client'. It is a set of classes that allow you to interact with ArcGIS for Server REST API (only reading though). Check out the examples near the bottom (line 966 and below). The module has no dependencies so you can play with just the single python script. https://github.com/NERC-CEH/arcapi/blob/feature-arrest/arrest.py The module is in a new branch so far and I would love to get some feedback from you. Is it a good idea? Do you miss anything? Can you add anything? I hope we can polish it and check it into master arcapi in couple of weeks. Cheers, Filip.
... View more
08-06-2014
11:29 AM
|
1
|
9
|
7198
|
|
POST
|
Thank you all for your responses about accessing variables out of event handlers. After some more trials I have to say though that none of your suggestions fully answered my question. I'll post back here if I find a solution to my problem. Filip.
... View more
08-06-2014
11:00 AM
|
0
|
0
|
1791
|
|
POST
|
Hi, Robert, both scale bars disappear when I click the map, but only because you binded the hide scalebar functionality to the second scalebar within the createScalebarWhenMapLoads function (lines 53-55 of your code). I want to be able to write similar lines on line 66, but that won't work because on line 66 scalebar2 is null. See, if I later decide the scalebar should do something else when I click the map, I don't want to modify the createScalebarWhenMapLoads function. Or maybe I will decide that the scalebar should hide when I do something else than clicking the map. I extended the example again with 3rd scale bar, which is loaded using deferreds. http://filipkral.com/dev/gisdesk/return-value-from-dojo-on.html I think the defferds version would be the most reliable, although I am not convinced it would always work in this example. If the scalebar widget had an event like 'loaded', I would resolve the deferred when this event occurs
scalebar.on('loaded', function(){deferred.resolve(scalebar); });
Anyhow, all those examples seem terribly complicated for what I am trying to do so I feel like I must be missing something obvious. I would be really glad if someone could explain to me how to do this kind of thing once for all. Cheers, Filip.
... View more
08-03-2014
02:12 PM
|
0
|
0
|
1791
|
|
POST
|
Hi, Thanks for the sample, Tim. I still have the same question though. Below is an extended version of Tim's code sample to illustrate the issue better. It is not really about creating scale bars, but about structuring the code so I don't need to keep everything in one file. Let me rephrase the quesion: You have function A that calls function B when an event occurs. How do you make function A return the value returned by function B?
<!DOCTYPE html>
<html><head>
<title>Create a Map</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<link rel="stylesheet" href="http://js.arcgis.com/3.10/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">
<style> html, body, #mapDiv{ padding: 0; margin: 0; height: 100%; } </style>
<script src="http://js.arcgis.com/3.10/"></script>
<script>
var map;
require(["esri/map", "esri/dijit/Scalebar", "dojo/on", "dojo/domReady!"], function(Map, Scalebar, on) {
map = new Map("mapDiv", { center: [-56.0, 38.0], zoom: 3, basemap: "streets"});
function createScalebar(opts){
//Create a Scalebar for opts.map
var themap = this.map;
var options = { map: themap, attachTo: "top-right" };
var scalebar = new Scalebar (options);
return scalebar;
}
function createScalebarWhenMapLoads(opts){
//Create a Scalebar for opts.map on the opts.map.load event
var themap = this.map;
var scalebar = null;
// maybe you don't need to wait for map.onLoad with scale bars but imagine something else
themap.on('load', function(){
var options = { map: themap, attachTo: "bottom-left", scalebarUnit: "dual" };
scalebar = new Scalebar (options);
});
return scalebar;
}
var scalebar = createScalebar({map:map});
var scalebar2 = createScalebarWhenMapLoads({map:map});
// When clicked on map scale bar will disappear
map.on("click", clickHandler);
function clickHandler(){
scalebar.hide();
};
// But scalebar2 is undefined (understandably), so it won't disappear
map.on("click", clickHandler2);
function clickHandler2(){
scalebar2.hide();
};
});
</script>
</head>
<body class="claro"><div id="mapDiv"></div> </body>
</html>
Also, if you use the 'on' method, is there a way how to change the context (what the 'this' keyword means)? Can the dojo.hitch function help here? In other words, how do you rewrite the above code to use only one clickHandler? With dojo.connect you could do something like this:
function clickHandler(){ this.scalebar.hide(); }
dojo.connect(map, 'click', {scalebar: scalebar, "callme": clickHandler}, "callme");
dojo.connect(map, 'click', {scalebar: scalebar2, "callme": clickHandler}, "callme");
I hope it is clear what I want to know. Filip.
... View more
08-02-2014
03:09 AM
|
0
|
3
|
1791
|
|
POST
|
Yeah, I think ArcMap is "the host application" that the graph will be added to, as Dan pointed out. Laura, you mentioned you would use matplotlib to make your plots. I always find that with matplotlib you need to write quite a bit of code to make even fairly basic plot. Have you got any predefined functions or hints that make plotting easier? We have some in arcapi library, but there is a space for enhancements. Filip.
... View more
08-02-2014
02:25 AM
|
0
|
1
|
1591
|
|
BLOG
|
I sincerely hope in_memory workspaces are here to stay. Even if you can save only simple tables an feature classes in them, they have been extremely useful. I don't really mind whether they are truly in memory or somewhere else, as long as they are fast and don't leave a trace when deleted.
... View more
08-01-2014
01:18 PM
|
0
|
0
|
652
|
|
POST
|
You can 'populate' the M values by the process of Linear Referencing , which you better read up about in the help. Specifically the topics on creating route feature class is probably what you need.
... View more
07-31-2014
03:51 PM
|
0
|
2
|
5174
|
|
POST
|
Hi Daniel, The limited (if any) options to manipulate strings like file paths in model builder quickly turned me to Python, where things like that area easy to do. Here is how to core of the script you described might look like. I would have to try that and tweak it to be able to publish that as a service, but hopefully it is clear enough to get you started.
import arcpy
import os
osj = os.path.join # define shortcut for a function
# if you need inputs, get them like so:
#some_input = arcpy.GetParameterAsText(0)
#some_other_input = arcpy.GetParameter(1)
sde = 'Database Connections\database_connection.sde'
ows = r'c:\output\workspace'
# lookup of feature class - exported file name - where clause
lookup = [
(osj(sde, 'M_X_CASING'), osj(ows, 'xCasing'), ''),
(osj(sde, 'M_X_AERIAL_MARKER'), osj(ows, 'xAirMrkr'), ''),
(osj(sde, 'M_X_WITHWHERE'), osj(ows, 'xWhere1'), '"COLUMN"=\'high\''),
(osj(sde, 'M_X_WITHWHERE'), osj(ows, 'xWhere1'), '"COLUMN"=\'low\'')
#, ...
]
exported = []
for item in lookup:
fc = item[0]
out = item[1]
wc = item[2]
result_i = arcpy.analysis.Select(fc, out, wc).getOutput(0)
exported.append(result_i)
# exported is now a list of results but you may not need that
# you will definitely need to set some output, like so:
arcpy.SetParameter(1, exported[0])
# you may want to zip the whole output directory and
# set the zip file as output
# http://resources.arcgis.com/en/help/main/10.1/index.html#//005700000078000000
Filip.
... View more
07-31-2014
01:40 PM
|
0
|
1
|
1404
|
|
POST
|
Hi, I have quite a few calls like this in my JavaScript:
dojo.connect(map, "onLoad", {map: map, do:buildScalebar}, "do");
and I would like to simplify to something like this:
var scalebar = buildScalebar({ map: map });
// the retuned value should be the scale bar widget so I could do:
scalebar.hide();
scalebar.show(); // and so on
What is the best way to do it? Here is the buildScalebar function from the second case, which however returns null.
function buildScalebar(opts){
/* Build the scalebar widget with options:
* .map -- map for which to load the scalebar
* .unit -- scalebarUnit, dual|metric|english, default is "dual"
* .anchor -- top-right|bottom-right|top-center|bottom-center|bottom-left|top-left, default value is "bottom-left"
*
* Returns the widget. (BUT IT DOESN'T!!!)
*/
var o = this;
if ('map' in opts) { o = opts; }
var map = opts.map;
var anchor = 'anchor' in opts ? opts.anchor : "bottom-left";
var unit = 'unit' in opts ? opts.unit : "dual";
var scalebar = null;
dojo.connect(map, "onLoad", {
"map": map,
"attachTo": anchor,
"scalebarUnit": unit,
"do": function () {
var options = {"map": this.map, "attachTo": this.attachTo, "scalebarUnit": this.scalebarUnit }
scalebar = new esri.dijit.Scalebar( options );
}
}, "do");
return scalebar;
}
I would like to use this pattern for other widgets and functionality, not just the scale bar widget. Is it a good idea? Do I need some kind of Deferreds here? Can you help me with an example? Cheers, Filip.
... View more
07-31-2014
08:09 AM
|
0
|
11
|
3474
|
|
POST
|
Watch this quick introductory video to get an idea what the arcapi Python library is all about. Then join or follow the arcapi group on GeoNet or watch the GitHub repository.
... View more
07-29-2014
11:41 AM
|
1
|
1
|
2187
|
|
POST
|
Hi Kevin, Sound to me like you would like to Dissolve Polygon Boundaries using Symbol Levels: http://resources.arcgis.com/en/help/main/10.1/index.html#//00s500000025000000 I am not sure what you mean by 'group them for later use' so depending on what the later use is, you might need to Dissolve the polygons and so create a new feature class. Hope this helps, Filip.
... View more
07-24-2014
08:35 AM
|
0
|
0
|
2717
|
|
POST
|
Aha! It seems the problems occurred due to incompatibility between ArcGIS for Desktop 10.1 SP1 and ArcSDE 10.0. I successfully imported the polygons with ArcMap 10.0 and ArcSDE 10.0 Again, many thanks for looking into this, it is much appreciated. Filip.
... View more
07-23-2014
09:05 AM
|
2
|
0
|
1477
|
|
POST
|
Thank you both for checking. I still have the same problem but at least thanks to you I know the problems is not in the feature class. I'll post a solution back here if I ever figure out what the problem was. Filip.
... View more
07-23-2014
08:04 AM
|
0
|
0
|
1477
|
|
POST
|
Well spotted Andrew, and a fair point for an enterprise. I just wanted to say it works for me on ArcGIS 10.1 with Python 2.7. Filip.
... View more
07-22-2014
11:33 AM
|
0
|
0
|
5903
|
|
POST
|
Hello, I am having hard time importing the three attached polygons to Oracle SDE with SDO_GEOMETRY data type (configuration keyword). No matter what I try, ArcMap crashes with a Windows massage "ArcMap has stopped working" and I have to "close the program". Import as SDEBINARY works. We have been using SDO_GEOMETRY for everything else and I imported similar polygons as SDO_GEOMETRY successfully before using the Feature Class to Feature Class tool and Copy Features Tool too. It seems the crash occurs because of the large parts in the polygons, but the largest part has some 11000 vertices, which should be way below the limit. I would very much appreciate if someone with SDE (ideally on Oracle) tried to import them and let me know if it works. Any ideas what might be wrong with the polygons? Using Check Geometry and Repair Geometry made no difference. I am using ArcGIS for Desktop 10.1 and Oracle 11g with SDE 10.0. Regards, Filip
... View more
07-21-2014
09:16 AM
|
0
|
4
|
4553
|
| 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
|