|
POST
|
I am trying to convert a shape file to raster by a python script. But it did not work. However, this conversion was done successfully by ArcToolBox. I used similar parmeters for raster conversion in the script - but I have got following errors. Any idea? # print arcpy.GetMessages Traceback (most recent call last): File "K:\SCRIPT\Python_Script\ShapeToRaster.py", line 22, in <module> arcpy.FeatureToRaster_conversion(inFeatures, field, outRaster, cellSize) File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\conversion.py", line 1686, in FeatureToRaster raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000860: Input features: is not the type of Composite Geodataset, or does not exist. ERROR 001000: Field: Field MUKEY does not exist Failed to execute (FeatureToRaster). --------------------------------------------------------------------- # Import system modules import arcpy, os,sys # # Set environment settings arcpy.env.workspace = "K:/STATE_MUKEY/AREA.gdb" # # Set local variables inFeature = "soilmu_in.shp" field = "MUKEY" outRaster = "K:/STATE_MUKEY/RASTER.gdb/soilmu_in" #assignmentType = "CELL_CENTER" #priorityField = "NONE" cellSize = 90 # Execute FeatureToRaster arcpy.FeatureToRaster_conversion(inFeature, field, outRaster, cellSize) print arcpy.GetMessages You set up arcpy.env.workspace = "K:/STATE_MUKEY/AREA.gdb" and inFeature = "soilmu_in.shp". Basically you are telling arcpy to find soilmu_in.shp in K:/STATE_MUKEY/AREA.gdb, which does not exist.
... View more
08-17-2011
04:49 AM
|
0
|
0
|
4863
|
|
POST
|
Hi, I am trying to connect to an external SQL server with a table with an x and y fields using pyodbc. Next I am making an XYEventLayer using arcpy, and then converting the XYEventLayer to a feature class. When I run the code outside of ArcView it chokes and says the dataset is not supported or does not exist. I am not sure if calling the APP keyword is the correct way to do this. When I use the �??arcpy.ListDatasets()�?? command I just get �??()�?? return. Thank you in advance for your help import arcpy
import pyodbc
from arcpy import env
cnxn = pyodbc.connect('Driver={SQL Server Native Client 10.0};UID=user;PWD=Pass;SERVER=****.usace.army.mil; DATABASE=ftord; APP=MyApp')
arcpy.env.workspace= 'MyApp'
in_Table = "dbo.Wells_view"
y_coords = "northing"
x_coords = "easting"
out_layer = "wells"
arcpy.env.overwriteOutput = 'true'
saved_Layer = r"G:\Temp\Bart\layers\Wells.lyr"
arcpy.MakeXYEventLayer_management(in_Table, x_coords, y_coords, out_layer)
arcpy.FeatureClassToFeatureClass_conversion("Wells", r"G:\Temp\Bart\scratch.gdb", "wells") arcpy.MakeXYEventLayer_management wouldn't work in this case. Because in_Table is not a arcpy Table View rather than a table or view from pyodbc. One solution you can try is to create a feature class using arcpy.CreateFeatureclass_management. Then loop through the pyodbc cursor on your in_Table and use arcpy.InsertCursor to add each row from pyodbc cursor to the feature class.
... View more
08-16-2011
11:55 AM
|
0
|
0
|
976
|
|
POST
|
Is there a way to duplicate the functionality found when you right-click on a rster layer and choose "Export"? I'm trying to convert 32 bit images to 8 bit similar to the way you can check the Use Renderer and Froce RGB option in the Export Raster Data window. I've tried using CopyRaster_management, but the results I get from that tool are incorrect (I get a raster image where all the pixels have the same value: arcpy.CopyRaster_management("test", "C:/Temp/grids/test_8bit.tif", "", "", "", "", "ColormapToRGB", "8_BIT_UNSIGNED") I've tried every possible combination of parameters to no avail... Wade I think the problem might lie in your pixel_type parameter. The tool help stated: If the pixel type is demoted (lowered), the raster values outside the valid range for that pixel depth will be truncated and lost. 8_BIT_UNSIGNED value range from 0-255 while 32_BIT_UNSIGNED value range from 0 to 4,294,967,295. Try the same pixel_type as your orignal raster and see what happens.
... View more
08-16-2011
10:57 AM
|
0
|
0
|
1211
|
|
POST
|
If available, you could use the '/layers' REST endpoint to get back all the information you need in a single call. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Create Map</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/dojo/dijit/themes/claro/claro.css">
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.4"></script>
<script type="text/javascript">
dojo.require("esri.map");
function init() {
var map = new esri.Map("map");
var imageParameters = new esri.layers.ImageParameters();
imageParameters.format = "jpeg";
var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer", {
"opacity":0.5,
"imageParameters":imageParameters
});
map.addLayer(dynamicMapServiceLayer);
// GET MAP SERVICE INFORMATION
getMapServiceInformation(dynamicMapServiceLayer.url);
}
// GET MAP SERVICE INFORMATION
function getMapServiceInformation(mapServiceUrl) {
var mapServiceInfoDeferred = esri.request({
url: dojo.replace("{0}/layers",[mapServiceUrl]),
content: {
f: 'json'
},
callbackParamName: "callback"
});
mapServiceInfoDeferred.then( function(response) {
// THE INFORMATION RETURNED HERE IS NOT THE SAME OBJECT/INSTANCE AS
// THE JS API LAYER CREATED ABOBE, IT'S JUST A SIMPLE JSON OBJECT
// REPRESENTATION OF MAP SERVICE INFORMAITON
dojo.forEach(response.layers, function(layerInfo) {
var layerInfoNode = dojo.create('li', {
'innerHTML': dojo.replace("<b>{name}</b> [{type}]",layerInfo),
'style':'font-size:larger;margin-bottom:20px;'
},'mapServiceInfo');
if(layerInfo.fields) {
var fieldsInfoNode = dojo.create('ul', {
},layerInfoNode);
dojo.forEach(layerInfo.fields, function(fieldInfo) {
var fieldInfoNode = dojo.create('li', {
'innerHTML': dojo.replace("<b>{name}</b> (<i>{alias}</i>) {type}",fieldInfo)
},fieldsInfoNode);
});
}
});
}, function(error) {
dojo.byId('mapServiceInfo').innerHTML = dojo.toJson(error);
});
}
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
<div id="map" style="width:500px; height:300px; border:1px solid #000;">
</div>
<ul id="mapServiceInfo">
</ul>
</body>
</html> Good job! Gary. I missed that (ArcGIS server REST API -All Layers and Tables).
... View more
08-16-2011
09:51 AM
|
0
|
0
|
2655
|
|
POST
|
You will either need to escape your double-quotes with backslashes or single-quotes. Backslashes are probably the most obvious: "\"ADDRNO\" = 2 AND \"ADDRSTREET\" = 'PONDEROSA' AND \"ADDRSUFFIX\" = 'LANE'" I have successfully used expression in searchCursor. You really don't need quotes (single or double) for field names for arcpy. Not sure why it did not work. If you could post your script and part of data, i will test it myself and get back to you.
... View more
08-16-2011
09:40 AM
|
0
|
0
|
2426
|
|
POST
|
Storing the info in the MXD is a good workaround, but I need something guaranteed to work (ie, without the dependency on the MXD author to remember to make the change). What about doing something with a JSON request, like in this sample? Do you think this would work? The URL http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer/layers?f=json returns a JSON string containing the field names, but I can't work out how to access this using the JSON request methodology in that sample. Can you give any clues? Cheers, Steve Steve, Json request would definitely work. However these are extra steps (trips to server). Just image you have many layers! If you really want to use json request, more feasible way would be put your fields info into a txt or dat file, and use json request to get the file content and go from there.
... View more
08-16-2011
06:18 AM
|
0
|
0
|
2655
|
|
POST
|
have you tested the query through the standard select by attributes interface in ArcMap? Have you tried it incrementally (ie add one piece, then the second etc)? You stated that your first field is a numeric. If that is the case, you need parse you first parameter to a numeric. something like this: PAR1 = arcpy.GetParameterAsText(0) # don't know what your numeric type is, so just put int here for demo PAR1_int =int(PAR1) whereClause = "ADDRNO = PAR1_int AND ADDRSTREET = PAR2 AND ADDRSUFFIX = PAR3"
... View more
08-16-2011
05:33 AM
|
0
|
0
|
2426
|
|
POST
|
See the sample below, which adds a DynamicMapServiceLayer to a map using the URL: http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer Navigating to this REST endpoint in a browser shows the component Layers, and each layer's Fields. How can I retrieve this information programatically? I need a list of the available layers (0,1,2) and each layer's available fields (eg layer 0 contains objectid, lifecyclestatus, incident_number, etc) My goal is to add this information to a Query function, so I need to know that I can search layer 1 for the field collection_time, etc. Looping through the layerInfos tells me about each available layer - how can I retrieve information on the fields? (One option is to create a new feature layer from each layer and add it to the map, but I'd really like to avoid this workaround). Thanks, Steve <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
<!--The viewport meta tag is used to improve the presentation and behavior of the samples
on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>layer infos</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/dojo/dijit/themes/claro/claro.css">
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.4"></script>
<script type="text/javascript">
dojo.require("esri.map");
function init() {
var map = new esri.Map("map");
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(basemap);
var url = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer/";
var dynLayer = new esri.layers.ArcGISDynamicMapServiceLayer(url);
map.addLayer(dynLayer);
dojo.connect(dynLayer, "onLoad", function() {
var infos = dynLayer.layerInfos;
for (var i = 0; i <= infos.length - 1; i++) {
var layerId = infos.id;
var restEndPoint = url + layerId;
//restEndPoint is the layer's URL - how can I retrieve its fields?
}
});
}
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
<div id="map" style="width:900px; height:600px; border:1px solid #000;"></div>
</body>
</html> That is a good question. I thought this before when i was developing an app. Unfortunately i don't think you could find a property or a method (other than featuelayer) to get field info without extra steps. One work around i thought about is putting field infos for each layer in .mxd description, and then getting them through layer.description. Of cause, you need put them in .mxd description in a way that you could manipulate them through string functions to get the field name out.
... View more
08-16-2011
05:13 AM
|
0
|
0
|
2655
|
|
POST
|
Hello, Where can we find a sample map using API for Javascript that has the same set of functionalities as a standard web application genarated by ArcGIS Server, specifically, having map content window, tool bar with zoom in, zoom out, pan, full view, back extent, forward extent, goto XY, magnifier, identifier, measurement, and overview map. We'd like to use API for Javascript over the standard generated map to avoid ASP.NET WebForm. Thanks, Vu Dang You can use JS API navigation toolbar to zoom in, zoom out, pan, full view, back extent, forward extent (sample: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/toolbar_navigation.html). You can use JS API measurement Widget to do measurement (sample: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/widget_measurement.html). There is a JS API Overview Map Widget for overview map. You could also use JS API to build your own identify and goto X, Y. Not sure about magnifier.
... View more
08-15-2011
09:47 AM
|
0
|
0
|
1186
|
|
POST
|
Thanks for the suggestion. When I tried it, I got a new error: <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000825: The value is not a layer or table view ERROR 000840: The value is not a Raster Layer. ERROR 000840: The value is not a Mosaic Layer. Failed to execute (SelectLayerByAttribute). Failed to execute (TestAddressZoomTo). Any other suggestions? Again, I am trying to select 3 address fields and zoom to the selected feature. The first field is numeric, the other 2 fields are text. I also tried changing the script so that the 3 fields were user defined parameters. Then I used the GetParameterAsText function within the SelectLayerByAttribute where clause. I got the same error as listed above. Here is the revised script I was trying: # Script arguments PAR1 = arcpy.GetParameterAsText(0) PAR2 = arcpy.GetParameterAsText(1) PAR3 = arcpy.GetParameterAsText(2) #Select by Attributes parcels = "C:\PreApp Maps\Parcels.lyr" whereClause = "ADDRNO = PAR1 AND ADDRSTREET = PAR2 AND ADDRSUFFIX = PAR3" arcpy.SelectLayerByAttribute_management (parcels, "NEW_SELECTION", whereClause) #Zoom to Selected mxd = arcpy.mapping.MapDocument(r"Current") df = arcpy.mapping.ListDataFrames(mxd, "Boulder County")[0] df.zoomToSelectedFeatures() #arcpy.RefreshActiveView() Based on your error message, it looks like it doesn't recognize parcels as a feature layer or table view. Either check parcels path make sure its souce is accessible or make a layer explicitly:
arcpy.env.workspace ="C:\PreApp Maps"
arcpy.MakeFeatureLayer_management("Parcels", "lyr")
...
arcpy.SelectLayerByAttribute_management ("lyr", "NEW_SELECTION", whereClause)
... View more
08-15-2011
09:28 AM
|
0
|
0
|
3797
|
|
POST
|
Hi Heming, thanks - turns out I am being dim on a Monday. Create the feature layer, *then* find the geometry type, symbolise accordingly. It is a little strange that the type isn't accessible without first creating a featureLayer; I'd expect that to be in layerInfos[layerId], or similar. Cheers, Ben. I agreed with you on that.
... View more
08-15-2011
05:32 AM
|
0
|
0
|
3748
|
|
POST
|
What is the schema for your featureset input? It sounds like something might be wonky with that since you are getting data out the other end, just missing fields. 1) Check schema of featureset input for tool. 2) If this is correct, you might want to do some error checking in your tool itself before you output to feature class. Make sure all the fields are going into your featureclass->featureclass
featureset = your featureset
fields = arcpy.ListFields(featureset)
for field in fields:
arcpy.AddMessage(field.name)
arcpy.CopyFeatures_management(featureset, outputFeatureclass)
First of all, I cann't use predefined schema because the featureset is based on user's choice of layer in .mxd, it is dynamic. Since featureset is the lightweight of featureclass, I thought the arcpy.ListFields(featureset) would give me a list of fields. Actually it is not the case. Featureset is a common result of interacting with map, unfortunately there is no easy ways to get its field names through arcpy. Thanks for your suggestion.
... View more
08-15-2011
05:27 AM
|
0
|
0
|
3029
|
|
POST
|
Hello all, I may just be being dim on a Monday afternoon, but I can't seem to find any way of finding a layer's specified geometry type. This is shown in the REST endpoint as "Geometry Type: esriGeometryPoint"; unfortunately it doesn't seem to be exposed in either the Layer properties, or in the layerInfos object. What I need to do is create a custom-symbolised featureLayer on the fly, and in order for that to work I need to know the geometry present in this particular layer. Sadly, I can't use layerDefinitions (which would be far more appropriate). Any ideas? - Ben FeatureLayer.geometryType.
... View more
08-15-2011
04:45 AM
|
0
|
0
|
3748
|
|
POST
|
Thanks axxl & to others also. But Axxl what have u said i have done before u said but it doesn't work. And i can't save map as an image , but i can save the html page. Axxl it's not a normal image, it's map where has many layers combination, may be that's why it different. However thanks again, because I see here has many helpful hands who are really willing to help other. :cool: exportMapImage will save the image to \\arcgisserver\output folder, usually you can get its source by using MapImage.href (using a hyperlink...). However things might get a little complicated if you are using a reverse proxy or java web server, you have to make sure the your MapImage.href is accessable by your ArcGISWebService account.
... View more
08-12-2011
05:36 AM
|
0
|
0
|
2321
|
|
POST
|
Heming, I have a script that does something similar, but rather than creating a feature class in the scratch.gdb, my script creates a new file geodatabase in the the scratch folder and uses feature class to feature class to populate features while applying a query. The geodatabase is then zipped so it can be downloaded by a user. You could try creating a new file GDB in the scratch folder and populate the feature class using Feature Class to Feature Class in the new GDB rather than using the sratch.gdb. Alternately, rather than populating with Feature Class to Feature Class. You could create a new empty feature class in the sratch.gdb using Create Feature Class, setting your input or feature set as the template feature class (so the schemas match) . You could then use the Append to add the feature set (or a feature layer to which you apply your query) to the newly created feature class. Not sure why what you are trying wouldn't work, but it my be worth trying a work around. Best of luck, BZ Thanks for reply. I have tried all the things you mentioned. I got the same results. I think the problem is not on those arcpy functions other than arcpy does not treat a featureset, which is a queryTask result from Web API, as a feature class or feature layer as ESRI doc claim. I do find a work around by changing the type from FeaturSet to FeatureLayer. Thanks for your suggestion anyway!
... View more
08-12-2011
05:08 AM
|
0
|
0
|
3029
|
| 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
|