|
POST
|
What I am trying to do is create a definition query or where clause on a polygon grid feature layer. Each grid feature has a name and that name references a unique geodatabase in a directory. What I am doing is checking for a particular layer(s) in each geodatabase, saving that corresponding name in the feature layer if found, and outputting another feature layer with just the polygons that have a geodatabase with a corresponding feature class. Hopefully that wasn't too convoluted. My problem is, no matter what I've tried, I can't seem to pass this list on to something arcpy will take. Here's my code so far, simplified to just test if the geodatabase has features at all. The bold lines are where I would think I need to change to get this to work, crashes on the makefeaturelayer.
inputWorkspace = myWorkspace
dataList = list()
twnshpLyr = r"TFM_BKG.NEATLINE"
selectSearch = arcpy.SearchCursor(twnshpLyr)
for row in selectSearch:
township = row.getValue("TILE_NAME")
arcpy.env.workspace = inputWorkspace+os.sep+township+".mdb"
fcList = arcpy.ListFeatureClasses()
if fcList:
dataList.append(str(township))
else: continue
arcpy.MakeFeatureLayer_management(twnshpLyr, "townshipData", "TILE_NAME in (",str(dataList)+")")
Here is the error I get from the python window: Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Workspace or Feature Dataset: Dataset (...all the feature values in the list...) does not exist or is not supported Failed to execute (MakeFeatureLayer). Based on your script, you tried to creat an out_layer in inputWorkspace+os.sep+township+".mdb which is invalid workspace for lyr file.
... View more
10-28-2011
09:33 AM
|
0
|
0
|
1367
|
|
POST
|
Ok, that was helpful. Using the find feature I've retrieved the graphic and passed it to graphicsExtent. Question I have now is how to make graphic extent zoom to extent of the found object. This is without a map since I only want min max to create export image. extent =esri.graphicsExtent(featureSet.features). var src ="http://yourMapService/export?bbox="+extent.xmin+","+extent.ymin+","+extent.xmax+","+extent.ymax+"&f=image"
... View more
10-26-2011
06:15 AM
|
0
|
0
|
953
|
|
POST
|
Using rest api I need the bbox values from a query in order to export an image. What is the easiest way from rest to query a field from a MapService and return the extent to then export that image? esri.graphicsExtent(featureSet.features).
... View more
10-25-2011
09:09 AM
|
0
|
0
|
953
|
|
POST
|
Hi all, Just been looking at the network traffic and it seems the zoom is failing because the following request is being generated from my code: http://<server>/ArcGIS/rest/services/SLR/CadastreRoad/MapServer/0/query? f=json &returnGeometry=true &spatialRel=esriSpatialRelIntersects &objectIds=2401863 &outFields=PLANNUMBER%2CLOTNUMBER%2COBJECTID%2CSECTIONNUMBER%2CclassSubtype &outSR=102113 &callback=dojo.io.script.jsonp_dojoIoScript10._jsonpCallback The problem is that %2classSubtype is being added to the end of the request for some reason. Does anyone know why this is happening?? Where is that coming from? Thanks for the help. Ed Another thought is your dojo.some. It is use to validate the exist of a value rather then loop through each query result. Try dojo.forEach.
... View more
10-25-2011
05:20 AM
|
0
|
0
|
767
|
|
POST
|
Hey Guys, Just wondering if there is a way of manually setting the geometry of a Query task using a lat long value? To explain: I center the map on a lat lon and I want to also select the polygon that this lat lon is inside of. Can anyone help? Thanks, Matt. esri.geometry.Polygon.contains(point)??
... View more
10-25-2011
05:04 AM
|
0
|
0
|
448
|
|
POST
|
Ok if you hard code the paths and run the script on a single file it works. So, I'm wondering whether its ListRasters or the For loop - can't remeber having this problem before!! EXTRA NOTE***** - Is there any other way I can get a list or loop through files in a folder? env.workspace = "C:/Data/asc" for file in arcpy.ListFiles("*.asc"):
... View more
10-24-2011
12:25 PM
|
0
|
0
|
2368
|
|
POST
|
shouldn't this read env.workspace = r"C:/Data/asc" ?? env.workspace = r"C:\Data\asc"
... View more
10-24-2011
11:51 AM
|
0
|
0
|
2368
|
|
POST
|
dtm is in the file name so have used rstrip("dtm.asc") to strip dtm and asc from the filename so it doesn't exceed 13 characters - so not sure this is the answer as its the input file it can't find! ***Extra note - just ran your suggestion and same issue - for some reason it is saying the input file doesn't exist which is bizarre when it has got the name from the rasterlist which has just cycled through that folder!!! ERROR 000865: Input ASCII raster file: sx0051dtm.asc does not exist Hard code the input and output path to see if it works.
... View more
10-24-2011
11:28 AM
|
0
|
0
|
2368
|
|
POST
|
Hope someone can help - I've written this script several times in the past but unfortunately my laptop is being serviced and I forgot to backup my python scripts directory - ~DOH 😮 Anyway, this should be really simple - I'm looping through some ascii files in a directory and converting them to a raster. However, Python returns the error - Failed to execute (ASCIIToRaster). I know the ascii file is there as I have manually converted in toolbox and its fine. I've posted the code below. # Import arcpy module import arcpy from arcpy import env # Local variables: env.workspace = "C:/Data/asc" outputraster = raster.rstrip("dtm.asc") datatype = "FLOAT" #Get a list of ascii files rasterList = arcpy.ListRasters() for raster in rasterList: arcpy.ASCIIToRaster_conversion(raster,outputraster,datatype) The issu is outputraster = raster.rstrip("dtm.asc"). It does not create "dtm". Try use outputraster = raster.split(".")[0] instead
... View more
10-24-2011
10:46 AM
|
0
|
0
|
2368
|
|
POST
|
Hi all, This is probably an easy one but I can't figure it out...I'm sending query tasks results to a graphics layers with attributes. I'm also populating a DataGrid with the results and then trying to zoom to a record when the user clicks on a row. Except the zoom function doesn't work and I get the following error: 'graphic.attributes is undefined' at the following line in the zoomRow function: if (graphic.attributes.OBJECTID.toString() === id) { It seems that when the zoom function tries to access the graphics layer attributes, it can't find OBJECTID. Below is the code for the query task. Any help is VERY much appreciated! Thanks, Ed function executeTask() { var planNumber = dijit.byId('planNumber').value; var lotNumber = dijit.byId('lotNumber').value; var queryTask = new esri.tasks.QueryTask("http://<server>/ArcGIS/rest/services/SLR/CadastreRoad/MapServer/0"); var query = new esri.tasks.Query(); query.returnGeometry=true; query.outFields = ["PLANNUMBER","LOTNUMBER","OBJECTID","SECTIONNUMBER"]; query.where = "PLANNUMBER='" + planNumber + "' AND LOTNUMBER='" + lotNumber + "'"; dojo.connect(queryTask,"onComplete", function(featureSet) { //build an array of attributes var items = dojo.map(featureSet.features, function(feature) { return feature.attributes; }); var data = { identifier:"OBJECTID", items:items }; store = new dojo.data.ItemFileReadStore({ data:data }); grid.setStore(store); grid.setSortIndex(1,"true"); //sort on the state name dojo.forEach (featureSet.features, function(feature) { map.graphics.add(feature); }); }); queryTask.execute(query); } function makeZoomButton(id) { var zBtn = "<div dojoType='dijit.form.Button'><img src='images/zoom.png'"; zBtn = zBtn + " width='18' height='18'"; zBtn = zBtn + " onClick=\"zoomRow('"+id+"')\"></div>"; return zBtn; } function zoomRow(id) { selectionLayer.clear(); dojo.some(map.graphics.graphics, function(graphic) { if (graphic.attributes.OBJECTID.toString() === id) { var selectedState = new esri.Graphic(graphic.geometry).setAttributes( graphic.attributes); selectionLayer.add(selectedState); var stateExtent = selectedState.geometry.getExtent().expand(5.0); map.setExtent(stateExtent); return true; } }); } Change strict comparison === to == and try again.
... View more
10-24-2011
05:56 AM
|
0
|
0
|
767
|
|
POST
|
I was able to get the example Heming provided to work, except it now affects the format of my "BaseMapGallery" widget because the logo is in the same section (below). <style type="text/css">
div.map img
{
position:absolute;
bottom:20px;
right:20px;
z-index:100;
width:15px;
heigth:15px;
}
<body class="nihilo">
</style>
<div id="map" dojotype="dijit.layout.ContentPane" region="center" style="border:1px solid #000;padding:0;">
<a href="http://www.google.com"><img src="logo.png" alt="View Logo" /></a>
<div style="position:absolute; right:20px; top:10px; z-Index:999;">
<div dojoType="dijit.TitlePane" title="Switch Basemap" closable="false" open="false">
<div dojoType="dijit.layout.ContentPane" style="width:380px; height:280px; overflow:auto;">
<div id="basemapGallery" ></div> Barry, what is the issue?
... View more
10-21-2011
05:52 AM
|
0
|
0
|
1876
|
|
POST
|
Three lines of code? Not sure which code you are using (perhaps a combination of what Bailey and yourself posted)? Is there an additional "dojo.require" statement that may be necessary? A simple combination of hide ESRI logo and add an image link with css will achieve your goal. Something like this
<style type="text/css">
div.map img
{
position:absolute;
bottom:20px;
right:20px;
z-index:100;
width:15px;
heigth:15px;
}
</style>
<script type="text/javascript">
function init()
{
map = new esri.Map("map", {
extent: initialExtent, logo: false
});
}
...
</script>
<body class="claro">
...
<div id="map" class="roundedCorners" dojotype="dijit.layout.ContentPane" region="center">
<a href="http://www.google.com"><img src="logo.png" alt="View Logo" /></a>
</div>
...
</body>
... View more
10-20-2011
11:54 AM
|
0
|
0
|
1876
|
|
POST
|
Hi, I've hit a snag with the union JavaScript code above. The code breaks with the following cases: If I have a polygon with a hole in it, but that hole is occupied by 2 more polygons that exactly fit the space, each taking up about half the hole space, together they fill the hole. Put another way imagine a polygon with a square hole in it, and that hole is filled by 2 rectangular polygons. i.e. trying to union 3 polygons to create one seamless/holeless shape. If I have a polygon with 2 holes in it, and each hole is filled with a perfectly fitting polygon. i.e. trying to union 3 polygons to create one seamless/holeless shape. Has anyone come up with some JS code to handle this please? Thanks. Mark, When this this thread was posted, the GeometryService class did not have function to deal with your case. Now, you might be able to use GeometryService.union(geometries, callback?, errback?) for your case.
... View more
10-20-2011
08:01 AM
|
0
|
0
|
1031
|
|
POST
|
Hi, I have two questions related to Dojox Data Grid: 1. I have an application where the datagrid has two columns. One column always displays unique names (e.g. state names) and the second column has to display indicator value for each state depending on which indicator is selected i.e. When user selects 'Population' from a dropdown select form, the second column displays its value. I would like this column to refresh its value when user makes another selection. The data grid examples on esri.com show hard-coded field name in the HTML markup. Is there a way to make the field name dynamic? 2. Is there a way to apply my own css style to the table (cells, borders, heading etc.)? Thanks for your help, Samir 1. Use dojo.data.ItemFileWriteStore (instead of dojo.data.ItemFileReadStore) to bind with datagrid will allow you change or update the column value (like this: store.setValue(item, columnName, dropdownValue). 2. You can overwrite dategrid css style with you own. Like this: .dojoxGrid{}, .dojoxGrid table{}, .dojoxGrid th, tr{} etc.
... View more
10-19-2011
11:57 AM
|
0
|
0
|
3053
|
|
POST
|
Hi, I have Navigation toolbar and normal toolbar (esri.toolbars.draw) to draw various shapes of graphics.When I click normal toolbar, I can draw my graphics, that is fine.However,if immediately after this, I click on any navigation tool (say zoom in), previously draw graphics is also drawn along with zoom in rectanlge.So map is zoomed in but graphics is also drawn.I have to deactivate the normal toolbar (the one that draws graphics.) Since, nav toolbar tools are mere calls to API methods, how can a catch the click event of any tool on the navigation toolbar? In this event, I would call deactivate method. I am very new to JS API, so any help is much appreciated. Regards, Sanjay. When you activate the draw toolbar, API will automatically deactivate the map navigation. It does not, however, do the opposite way. But you can easily add one statement to deactivate your drawing toolbar when you activate your navigation bar. For example, in http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/toolbar_navigation.html. you could add drawingtoolbar.deactivate() in onClick:function(){navToolbar.activate(esri.toolbars.Navigation.ZOOM_IN);drawingtoolbar.deactivate();}
... View more
10-19-2011
11:33 AM
|
0
|
0
|
772
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-11-2011 12:16 PM | |
| 1 | 05-25-2017 08:26 AM | |
| 1 | 06-02-2017 07:37 AM | |
| 1 | 06-28-2011 07:02 AM | |
| 1 | 06-12-2017 10:10 AM |
| Online Status |
Offline
|
| Date Last Visited |
10-01-2024
09:57 PM
|